private MDIChild CreateMDIChild(Uri file, string rdl, bool bMenuUpdate)
{
MDIChild mcOpen = null;
if (file != null)
{
foreach (MDIChild mc in this.MdiChildren)
{
if (mc.SourceFile != null && file.LocalPath == mc.SourceFile.LocalPath)
{ // we found it
mcOpen = mc;
break;
}
}
}
if (mcOpen == null)
{
MDIChild mc = null;
try
{
mc = new MDIChild(this.ClientRectangle.Width * 3 / 5, this.ClientRectangle.Height * 3 / 5);
mc.OnSelectionChanged += new MDIChild.RdlChangeHandler(SelectionChanged);
mc.OnSelectionMoved += new MDIChild.RdlChangeHandler(SelectionMoved);
mc.OnReportItemInserted += new MDIChild.RdlChangeHandler(ReportItemInserted);
mc.OnDesignTabChanged += new MDIChild.RdlChangeHandler(DesignTabChanged);
mc.OnOpenSubreport += new DesignCtl.OpenSubreportEventHandler(OpenSubReportEvent);
mc.OnHeightChanged += new DesignCtl.HeightEventHandler(HeightChanged);
mc.MdiParent = this;
if (this._ShowTabbedInterface)
mc.WindowState = FormWindowState.Maximized;
mc.Viewer.GetDataSourceReferencePassword = _GetPassword;
if (file != null)
{
mc.Viewer.Folder = Path.GetDirectoryName(file.LocalPath);
mc.SourceFile = file;
mc.Text = Path.GetFileName(file.LocalPath);
mc.DrawCtl.Folder = Path.GetDirectoryName(file.LocalPath);
mc.Viewer.ReportName = Path.GetFileNameWithoutExtension(file.LocalPath);
NoteRecentFiles(file, bMenuUpdate);
}
else
{
mc.SourceRdl = rdl;
mc.Viewer.ReportName = mc.Text = Strings.RdlDesigner_CreateMDIChild_Untitled;
}
mc.ShowEditLines(this._ShowEditLines);
mc.ShowReportItemOutline = this.ShowReportItemOutline;
mc.ShowPreviewWaitDialog(this._ShowPreviewWaitDialog);
// add to toolbar tab
TabPage tp = new TabPage();
tp.Location = new System.Drawing.Point(0, 0);
tp.Name = mc.Text;
tp.TabIndex = 1;
tp.Text = mc.Text;
tp.Tag = mc; // tie the mdichild to the tabpage
tp.ToolTipText = file == null ? "" : file.LocalPath;
mainTC.Controls.Add(tp);
mc.Tab = tp;
mc.Show();
mcOpen = mc;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
if (mc != null)
mc.Close();
return null;
}
}
else
{
mcOpen.Activate();
}
return mcOpen;
}