public void SetNodeText(ICustomPaint theObject, TreeNode theNode) { if (theObject is TextField) { TextField txtField = (TextField)theObject; string theText = txtField.Text.Length > 25 ? txtField.Text.Substring(0, 25) + "..." : txtField.Text; theNode.Name = txtField.Name; theNode.Text = "Text field [" + theText + "]"; } else if (theObject is daReport.PictureBox) { theNode.Text = "Picture"; } else if (theObject is daReport.ChartBox) { ChartBox chartBox = (ChartBox)theObject; theNode.Text = "Chart [" + chartBox.Name + "]"; } else if (theObject is daReport.StyledTable) { StyledTable styledTable = (StyledTable)theObject; if (styledTable.DataSource != null) { theNode.Text = "Styled table [" + styledTable.DataSource + "]"; } else { theNode.Text = "Styled table"; } } }
public ConditionEditorDialog(StyledTable table) : this() { for (int i = 0; i < table.Columns.Length; i++) { fieldsBox.Items.Add(table.Columns[i].Name); } addFieldButton.Enabled = fieldsBox.Items.Count > 0; this.toolTip.SetToolTip(this.conditionField, "Tip on data formats:\r\nString format : 'text' \r\nDate format : #MM/dd/yyyy# \r\nColumn name format : [columnName] "); }
/// <summary> /// Edits the value of the specified object using the editor style indicated by GetEditStyle. /// </summary> /// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param> /// <param name="provider">An IServiceProvider that this editor can use to obtain services. </param> /// <param name="value">The object to edit. </param> /// <returns>The new value of the object.</returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = ((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService))); if (edSvc == null) { return(null); } if (context.Instance is StyledTable) { StyledTable styledTable = context.Instance as StyledTable; table = styledTable; columns = styledTable.Columns; //this.SetItems(styledTable.Columns[0], styledTable.Columns); CollectionForm collectionForm = this.CreateCollectionForm(); collectionForm.EditValue = styledTable.Columns; collectionForm.Text = "Columns Editor"; //if (edSvc.ShowDialog(collectionForm) == DialogResult.OK) //{ //return f..Data; // return collectionForm.EditValue; //} //Console.WriteLine(edSvc.ShowDialog(collectionForm)); base.EditValue(context, provider, value); } return(value); }
public static void WriteReport(string theFilename, ArrayList parameters, ICustomPaint[] staticObjects, ICustomPaint[] dynamicObjects, DaPrintDocument printDocument) { StreamWriter sw = new StreamWriter(theFilename, false, System.Text.Encoding.UTF8); //sw.Write("<?xml version='1.0' encoding='utf-8'?>"); string theLayout = "Portrait"; if (printDocument.Layout == DaPrintDocument.LayoutType.Landscape) { theLayout = "Landscape"; } sw.WriteLine("<daReport papersize=\"" + printDocument.PaperType.ToString() + "\" layout=\"" + theLayout + "\">"); sw.WriteLine("<margins left=\"" + printDocument.Margins.Left + "\" top=\"" + printDocument.Margins.Top + "\" right=\"" + printDocument.Margins.Right + "\" bottom=\"" + printDocument.Margins.Bottom + "\"></margins>"); // write down report parameters if (parameters != null || parameters.Count > 0) { sw.WriteLine("<parameters>"); for (int i = 0; i < parameters.Count; i++) { sw.WriteLine(" <parameter name=\"" + parameters[i] + "\" />"); } sw.WriteLine("</parameters>"); } // end writing parameters sw.WriteLine("<content>"); // writing down static objects if (staticObjects.Length > 0) { sw.WriteLine("<staticContent>"); for (int i = 0; i < staticObjects.Length; i++) { if (staticObjects[i] is TextField) { TextField txtField = (TextField)staticObjects[i]; sw.WriteLine(" "); sw.WriteLine("<textField name=\"" + txtField.Name.ToString() + "\" x=\"" + txtField.X + "\" y=\"" + txtField.Y + "\" width=\"" + txtField.Width + "\" height=\"" + txtField.Height + "\" horAlignment=\"" + txtField.HorizontalAlignment.ToString() + "\" verAlignment=\"" + txtField.VerticalAlignment.ToString() + "\" Selectable=\"" + txtField.Selectable.ToString() + "\">"); sw.WriteLine("<text horAlignment=\"" + txtField.TextAlignment.ToString() + "\" verAlignment=\"" + txtField.TextVerticalAlignment.ToString() + "\">" + ReplaceForXML(txtField.Text) + "</text>"); if (txtField.Font != null) { string style = ""; if (txtField.Font.Bold && txtField.Font.Italic) { style = " style=\"Bold Italic\""; } else if (txtField.Font.Bold) { style = " style=\"Bold\""; } else if (txtField.Font.Italic) { style = " style=\"Italic\""; } sw.WriteLine("<font family=\"" + txtField.Font.Name + "\" size=\"" + txtField.Font.Size.ToString("f00") + "\" " + style + "></font>"); } sw.WriteLine("<foregroundColor color=\"" + txtField.ForegroundColor.Name + "\"></foregroundColor>"); sw.WriteLine("<backgroundColor color=\"" + txtField.BackgroundColor.Name + "\"></backgroundColor>"); sw.WriteLine("<border width=\"" + txtField.BorderWidth.ToString() + "\" color=\"" + txtField.BorderColor.Name + "\"></border>"); sw.WriteLine("</textField>"); } else if (staticObjects[i] is PictureBox) { PictureBox pictureBox = (PictureBox)staticObjects[i]; sw.WriteLine(" "); sw.WriteLine("<pictureBox name=\"" + pictureBox.Name.ToString() + "\" x=\"" + pictureBox.X + "\" y=\"" + pictureBox.Y + "\" width=\"" + pictureBox.Width + "\" height=\"" + pictureBox.Height + "\" stretch=\"" + (pictureBox.Stretch == true ? "true" : "false") + "\" horAlignment=\"" + pictureBox.HorizontalAlignment.ToString() + "\" verAlignment=\"" + pictureBox.VerticalAlignment.ToString() + "\" Selectable=\"" + pictureBox.Selectable.ToString() + "\">"); sw.WriteLine(@"<file>" + (pictureBox.ImageFile == null?" ":ReplaceForXML(pictureBox.ImageFile)) + "</file>"); sw.WriteLine("<border width=\"" + pictureBox.BorderWidth.ToString() + "\" color=\"" + pictureBox.BorderColor.Name + "\"></border>"); sw.WriteLine("</pictureBox>"); } else if (staticObjects[i] is ChartBox) { ChartBox chartBox = (ChartBox)staticObjects[i]; string style = ""; if (chartBox.Type == ChartBox.ChartType.Pie) { style = " type=\"Pie\""; } else { style = " type=\"Bars\""; } sw.WriteLine(" "); sw.WriteLine("<chartBox name=\"" + ReplaceForXML(chartBox.Name) + "\" x=\"" + chartBox.X + "\" y=\"" + chartBox.Y + "\" width=\"" + chartBox.Width + "\" height=\"" + chartBox.Height + "\" " + style + " horAlignment=\"" + chartBox.HorizontalAlignment.ToString() + "\" verAlignment=\"" + chartBox.VerticalAlignment.ToString() + "\" Selectable=\"" + chartBox.Selectable.ToString() + "\">"); sw.WriteLine("<title>" + ReplaceForXML(chartBox.Title) + "</title>"); if (chartBox.TitleFont != null) { string fontStyle = ""; if (chartBox.TitleFont.Bold && chartBox.TitleFont.Italic) { fontStyle = " style=\"Bold Italic\""; } else if (chartBox.TitleFont.Bold) { fontStyle = " style=\"Bold\""; } else if (chartBox.TitleFont.Italic) { fontStyle = " style=\"Italic\""; } sw.WriteLine("<titleFont family=\"" + chartBox.TitleFont.Name + "\" size=\"" + chartBox.TitleFont.Size.ToString("f00") + "\" " + fontStyle + "></titleFont>"); } sw.WriteLine("<xLabel>" + ReplaceForXML(chartBox.XLabel) + "</xLabel>"); if (chartBox.LabelFont != null) { string fontStyle = ""; if (chartBox.LabelFont.Bold && chartBox.LabelFont.Italic) { fontStyle = " style=\"Bold Italic\""; } else if (chartBox.LabelFont.Bold) { fontStyle = " style=\"Bold\""; } else if (chartBox.LabelFont.Italic) { fontStyle = " style=\"Italic\""; } sw.WriteLine("<labelFont family=\"" + chartBox.LabelFont.Name + "\" size=\"" + chartBox.LabelFont.Size.ToString("f00") + "\" " + fontStyle + "></labelFont>"); } sw.WriteLine("<mapAreaColor>" + chartBox.MapAreaColor.Name + "</mapAreaColor>"); sw.WriteLine("<showLegend>" + chartBox.ShowLegend.ToString() + "</showLegend>"); sw.WriteLine("<border width=\"" + chartBox.BorderWidth.ToString() + "\" color=\"" + chartBox.BorderColor.Name + "\"></border>"); sw.WriteLine("</chartBox>"); } else if (staticObjects[i] is StyledTable) { // wrtie down table data StyledTable styledTable = (StyledTable)staticObjects[i]; sw.WriteLine(" "); sw.WriteLine("<table x=\"" + styledTable.X + "\" y=\"" + styledTable.Y + "\" width=\"" + styledTable.Width + "\" height=\"" + styledTable.Height + "\" drawEmptyRows=\"" + (styledTable.DrawEmptyRows == true?"true":"false") + "\" cellHeight=\"" + styledTable.CellHeight.ToString() + "\" horAlignment=\"" + styledTable.HorizontalAlignment.ToString() + "\" verAlignment=\"" + styledTable.VerticalAlignment.ToString() + "\" Selectable=\"" + styledTable.Selectable.ToString() + "\">"); string style = ""; if (styledTable.DataFont.Bold && styledTable.DataFont.Italic) { style = " style=\"Bold Italic\""; } else if (styledTable.DataFont.Bold) { style = " style=\"Bold\""; } else if (styledTable.DataFont.Italic) { style = " style=\"Italic\""; } sw.WriteLine("<font family=\"" + styledTable.DataFont.Name + "\" size=\"" + styledTable.DataFont.Size.ToString("f00") + "\" " + style + "></font>"); sw.WriteLine("<header headerColor=\"" + styledTable.HeaderBackgroundColor.Name + "\" headerFontColor=\"" + styledTable.HeaderFontColor.Name + "\">"); style = ""; if (styledTable.HeaderFont.Bold && styledTable.HeaderFont.Italic) { style = " style=\"Bold Italic\""; } else if (styledTable.HeaderFont.Bold) { style = " style=\"Bold\""; } else if (styledTable.HeaderFont.Italic) { style = " style=\"Italic\""; } sw.WriteLine("<font family=\"" + styledTable.HeaderFont.Name + "\" size=\"" + styledTable.HeaderFont.Size.ToString("f00") + "\" " + style + "></font>"); sw.WriteLine("</header>"); int numOfColumns = styledTable.Columns.Length; sw.WriteLine("<columns>"); for (int j = 0; j < numOfColumns; j++) { string textAlignment = "Left"; if (styledTable.Columns[j].Alignment == StyledTableColumn.AlignmentType.Center) { textAlignment = "Center"; } else if (styledTable.Columns[j].Alignment == StyledTableColumn.AlignmentType.Right) { textAlignment = "Right"; } else { textAlignment = "Left"; } sw.WriteLine("<column name=\"" + ReplaceForXML(styledTable.Columns[j].Name) + "\" label=\"" + ReplaceForXML(styledTable.Columns[j].Label) + "\" width=\"" + styledTable.Columns[j].Width + "\" align=\"" + textAlignment + "\" />"); } sw.WriteLine("</columns>"); if (styledTable.Data != null) { sw.WriteLine("<data>"); for (int j = 0; j < styledTable.Data.Rows.Count; j++) { sw.WriteLine(" <record>"); DataRow theRow = styledTable.Data.Rows[j]; for (int k = 0; k < styledTable.Data.Columns.Count; k++) { sw.WriteLine(" <field>" + ReplaceForXML(theRow[k].ToString()) + "</field>"); } sw.WriteLine(" </record>"); } sw.WriteLine("</data>"); } sw.WriteLine("</table>"); } } sw.WriteLine("</staticContent>"); } // end writing static objects sw.WriteLine(" "); if (dynamicObjects.Length > 0) { sw.WriteLine("<dynamicContent>"); for (int i = 0; i < dynamicObjects.Length; i++) { if (dynamicObjects[i] is TextField) { TextField txtField = (TextField)dynamicObjects[i]; sw.WriteLine(" "); sw.WriteLine("<textField name=\"" + txtField.Name.ToString() + "\" x=\"" + txtField.X + "\" y=\"" + txtField.Y + "\" width=\"" + txtField.Width + "\" height=\"" + txtField.Height + "\" horAlignment=\"" + txtField.HorizontalAlignment.ToString() + "\" verAlignment=\"" + txtField.VerticalAlignment.ToString() + "\" Selectable=\"" + txtField.Selectable.ToString() + "\">"); sw.WriteLine("<text horAlignment=\"" + txtField.TextAlignment.ToString() + "\" verAlignment=\"" + txtField.TextVerticalAlignment.ToString() + "\">" + ReplaceForXML(txtField.Text) + "</text>"); if (txtField.Font != null) { string style = ""; if (txtField.Font.Bold && txtField.Font.Italic) { style = " style=\"Bold Italic\""; } else if (txtField.Font.Bold) { style = " style=\"Bold\""; } else if (txtField.Font.Italic) { style = " style=\"Italic\""; } sw.WriteLine("<font family=\"" + txtField.Font.Name + "\" size=\"" + txtField.Font.Size.ToString("f00") + "\" " + style + "></font>"); } sw.WriteLine("<foregroundColor color=\"" + txtField.ForegroundColor.Name + "\"></foregroundColor>"); sw.WriteLine("<backgroundColor color=\"" + txtField.BackgroundColor.Name + "\"></backgroundColor>"); sw.WriteLine("<border width=\"" + txtField.BorderWidth.ToString() + "\" color=\"" + txtField.BorderColor.Name + "\"></border>"); sw.WriteLine("</textField>"); } else if (dynamicObjects[i] is StyledTable) { StyledTable styledTable = (StyledTable)dynamicObjects[i]; sw.WriteLine(" "); sw.WriteLine("<table x=\"" + styledTable.X + "\" y=\"" + styledTable.Y + "\" width=\"" + styledTable.Width + "\" height=\"" + styledTable.Height + "\" borderColor=\"" + styledTable.BorderColor.Name + "\" drawEmptyRows=\"" + (styledTable.DrawEmptyRows == true?"true":"false") + "\" cellHeight=\"" + styledTable.CellHeight.ToString() + "\" dataSource=\"" + ReplaceForXML(styledTable.DataSource) + "\" horAlignment=\"" + styledTable.HorizontalAlignment.ToString() + "\" verAlignment=\"" + styledTable.VerticalAlignment.ToString() + "\" Selectable=\"" + styledTable.Selectable.ToString() + "\" GroupByField=\"" + styledTable.GroupByField + "\">"); sw.WriteLine("<header headerColor=\"" + styledTable.HeaderBackgroundColor.Name + "\" headerFontColor=\"" + styledTable.HeaderFontColor.Name + "\">"); string style = ""; if (styledTable.HeaderFont.Bold && styledTable.HeaderFont.Italic) { style = " style=\"Bold Italic\""; } else if (styledTable.HeaderFont.Bold) { style = " style=\"Bold\""; } else if (styledTable.HeaderFont.Italic) { style = " style=\"Italic\""; } sw.WriteLine("<font family=\"" + styledTable.HeaderFont.Name + "\" size=\"" + styledTable.HeaderFont.Size.ToString("f00") + "\" " + style + "></font>"); sw.WriteLine("</header>"); sw.WriteLine("<dataRows dataFontColor=\"" + styledTable.DataFontColor.Name + "\">"); style = ""; if (styledTable.DataFont.Bold && styledTable.DataFont.Italic) { style = " style=\"Bold Italic\""; } else if (styledTable.DataFont.Bold) { style = " style=\"Bold\""; } else if (styledTable.DataFont.Italic) { style = " style=\"Italic\""; } sw.WriteLine("<font family=\"" + styledTable.DataFont.Name + "\" size=\"" + styledTable.DataFont.Size.ToString("f00") + "\" " + style + "></font>"); sw.WriteLine("</dataRows>"); int numOfColumns = styledTable.Columns.Length; sw.WriteLine("<columns>"); for (int j = 0; j < numOfColumns; j++) { string textAlignment = "Left"; if (styledTable.Columns[j].Alignment == StyledTableColumn.AlignmentType.Center) { textAlignment = "Center"; } else if (styledTable.Columns[j].Alignment == StyledTableColumn.AlignmentType.Right) { textAlignment = "Right"; } else { textAlignment = "Left"; } sw.WriteLine("<column name=\"" + ReplaceForXML(styledTable.Columns[j].Name) + "\" label=\"" + ReplaceForXML(styledTable.Columns[j].Label) + "\" FormatMask=\"" + ReplaceForXML(styledTable.Columns[j].FormatMask) + "\" width=\"" + styledTable.Columns[j].Width + "\" align=\"" + textAlignment + "\" Visible=\"" + styledTable.Columns[j].Visible + "\"/>"); } sw.WriteLine("</columns>"); sw.WriteLine("</table>"); } } sw.WriteLine("</dynamicContent>"); } sw.WriteLine(" "); sw.WriteLine("</content>"); sw.WriteLine("</daReport>"); sw.Close(); }
public void SetData(ArrayList parameters, ICustomPaint[] staticElements, ICustomPaint[] dynamicElements) { InitNodes(); for (int i = 0; i < parameters.Count; i++) { parametersNode.Nodes.Add(new TreeNode(parameters[i].ToString(), 2, 2)); } parametersNode.Expand(); for (int i = 0; i < staticElements.Length; i++) { if (staticElements[i] is TextField) { TextField txtField = (TextField)staticElements[i]; string theText = txtField.Text.Length > 25 ? txtField.Text.Substring(0, 25) + "..." : txtField.Text; string name = txtField.Name.ToString(); staticContentsNode.Nodes.Add(new TreeNode("Text field [" + name + "]", 0, 0)); } else if (staticElements[i] is daReport.PictureBox) { daReport.PictureBox picBox = (daReport.PictureBox)staticElements[i]; string theText = picBox.ImageFile == null ? "none" : picBox.ImageFile; staticContentsNode.Nodes.Add(new TreeNode("Picture [" + theText + "]", 1, 1)); } else if (staticElements[i] is daReport.ChartBox) { ChartBox chartBox = (ChartBox)staticElements[i]; staticContentsNode.Nodes.Add(new TreeNode("Chart [" + chartBox.Name + "]", 5, 5)); } else if (staticElements[i] is daReport.StyledTable) { StyledTable styledTable = (StyledTable)staticElements[i]; if (styledTable.DataSource != null) { staticContentsNode.Nodes.Add(new TreeNode("Styled table [" + styledTable.DataSource + "]", 3, 3)); } else { staticContentsNode.Nodes.Add(new TreeNode("Styled table", 3, 3)); } } } staticContentsNode.Expand(); for (int i = 0; i < dynamicElements.Length; i++) { if (dynamicElements[i] is TextField) { TextField txtField = (TextField)dynamicElements[i]; string theText = txtField.Text.Length > 25 ? txtField.Text.Substring(0, 25) + "..." : txtField.Text; dynamicContentsNode.Nodes.Add(new TreeNode("Text field [" + txtField.Name + "]", 0, 0)); } else if (dynamicElements[i] is daReport.PictureBox) { dynamicContentsNode.Nodes.Add(new TreeNode("Picture", 1, 1)); } else if (dynamicElements[i] is daReport.StyledTable) { StyledTable styledTable = (StyledTable)dynamicElements[i]; if (styledTable.DataSource != null) { dynamicContentsNode.Nodes.Add(new TreeNode("Styled table [" + styledTable.DataSource + "]", 3, 3)); } else { dynamicContentsNode.Nodes.Add(new TreeNode("Styled table", 3, 3)); } } } dynamicContentsNode.Expand(); }