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;
}
///
/// 设置图表
///
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);
}
///
/// 设置图表背景色
///
///
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;
}
}
///
/// 获取最大的间隔
///
/// 最小值
/// 最大值
/// 间隔数量
/// 最小显示参数
/// 最大显示参数
///
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();
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();
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);
}
}
}