static internal bool GetConnnectionInfo(DesignXmlDraw d, string ds, out string dataProvider, out string connection) { XmlNode dsNode = d.DataSourceName(ds); dataProvider = null; connection = null; if (dsNode == null) { return(false); } string dataSourceReference = d.GetElementValue(dsNode, "DataSourceReference", null); if (dataSourceReference != null) { // This is not very pretty code since it is assuming the structure of the windows parenting. // But there isn't any other way to get this information from here. Control p = d; MDIChild mc = null; while (p != null && !(p is RdlDesigner)) { if (p is MDIChild) { mc = (MDIChild)p; } p = p.Parent; } if (p == null || mc == null || mc.SourceFile == null) { MessageBox.Show(Strings.DataSetRowsCtl_ShowC_UnableLocateDSR); return(false); } Uri filename = new Uri(Path.GetDirectoryName(mc.SourceFile.LocalPath) + Path.DirectorySeparatorChar + dataSourceReference); if (!DesignerUtility.GetSharedConnectionInfo((RdlDesigner)p, filename.LocalPath, out dataProvider, out connection)) { return(false); } } else { XmlNode dp = DesignXmlDraw.FindNextInHierarchy(dsNode, "ConnectionProperties", "DataProvider"); if (dp == null) { return(false); } dataProvider = dp.InnerText; dp = DesignXmlDraw.FindNextInHierarchy(dsNode, "ConnectionProperties", "ConnectString"); if (dp == null) { return(false); } connection = dp.InnerText; } return(true); }
private void bValidate_Click(object sender, System.EventArgs e) { MDIChild mc = _RdlDesigner.ActiveMdiChild as MDIChild; if (mc == null || mc.DesignTab != DesignTabs.Edit) { MessageBox.Show(Strings.DialogValidateRdl_ShowC_SelectRDLTab); return; } string syntax = mc.SourceRdl; bool bNone = true; bool b2005 = true; Cursor saveCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; StringReader sr = null; XmlTextReader tr = null; XmlReader vr = null; try { // Find the namespace information in the <Report> element. // We could be more precise and really parse it but it doesn't really help // since we don't know the name and location of where the actual .xsd file is // in the general case. (e.g. xmlns="..." doesn't contain name of the .xsd file. int ir = syntax.IndexOf("<Report"); if (ir >= 0) { int er = syntax.IndexOf(">", ir); if (er >= 0) { if (syntax.IndexOf("xmlns", ir, er - ir) >= 0) { bNone = false; if (syntax.IndexOf("2005", ir, er - ir) < 0) { b2005 = false; } } } } _ValidationErrorCount = 0; _ValidationWarningCount = 0; this.lbSchemaErrors.Items.Clear(); sr = new StringReader(syntax); tr = new XmlTextReader(sr); XmlReaderSettings xrs = new XmlReaderSettings(); xrs.ValidationEventHandler += new ValidationEventHandler(ValidationHandler); xrs.ValidationFlags = XmlSchemaValidationFlags.AllowXmlAttributes | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ProcessInlineSchema; // add any schemas needed if (!bNone) { if (b2005) { xrs.Schemas.Add(SCHEMA2005, SCHEMA2005NAME); } else { xrs.Schemas.Add(SCHEMA2003, SCHEMA2003NAME); } } // we always use the designer schema string designerSchema = string.Format("file://{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Designer.xsd"); xrs.Schemas.Add(DESIGNERSCHEMA, designerSchema); vr = XmlReader.Create(tr, xrs); while (vr.Read()) { ; } this.lbSchemaErrors.Items.Add(string.Format("Validation completed with {0} warnings and {1} errors.", _ValidationWarningCount, _ValidationErrorCount)); } catch (Exception ex) { this.lbSchemaErrors.Items.Add(ex.Message + " Processing terminated."); } finally { Cursor.Current = saveCursor; if (sr != null) { sr.Close(); } if (tr != null) { tr.Close(); } if (vr != null) { vr.Close(); } } }
private void bLoad_Click(object sender, System.EventArgs e) { // Load the data from the SQL; we append the data to what already exists try { // Obtain the connection information XmlNode rNode = _Draw.GetReportNode(); XmlNode dsNode = _Draw.GetNamedChildNode(rNode, "DataSources"); if (dsNode == null) { return; } XmlNode datasource = null; foreach (XmlNode dNode in dsNode) { if (dNode.Name != "DataSource") { continue; } XmlAttribute nAttr = dNode.Attributes["Name"]; if (nAttr == null) // shouldn't really happen { continue; } if (nAttr.Value != _dsv.DataSourceName) { continue; } datasource = dNode; break; } if (datasource == null) { MessageBox.Show(string.Format("Datasource '{0}' not found.", _dsv.DataSourceName), "Load Failed"); return; } // get the connection information string connection = ""; string dataProvider = ""; string dataSourceReference = _Draw.GetElementValue(datasource, "DataSourceReference", null); if (dataSourceReference != null) { // This is not very pretty code since it is assuming the structure of the windows parenting. // But there isn't any other way to get this information from here. Control p = _Draw; MDIChild mc = null; while (p != null && !(p is RdlDesigner)) { if (p is MDIChild) { mc = (MDIChild)p; } p = p.Parent; } if (p == null || mc == null || mc.SourceFile == null) { MessageBox.Show("Unable to locate DataSource Shared file. Try saving report first"); return; } string filename = Path.GetDirectoryName(mc.SourceFile) + Path.DirectorySeparatorChar + dataSourceReference; if (!DesignerUtility.GetSharedConnectionInfo((RdlDesigner)p, filename, out dataProvider, out connection)) { return; } } else { XmlNode cpNode = DesignXmlDraw.FindNextInHierarchy(datasource, "ConnectionProperties", "ConnectString"); connection = cpNode == null ? "" : cpNode.InnerText; XmlNode datap = DesignXmlDraw.FindNextInHierarchy(datasource, "ConnectionProperties", "DataProvider"); dataProvider = datap == null ? "" : datap.InnerText; } // Populate the data table DesignerUtility.GetSqlData(dataProvider, connection, _dsv.CommandText, null, _DataTable); } catch (Exception ex) { MessageBox.Show(ex.Message, "Load Failed"); } }
// Create an MDI child. Only creates it if not already open. 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.Viewer.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; }
private void SetStatusNameAndPositionEdit(MDIChild mc) { var spos = string.Format("{2} {0} {3} {1}", mc.CurrentLine, mc.CurrentCh, Strings.RdlDesigner_Status_Ln, Strings.RdlDesigner_Status_Ch); statusSelected.Text = spos; statusPosition.Text = ""; }
private void SetStatusNameAndPositionDesign(MDIChild mc) { if (mc.DrawCtl.SelectedCount <= 0) { statusPosition.Text = statusSelected.Text = ""; return; } // Handle position var pos = mc.SelectionPosition; var sz = mc.SelectionSize; string spos; if (pos.X == float.MinValue) // no item selected is probable cause { spos = ""; } else { var rinfo = new RegionInfo(CultureInfo.CurrentCulture.LCID); double m72 = DesignXmlDraw.POINTSIZED; var x = pos.X/m72; var y = pos.Y/m72; var unit = rinfo.IsMetric ? Strings.RdlDesigner_Status_cm : Strings.RdlDesigner_Status_in; if (rinfo.IsMetric) { x *= 2.54d; y *= 2.54d; } if (sz.Width == float.MinValue) // item is in a table/matrix is probably cause { spos = string.Format(" x={0:0.00}{2}, y={1:0.00}{2} ", x, y, unit); } else { var w = sz.Width/m72; var h = sz.Height/m72; if (rinfo.IsMetric) { w *= 2.54d; h *= 2.54d; } spos = string.Format(" x={0:0.00}{4}, y={1:0.00}{4}, w={2:0.00}{4}, h={3:0.00}{4} ", x, y, w, h, unit); } } statusPosition.Text = spos; // Handle text statusSelected.Text = mc.SelectionName; }
private void SetProperties(MDIChild mc) { if (mc == null || !_ShowProperties || mc.DesignTab != "design") mainProperties.ResetSelection(null, null); else mainProperties.ResetSelection(mc.RdlEditor.DrawCtl, mc.RdlEditor.DesignCtl); }
private void SetMDIChildFocus(MDIChild mc) { // We don't want to be triggering any change events when the focus is changing bool bSuppress = bSuppressChange; bSuppressChange = true; mc.SetFocus(); bSuppressChange = bSuppress; }
void mdi_Activate(MDIChild mc) { if (mc == null) return; if (bMono) { mc.Activate(); this.Refresh(); //Forces a synchronous redraw of all controls } else { #if MONO mc.Activate(); this.Refresh(); //Forces a synchronous redraw of all controls #else LockWindowUpdate(this.Handle); mc.Activate(); this.Refresh(); //Forces a synchronous redraw of all controls LockWindowUpdate(IntPtr.Zero); #endif } }
void mdi_Activate(MDIChild mc) { if (mc == null) return; LockWindowUpdate(this.Handle); mc.Activate(); this.Refresh(); //Forces a synchronous redraw of all controls LockWindowUpdate(IntPtr.Zero); }
private void SetStatusNameAndPositionEdit(MDIChild mc) { string spos = string.Format("Ln {0} Ch {1}", mc.CurrentLine, mc.CurrentCh); if (spos != statusSelected.Text) statusSelected.Text = spos; if (statusPosition.Text != "") statusPosition.Text = ""; return; }
private void SetStatusNameAndPositionDesign(MDIChild mc) { if (mc.DrawCtl.SelectedCount <= 0) { statusPosition.Text = statusSelected.Text = ""; return; } // Handle position PointF pos = mc.SelectionPosition; SizeF sz = mc.SelectionSize; string spos; if (pos.X == float.MinValue) // no item selected is probable cause spos = ""; else { RegionInfo rinfo = new RegionInfo( CultureInfo.CurrentCulture.LCID ); double m72 = DesignXmlDraw.POINTSIZED; if (rinfo.IsMetric) { if (sz.Width == float.MinValue) // item is in a table/matrix is probably cause spos = string.Format(" x={0:0.00}cm, y={1:0.00}cm ", pos.X / (m72 / 2.54d), pos.Y / (m72 / 2.54d)); else spos = string.Format(" x={0:0.00}cm, y={1:0.00}cm, w={2:0.00}cm, h={3:0.00}cm ", pos.X / (m72 / 2.54d), pos.Y / (m72 / 2.54d), sz.Width / (m72 / 2.54d), sz.Height / (m72 / 2.54d)); } else { if (sz.Width == float.MinValue) spos = string.Format(" x={0:0.00}\", y={1:0.00}\" ", pos.X/m72, pos.Y/m72); else spos = string.Format(" x={0:0.00}\", y={1:0.00}\", w={2:0.00}\", h={3:0.00}\" ", pos.X/m72, pos.Y/m72, sz.Width/m72, sz.Height/m72); } } if (spos != statusPosition.Text) statusPosition.Text = spos; // Handle text string sname = mc.SelectionName; if (sname != statusSelected.Text) statusSelected.Text = sname; return; }
private void menuFilePrint_Click(object sender, EventArgs e) { MDIChild mc = this.ActiveMdiChild as MDIChild; if (mc == null) return; if (printChild != null) // already printing { MessageBox.Show("Can only print one file at a time.", "RDL Design"); return; } printChild = mc; PrintDocument pd = new PrintDocument(); pd.DocumentName = mc.SourceFile; pd.PrinterSettings.FromPage = 1; pd.PrinterSettings.ToPage = mc.PageCount; pd.PrinterSettings.MaximumPage = mc.PageCount; pd.PrinterSettings.MinimumPage = 1; pd.DefaultPageSettings.Landscape = mc.PageWidth > mc.PageHeight? true: false; PrintDialog dlg = new PrintDialog(); dlg.Document = pd; dlg.AllowSelection = true; dlg.AllowSomePages = true; if (dlg.ShowDialog() == DialogResult.OK) { try { if (pd.PrinterSettings.PrintRange == PrintRange.Selection) { pd.PrinterSettings.FromPage = mc.PageCurrent; } mc.Print(pd); } catch (Exception ex) { MessageBox.Show("Print error: " + ex.Message, "RDL Design"); } } printChild = null; }
private void bValidate_Click(object sender, System.EventArgs e) { MDIChild mc = _RdlDesigner.ActiveMdiChild as MDIChild; if (mc == null || mc.DesignTab != "edit") { MessageBox.Show("请先选择源码选项卡."); return; } string syntax = mc.SourceRdl; bool bNone = true; bool b2005 = true; Cursor saveCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; StringReader sr = null; XmlTextReader tr = null; XmlReader vr = null; try { int ir = syntax.IndexOf("<Report"); if (ir >= 0) { int er = syntax.IndexOf(">", ir); if (er >= 0) { if (syntax.IndexOf("xmlns", ir, er - ir) >= 0) { bNone = false; if (syntax.IndexOf("2005", ir, er - ir) < 0) { b2005 = false; } } } } _ValidationErrorCount = 0; _ValidationWarningCount = 0; this.lbSchemaErrors.Items.Clear(); sr = new StringReader(syntax); tr = new XmlTextReader(sr); XmlReaderSettings xrs = new XmlReaderSettings(); xrs.ValidationEventHandler += new ValidationEventHandler(ValidationHandler); xrs.ValidationFlags = XmlSchemaValidationFlags.AllowXmlAttributes | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ProcessInlineSchema; // add any schemas needed if (!bNone) { if (b2005) { xrs.Schemas.Add(SCHEMA2005, SCHEMA2005NAME); } else { xrs.Schemas.Add(SCHEMA2003, SCHEMA2003NAME); } } // we always use the designer schema string designerSchema = string.Format("file://{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Designer.xsd"); xrs.Schemas.Add(DESIGNERSCHEMA, designerSchema); vr = XmlReader.Create(tr, xrs); while (vr.Read()) { ; } this.lbSchemaErrors.Items.Add(string.Format("Validation completed with {0} warnings and {1} errors.", _ValidationWarningCount, _ValidationErrorCount)); } catch (Exception ex) { this.lbSchemaErrors.Items.Add(ex.Message + " Processing terminated."); } finally { Cursor.Current = saveCursor; if (sr != null) { sr.Close(); } if (tr != null) { tr.Close(); } if (vr != null) { vr.Close(); } } }