/// <summary>Writes PDF for specified auto-doc commands.</summary> /// <param name="section">The writer to write to.</param> /// <param name="tags">The autodoc tags.</param> /// <param name="workingDirectory">The working directory.</param> private void TagsToMigraDoc(Section section, List<AutoDocumentation.ITag> tags, string workingDirectory) { foreach (AutoDocumentation.ITag tag in tags) { if (tag is AutoDocumentation.Heading) { AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading; if (heading.headingLevel > 0 && heading.headingLevel <= 6) { if (heading.headingLevel == 1) section.AddPageBreak(); Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel); if (heading.headingLevel == 1) para.Format.OutlineLevel = OutlineLevel.Level1; else if (heading.headingLevel == 2) para.Format.OutlineLevel = OutlineLevel.Level2; else if (heading.headingLevel == 3) para.Format.OutlineLevel = OutlineLevel.Level3; else if (heading.headingLevel == 4) para.Format.OutlineLevel = OutlineLevel.Level4; else if (heading.headingLevel == 5) para.Format.OutlineLevel = OutlineLevel.Level5; else if (heading.headingLevel == 6) para.Format.OutlineLevel = OutlineLevel.Level6; } } else if (tag is AutoDocumentation.Paragraph) { AddFormattedParagraphToSection(section, tag as AutoDocumentation.Paragraph); } else if (tag is AutoDocumentation.GraphAndTable) { CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable, workingDirectory); } else if (tag is AutoDocumentation.Table) { CreateTable(section, tag as AutoDocumentation.Table, workingDirectory); } else if (tag is Graph) { GraphPresenter graphPresenter = new GraphPresenter(); GraphView graphView = new GraphView(); graphView.BackColor = System.Drawing.Color.White; graphView.FontSize = 12; graphView.Width = 500; graphView.Height = 500; graphPresenter.Attach(tag, graphView, ExplorerPresenter); string PNGFileName = graphPresenter.ExportToPDF(workingDirectory); section.AddImage(PNGFileName); string caption = (tag as Graph).Caption; if (caption != null) section.AddParagraph(caption); graphPresenter.Detach(); } else if (tag is Map) { Form f = new Form(); f.Width = 700; // 1100; f.Height = 500; // 600; MapPresenter mapPresenter = new MapPresenter(); MapView mapView = new MapView(); mapView.BackColor = System.Drawing.Color.White; mapView.Parent = f; (mapView as Control).Dock = DockStyle.Fill; f.Show(); mapPresenter.Attach(tag, mapView, ExplorerPresenter); Application.DoEvents(); Thread.Sleep(2000); Application.DoEvents(); string PNGFileName = mapPresenter.ExportToPDF(workingDirectory); section.AddImage(PNGFileName); mapPresenter.Detach(); f.Close(); } else if (tag is AutoDocumentation.Image) { AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image; if (imageTag.image.Width > 700) imageTag.image = ImageUtilities.ResizeImage(imageTag.image, 700, 500); string PNGFileName = Path.Combine(workingDirectory, imageTag.name); imageTag.image.Save(PNGFileName, System.Drawing.Imaging.ImageFormat.Png); section.AddImage(PNGFileName); } } }
/// <summary>Initializes a new instance of the <see cref="SeriesView" /> class</summary> public SeriesView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.SeriesView.glade", "vbox1"); gxml.Autoconnect(this); _mainWidget = vbox1; graphView1 = new GraphView(this); vbox1.PackStart(graphView1.MainWidget, true, true, 0); dropDownView1 = new DropDownView(this); dropDownView2 = new DropDownView(this); dropDownView3 = new DropDownView(this); dropDownView4 = new DropDownView(this); dropDownView5 = new DropDownView(this); dropDownView6 = new DropDownView(this); dropDownView7 = new DropDownView(this); dropDownView8 = new DropDownView(this); dropDownView9 = new ColourDropDownView(this); dropDownView10 = new DropDownView(this); dropDownView11 = new DropDownView(this); checkBoxView1 = new CheckBoxView(this); checkBoxView1.TextOfLabel = "on top?"; checkBoxView2 = new CheckBoxView(this); checkBoxView2.TextOfLabel = "on right?"; checkBoxView3 = new CheckBoxView(this); checkBoxView3.TextOfLabel = "cumulative?"; checkBoxView4 = new CheckBoxView(this); checkBoxView4.TextOfLabel = "cumulative?"; checkBoxView5 = new CheckBoxView(this); checkBoxView5.TextOfLabel = "Show in legend?"; checkBoxView6 = new CheckBoxView(this); checkBoxView6.TextOfLabel = "Include series name in legend?"; editView1 = new EditView(this); table1.Attach(dropDownView1.MainWidget, 1, 2, 0, 1, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView2.MainWidget, 1, 2, 1, 2, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView3.MainWidget, 1, 2, 2, 3, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView5.MainWidget, 1, 2, 3, 4, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView4.MainWidget, 1, 2, 4, 5, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView6.MainWidget, 1, 2, 5, 6, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView7.MainWidget, 1, 2, 6, 7, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView8.MainWidget, 1, 2, 7, 8, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView9.MainWidget, 1, 2, 8, 9, AttachOptions.Fill, 0, 10, 2); table1.Attach(editView1.MainWidget, 1, 2, 9, 10, AttachOptions.Fill, 0, 10, 2); table1.Attach(checkBoxView1.MainWidget, 2, 3, 1, 2, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView2.MainWidget, 2, 3, 2, 3, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView3.MainWidget, 3, 4, 1, 2, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView4.MainWidget, 3, 4, 2, 3, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView5.MainWidget, 2, 4, 8, 9, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView6.MainWidget, 2, 4, 9, 10, AttachOptions.Fill, 0, 0, 0); table1.Attach(dropDownView10.MainWidget, 3, 4, 6, 7, AttachOptions.Fill, 0, 0, 5); table1.Attach(dropDownView11.MainWidget, 3, 4, 7, 8, AttachOptions.Fill, 0, 0, 5); }
/// <summary> /// Initializes a new instance of the <see cref="InitialWaterView" /> class. /// </summary> public XYPairsView(ViewBase owner) : base(owner) { vpaned = new VPaned(); _mainWidget = vpaned; gridView = new GridView(this); graphView = new GraphView(this); vpaned.Pack1(gridView.MainWidget, true, false); vpaned.Pack2(graphView.MainWidget, true, false); }
/// <summary> /// Initializes a new instance of the <see cref="InitialWaterView" /> class. /// </summary> public InitialWaterView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.InitialWaterView.glade", "hpaned1"); gxml.Autoconnect(this); _mainWidget = hpaned1; combobox1.PackStart(comboRender, false); combobox1.AddAttribute(comboRender, "text", 0); combobox1.Model = comboModel; graphView1 = new GraphView(this); hpaned1.Pack2(graphView1.MainWidget, true, true); entry1.Changed += OnTextBox1TextChanged; entry2.Changed += OnTextBox2TextChanged; radiobutton1.Toggled += OnRadioButton1CheckedChanged; spinbutton1.Changed += OnNumericUpDown1ValueChanged; combobox1.Changed += OnComboBox1SelectedValueChanged; _mainWidget.Destroyed += _mainWidget_Destroyed; }
public ProfileView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.ProfileView.glade", "vpaned1"); gxml.Autoconnect(this); _mainWidget = vpaned1; PropertyGrid = new GridView(this); vbox1.PackStart(PropertyGrid.MainWidget, true, true, 0); //vpaned1.Pack1(PropertyGrid.MainWidget, true, true); ProfileGrid = new GridView(this); vpaned2.Pack1(ProfileGrid.MainWidget, true, true); Graph = new GraphView(this); vpaned2.Pack2(Graph.MainWidget, true, true); }
/// <summary>Creates the graph.</summary> /// <param name="writer">The writer.</param> /// <param name="graphAndTable">The graph and table to convert to html.</param> /// <param name="workingDirectory">The working directory.</param> private void CreateGraphPDF(Section section, AutoDocumentation.GraphAndTable graphAndTable, string workingDirectory) { // Create a 2 column, 1 row table. Image in first cell, X/Y data in second cell. Table table = section.AddTable(); table.Style = "GraphAndTable"; table.Rows.LeftIndent = graphAndTable.indent + "cm"; Column column1 = table.AddColumn(); column1.Width = "8cm"; //column1.Format.Alignment = ParagraphAlignment.Right; Column column2 = table.AddColumn(); column2.Width = "8cm"; //column2.Format.Alignment = ParagraphAlignment.Right; Row row = table.AddRow(); // Ensure graphs directory exists. string graphDirectory = Path.Combine(workingDirectory, "Graphs"); Directory.CreateDirectory(graphDirectory); // Determine the name of the .png file to write. string PNGFileName = Path.Combine(graphDirectory, graphAndTable.xyPairs.Parent.Parent.Name + graphAndTable.xyPairs.Parent.Name + ".png"); // Setup graph. GraphView graph = new GraphView(); graph.Clear(); // Create a line series. graph.DrawLineAndMarkers("", graphAndTable.xyPairs.X, graphAndTable.xyPairs.Y, Models.Graph.Axis.AxisType.Bottom, Models.Graph.Axis.AxisType.Left, System.Drawing.Color.Blue, Models.Graph.LineType.Solid, Models.Graph.MarkerType.None, Models.Graph.LineThicknessType.Normal, Models.Graph.MarkerSizeType.Normal, true); // Format the axes. graph.FormatAxis(Models.Graph.Axis.AxisType.Bottom, graphAndTable.xName, false, double.NaN, double.NaN, double.NaN); graph.FormatAxis(Models.Graph.Axis.AxisType.Left, graphAndTable.yName, false, double.NaN, double.NaN, double.NaN); graph.BackColor = System.Drawing.Color.White; graph.FontSize = 10; graph.Refresh(); // Export graph to bitmap file. Bitmap image = new Bitmap(400, 250); graph.Export(image, false); image.Save(PNGFileName, System.Drawing.Imaging.ImageFormat.Png); MigraDoc.DocumentObjectModel.Shapes.Image image1 = row.Cells[0].AddImage(PNGFileName); // Add x/y data. Paragraph xyParagraph = row.Cells[1].AddParagraph(); xyParagraph.Style = "xyStyle"; AddFixedWidthText(xyParagraph, "X", 10); AddFixedWidthText(xyParagraph, "Y", 10); xyParagraph.AddLineBreak(); for (int i = 0; i < graphAndTable.xyPairs.X.Length; i++) { AddFixedWidthText(xyParagraph, graphAndTable.xyPairs.X[i].ToString(), 10); AddFixedWidthText(xyParagraph, graphAndTable.xyPairs.Y[i].ToString(), 10); xyParagraph.AddLineBreak(); } // Add an empty paragraph for spacing. Paragraph spacing = section.AddParagraph(); }
/// <summary>Writes PDF for specified auto-doc commands.</summary> /// <param name="section">The writer to write to.</param> /// <param name="tags">The autodoc tags.</param> /// <param name="workingDirectory">The working directory.</param> private void TagsToMigraDoc(Section section, List<AutoDocumentation.ITag> tags, string workingDirectory) { foreach (AutoDocumentation.ITag tag in tags) { if (tag is AutoDocumentation.Heading) { AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading; if (heading.headingLevel > 0 && heading.headingLevel <= 6) { if (heading.headingLevel == 1) section.AddPageBreak(); Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel); if (heading.headingLevel == 1) para.Format.OutlineLevel = OutlineLevel.Level1; else if (heading.headingLevel == 2) para.Format.OutlineLevel = OutlineLevel.Level2; else if (heading.headingLevel == 3) para.Format.OutlineLevel = OutlineLevel.Level3; else if (heading.headingLevel == 4) para.Format.OutlineLevel = OutlineLevel.Level4; else if (heading.headingLevel == 5) para.Format.OutlineLevel = OutlineLevel.Level5; else if (heading.headingLevel == 6) para.Format.OutlineLevel = OutlineLevel.Level6; } } else if (tag is AutoDocumentation.Paragraph) { AddFormattedParagraphToSection(section, tag as AutoDocumentation.Paragraph); } else if (tag is AutoDocumentation.GraphAndTable) { CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable, workingDirectory); } else if (tag is AutoDocumentation.Table) { CreateTable(section, tag as AutoDocumentation.Table, workingDirectory); } else if (tag is Graph) { GraphPresenter graphPresenter = new GraphPresenter(); GraphView graphView = new GraphView(null); graphView.BackColor = OxyPlot.OxyColors.White; graphView.FontSize = 12; graphView.Width = 500; graphView.Height = 500; graphPresenter.Attach(tag, graphView, ExplorerPresenter); string PNGFileName = graphPresenter.ExportToPDF(workingDirectory); section.AddImage(PNGFileName); string caption = (tag as Graph).Caption; if (caption != null) section.AddParagraph(caption); graphPresenter.Detach(); graphView.MainWidget.Destroy(); } else if (tag is Map && (tag as Map).GetCoordinates().Count > 0) { MapPresenter mapPresenter = new MapPresenter(); MapView mapView = new MapView(null); mapPresenter.Attach(tag, mapView, ExplorerPresenter); string PNGFileName = mapPresenter.ExportToPDF(workingDirectory); if (!String.IsNullOrEmpty(PNGFileName)) section.AddImage(PNGFileName); mapPresenter.Detach(); mapView.MainWidget.Destroy(); } else if (tag is AutoDocumentation.Image) { AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image; if (imageTag.image.Width > 700) imageTag.image = ImageUtilities.ResizeImage(imageTag.image, 700, 500); string PNGFileName = Path.Combine(workingDirectory, imageTag.name); imageTag.image.Save(PNGFileName, System.Drawing.Imaging.ImageFormat.Png); section.AddImage(PNGFileName); } } }
/// <summary>Writes PDF for specified auto-doc commands.</summary> /// <param name="section">The writer to write to.</param> /// <param name="tags">The autodoc tags.</param> /// <param name="workingDirectory">The working directory.</param> private void TagsToMigraDoc(Section section, List<AutoDocumentation.ITag> tags, string workingDirectory) { foreach (AutoDocumentation.ITag tag in tags) { if (tag is AutoDocumentation.Heading) { AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading; if (heading.headingLevel > 0 && heading.headingLevel < 4) { Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel); if (heading.headingLevel == 1) para.Format.OutlineLevel = OutlineLevel.Level1; else if (heading.headingLevel == 2) para.Format.OutlineLevel = OutlineLevel.Level2; else if (heading.headingLevel == 3) para.Format.OutlineLevel = OutlineLevel.Level3; else if (heading.headingLevel == 4) para.Format.OutlineLevel = OutlineLevel.Level4; } } else if (tag is AutoDocumentation.Paragraph) { AddFormattedParagraphToSection(section, tag as AutoDocumentation.Paragraph); } else if (tag is AutoDocumentation.GraphAndTable) { CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable, workingDirectory); } else if (tag is Graph) { GraphPresenter graphPresenter = new GraphPresenter(); GraphView graphView = new GraphView(); graphView.BackColor = System.Drawing.Color.White; graphPresenter.Attach(tag, graphView, ExplorerPresenter); string PNGFileName = graphPresenter.ExportToPDF(workingDirectory); section.AddImage(PNGFileName); string caption = (tag as Graph).Caption; if (caption != null) section.AddParagraph(caption); graphPresenter.Detach(); } } }
/// <summary>Initializes a new instance of the <see cref="TabbedMetDataView"/> class.</summary> public TabbedMetDataView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.TabbedMetDataView.glade", "vbox1"); gxml.Autoconnect(this); _mainWidget = vbox1; graphViewSummary = new GraphView(this); alignSummary.Add(graphViewSummary.MainWidget); graphViewRainfall = new GraphView(this); vboxRainChart.PackEnd(graphViewRainfall.MainWidget); graphViewMonthlyRainfall = new GraphView(this); vboxRainMonthly.PackEnd(graphViewMonthlyRainfall.MainWidget); graphViewTemperature = new GraphView(this); vboxTemp.PackEnd(graphViewTemperature.MainWidget); graphViewRadiation = new GraphView(this); vboxRadn.PackEnd(graphViewRadiation.MainWidget); gridViewData = new GridView(this); gridViewData.ReadOnly = true; alignData.Add(gridViewData.MainWidget); button1.Clicked += OnButton1Click; spinStartYear.ValueChanged += OnGraphStartYearValueChanged; spinNYears.ValueChanged += OnGraphShowYearsValueChanged; notebook1.SwitchPage += TabControl1_SelectedIndexChanged; GraphStartYearMaxValue = 2100; GraphStartYearMinValue = 1900; GraphStartYearValue = 2000; GraphShowYearsValue = 1; worksheetCombo = new DropDownView(this); alignment10.Add(worksheetCombo.MainWidget); worksheetCombo.IsVisible = true; worksheetCombo.Changed += WorksheetCombo_Changed; _mainWidget.Destroyed += _mainWidget_Destroyed; }
/// <summary>Initializes a new instance of the <see cref="SeriesView" /> class</summary> public SeriesView(ViewBase owner) : base(owner) { Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.SeriesView.glade", "vbox1"); gxml.Autoconnect(this); _mainWidget = vbox1; graphView1 = new GraphView(this); vbox1.PackStart(graphView1.MainWidget, true, true, 0); dropDownView1 = new DropDownView(this); dropDownView2 = new DropDownView(this); dropDownView3 = new DropDownView(this); dropDownView4 = new DropDownView(this); dropDownView5 = new DropDownView(this); dropDownView6 = new DropDownView(this); dropDownView7 = new DropDownView(this); dropDownView8 = new DropDownView(this); dropDownView9 = new ColourDropDownView(this); dropDownView10 = new DropDownView(this); dropDownView11 = new DropDownView(this); checkBoxView1 = new CheckBoxView(this); checkBoxView1.TextOfLabel = "on top?"; checkBoxView2 = new CheckBoxView(this); checkBoxView2.TextOfLabel = "on right?"; checkBoxView3 = new CheckBoxView(this); checkBoxView3.TextOfLabel = "cumulative?"; checkBoxView4 = new CheckBoxView(this); checkBoxView4.TextOfLabel = "cumulative?"; checkBoxView5 = new CheckBoxView(this); checkBoxView5.TextOfLabel = "Show in legend?"; checkBoxView6 = new CheckBoxView(this); checkBoxView6.TextOfLabel = "Include series name in legend?"; editView1 = new EditView(this); table1.Attach(dropDownView1.MainWidget, 1, 2, 0, 1, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView2.MainWidget, 1, 2, 1, 2, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView3.MainWidget, 1, 2, 2, 3, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView5.MainWidget, 1, 2, 3, 4, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView4.MainWidget, 1, 2, 4, 5, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView6.MainWidget, 1, 2, 5, 6, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView7.MainWidget, 1, 2, 6, 7, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView8.MainWidget, 1, 2, 7, 8, AttachOptions.Fill, 0, 10, 2); table1.Attach(dropDownView9.MainWidget, 1, 2, 8, 9, AttachOptions.Fill, 0, 10, 2); Image helpImage = new Image(null, "ApsimNG.Resources.help.png"); EventBox ebHelp = new EventBox(); ebHelp.Add(helpImage); ebHelp.ButtonPressEvent += Help_ButtonPressEvent; HBox filterBox = new HBox(); filterBox.PackStart(editView1.MainWidget, true, true, 0); filterBox.PackEnd(ebHelp, false, true, 0); //table1.Attach(editView1.MainWidget, 1, 2, 9, 10, AttachOptions.Fill, 0, 10, 2); table1.Attach(filterBox, 1, 2, 9, 10, AttachOptions.Fill, 0, 10, 2); table1.Attach(checkBoxView1.MainWidget, 2, 3, 1, 2, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView2.MainWidget, 2, 3, 2, 3, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView3.MainWidget, 3, 4, 1, 2, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView4.MainWidget, 3, 4, 2, 3, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView5.MainWidget, 2, 4, 8, 9, AttachOptions.Fill, 0, 0, 0); table1.Attach(checkBoxView6.MainWidget, 2, 4, 9, 10, AttachOptions.Fill, 0, 0, 0); table1.Attach(dropDownView10.MainWidget, 3, 4, 6, 7, AttachOptions.Fill, 0, 0, 5); table1.Attach(dropDownView11.MainWidget, 3, 4, 7, 8, AttachOptions.Fill, 0, 0, 5); }