From 294b81166f21e12247e784d6bf404f5f34b2ee19 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期三, 19 二月 2025 12:51:14 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraReport1.cs | 1032 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 945 insertions(+), 87 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraReport1.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraReport1.cs index 4754ec1..35ab2c9 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraReport1.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/99-test/XtraReport1.cs @@ -1,15 +1,7 @@ -锘縰sing Aspose.Words.Drawing.Charts; -using DevExpress.CodeParser; -using DevExpress.XtraBars.Docking; +锘縰sing DevExpress.Charts.Native; +using DevExpress.Utils; using DevExpress.XtraCharts; using DevExpress.XtraReports.UI; -using DevExpress.XtraSpreadsheet.Model; -using NPOI.POIFS.NIO; -using Org.BouncyCastle.Tls; -using System; -using System.Collections; -using System.ComponentModel; -using System.Drawing; namespace HStation.WinFrmUI { @@ -22,105 +14,971 @@ private SimulationPrintViewModel _printViewModel; - public void SetBingdingData(SimulationPrintViewModel viewModel) + public void SetBingdingData(SimulationPrintViewModel vm) { - _printViewModel = viewModel; - ininal(); - } + // A4璁剧疆 827 1169 + this.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4; + this.Margins = new DevExpress.Drawing.DXMargins(50, 50, 50, 50); - private void ininal() - { - this.DataSource = _printViewModel.PumpList; - this.xrLabel1.DataBindings.Add("Text", _printViewModel.Project, "Name"); - this.xrTable2.DataBindings.Add("Text", _printViewModel.PumpList, "Name"); - this.xrTable2.DataBindings.Add("Text", _printViewModel.PumpList, "BeginGroup"); + // 鍐呭瀹藉害 + float contentWidth = 727F; // 鍐呭瀹藉害 + float firstCaptionHeight = 30F; // 涓�绾ф爣棰橀珮搴� + float pageHeight = 1069F; // 椤甸潰鍙敤楂樺害 + float currentY = 0F; // 褰撳墠Y鍧愭爣 - // 鍒涘缓 XRChart 鎺т欢瀹炰緥 - XRChart xrChart = new XRChart(); - foreach (var item in GenerateAllChartData(1)) + #region 椤电湁 + + var labForCorp = new XRLabel(); + labForCorp.Name = "椤电湁"; + labForCorp.Text = "鏉窞绉戠淮鑺傝兘鎶�鏈偂浠芥湁闄愬叕鍙�"; + labForCorp.Multiline = true; + labForCorp.LocationFloat = new DevExpress.Utils.PointFloat(482F, 16F); + labForCorp.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + labForCorp.SizeF = new System.Drawing.SizeF(236F, 24F); + labForCorp.StylePriority.UseTextAlignment = false; + labForCorp.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; + this.TopMargin.Controls.Add(labForCorp); + + #endregion 椤电湁 + + #region 椤佃剼 + + var pageForCurrentNum = new XRPageInfo(); + pageForCurrentNum.LocationFloat = new DevExpress.Utils.PointFloat(617F, 10.00001F); + pageForCurrentNum.Name = "椤佃剼"; + pageForCurrentNum.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + pageForCurrentNum.SizeF = new System.Drawing.SizeF(100F, 23F); + pageForCurrentNum.StylePriority.UseTextAlignment = false; + pageForCurrentNum.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; + pageForCurrentNum.TextFormatString = "绗瑊0}椤�"; + this.BottomMargin.Controls.Add(pageForCurrentNum); + + #endregion 椤佃剼 + + #region 鏍囬 + + var labForTitle = new XRLabel(); + labForTitle.AnchorHorizontal = ((DevExpress.XtraReports.UI.HorizontalAnchorStyles)((DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right))); + labForTitle.Font = new DevExpress.Drawing.DXFont("Arial", 15F, DevExpress.Drawing.DXFontStyle.Bold); + labForTitle.LocationFloat = new DevExpress.Utils.PointFloat(0F, currentY); + labForTitle.Multiline = true; + labForTitle.Name = "labTitle"; + labForTitle.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F); + labForTitle.SizeF = new System.Drawing.SizeF(727F, 50F); + labForTitle.StylePriority.UseFont = false; + labForTitle.StylePriority.UseTextAlignment = false; + labForTitle.Text = $"{vm.Project.Name}椤圭洰鑺傝兘鎶ュ憡"; + labForTitle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; + this.Detail.Controls.Add(labForTitle); + currentY += 50F; + + #endregion 鏍囬 + + #region 涓�銆侀」鐩杩� + + var labForDescription = CreateFirstCaption("涓�銆侀」鐩杩�", contentWidth, firstCaptionHeight, 0F, currentY); + this.Detail.Controls.Add(labForDescription); + currentY += firstCaptionHeight; + + #endregion 涓�銆侀」鐩杩� + + #region 椤圭洰姒傝堪鍐呭 + + var labForDescriptionContent = new XRLabel(); + labForDescriptionContent.AnchorHorizontal = (DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right); + labForDescriptionContent.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + labForDescriptionContent.LocationFloat = new DevExpress.Utils.PointFloat(0F, currentY); + labForDescriptionContent.Multiline = true; + labForDescriptionContent.Name = "labForDescriptionContent"; + labForDescriptionContent.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F); + labForDescriptionContent.SizeF = new System.Drawing.SizeF(727F, 100F); + labForDescriptionContent.StylePriority.UseFont = false; + labForDescriptionContent.StylePriority.UseTextAlignment = false; + labForDescriptionContent.Text = $" {vm.Project.Description}"; + labForDescriptionContent.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; + this.Detail.Controls.Add(labForDescriptionContent); + currentY += 100F; + + #endregion 椤圭洰姒傝堪鍐呭 + + // 浜屻�佹按娉垫槑缁� + var labForPumpList = new XRLabel(); + labForPumpList.AnchorHorizontal = (DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right); + labForPumpList.Font = new DevExpress.Drawing.DXFont("Arial", 12F, DevExpress.Drawing.DXFontStyle.Bold); + labForPumpList.LocationFloat = new DevExpress.Utils.PointFloat(0F, currentY); + labForPumpList.Multiline = true; + labForPumpList.Name = "labForPumpList"; + labForPumpList.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + labForPumpList.SizeF = new System.Drawing.SizeF(727F, 25F); + labForPumpList.StylePriority.UseFont = false; + labForPumpList.StylePriority.UseTextAlignment = false; + labForPumpList.Text = "浜屻�佹按娉垫槑缁�"; + labForPumpList.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; + this.Detail.Controls.Add(labForPumpList); + currentY += 25F; + + // 姘存车鏄庣粏鍐呭 + if (vm.PumpList != null && vm.PumpList.Count > 0) { - // 鍒涘缓涓�涓郴鍒楋紙鏇茬嚎锛� - Series series = new Series(item.SeriesName, ViewType.Spline); + // 鍒涘缓 XRTable + var tableForPumpList = new XRTable(); + tableForPumpList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + tableForPumpList.SizeF = new SizeF(727F, 30F + vm.PumpList.Count * 25F); // 璁剧疆澶у皬 - // 璁剧疆绯诲垪鐨勬暟鎹瓫閫夋潯浠� - series.FilterString = $"SeriesName = '{item.SeriesName}'"; + // 鍒涘缓琛ㄥご琛� + XRTableRow headerRowPumpList = new XRTableRow(); + headerRowPumpList.BackColor = Color.LightGray; // 璁剧疆鑳屾櫙棰滆壊 - // 璁剧疆绯诲垪鐨勬暟鎹粦瀹� - series.ArgumentDataMember = "XValue"; - series.ValueDataMembers.AddRange(new string[] { "YValue" }); + // 娣诲姞琛ㄥご鍒� + headerRowPumpList.Cells.Add(CreateTableCell("鍚嶇О", 100)); + headerRowPumpList.Cells.Add(CreateTableCell("缂栫爜", 100)); + headerRowPumpList.Cells.Add(CreateTableCell("棰濆畾娴侀噺", 100)); + headerRowPumpList.Cells.Add(CreateTableCell("棰濆畾鎵▼", 100)); + headerRowPumpList.Cells.Add(CreateTableCell("棰濆畾鍔熺巼", 100)); + headerRowPumpList.Cells.Add(CreateTableCell("棰濆畾杞��", 100)); - // 灏嗙郴鍒楁坊鍔犲埌鍥捐〃鐨勭郴鍒楅泦鍚堜腑 - xrChart.Series.Add(series); + // 灏嗚〃澶磋娣诲姞鍒拌〃鏍� + tableForPumpList.Rows.Add(headerRowPumpList); + + // 閬嶅巻姘存车 + foreach (var pump in vm.PumpList) + { + // 鍒涘缓鏁版嵁琛� + var dataRow = new XRTableRow(); + dataRow.Cells.Add(new XRTableCell() + { + Text = pump.Name, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = pump.Code, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = pump.RatedQ.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = pump.RatedH.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = pump.RatedP.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = pump.RatedN.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + tableForPumpList.Rows.Add(dataRow); + } + + // 灏嗚〃鏍兼坊鍔犲埌Detail + this.Detail.Controls.Add(tableForPumpList); + currentY += tableForPumpList.HeightF; + //currentY += vm.PumpList.Count*10; } - xrChart.DataSource = GenerateAllChartData(1); - //Detail1.Controls.Add(xrChart); - } - public class ChartDataPoint - { - public double XValue { get; set; } // 妯潗鏍囧�� - public double YValue { get; set; } // 绾靛潗鏍囧�� - public string SeriesName { get; set; } // 绯诲垪鍚嶇О锛岀敤浜庡尯鍒嗕笉鍚岀殑绾� - } - - public List<ChartDataPoint> GenerateAllChartData(int i) - { - List<ChartDataPoint> series1Data = new List<ChartDataPoint>(); - foreach (var item in _printViewModel.WorkingList.First().PumpAnaly.Items[i].RatedCurveQE) + var labForWorking = CreateFirstCaption("涓夈�佸伐鍐佃鍥�", contentWidth, firstCaptionHeight, 0F, currentY); + this.Detail.Controls.Add(labForWorking); + currentY += firstCaptionHeight; + var labForAccuracy = CreateFirstCaption("(1)銆佺簿搴﹁瘎浼�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForAccuracy); + currentY += firstCaptionHeight; + if (vm.WorkingList != null && vm.WorkingList.Count > 0) { - series1Data.Add(new ChartDataPoint + foreach (var working in vm.WorkingList) { - XValue = item.X, - YValue = item.Y, - SeriesName = _printViewModel.WorkingList.First().PumpAnaly.Items[i].Name - }); - }; + /*XRChart chart = new XRChart(); + chart.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + chart.WidthF = contentWidth; + chart.HeightF = 300F; - List<ChartDataPoint> series2Data = new List<ChartDataPoint>(); - foreach (var item in _printViewModel.WorkingList.First().PumpAnaly.Items[i].CurrentCurveQH) - { - series2Data.Add(new ChartDataPoint - { - XValue = item.X, - YValue = item.Y, - SeriesName = _printViewModel.WorkingList.First().PumpAnaly.Items[i].Name - }); - }; + // 鍒涘缓涓�涓嚎绯诲垪 + Series series = new Series("Series1", ViewType.Spline); + // 娣诲姞鏁版嵁鐐� + foreach (var item in working.PumpAnaly.Items[0].RatedCurveQH) + { + series.Points.Add(new SeriesPoint(item.X, item.Y)); + } + chart.Series.Add(series); + Series series2 = new Series("Series2", ViewType.Spline); + // 娣诲姞鏁版嵁鐐� + foreach (var item in working.PumpAnaly.Items[0].CurrentCurveQE) + { + series2.Points.Add(new SeriesPoint(item.X, item.Y)); + } + chart.Series.Add(series2); + Series series3 = new Series("Series3", ViewType.Spline); + // 娣诲姞鏁版嵁鐐� + foreach (var item in working.PumpAnaly.Items[0].CurrentCurveQP) + { + series3.Points.Add(new SeriesPoint(item.X, item.Y)); + } + chart.Series.Add(series3); - List<ChartDataPoint> series3Data = new List<ChartDataPoint>(); - foreach (var item in _printViewModel.WorkingList.First().PumpAnaly.Items[i].CurrentCurveQP) + Detail.Controls.Add(chart); + currentY += chart.HeightF;*/ + /* var accuracyFlowChart = CreateAccuracyItem(working.Accuracy.Flow?.AvgError ?? 0, 213F, 250F, 300F, currentY); + if (currentY + accuracyFlowChart.HeightF > pageHeight) + { + accuracyFlowChart.LocationF = new DevExpress.Utils.PointFloat(accuracyFlowChart.LocationF.X, currentY); + } + Detail.Controls.Add(accuracyFlowChart); + currentY += accuracyFlowChart.HeightF; + + var accuracyPressChart = CreateAccuracyItem(working.Accuracy.Press?.AvgError ?? 0, 213F, 250F, 513F, currentY); + if (currentY + accuracyPressChart.HeightF > pageHeight) + { + accuracyPressChart.LocationF = new DevExpress.Utils.PointFloat(accuracyPressChart.LocationF.X, currentY); + } + Detail.Controls.Add(accuracyPressChart); + currentY += accuracyPressChart.HeightF;*/ + var accuracyScaleChart = CreateAccuracyScale(working.Accuracy.Scale, 300F, 230F, currentY); + Detail.Controls.Add(accuracyScaleChart); + var accuracyFlowChart = CreateAccuracyItem(working.Accuracy.Flow?.AvgError ?? 0, 213F, 230F, 300F, currentY); + Detail.Controls.Add(accuracyFlowChart); + var accuracyPressChart = CreateAccuracyItem(working.Accuracy.Press?.AvgError ?? 0, 213F, 230F, 513F, currentY); + Detail.Controls.Add(accuracyPressChart); + currentY += accuracyScaleChart.HeightF; + } + currentY += 20F; + } + var labForAccuracyList = CreateFirstCaption("(1.1)銆佽瘎浼板垪琛�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForAccuracyList); + currentY += firstCaptionHeight; + + #region 璇勪及鍒楄〃 + + if (vm.WorkingList != null && vm.WorkingList.Count > 0) { - series3Data.Add(new ChartDataPoint + foreach (var working in vm.WorkingList) { - XValue = item.X, - YValue = item.Y, - SeriesName = _printViewModel.WorkingList.First().PumpAnaly.Items[i].Name - }); - }; - // 鍚堝苟鎵�鏈夌郴鍒楃殑鏁版嵁 - List<ChartDataPoint> allData = new List<ChartDataPoint>(); - allData.AddRange(series1Data); - allData.AddRange(series2Data); - allData.AddRange(series3Data); - return allData; + if (working.Accuracy.Items != null && working.Accuracy.Items.Count > 0) + { // 鍒涘缓 XRTable + var tableForAccuracyList = new XRTable(); + tableForAccuracyList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + tableForAccuracyList.SizeF = new SizeF(727F, 30F + working.Accuracy.Items.Count * 25F); // 璁剧疆澶у皬 + + // 鍒涘缓琛ㄥご琛� + XRTableRow headerRowAccuracyList = new XRTableRow(); + headerRowAccuracyList.BackColor = Color.LightGray; // 璁剧疆鑳屾櫙棰滆壊 + + // 娣诲姞琛ㄥご鍒� + headerRowAccuracyList.Cells.Add(CreateTableCell("璇勪及鏋勪欢", 100)); + headerRowAccuracyList.Cells.Add(CreateTableCell("璇勪及椤�", 100)); + headerRowAccuracyList.Cells.Add(CreateTableCell("鐩戞祴鍊�", 100)); + headerRowAccuracyList.Cells.Add(CreateTableCell("璁$畻鍊�", 100)); + headerRowAccuracyList.Cells.Add(CreateTableCell("璇勪及璇樊", 100)); + + // 灏嗚〃澶磋娣诲姞鍒拌〃鏍� + tableForAccuracyList.Rows.Add(headerRowAccuracyList); + + foreach (var item in working.Accuracy.Items) + { + // 鍒涘缓鏁版嵁琛� + var dataRow = new XRTableRow(); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.EvaluateName, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.EvaluateItem, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.MonitorValue.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.CalcuValue.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.EvaluateError?.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + tableForAccuracyList.Rows.Add(dataRow); + } + // 灏嗚〃鏍兼坊鍔犲埌Detail + this.Detail.Controls.Add(tableForAccuracyList); + currentY += tableForAccuracyList.HeightF; + } + } + currentY += 20F; + } + + #endregion 璇勪及鍒楄〃 + + #region 姘存车鍒嗘瀽 + + var labForPump = CreateFirstCaption("(2)銆佹按娉靛垎鏋�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForPump); + currentY += 20F; + if (vm.WorkingList != null && vm.WorkingList.Count > 0) + { + foreach (var working in vm.WorkingList) + { + if (working.PumpAnaly != null && working.PumpAnaly.Items != null && working.PumpAnaly.Items.Count > 0) + { + foreach (var item in working.PumpAnaly.Items) + { + var label = CreateFirstCaption(item.Name, contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(label); + currentY += 20F; + + XRChart chart = new XRChart(); + ((System.ComponentModel.ISupportInitialize)(chart)).BeginInit(); + chart.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + chart.WidthF = contentWidth; + chart.HeightF = 700F; + chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; + + // 鍒涘缓 XY 鍥捐〃 + XYDiagram xyDiagram = new XYDiagram(); + ((System.ComponentModel.ISupportInitialize)(xyDiagram)).BeginInit(); + + // 閰嶇疆涓� X 杞� + xyDiagram.AxisX.Title.Text = "娴侀噺(m鲁/h)"; + xyDiagram.AxisX.Title.Visibility = DefaultBoolean.True; + xyDiagram.AxisX.Visibility = DefaultBoolean.True; + xyDiagram.AxisX.Alignment = AxisAlignment.Far; // 灏� X 杞磋缃湪鍥捐〃搴曢儴 + + // 閰嶇疆涓� Y 杞� + xyDiagram.AxisY.Title.Text = "鎵▼/m"; + xyDiagram.AxisY.Title.Visibility = DefaultBoolean.True; + xyDiagram.AxisY.Visibility = DefaultBoolean.True; + + // 鍒涘缓涓や釜闈㈡澘 + XYDiagramPane pane1 = new XYDiagramPane(); + pane1.Name = "Pane 1"; + xyDiagram.Panes.Add(pane1); + + XYDiagramPane pane2 = new XYDiagramPane(); + pane2.Name = "Pane 2"; + xyDiagram.Panes.Add(pane2); + + // 鍒涘缓娆¤ Y 杞� + SecondaryAxisY secondaryAxisY1 = new SecondaryAxisY("Secondary Y-Axis 1"); + secondaryAxisY1.Title.Text = "鍔熺巼"; + secondaryAxisY1.Title.Visibility = DefaultBoolean.True; + secondaryAxisY1.Visibility = DefaultBoolean.True; + xyDiagram.SecondaryAxesY.Add(secondaryAxisY1); + + SecondaryAxisY secondaryAxisY2 = new SecondaryAxisY("Secondary Y-Axis 2"); + secondaryAxisY2.Title.Text = "鏁堢巼"; + secondaryAxisY2.Title.Visibility = DefaultBoolean.True; + secondaryAxisY2.Visibility = DefaultBoolean.True; + xyDiagram.SecondaryAxesY.Add(secondaryAxisY2); + + chart.Diagram = xyDiagram; + ((System.ComponentModel.ISupportInitialize)(xyDiagram)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(chart)).EndInit(); + + // 鍒涘缓绗竴涓郴鍒� + Series series1 = new Series("Series 1", ViewType.Spline); + foreach (var qh in item.RatedCurveQH) + { + series1.Points.Add(new SeriesPoint(qh.X, qh.Y)); + } + series1.LabelsVisibility = DefaultBoolean.False; + chart.Series.Add(series1); + // 鍒涘缓绗簩涓郴鍒� + Series series2 = new Series("Series 2", ViewType.Spline); + foreach (var qe in item.RatedCurveQE) + { + series2.Points.Add(new SeriesPoint(qe.X, qe.Y)); + } +((XYDiagramSeriesViewBase)series2.View).Pane = pane2; + ((XYDiagramSeriesViewBase)series2.View).AxisY = secondaryAxisY2; + series2.LabelsVisibility = DefaultBoolean.False; + chart.Series.Add(series2); + // 鍒涘缓绗笁涓郴鍒� + Series series3 = new Series("Series 3", ViewType.Spline); + foreach (var qp in item.RatedCurveQP) + { + series3.Points.Add(new SeriesPoint(qp.X, qp.Y)); + } +((XYDiagramSeriesViewBase)series3.View).Pane = pane1; + ((XYDiagramSeriesViewBase)series3.View).AxisY = secondaryAxisY1; + series3.LabelsVisibility = DefaultBoolean.False; + chart.Series.Add(series3); + + Detail.Controls.Add(chart); + currentY += chart.HeightF; + } + } + } + currentY += 20F; + } + + #endregion 姘存车鍒嗘瀽 + + #region 鐩戞祴鍒嗘瀽 + + var labForMonitor = CreateFirstCaption("(3)銆佺洃娴嬪垎鏋�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForMonitor); + currentY += 20F; + if (vm.WorkingList != null && vm.WorkingList.Count > 0) + { + foreach (var working in vm.WorkingList) + { + if (working.MonitorAnaly.Items != null && working.MonitorAnaly.Items.Count > 0) + { // 鍒涘缓 XRTable + var tableForMonitorList = new XRTable(); + tableForMonitorList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + tableForMonitorList.SizeF = new SizeF(727F, 30F + working.MonitorAnaly.Items.Count * 25F); // 璁剧疆澶у皬 + + // 鍒涘缓琛ㄥご琛� + XRTableRow headerRowMonitorList = new XRTableRow(); + headerRowMonitorList.BackColor = Color.LightGray; // 璁剧疆鑳屾櫙棰滆壊 + + // 娣诲姞琛ㄥご鍒� + headerRowMonitorList.Cells.Add(CreateTableCell("鏋勪欢", 100)); + headerRowMonitorList.Cells.Add(CreateTableCell("灞炴��", 100)); + headerRowMonitorList.Cells.Add(CreateTableCell("璁$畻鍊�", 100)); + headerRowMonitorList.Cells.Add(CreateTableCell("鍗曚綅", 100)); + + // 灏嗚〃澶磋娣诲姞鍒拌〃鏍� + tableForMonitorList.Rows.Add(headerRowMonitorList); + + foreach (var item in working.MonitorAnaly.Items) + { + // 鍒涘缓鏁版嵁琛� + var dataRow = new XRTableRow(); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.VisualName, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.PropName, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.CalcuValue?.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.UnitName, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + tableForMonitorList.Rows.Add(dataRow); + } + // 灏嗚〃鏍兼坊鍔犲埌Detail + this.Detail.Controls.Add(tableForMonitorList); + currentY += tableForMonitorList.HeightF; + currentY += 20F; + } + } + } + + #endregion 鐩戞祴鍒嗘瀽 + + #region 鑳借�楀垎鏋� + + var labForEnergyAnaly = CreateFirstCaption("(4)銆佽兘鑰楀垎鏋�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForEnergyAnaly); + currentY += 20F; + if (vm.WorkingList != null && vm.WorkingList.Count > 0) + { + foreach (var working in vm.WorkingList) + { + if (working.EnergyAnaly != null) + { + if (working.EnergyAnaly.Items != null && working.EnergyAnaly.Items.Count > 0) + { + var group = working.EnergyAnaly.Items.GroupBy(x => x.BeginGroup).ToArray(); + foreach (var item in group) + { + var label = CreateFirstCaption(item.Key, contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(label); + currentY += 20F; + + XRChart chartQh = new XRChart(); + chartQh.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + chartQh.WidthF = contentWidth; + chartQh.HeightF = 300F; + + XRChart chartQE = new XRChart(); + chartQE.LocationF = new DevExpress.Utils.PointFloat(0F, currentY + chartQh.HeightF); + chartQE.WidthF = contentWidth; + chartQE.HeightF = 300F; + + XRChart chartQP = new XRChart(); + chartQP.LocationF = new DevExpress.Utils.PointFloat(0F, currentY + chartQh.HeightF + chartQE.HeightF); + chartQP.WidthF = contentWidth; + chartQP.HeightF = 300F; + + foreach (var valve in item) + { + // 鍒涘缓涓�涓嚎绯诲垪 + Series series = new Series(valve.Code, ViewType.Spline); + // 娣诲姞鏁版嵁鐐� + foreach (var qh in valve.CurrentCurveQH) + { + series.Points.Add(new SeriesPoint(qh.X.ToString(), qh.Y.ToString())); + } + chartQh.Series.Add(series); + + Series series2 = new Series("Series2", ViewType.Spline); + // 娣诲姞鏁版嵁鐐� + foreach (var qe in valve.CurrentCurveQE) + { + series2.Points.Add(new SeriesPoint(qe.X.ToString(), qe.Y.ToString())); + } + chartQE.Series.Add(series2); + + Series series3 = new Series("Series3", ViewType.Spline); + // 娣诲姞鏁版嵁鐐� + foreach (var qp in valve.CurrentCurveQP) + { + series3.Points.Add(new SeriesPoint(qp.X.ToString(), qp.Y.ToString())); + } + chartQP.Series.Add(series3); + } + + this.Detail.Controls.Add(chartQh); + this.Detail.Controls.Add(chartQE); + this.Detail.Controls.Add(chartQP); + + currentY += chartQh.HeightF + chartQE.HeightF + chartQP.HeightF; + } + } + } + } + } + + #endregion 鑳借�楀垎鏋� + + //鑳芥晥鏄庣粏 + var labForEnergyDetails = CreateFirstCaption("(4.1)銆佽兘鏁堟槑缁�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForEnergyDetails); + currentY += 20F; + if (vm.WorkingList != null && vm.WorkingList.Count > 0) + { + foreach (var working in vm.WorkingList) + { + if (working.EnergyAnaly.Items != null && working.EnergyAnaly.Items.Count > 0) + { + // 鍒涘缓 XRTable + var tableForEnergyDetails = new XRTable(); + tableForEnergyDetails.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + tableForEnergyDetails.SizeF = new SizeF(727F, 30F + working.EnergyAnaly.Items.Count * 25F); // 璁剧疆澶у皬 + + // 鍒涘缓琛ㄥご琛� + XRTableRow headerRowEnergyDetails = new XRTableRow(); + headerRowEnergyDetails.BackColor = Color.LightGray; // 璁剧疆鑳屾櫙棰滆壊 + + // 娣诲姞琛ㄥご鍒� + headerRowEnergyDetails.Cells.Add(CreateTableCell("鍒嗙粍", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("鍚嶇О", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("杩愯鐘舵��", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("璁惧畾璇勭巼(hz)", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("璁惧畾娴侀噺(m鲁/h)", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("杩涘彛鍘嬪姏(m)", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("鍑哄彛鍘嬪姏(m)", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("鎵▼(m)", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("鍔熺巼(Kw)", 100)); + headerRowEnergyDetails.Cells.Add(CreateTableCell("鏁堢巼(%)", 100)); + // 灏嗚〃澶磋娣诲姞鍒拌〃鏍� + tableForEnergyDetails.Rows.Add(headerRowEnergyDetails); + + foreach (var item in working.EnergyAnaly.Items) + { + // 鍒涘缓鏁版嵁琛� + var dataRow = new XRTableRow(); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.BeginGroup, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.Name, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.LinkStatus, + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.CurrentHz.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + dataRow.Cells.Add(new XRTableCell() + { + Text = item.RatedHz.ToString(), + WidthF = 100F, + TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter, + Borders = DevExpress.XtraPrinting.BorderSide.All + }); + tableForEnergyDetails.Rows.Add(dataRow); + } + // 灏嗚〃鏍兼坊鍔犲埌Detail + this.Detail.Controls.Add(tableForEnergyDetails); + currentY += tableForEnergyDetails.HeightF; + currentY += 20F; + } + } + } + + #region 鎹熷け鏇茬嚎 + + var labForLossCurve = CreateFirstCaption("(5)銆佹崯澶辨洸绾�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForLossCurve); + currentY += 20F; + if (vm.WorkingList != null && vm.WorkingList.Count > 0) + { + foreach (var working in vm.WorkingList) + { + if (working.LossCurve != null && working.LossCurve.Items != null) + { + XRChart chart = new XRChart(); + chart.LocationF = new DevExpress.Utils.PointFloat(0F, currentY); + chart.WidthF = contentWidth; + chart.HeightF = 300F; + + // 鍒涘缓涓�涓嚎绯诲垪 + Series series = new Series("Series1", ViewType.Area); + Series series2 = new Series("Series2", ViewType.Area); + Series series3 = new Series("Series3", ViewType.Area); + // 娣诲姞鏁版嵁鐐� + foreach (var item in working.LossCurve.End.Items) + { + series.Points.Add(new SeriesPoint(item.X, item.Y)); + } + // 娣诲姞鏁版嵁鐐� + foreach (var item in working.LossCurve.Start.Items) + { + series2.Points.Add(new SeriesPoint(item.X, item.Y)); + } // 娣诲姞鏁版嵁鐐� + foreach (var item in working.LossCurve.Elev.Items) + { + series3.Points.Add(new SeriesPoint(item.X, item.Y)); + } + + chart.Series.Add(series); + chart.Series.Add(series2); + chart.Series.Add(series3); + Detail.Controls.Add(chart); + currentY += chart.HeightF; + } + } + } + + #endregion 鎹熷け鏇茬嚎 + + #region 鎹熷け缁熻 + + var labForLossStatistics = CreateFirstCaption("(6)銆佹崯澶辩粺璁�", contentWidth - 25F, 15F, 20F, currentY); + this.Detail.Controls.Add(labForLossStatistics); + currentY += 20F; + if (vm.WorkingList != null && vm.WorkingList.Count > 0) + { + foreach (var working in vm.WorkingList) + { + var accuracyScaleChart = CreateLossStatistics(working.LossStatistics, 350F, 230F, 0F, currentY); + Detail.Controls.Add(accuracyScaleChart); + var EnergyLossChart = CreateEnergyLoss(working.LossStatistics, 377F, 230F, 350F, currentY); + Detail.Controls.Add(EnergyLossChart); + currentY += accuracyScaleChart.HeightF; + var CategoryChart = CreateCategory(working.LossStatistics, 727F, 230F, 0F, currentY); + Detail.Controls.Add(CategoryChart); + } + } + + #endregion 鎹熷け缁熻 } - public class Product + //鍒涘缓涓�绾ф爣棰� + private XRLabel CreateFirstCaption(string caption, float sizeX, float sizeY, float locationX, float locationY) { - public string Name { get; set; } - public decimal Code { get; set; } + var lab = new XRLabel(); + lab.AnchorHorizontal = (DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right); + lab.Font = new DevExpress.Drawing.DXFont("Arial", 12F, DevExpress.Drawing.DXFontStyle.Bold); + lab.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY); + lab.Multiline = true; + lab.Name = "lab"; + lab.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + lab.SizeF = new System.Drawing.SizeF(sizeX, sizeY); + lab.StylePriority.UseFont = false; + lab.StylePriority.UseTextAlignment = false; + lab.Text = caption; + lab.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; + return lab; } - public List<Product> CreateSampleProductList() + //鍒涘缓绮惧害姣斾緥 + private XRChart CreateAccuracyScale(SimulationPrintAccuracyScaleViewModel scale, float sizeX, float sizeY, float locationY) { - List<Product> products = new List<Product> - { - new Product { Name = "鑻规灉", Code = 5.99m }, - new Product { Name = "棣欒晧", Code = 3.99m }, - new Product { Name = "姗欏瓙", Code = 4.99m } - }; + var chart = new XRChart(); + chart.BackColor = System.Drawing.Color.Transparent; + chart.BorderColor = System.Drawing.Color.Black; + chart.Borders = DevExpress.XtraPrinting.BorderSide.All; + chart.Legend.Name = "Default Legend"; + chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; + chart.LocationFloat = new DevExpress.Utils.PointFloat(0F, locationY); + chart.Name = "chart"; + chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F); - return products; + var series = new DevExpress.XtraCharts.Series(); + series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; + series.Name = "Series"; + var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView(); + doughnutSeriesView.HoleRadiusPercent = 45; + doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 12F, DevExpress.Drawing.DXFontStyle.Bold); + doughnutSeriesView.TotalLabel.Visible = true; + series.View = doughnutSeriesView; + series.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.True; + series.Label.TextPattern = "{A}锛歿VP:P1}"; + chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series }; + chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY); + chart.StylePriority.UseBackColor = false; + chart.StylePriority.UsePadding = false; + if (scale != null) + { + if (scale.Items != null && scale.Items.Count > 0) + { + foreach (var item in scale.Items) + { + series.Points.Add(new SeriesPoint(item.EvaluateItem, item.EvaluateCount)); + } + } + doughnutSeriesView.TotalLabel.TextPattern = string.Format("{0:0%}", (scale.AvgError ?? 0) / 100F); + } + return chart; + } + + //鍒涘缓鑳介噺杈撳叆 + private XRChart CreateLossStatistics(HydroLossStatisticsViewModel statistics, float sizeX, float sizeY, float locationX, float locationY) + { + var chart = new XRChart(); + chart.BackColor = System.Drawing.Color.Transparent; + chart.BorderColor = System.Drawing.Color.Black; + chart.Borders = DevExpress.XtraPrinting.BorderSide.All; + chart.Legend.Name = "Default Legend"; + chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; + chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY); + chart.Name = "chart"; + chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F); + + var series = new DevExpress.XtraCharts.Series(); + series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; + series.Name = "Series"; + var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView(); + doughnutSeriesView.HoleRadiusPercent = 45; + doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 8F, DevExpress.Drawing.DXFontStyle.Bold); + doughnutSeriesView.TotalLabel.Visible = true; + series.View = doughnutSeriesView; + series.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.True; + series.Label.TextPattern = "{A}锛歿VP:P1}"; + chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series }; + chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY); + chart.StylePriority.UseBackColor = false; + chart.StylePriority.UsePadding = false; + if (statistics != null) + { + if (statistics.Input.Items != null && statistics.Input.Items.Count > 0) + { + foreach (var item in statistics.Input.Items) + { + series.Points.Add(new SeriesPoint(item.EnergyName.ToString(), item.EnergyValue)); + } + } + doughnutSeriesView.TotalLabel.TextPattern = $"鎬昏兘閲�:{statistics.Input.TotalEnergyValue:P0}"; + } + return chart; + } + + //鍒涘缓鑳介噺缁熻 + private XRChart CreateCategory(HydroLossStatisticsViewModel statistics, float sizeX, float sizeY, float locationX, float locationY) + { + var chart = new XRChart(); + chart.BackColor = System.Drawing.Color.Transparent; + chart.BorderColor = System.Drawing.Color.Black; + chart.Borders = DevExpress.XtraPrinting.BorderSide.All; + chart.Legend.Name = "Default Legend"; + chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; + chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY); + chart.Name = "chart"; + chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F); + chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY); + chart.StylePriority.UseBackColor = false; + chart.StylePriority.UsePadding = false; + if (statistics != null) + { + if (statistics.Category != null && statistics.Category.Items.Count > 0) + { + foreach (var item in statistics.Category.Items) + { + var series1 = new Series(item.EnergyName, ViewType.Bar); + series1.Points.Add(new SeriesPoint(item.EnergyName.ToString(), item.EnergyValue)); + // 鑾峰彇绯诲垪瑙嗗浘骞惰浆鎹负 BarSeriesView 绫诲瀷 + BarSeriesView barSeriesView = (BarSeriesView)series1.View; + series1.Label.TextPattern = "{V} KW"; + // 璁剧疆鏌卞瓙瀹藉害锛岃繖閲岃缃负 0.8锛屽彲鏍规嵁闇�瑕佽皟鏁� + barSeriesView.BarWidth = 2.5; + // 灏嗙郴鍒楁坊鍔犲埌鍥捐〃涓� + chart.Series.Add(series1); + } + } + } + return chart; + } + + //鍒涘缓鑳介噺鎹熷け + private XRChart CreateEnergyLoss(HydroLossStatisticsViewModel statistics, float sizeX, float sizeY, float locationX, float locationY) + { + var chart = new XRChart(); + chart.BackColor = System.Drawing.Color.Transparent; + chart.BorderColor = System.Drawing.Color.Black; + chart.Borders = DevExpress.XtraPrinting.BorderSide.All; + chart.Legend.Name = "Default Legend"; + chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; + chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY); + chart.Name = "chart"; + chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F); + + var series = new DevExpress.XtraCharts.Series(); + series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True; + series.Name = "Series"; + var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView(); + doughnutSeriesView.HoleRadiusPercent = 45; + doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 8F, DevExpress.Drawing.DXFontStyle.Bold); + doughnutSeriesView.TotalLabel.Visible = true; + series.View = doughnutSeriesView; + series.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.True; + series.Label.TextPattern = "{A}锛歿VP:P1}"; + chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series }; + chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY); + chart.StylePriority.UseBackColor = false; + chart.StylePriority.UsePadding = false; + if (statistics != null) + { + if (statistics.Catalog != null && statistics.Catalog.Items.Count > 0) + { + foreach (var item in statistics.Catalog.Items) + { + series.Points.Add(new SeriesPoint(item.EnergyName.ToString(), item.EnergyValue)); + } + } + doughnutSeriesView.TotalLabel.TextPattern = $"鎬绘崯澶�:{statistics.Input.TotalEnergyValue:P0}"; + } + return chart; + } + + //鍒涘缓绮惧害椤� + private XRChart CreateAccuracyItem(double value, float sizeX, float sizeY, float locationX, float locationY) + { + var chart = new XRChart(); + chart.BackColor = System.Drawing.Color.Transparent; + chart.BorderColor = System.Drawing.Color.Black; + chart.Borders = DevExpress.XtraPrinting.BorderSide.All; + chart.Legend.Name = "Default Legend"; + chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; + chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY); + chart.Name = "chart"; + chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F); + chart.PaletteRepository.Add("Palette 1", new DevExpress.XtraCharts.Palette("Palette 1", DevExpress.XtraCharts.PaletteScaleMode.Repeat, new DevExpress.XtraCharts.PaletteEntry[] { + new DevExpress.XtraCharts.PaletteEntry(System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(174)))), ((int)(((byte)(197))))), System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(174)))), ((int)(((byte)(197)))))), + new DevExpress.XtraCharts.PaletteEntry(System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(236)))), ((int)(((byte)(240))))), System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(236)))), ((int)(((byte)(240))))))})); + chart.PaletteName = "Palette 1"; + + var series = new DevExpress.XtraCharts.Series(); + series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False; + series.Name = "Series"; + var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView(); + doughnutSeriesView.HoleRadiusPercent = 45; + doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 12F, DevExpress.Drawing.DXFontStyle.Bold); + doughnutSeriesView.TotalLabel.Visible = true; + series.View = doughnutSeriesView; + chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series }; + chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY); + chart.StylePriority.UseBackColor = false; + chart.StylePriority.UsePadding = false; + + var otherValue = 100 - value; + series.Points.Add(new SeriesPoint("璇樊", value)); + series.Points.Add(new SeriesPoint("鍏朵粬", otherValue)); + + doughnutSeriesView.TotalLabel.TextPattern = string.Format("{0:0%}", value / 100f); + return chart; + } + + // 鍒涘缓琛ㄥご鍗曞厓鏍� + private XRTableCell CreateTableCell(string text, int width) + { + XRTableCell cell = new XRTableCell(); + cell.Text = text; + cell.Width = width; + cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; // 鏂囨湰灞呬腑 + cell.Borders = DevExpress.XtraPrinting.BorderSide.All; // 璁剧疆杈规 + return cell; + } + + // 鍒涘缓鏁版嵁缁戝畾鍗曞厓鏍� + private XRTableCell CreateTableCellWithBinding(string dataMember, int width) + { + XRTableCell cell = new XRTableCell(); + cell.DataBindings.Add(new XRBinding("Text", null, dataMember)); // 缁戝畾鏁版嵁瀛楁 + cell.Width = width; + cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; // 鏂囨湰宸﹀榻� + cell.Borders = DevExpress.XtraPrinting.BorderSide.All; // 璁剧疆杈规 + return cell; } } } \ No newline at end of file -- Gitblit v1.9.3