duheng
2025-02-17 26f45822a2a84af81e20ca543da98d3b822c5afd
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/report/SimulationCommonReport.cs
@@ -204,23 +204,70 @@
            {
                foreach (var working in vm.WorkingList)
                {
                    XRChart chart = new XRChart();
                    chart.LocationF = new DevExpress.Utils.PointFloat(0F, locationY);
                    chart.WidthF = contentWidth;
                    chart.HeightF = 300F;
                    //XRChart chart = new XRChart();
                    //chart.LocationF = new DevExpress.Utils.PointFloat(0F, locationY);
                    //chart.WidthF = contentWidth;
                    //chart.HeightF = 300F;
                    // 创建一个线系列
                    Series series = new Series("Series1", ViewType.Spline);
                    //// 创建一个线系列
                    //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));
                    }
                    //// 添加数据点
                    //foreach (var item in working.PumpAnaly.Items[0].RatedCurveQH)
                    //{
                    //    series.Points.Add(new SeriesPoint(item.X, item.Y));
                    //}
                    chart.Series.Add(series);
                    //chart.Series.Add(series);
                    Detail.Controls.Add(chart);
                    //Detail.Controls.Add(chart);
                    var accuracyScaleChart = CreateAccuracyScale(working.Accuracy.Scale, 300F, 250F, locationY);
                    Detail.Controls.Add(accuracyScaleChart);
                    var accuracyFlowChart = CreateAccuracyItem(working.Accuracy.Flow?.AvgError ?? 0, 213F, 250F, 300F, locationY);
                    Detail.Controls.Add(accuracyFlowChart);
                    var accuracyPressChart = CreateAccuracyItem(working.Accuracy.Press?.AvgError ?? 0, 213F, 250F, 513F, locationY);
                    Detail.Controls.Add(accuracyPressChart);
                    //var chart = new XRChart();
                    //chart.BackColor = System.Drawing.Color.Transparent;
                    //chart.BorderColor = System.Drawing.Color.Black;
                    //chart.Borders = DevExpress.XtraPrinting.BorderSide.None;
                    ////chart.Legend.LegendID = -1;
                    //chart.Legend.Name = "Default Legend";
                    //chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
                    //chart.LocationFloat = new DevExpress.Utils.PointFloat(20F, locationY);
                    //chart.Name = "xrChart6";
                    //chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 96F);
                    //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 1";
                    ////series.SeriesID = 0;
                    //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(175F, 185F);
                    //chart.StylePriority.UseBackColor = false;
                    //chart.StylePriority.UsePadding = false;
                    //series.Points.Add(new SeriesPoint("误差", 15));
                    //series.Points.Add(new SeriesPoint("其他", 85));
                    //doughnutSeriesView.TotalLabel.TextPattern = string.Format("{0:0%}", 0.15);
                    //this.Detail.Controls.Add(chart);
                }
            }
        }
@@ -243,6 +290,83 @@
            return lab;
        }
        //创建精度比例
        private XRChart CreateAccuracyScale(SimulationPrintAccuracyScaleViewModel scale, float sizeX, float sizeY, 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(0F, 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", 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.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 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)