ningshuxia
2025-03-24 7b8ae93d47186c442ff890a1a83d108f115924c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
using DevExpress.Utils;
using DevExpress.Utils.Drawing;
using DevExpress.XtraCharts;
using DevExpress.XtraReports.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yw.WinFrmUI.Phart;
 
namespace HStation.WinFrmUI
{
    public class ReportHelper
    {
        //创建一级标题
        public static XRLabel CreateFirstCaption(string caption, float sizeX, float sizeY, float locationX, float locationY)
        {
            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 static XRLabel CreateGroupCaption(string caption, float sizeX, float sizeY, float locationX, float locationY)
        {
            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;
 
            // 设置背景颜色
            lab.BackColor = System.Drawing.Color.AliceBlue;
            // 设置边框样式
            //lab.BorderDashStyle = DevExpress.XtraPrinting.BorderSide.All;
            lab.BorderWidth = 1;
            lab.BorderColor = System.Drawing.Color.AliceBlue;
            return lab;
        }
 
        //创建精度比例
        public static XRChart CreateAccuracyScale(HydroAccuracyScaleViewModel 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 != 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;
        }
 
        //创建能量输入
        public static 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);
 
            ChartTitle title = new ChartTitle();
            title.Text = "能量输入"; // 设置标题文本
            title.Font = new DevExpress.Drawing.DXFont("Arial", 14, DevExpress.Drawing.DXFontStyle.Bold); // 设置标题字体
            title.Alignment = StringAlignment.Center; // 设置标题对齐方式
            chart.Titles.Add(title);
 
            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}KW";
            }
            return chart;
        }
 
        //创建能量统计
        public static 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;
 
            ChartTitle title = new ChartTitle();
            title.Text = "能量统计"; // 设置标题文本
            title.Font = new DevExpress.Drawing.DXFont("Arial", 14, DevExpress.Drawing.DXFontStyle.Bold); // 设置标题字体
            title.Alignment = StringAlignment.Center; // 设置标题对齐方式
            chart.Titles.Add(title);
 
            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;
        }
 
        //创建能量损失
        public static 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);
 
            ChartTitle title = new ChartTitle();
            title.Text = "能量损失"; // 设置标题文本
            title.Font = new DevExpress.Drawing.DXFont("Arial", 14, DevExpress.Drawing.DXFontStyle.Bold); // 设置标题字体
            title.Alignment = StringAlignment.Center; // 设置标题对齐方式
            chart.Titles.Add(title);
 
            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}KW";
            }
            return chart;
        }
 
        //创建精度项
        public static 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;
        }
 
        // 创建表头单元格
        public static 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;
        }
 
        // 创建数据绑定单元格
        public static 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;
        }
 
        public static void SetAxisX(XYDiagram xyDiagram, double Min, double Max)
        {
            /*  xyDiagram.AxisX.VisualRange.Auto = false;
              xyDiagram.AxisX.WholeRange.Auto = false;
              xyDiagram.AxisX.NumericScaleOptions.AutoGrid = false;*/
 
            xyDiagram.AxisX.VisualRange.Auto = false;
            xyDiagram.AxisX.WholeRange.Auto = false;
            xyDiagram.AxisX.WholeRange.SideMarginsValue = 0;
            xyDiagram.AxisX.VisualRange.SideMarginsValue = 0;
            xyDiagram.AxisX.WholeRange.SetMinMaxValues(Min, Max);
            xyDiagram.AxisX.VisualRange.SetMinMaxValues(Min, Max);
            xyDiagram.AxisX.GridLines.Color = Color.Silver;// CurveChartDisplay.CurveColorQP;
            xyDiagram.AxisX.GridLines.LineStyle.DashStyle = (DashStyle)PumpChartDisplay.GridLineTypeY;
            xyDiagram.AxisX.GridLines.Visible = true;
        }
 
        public static void SetAxisY(XYDiagram xyDiagram, double Min, double Max)
        {
            //xyDiagram.AxisY.VisualRange.Auto = false;
            //xyDiagram.AxisY.WholeRange.Auto = false;
            //xyDiagram.AxisY.NumericScaleOptions.AutoGrid = false;
            xyDiagram.AxisY.WholeRange.SideMarginsValue = 0;
            xyDiagram.AxisY.VisualRange.SideMarginsValue = 0;
            xyDiagram.AxisY.WholeRange.SetMinMaxValues(Min, Max);
            xyDiagram.AxisY.VisualRange.SetMinMaxValues(Min, Max);
            xyDiagram.AxisY.GridLines.Color = Color.Silver;// CurveChartDisplay.CurveColorQP;
            xyDiagram.AxisY.GridLines.LineStyle.DashStyle = (DashStyle)PumpChartDisplay.GridLineTypeY;
            xyDiagram.AxisY.GridLines.Visible = true;
        }
 
        public static void SetSecondaryAxisY(SecondaryAxisY AxisY, double Min, double Max)
        {
            AxisY.WholeRange.SideMarginsValue = 0;
            AxisY.VisualRange.SideMarginsValue = 0;
            AxisY.WholeRange.SetMinMaxValues(Min, Max);
            AxisY.VisualRange.SetMinMaxValues(Min, Max);
            AxisY.GridLines.Color = Color.Silver;// CurveChartDisplay.CurveColorQP;
            AxisY.GridLines.LineStyle.DashStyle = (DashStyle)PumpChartDisplay.GridLineTypeY;
            AxisY.GridLines.Visible = true;
        }
 
        /// <summary>
        /// 设置图表
        /// </summary>
        public static void SetChartDisplay(XRChart chart)
        {
            chart.Legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Right;
            chart.Legend.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
            chart.Legend.Direction = DevExpress.XtraCharts.LegendDirection.LeftToRight;
            chart.Legend.MarkerMode = DevExpress.XtraCharts.LegendMarkerMode.Marker;
            /*    chart.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False;
                chart.SeriesSelectionMode = SeriesSelectionMode.Point;*/
 
            SetChartBackColor(chart);
        }
 
        /// <summary>
        /// 设置图表背景色
        /// </summary>
        /// <param name="chart"></param>
        public static void SetChartBackColor(XRChart chart)
        {
            chart.BackColor = PumpChartDisplay.ChartBackColor;
            foreach (var title in chart.Titles)
            {
                if (title is ChartTitle chartTitle)
                    chartTitle.TextColor = PumpChartDisplay.ChartChartTitle;
            }
 
            if (chart.Diagram is XYDiagram xyDiagram)
            {
                xyDiagram.DefaultPane.Title.Alignment = StringAlignment.Near;
                xyDiagram.DefaultPane.Title.DXFont = new Font("Tahoma", 9);
                xyDiagram.DefaultPane.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;
                xyDiagram.DefaultPane.BackColor = PumpChartDisplay.ChartBackColor;
                for (int i = 0; i < xyDiagram.Panes.Count; i++)
                {
                    xyDiagram.Panes[i].BackColor = PumpChartDisplay.ChartBackColor;
                }
 
                xyDiagram.AxisX.GridLines.MinorColor = Color.Silver;
                xyDiagram.AxisY.GridLines.MinorColor = Color.Silver;
 
                for (int i = 0; i < xyDiagram.SecondaryAxesX.Count; i++)
                {
                    var axis = xyDiagram.SecondaryAxesX[i];
                    axis.GridLines.MinorColor = Color.Silver;
                }
 
                for (int i = 0; i < xyDiagram.SecondaryAxesY.Count; i++)
                {
                    var axis = xyDiagram.SecondaryAxesY[i];
                    axis.GridLines.MinorColor = Color.Silver;
                }
            }
        }
 
        public static TextAnnotation AddAnnotation(string tag, string caption, Color color, AxisYBase axis_y, XYDiagramPaneBase pane, Yw.Geometry.Point2d pt, double angle = -10, double connector_length = 20)
        {
            if (pt == null)
                return null;
            var anchor_pt = pt;
            var pane_anchor_pt = new DevExpress.XtraCharts.PaneAnchorPoint();
            pane_anchor_pt.Pane = pane;
            pane_anchor_pt.AxisYCoordinate.Axis = axis_y;
            pane_anchor_pt.AxisXCoordinate.AxisValue = anchor_pt.X;
            pane_anchor_pt.AxisYCoordinate.AxisValue = anchor_pt.Y;
            pane_anchor_pt.Tag = tag;
 
            var relative_position = new DevExpress.XtraCharts.RelativePosition();
            relative_position.Angle = angle;
            relative_position.ConnectorLength = connector_length;
 
            var text_annotation = new TextAnnotation();
            text_annotation.AnchorPoint = pane_anchor_pt;
            text_annotation.AutoHeight = true;
            text_annotation.AutoWidth = true;
            text_annotation.BackColor = System.Drawing.Color.Transparent;
            text_annotation.Border.Color = System.Drawing.Color.Transparent;
            text_annotation.Border.Visibility = DefaultBoolean.False;
            text_annotation.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.None;
            text_annotation.Tag = 1;
            text_annotation.Padding.Bottom = 1;
            text_annotation.Padding.Left = 1;
            text_annotation.Padding.Right = 1;
            text_annotation.Padding.Top = 1;
            text_annotation.RuntimeMoving = false;
            text_annotation.RuntimeAnchoring = true;
            text_annotation.RuntimeResizing = false;
            text_annotation.RuntimeRotation = false;
            text_annotation.RuntimeEditing = false;
            text_annotation.Text = caption;
            text_annotation.TextColor = color;
            text_annotation.ShapePosition = relative_position;
            text_annotation.Visible = true;
            text_annotation.EnableAntialiasing = DefaultBoolean.True;
 
            text_annotation.DXFont = new DevExpress.Drawing.DXFont("", 8F);
            return text_annotation;
        }
 
        public static double RoundUpMax(double value)
        {
            if (value > 50 && value < 100)
                return 100;
            double power = Math.Pow(10, Math.Floor(Math.Log10(value)));
 
            // 如果 power 太大,缩小基数
            if (value / power < 2)
            {
                power /= 10; // 缩小基数,使其更接近输入值
            }
 
            // 向上取整到最近的 power 的倍数
            return Math.Ceiling(value / power) * power;
        }
 
        public static double RoundDownMin(double value)
        {
            // 处理值为 0 的情况
            if (value == 0)
            {
                return 0;
            }
 
            // 计算最接近的 10 的幂次
            double power = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(value))));
 
            if (value >= 0)
            {
                // 正数向下取整到最近的 power 的倍数
                return Math.Floor(value / power) * power;
            }
            else
            {
                // 负数也向下取整到最近的 power 的倍数(绝对值更大)
                return -Math.Ceiling(-value / power) * power;
            }
        }
 
        /// <summary>
        /// 获取最大的间隔
        /// </summary>
        /// <param name="minValue">最小值</param>
        /// <param name="maxValue">最大值</param>
        /// <param name="spaceNum">间隔数量</param>
        /// <param name="minDisplay">最小显示参数</param>
        /// <param name="maxDisplay">最大显示参数</param>
        /// <returns></returns>
        public static void GetOptimalSpaceMax(double minValue, double maxValue, int spaceNum, out double minDisplay, out double maxDisplay)
        {
            PhartCoordinateHelper.GetOptimalSpaceMax(minValue, maxValue, spaceNum, out minDisplay, out maxDisplay);
        }
 
        public static void DrawEquipPoint(XYDiagram diagram, AxisX axis_x_flow, AxisY axis_y_head, SecondaryAxisY axis_y_power, SecondaryAxisY axis_y_eff, Graphics cache, Pen pen, HydroEnergyAnalyPipeItemViewModel sect_pt)
        {
            if (sect_pt == null)
                return;
            if (!sect_pt.PipeQ.HasValue || !sect_pt.PipeH.HasValue)
            {
                return;
            }
            double Q = sect_pt.PipeQ.Value;
            double H = sect_pt.PipeH.Value;
            // double? E = sect_pt.E;
            //  double? P = sect_pt.P;
 
            var offset_size = 4;
            var qh_pt = diagram.DiagramToPoint(Q, H, axis_x_flow, axis_y_head);
 
            var qh_pt_x = qh_pt.Point.X;
            var qh_pt_y = qh_pt.Point.Y;
            //cache.DrawLine(pen, new Point(qh_pt_x, qh_pt_y - offset_size), new Point(qh_pt_x, qh_pt_y + offset_size));
 
            var x = qh_pt_x;
            var y = qh_pt_y;
 
            var length = 8;
            using Pen pen1 = new Pen(Color.Magenta, 1);
            cache.DrawLine(pen1, new Point(x - length, y), new Point(x + length, y));
            cache.DrawLine(pen1, new Point(x, y - length), new Point(x, y + length));
            cache.DrawEllipse(pen1, new Rectangle(x - 5, y - 5, length, length));
 
            //pen.Width = 1;
            //pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            //pen.Color = Color.Black;
            //cache.DrawEllipse(pen, new Rectangle(x - 2, y - 2, 4, 4));
            //cache.DrawEllipse(pen, new Rectangle(x - 5, y - 5, 10, 10));
            //cache.DrawEllipse(pen, new Rectangle(x - 10, y - 10, 20, 20));
 
            /* if (E.HasValue)
             {
                 var qe_pt = diagram.DiagramToPoint(Q, E.Value, axis_x_flow, axis_y_eff);
                 var qe_pt_x = qe_pt.Point.X;
                 var qe_pt_y = qe_pt.Point.Y;
                 cache.DrawLine(pen, new Point(qe_pt_x, qe_pt_y - offset_size), new Point(qe_pt_x, qe_pt_y + offset_size));
             }
 
             if (P.HasValue)
             {
                 var qp_pt = diagram.DiagramToPoint(Q, P.Value, axis_x_flow, axis_y_power);
                 var qp_pt_x = qp_pt.Point.X;
                 var qp_pt_y = qp_pt.Point.Y;
                 cache.DrawLine(pen, new Point(qp_pt_x, qp_pt_y - offset_size), new Point(qp_pt_x, qp_pt_y + offset_size));
             }*/
        }
 
        public static void DrawEquipLine(XYDiagram diagram, AxisX axis_x_flow, AxisY axis_y_head, Graphics cache, Pen pen, HydroEnergyAnalyPipeItemViewModel sect_pt)
        {
            if (sect_pt == null)
                return;
            if (!sect_pt.PipeQ.HasValue || !sect_pt.PipeH.HasValue)
            {
                return;
            }
            double Q = sect_pt.PipeQ.Value;
            double H = sect_pt.PipeH.Value;
            double StartH = sect_pt.StartH;
            var pt_f_list = new List<Yw.Geometry.Point2d>();
            var start_point = new Yw.Geometry.Point2d(0.0, StartH);
            var end_point = new Yw.Geometry.Point2d(Q, H);
            pt_f_list = Yw.Pump.PerformParabolaHelper.GetEquipCurvePointList(start_point, end_point, 30);
 
            if (pt_f_list == null || !pt_f_list.Any())
                return;
            var pointF = new List<PointF>();
 
            foreach (var pt in pt_f_list)
            {
                var x = pt.X;
                var y = pt.Y;
                var c_pt = diagram.DiagramToPoint(x, y, axis_x_flow, axis_y_head);
                pointF.Add(new PointF(c_pt.Point.X, c_pt.Point.Y));
            }
            using var path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddCurve(pointF.ToArray());
            cache.DrawPath(pen, path);
        }
    }
}