Shuxia Ning
2024-12-10 cecd5e98941ff09c2e00b50d1c3e5733d2d9309c
workingChart
已修改4个文件
已添加8个文件
2706 ■■■■■ 文件已修改
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart - 复制.Designer.cs 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart - 复制.cs 958 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart - 复制.resx 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart.cs 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewViewModel.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewChart.Designer.cs 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewChart.cs 838 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewChart.resx 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewItemViewModel.cs 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewViewModel.cs 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/Yw.WinFrmUI.Phart.Core.csproj 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs
@@ -1092,8 +1092,7 @@
                    {
                        _onMoveWorkPointLine = true;
                    }
                }
                else if (hitInfo.InAnnotation)
                {
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart - ¸´ÖÆ.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,177 @@
namespace Yw.WinFrmUI.Phart
{
    partial class PumpRunViewChart
    {
        /// <summary>
        /// Requipuired designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        #region Component Designer generated code
        /// <summary>
        /// Requipuired method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            DevExpress.XtraCharts.XYDiagram xyDiagram1 = new DevExpress.XtraCharts.XYDiagram();
            DevExpress.XtraCharts.LayoutDefinition layoutDefinition1 = new DevExpress.XtraCharts.LayoutDefinition();
            DevExpress.XtraCharts.LayoutDefinition layoutDefinition2 = new DevExpress.XtraCharts.LayoutDefinition();
            DevExpress.XtraCharts.LayoutDefinition layoutDefinition3 = new DevExpress.XtraCharts.LayoutDefinition();
            DevExpress.XtraCharts.XYDiagramPane xyDiagramPane1 = new DevExpress.XtraCharts.XYDiagramPane();
            DevExpress.XtraCharts.SecondaryAxisY secondaryAxisy1 = new DevExpress.XtraCharts.SecondaryAxisY();
            DevExpress.XtraCharts.SecondaryAxisY secondaryAxisy2 = new DevExpress.XtraCharts.SecondaryAxisY();
            DevExpress.XtraCharts.Series series1 = new DevExpress.XtraCharts.Series();
            DevExpress.XtraCharts.SplineSeriesView splineSeriesView1 = new DevExpress.XtraCharts.SplineSeriesView();
            DevExpress.XtraCharts.Series series2 = new DevExpress.XtraCharts.Series();
            DevExpress.XtraCharts.SplineSeriesView splineSeriesView2 = new DevExpress.XtraCharts.SplineSeriesView();
            DevExpress.XtraCharts.Series series3 = new DevExpress.XtraCharts.Series();
            DevExpress.XtraCharts.SplineSeriesView splineSeriesView3 = new DevExpress.XtraCharts.SplineSeriesView();
            chartControl1 = new DevExpress.XtraCharts.ChartControl();
            bar1 = new DevExpress.XtraBars.Bar();
            ((System.ComponentModel.ISupportInitialize)chartControl1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)xyDiagram1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)xyDiagramPane1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy2).BeginInit();
            ((System.ComponentModel.ISupportInitialize)series1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)series2).BeginInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView2).BeginInit();
            ((System.ComponentModel.ISupportInitialize)series3).BeginInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView3).BeginInit();
            SuspendLayout();
            //
            // chartControl1
            //
            chartControl1.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False;
            xyDiagram1.AxisX.Title.Text = "流量 ï¼ˆm³/h)";
            xyDiagram1.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            xyDiagram1.AxisX.VisibleInPanesSerializable = "-1";
            xyDiagram1.AxisY.Color = Color.DodgerBlue;
            xyDiagram1.AxisY.Label.TextColor = Color.DodgerBlue;
            xyDiagram1.AxisY.Title.Alignment = StringAlignment.Far;
            xyDiagram1.AxisY.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.False;
            xyDiagram1.AxisY.Title.Text = "扬程/m";
            xyDiagram1.AxisY.Title.TextColor = Color.DodgerBlue;
            xyDiagram1.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            xyDiagram1.AxisY.VisibleInPanesSerializable = "-1";
            xyDiagram1.DefaultPane.BorderVisible = false;
            xyDiagram1.DefaultPane.Title.Text = "无数据";
            xyDiagram1.PaneLayout.AutoLayoutMode = DevExpress.XtraCharts.PaneAutoLayoutMode.Grid;
            xyDiagram1.PaneLayout.RowDefinitions.AddRange(new DevExpress.XtraCharts.LayoutDefinition[] { layoutDefinition1, layoutDefinition2, layoutDefinition3 });
            xyDiagramPane1.BorderVisible = false;
            xyDiagramPane1.LayoutOptions.Column = 0;
            xyDiagramPane1.LayoutOptions.Row = 2;
            xyDiagramPane1.Name = "BottomPanel";
            xyDiagramPane1.PaneID = 1;
            xyDiagramPane1.RuntimeCollapse = DevExpress.Utils.DefaultBoolean.False;
            xyDiagramPane1.SelectionRectangle.BorderVisible = false;
            xyDiagram1.Panes.AddRange(new DevExpress.XtraCharts.XYDiagramPane[] { xyDiagramPane1 });
            secondaryAxisy1.AxisID = 0;
            secondaryAxisy1.Color = Color.Green;
            secondaryAxisy1.Label.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
            secondaryAxisy1.Label.TextColor = Color.Green;
            secondaryAxisy1.Name = "AxisYQE";
            secondaryAxisy1.Title.Text = "效率/%";
            secondaryAxisy1.Title.TextColor = Color.Green;
            secondaryAxisy1.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            secondaryAxisy1.VisibleInPanesSerializable = "-1";
            secondaryAxisy2.Alignment = DevExpress.XtraCharts.AxisAlignment.Near;
            secondaryAxisy2.AxisID = 1;
            secondaryAxisy2.Label.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
            secondaryAxisy2.Label.TextColor = Color.Crimson;
            secondaryAxisy2.Name = "AxisYQP";
            secondaryAxisy2.NumericScaleOptions.AutoGrid = false;
            secondaryAxisy2.NumericScaleOptions.GridSpacing = 2D;
            secondaryAxisy2.Title.Alignment = StringAlignment.Near;
            secondaryAxisy2.Title.Text = "功率/kW";
            secondaryAxisy2.Title.TextColor = Color.Crimson;
            secondaryAxisy2.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            secondaryAxisy2.VisibleInPanesSerializable = "1";
            xyDiagram1.SecondaryAxesY.AddRange(new DevExpress.XtraCharts.SecondaryAxisY[] { secondaryAxisy1, secondaryAxisy2 });
            chartControl1.Diagram = xyDiagram1;
            chartControl1.Dock = DockStyle.Fill;
            chartControl1.Legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Right;
            chartControl1.Legend.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
            chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.LeftToRight;
            chartControl1.Legend.LegendID = -1;
            chartControl1.Legend.MarkerMode = DevExpress.XtraCharts.LegendMarkerMode.CheckBoxAndMarker;
            chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
            chartControl1.Location = new Point(0, 0);
            chartControl1.Name = "chartControl1";
            series1.Name = "SeriesQH";
            series1.SeriesID = 0;
            splineSeriesView1.Color = Color.FromArgb(84, 141, 212);
            series1.View = splineSeriesView1;
            series2.Name = "SeriesQE";
            series2.SeriesID = 1;
            splineSeriesView2.AxisYName = "AxisYQE";
            splineSeriesView2.Color = Color.FromArgb(155, 187, 89);
            series2.View = splineSeriesView2;
            series3.Name = "SeriesQP";
            series3.SeriesID = 2;
            splineSeriesView3.AxisYName = "AxisYQP";
            splineSeriesView3.Color = Color.FromArgb(192, 0, 0);
            splineSeriesView3.PaneName = "BottomPanel";
            series3.View = splineSeriesView3;
            chartControl1.SeriesSerializable = new DevExpress.XtraCharts.Series[]
    {
    series1,
    series2,
    series3
    };
            chartControl1.Size = new Size(1023, 857);
            chartControl1.TabIndex = 0;
            //
            // bar1
            //
            bar1.BarName = "Custom 2";
            bar1.DockCol = 0;
            bar1.DockRow = 0;
            bar1.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
            bar1.OptionsBar.MultiLine = true;
            bar1.OptionsBar.UseWholeRow = true;
            bar1.Text = "Custom 2";
            //
            // PumpRunViewChart
            //
            AutoScaleDimensions = new SizeF(10F, 22F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(chartControl1);
            Name = "PumpRunViewChart";
            Size = new Size(1023, 857);
            ((System.ComponentModel.ISupportInitialize)xyDiagramPane1).EndInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy1).EndInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy2).EndInit();
            ((System.ComponentModel.ISupportInitialize)xyDiagram1).EndInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView1).EndInit();
            ((System.ComponentModel.ISupportInitialize)series1).EndInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView2).EndInit();
            ((System.ComponentModel.ISupportInitialize)series2).EndInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView3).EndInit();
            ((System.ComponentModel.ISupportInitialize)series3).EndInit();
            ((System.ComponentModel.ISupportInitialize)chartControl1).EndInit();
            ResumeLayout(false);
        }
        #endregion
        private DevExpress.XtraCharts.ChartControl chartControl1;
        private DevExpress.XtraBars.Bar bar1;
    }
}
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart - ¸´ÖÆ.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,958 @@
using DevExpress.Utils;
using DevExpress.Utils.Drawing;
using DevExpress.Utils.Html.Internal;
using DevExpress.XtraCharts;
namespace Yw.WinFrmUI.Phart
{
    /// <summary>
    /// æ³µè¿è¡Œè§†å›¾å›¾è¡¨
    /// </summary>
    public partial class PumpRunViewChart : DevExpress.XtraEditors.XtraUserControl
    {
        public PumpRunViewChart()
        {
            InitializeComponent();
            InitialChart();
            this.chartControl1.RuntimeHitTesting = true;
            this.chartControl1.SelectionMode = ElementSelectionMode.Extended;
            this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Point;
        }
        #region Private Variable
        private readonly string _tag_qh = "QH", _tag_qe = "QE", _tag_qp = "QP";
        private XYDiagram _diagram;
        private XYDiagramDefaultPane _default_pane;
        private XYDiagramPane _bottom_pane;
        private AxisX _axis_x_flow;
        private AxisY _axis_y_head;
        private SecondaryAxisY _axis_y_eff, _axis_y_power;
        private PumpCoordinate _coordinate;
        private bool _qe_visible = true;
        private bool _qp_visible = true;
        private bool _run_point_visible = true;
        private bool _initial_data = false;
        private PumpRunViewViewModel _vm = null;
        #endregion
        #region Public Variable
        /// <summary>
        /// æ•ˆçŽ‡æ˜¾ç¤º
        /// </summary>
        public bool QEVisible
        {
            get => _qe_visible;
            set
            {
                _qe_visible = value;
                SetQEVisible(_qe_visible);
            }
        }
        /// <summary>
        /// åŠŸçŽ‡æ˜¾ç¤º
        /// </summary>
        public bool QPVisble
        {
            get => _qp_visible;
            set
            {
                _qp_visible = value;
                SetQPVisible(_qp_visible);
            }
        }
        /// <summary>
        /// è¿è¡Œç‚¹æ˜¾ç¤º
        /// </summary>
        public bool RunPointVisible
        {
            get => _run_point_visible;
            set
            {
                _run_point_visible = value;
            }
        }
        #endregion
        #region Public Evnet
        /// <summary>
        /// åæ ‡å˜æ¢äº‹ä»¶
        /// </summary>
        public event Action<PumpCoordinate> CoordinateChangedEvent = null;
        /// <summary>
        /// è¿è¡Œç‚¹é€‰æ‹©äº‹ä»¶
        /// </summary>
        public event Action<PumpRunViewItemViewModel> RunPointSelectedEvent = null;
        #endregion
        #region Initial
        /// <summary>
        /// åˆå§‹åŒ–图表
        /// </summary>
        private void InitialChart()
        {
            this.chartControl1.SetChartDisplay();
            this.chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.TopToBottom;
            _diagram = (XYDiagram)this.chartControl1.Diagram;
            _default_pane = _diagram.DefaultPane;
            _bottom_pane = (XYDiagramPane)_diagram.FindPaneByName("BottomPanel");
            _axis_x_flow = _diagram.AxisX;
            _axis_x_flow.SetAxisXQDisplay();
            _axis_y_head = _diagram.AxisY;
            _axis_y_head.SetAxisYQHDisplay();
            _axis_y_eff = _diagram.SecondaryAxesY.GetAxisByName("AxisYQE");
            _axis_y_eff.SetSecondaryAxisYQEDisplay();
            _axis_y_eff.Alignment = AxisAlignment.Far;
            _axis_y_power = _diagram.SecondaryAxesY.GetAxisByName("AxisYQP");
            _axis_y_power.SetSecondaryAxisYQPDisplay();
            this.chartControl1.SetChartMonoColorDisplay();
            _axis_x_flow.Visibility = DefaultBoolean.False;
            _axis_x_flow.GridLines.Visible = false;
            _axis_y_head.Visibility = DefaultBoolean.False;
            _axis_y_head.GridLines.Visible = false;
            _axis_y_eff.Visibility = DefaultBoolean.False;
            _axis_y_eff.GridLines.Visible = false;
            _axis_y_power.Visibility = DefaultBoolean.False;
            _axis_y_power.GridLines.Visible = false;
            //this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseMove);
            this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseDown);
            this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseUp);
            this.chartControl1.CustomPaint += ChartControl1_CustomPaint;
        }
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
            return;
            if (!_run_point_visible)
                return;
            if (_tuple_list == null || !_tuple_list.Any())
                return;
            foreach (var rect in _tuple_list)
            {
                if (rect.Item1.Contains(e.Location))
                {
                    _rect_point = new Point(rect.Item1.X + 5, rect.Item1.Y + 5);
                    this.RunPointSelectedEvent?.Invoke(rect.Item3);
                    break;
                }
            }
            //if (!_initial_data)
            //    return;
            //var hitInfo = this.chartControl1.CalcHitInfo(e.Location);
            //if (e.Button == MouseButtons.Left)
            //{
            //    if (hitInfo.InSeries)
            //    {
            //        _sel = hitInfo.Series;
            //        this.RunPointSelectedEvent?.Invoke(_sel.Tag as PumpRunViewItemViewModel);
            //    }
            //    //if (hitInfo.InSeriesPoint)
            //    //{
            //    //    _sel_series_pt = hitInfo.SeriesPoint;
            //    //    this.RunPointSelectedEvent?.Invoke(_sel_series_pt.Tag as PumpRunViewItemViewModel);
            //    //}
            //    else
            //    {
            //        if (_sel != null)
            //        {
            //            this.chartControl1.SetObjectSelection(_sel);
            //        }
            //    }
            //}
        }
        private void chartControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            if (!_run_point_visible)
                return;
        }
        private void ChartControl1_CustomPaint(object sender, CustomPaintEventArgs e)
        {
            if (e is not DXCustomPaintEventArgs dxArgs)
                return;
            if (_vm == null)
                return;
            _tuple_list.Clear();
            if (_vm.Items != null && _vm.Items.Any() && _run_point_visible)
            {
                foreach (var vm in _vm.Items)
                {
                    var color = vm.Color;
                    var flow = vm.Q;
                    var head = vm.H;
                    var eff = vm.E;
                    var power = vm.P;
                    {
                        var dg_pt = _diagram.DiagramToPoint(flow, head, _axis_x_flow, _axis_y_head);
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                        _tuple_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                    }
                    if (eff.HasValue && _qe_visible)
                    {
                        var dg_pt = _diagram.DiagramToPoint(flow, eff.Value, _axis_x_flow, _axis_y_eff);
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                    }
                    if (power.HasValue && _qp_visible)
                    {
                        var dg_pt = _diagram.DiagramToPoint(flow, power.Value, _axis_x_flow, _axis_y_power);
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                    }
                }
                if (_rect_point.HasValue)
                {
                    //using Brush brush = new SolidBrush(_rect_color_sel.Value);
                    //dxArgs.Cache.FillEllipse(brush, _rect_sel.Value);
                    var x= _rect_point.Value.X+5;
                    var y= _rect_point.Value.Y+5;
                    var crossWidth = 20;
                    var crossHeight = 20;
                    // ç»˜åˆ¶åå­—æž¶
                    using Pen pen = new Pen(Color.Magenta, 2);
                    dxArgs.Cache.DrawLine(pen,new Point(x - crossWidth, y), new Point(x + crossWidth, y));
                    dxArgs.Cache.DrawLine(pen, new Point(x, y - crossHeight), new Point(x, y + crossHeight) );
                }
            }
        }
        private List<Tuple<Rectangle,Color,PumpRunViewItemViewModel>> _tuple_list = new ();
        private Point? _rect_point = null;
        private Rectangle DrawWorkPoint(GraphicsCache cache, Color color, AxisYBase axis_y, double x, double y)
        {
            var dg_pt = _diagram.DiagramToPoint(x, y, _axis_x_flow, axis_y);
            var dg_x = dg_pt.Point.X - 5;
            var dg_y = dg_pt.Point.Y - 5;
            cache.FillEllipse(dg_x, dg_y, 10, 10, color);
            return new Rectangle(dg_x, dg_y, 10, 10);
        }
        /// <summary>
        /// åˆå§‹åŒ–图表数据
        /// </summary>
        public void InitialChartData()
        {
            _initial_data = false;
            _coordinate = null;
            UpdateChart(false);
        }
        #endregion
        #region Set
        /// <summary>
        /// ç»‘定数据
        /// </summary>
        public void SetBindingData(PumpRunViewViewModel vm)
        {
            _vm = vm;
            _initial_data = vm != null;
            UpdateChart(true);
        }
        /// <summary>
        /// æ¸…空曲线
        /// </summary>
        public void Clear()
        {
            _vm = null;
            _initial_data = false;
            UpdateChart(true);
        }
        /// <summary>
        /// æ›´æ–°å›¾è¡¨
        /// </summary>
        public void UpdateChart(bool calc_coordinate = false)
        {
            _rect_point = null;
            _tuple_list = new ();
            if (calc_coordinate || _coordinate == null)
            {
                //不强迫计算,就用上次更新的坐标系
                CalcCoordinate();
            }
            CalcSeries();
            CalcChartAxis();
        }
        #endregion
        #region Calc
        private double _min_flow, _max_flow;
        private double _max_head = 0, _min_head = 10000;
        private double _max_eff = 0, _min_eff = 0;
        private double _max_power = 0, _min_power = 1000;
        /// <summary>
        /// è®¡ç®—坐标
        /// </summary>
        private void CalcCoordinate()
        {
            if (_vm == null)
            {
                //设置成白板坐标
                _coordinate = new PumpCoordinate();
                _coordinate.GridNumberX = 30;
                _coordinate.GridNumberY = 16;
                //显示的坐标线号
                _coordinate.StartLineNoH = 10;
                _coordinate.EndLineNoH = 15;
                _coordinate.StartLineNoE = 0;
                _coordinate.EndLineNoE = 10;
                _coordinate.StartLineNoP = 2;
                _coordinate.EndLineNoP = 9;
                //坐标最小值和间隔
                _coordinate.CoordMinQ = 0; _coordinate.CoordSpaceQ = 1000;
                _coordinate.CoordMinH = 10; _coordinate.CoordSpaceH = 100;
                _coordinate.CoordMinE = 0; _coordinate.CoordSpaceE = 100;
                _coordinate.CoordMinP = 10; _coordinate.CoordSpaceP = 100;
                return;
            }
            _max_flow = 0; _min_flow = 10000;
            _max_head = 0; _min_head = 10000;
            _max_eff = 0; _min_eff = 0;
            _max_power = 0; _min_power = 1000;
            double _scaleMinH = 1, _scaleMaxH = 1;
            {
                var qh_pt_list = _vm.CurveQH.GetPointList();
                var xxx = qh_pt_list.Select(x => x.X);
                var yyy = qh_pt_list.Select(x => x.Y);
                _min_flow = Math.Min(_min_flow, xxx.Min());
                _max_flow = Math.Max(_max_flow, xxx.Max());
                _min_head = Math.Min(_min_head, yyy.Min());
                _max_head = Math.Max(_max_head, yyy.Max());
            }
            if (_vm.CurveQE != null)
            {
                var qe_pt_list = _vm.CurveQE.GetPointList();
                var yyy = qe_pt_list.Select(x => x.Y);
                _min_eff = Math.Min(_min_eff, yyy.Min());
                _max_eff = Math.Max(_max_eff, yyy.Max());
            }
            if (_vm.CurveQP != null)
            {
                var yyy = _vm.CurveQP.GetPointList().Select(x => x.Y);
                _min_power = Math.Min(_min_power, yyy.Min());
                _max_power = Math.Max(_max_power, yyy.Max());
            }
            if (_vm.Items != null && _vm.Items.Any())
            {
                foreach (var vm in _vm.Items)
                {
                    {
                        var qh_pt_list = vm.CurveQH.GetPointList();
                        var xxx = qh_pt_list.Select(x => x.X);
                        var yyy = qh_pt_list.Select(x => x.Y);
                        _min_flow = Math.Min(_min_flow, xxx.Min());
                        _max_flow = Math.Max(_max_flow, xxx.Max());
                        _min_head = Math.Min(_min_head, yyy.Min());
                        _max_head = Math.Max(_max_head, yyy.Max());
                    }
                    if (vm.CurveQE != null)
                    {
                        var qe_pt_list = vm.CurveQE.GetPointList();
                        var yyy = qe_pt_list.Select(x => x.Y);
                        _min_eff = Math.Min(_min_eff, yyy.Min());
                        _max_eff = Math.Max(_max_eff, yyy.Max());
                    }
                    if (vm.CurveQP != null)
                    {
                        var yyy = vm.CurveQP.GetPointList().Select(x => x.Y);
                        _min_power = Math.Min(_min_power, yyy.Min());
                        _max_power = Math.Max(_max_power, yyy.Max());
                    }
                }
            }
            _coordinate = PumpCoordinate.CalcCoordinate(_min_flow,
                                                                         _max_flow,
                                                                         _min_head * _scaleMinH,
                                                                         _max_head * _scaleMaxH,
                                                                         _min_eff,
                                                                         _max_eff,
                                                                         _min_power,
                                                                         _max_power);
            if (_coordinate == null)
                return;
            if (_coordinate.CoordMinQ + _coordinate.CoordSpaceQ * this._coordinate.GridNumberX < _max_flow * 1.05)
            {
                _coordinate.GridNumberX++;
            }
        }
        /// <summary>
        /// è®¡ç®—图表轴
        /// </summary>
        private void CalcChartAxis()
        {
            _axis_x_flow.Visibility = DefaultBoolean.False;
            _axis_x_flow.GridLines.Visible = false;
            _axis_y_head.Visibility = DefaultBoolean.False;
            _axis_y_head.GridLines.Visible = false;
            _axis_y_eff.Visibility = DefaultBoolean.False;
            _axis_y_eff.GridLines.Visible = false;
            _axis_y_power.Visibility = DefaultBoolean.False;
            _axis_y_power.GridLines.Visible = false;
            _bottom_pane.Visibility = ChartElementVisibility.Hidden;
            _bottom_pane.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
            //计算刻度 Q
            var axisQLabels = new List<CustomAxisLabel>();
            var disQ = _coordinate.CoordMinQ;
            for (int i = 0; i < _coordinate.GridNumberX + 1; i++)
            {
                axisQLabels.Add(new CustomAxisLabel(disQ.ToString("N0"), disQ));
                disQ = disQ + _coordinate.CoordSpaceQ;
            }
            _axis_x_flow.CustomLabels.Clear();
            _axis_x_flow.CustomLabels.AddRange(axisQLabels.ToArray());
            _axis_x_flow.Visibility = DefaultBoolean.True;
            _axis_x_flow.GridLines.Visible = true;
            //计算刻度
            var axis_head_labels = new List<CustomAxisLabel>();
            var display_head = _coordinate.CoordMinH + _coordinate.CoordSpaceH * _coordinate.StartLineNoH;
            for (int i = _coordinate.StartLineNoH; i < _coordinate.EndLineNoH + 1; i++)
            {
                axis_head_labels.Add(new CustomAxisLabel(display_head.ToString(), display_head));
                display_head = display_head + _coordinate.CoordSpaceH;
            }
            _axis_y_head.CustomLabels.Clear();
            _axis_y_head.CustomLabels.AddRange(axis_head_labels.ToArray());
            _axis_y_head.Visibility = DefaultBoolean.True;
            _axis_y_head.GridLines.Visible = true;
            //效率
            if (_max_eff > _min_eff && _qe_visible)
            {
                //计算刻度
                var labels = new List<CustomAxisLabel>();
                var display_eff = _coordinate.CoordMinE + _coordinate.CoordSpaceE * _coordinate.StartLineNoE;
                for (int i = _coordinate.StartLineNoE; i < _coordinate.EndLineNoE + 1; i++)
                {
                    labels.Add(new CustomAxisLabel(display_eff.ToString(), display_eff));
                    display_eff = display_eff + _coordinate.CoordSpaceE;
                }
                _axis_y_eff.CustomLabels.Clear();
                _axis_y_eff.CustomLabels.AddRange(labels.ToArray());
                _axis_y_eff.Visibility = DefaultBoolean.True;
                _axis_y_eff.GridLines.Visible = true;
            }
            //功率
            if (_max_power > _min_power && _qp_visible)
            {
                //计算刻度
                var labels = new List<CustomAxisLabel>();
                double display_power = _coordinate.CoordMinP + _coordinate.CoordSpaceP * _coordinate.StartLineNoP;
                for (int i = _coordinate.StartLineNoP; i < _coordinate.EndLineNoP + 1; i++)
                {
                    labels.Add(new CustomAxisLabel(display_power.ToString(), display_power));
                    display_power = display_power + _coordinate.CoordSpaceP;
                }
                _axis_y_power.CustomLabels.Clear();
                _axis_y_power.CustomLabels.AddRange(labels.ToArray());
                _axis_y_power.Visibility = DefaultBoolean.True;
                _axis_y_power.GridLines.Visible = true;
            }
            var min_flow = _coordinate.CoordMinQ;
            var max_flow = _coordinate.DispMaxQ();
            _axis_x_flow.SetAxisRange(min_flow, max_flow);
            var grid_count_head = _coordinate.EndLineNoH - _coordinate.StartLineNoH;
            var grid_count_eff = _coordinate.EndLineNoE - _coordinate.StartLineNoE;
            int grid_count_up = Math.Max(grid_count_head, grid_count_eff);
            if (_qe_visible)
            {
                grid_count_up += 2;//多两条
            }
            var max_axis_head = _coordinate.CoordMinH + _coordinate.EndLineNoH * _coordinate.CoordSpaceH;
            var min_axis_head = max_axis_head - grid_count_up * _coordinate.CoordSpaceH;
            _axis_y_head.SetAxisRange(min_axis_head, max_axis_head);
            var min_axis_eff = _coordinate.CoordMinE + _coordinate.StartLineNoE * _coordinate.CoordSpaceE;
            var max_axis_eff = min_axis_eff + grid_count_up * _coordinate.CoordSpaceE;
            _axis_y_eff.SetAxisRange(min_axis_eff, max_axis_eff);
            var grid_count_power = _coordinate.EndLineNoP - _coordinate.StartLineNoP;
            var min_axis_power = _coordinate.CoordMinP + _coordinate.StartLineNoP * _coordinate.CoordSpaceP;
            var max_axis_power = min_axis_power + grid_count_power * _coordinate.CoordSpaceP;
            _axis_y_power.SetAxisRange(min_axis_power, max_axis_power);
        }
        /// <summary>
        /// è®¡ç®—系列
        /// </summary>
        private void CalcSeries()
        {
            this.chartControl1.BeginInit();
            this.chartControl1.Series.Clear();
            this.chartControl1.AnnotationRepository.Clear();
            this.chartControl1.Legend.CustomItems.Clear();
            if (_vm != null)
            {
                if (_vm.Items == null || !_vm.Items.Any())
                {
                    CreateLineSeries(_vm.Id, _vm.Color, _vm.Name, _vm.CurveQH, _vm.CurveQE, _vm.CurveQP);
                }
                else
                {
                    if (_vm.Items != null && _vm.Items.Any())
                    {
                        if (_vm.Items[0].Hz != 50)
                            CreateLineSeries(_vm.Id, _vm.Color, _vm.Name, _vm.CurveQH, _vm.CurveQE, _vm.CurveQP);
                        for (int i = 0; i < _vm.Items.Count; i++)
                        {
                            var vm = _vm.Items[i];
                            CreateCurrentLineSeries(vm.Id, vm.Color, vm.CurveName, vm.CurveQH, vm.CurveQE, vm.CurveQP);
                            //CreatePointSeries(vm, _axis_x_flow, _axis_y_head, _default_pane, vm.Q, vm.H);
                            //if (vm.E.HasValue)
                            //    CreatePointSeries(vm, _axis_x_flow, _axis_y_eff, _default_pane, vm.Q, vm.E.Value);
                            //if (vm.P.HasValue)
                            //    CreatePointSeries(vm, _axis_x_flow, _axis_y_power, _bottom_pane, vm.Q, vm.P.Value);
                        }
                    }
                }
            }
            this.chartControl1.EndInit();
        }
        /// <summary>
        /// åˆ›å»ºç‚¹ç³»åˆ—
        /// </summary>
        private void CreatePointSeries(PumpRunViewItemViewModel vm,  AxisXBase axis_x, AxisYBase axis_y, XYDiagramPaneBase pane,double x,double y)
        {
            var color=vm.Color;
            var view = new DevExpress.XtraCharts.PointSeriesView();
            view.PointMarkerOptions.Size = 10;
            view.PointMarkerOptions.Kind = MarkerKind.Cross;
            view.PointMarkerOptions.BorderColor = color;
            view.Color = color;
            view.AxisX = axis_x;
            view.AxisY = axis_y;
            view.Pane = pane;
            var series_pt = new SeriesPoint(x, new double[] { y });
            series_pt.Tag = vm;
            var series = new DevExpress.XtraCharts.Series();
            series.Tag = vm;
            series.ShowInLegend = false;
            series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
            series.CrosshairEnabled = DefaultBoolean.False;
            series.SeriesPointsSorting = SortingMode.None;
            series.Visible = true;
            series.View = view;
            series.Points.Add(series_pt);
            this.chartControl1.Series.Add(series);
        }
        /// <summary>
        /// åˆ›å»ºçº¿ç³»åˆ—
        /// </summary>
        private void CreateLineSeries(string id, Color color, string curve_name, Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp)
        {
            var series_qh = new DevExpress.XtraCharts.Series();
            series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            series_qh.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
            series_qh.Name = _tag_qh + id;
            series_qh.ShowInLegend = false;
            series_qh.CrosshairEnabled = DefaultBoolean.False;
            series_qh.LegendTextPattern = curve_name;
            var series_qh_view = new DevExpress.XtraCharts.LineSeriesView();
            series_qh_view.LineStyle.Thickness = 2;
            series_qh_view.LineStyle.DashStyle = DashStyle.Dash;
            series_qh_view.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;
            series_qh_view.Color = color;
            series_qh_view.EnableAntialiasing = DefaultBoolean.True;
            series_qh.SeriesPointsSorting = SortingMode.None;
            series_qh.SeriesPointsSortingKey = SeriesPointKey.Value_1;
            series_qh.View = series_qh_view;
            series_qh.Visible = true;
            var pt_qh_list = qh.GetPointList(100);
            for (int i = 0; i < pt_qh_list.Count; i++)
            {
                series_qh.Points.Add(new SeriesPoint(pt_qh_list[i].X, new double[] { pt_qh_list[i].Y }));
            }
            var point_qh = pt_qh_list[pt_qh_list.Count - 1];
            var anchor_qh_pt = new DevExpress.XtraCharts.PaneAnchorPoint();
            anchor_qh_pt.Pane = _default_pane;
            anchor_qh_pt.AxisXCoordinate.AxisValue = point_qh.X.ToString();
            anchor_qh_pt.AxisYCoordinate.AxisValue = point_qh.Y.ToString();
            var position_qh = new DevExpress.XtraCharts.RelativePosition();
            position_qh.Angle = -50;
            position_qh.ConnectorLength = 10;
            var txt_qh = new TextAnnotation();
            txt_qh.Border.Visibility = DefaultBoolean.False;
            txt_qh.AnchorPoint = anchor_qh_pt;
            txt_qh.AutoHeight = true;
            txt_qh.AutoWidth = true;
            txt_qh.BackColor = System.Drawing.Color.Transparent;
            txt_qh.Border.Color = color;
            txt_qh.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.Line;
            txt_qh.DXFont = PumpChartDisplay.AnnoFontQH;
            txt_qh.Name = _tag_qh + id;
            txt_qh.Padding.Bottom = 1;
            txt_qh.Padding.Left = 1;
            txt_qh.Padding.Right = 1;
            txt_qh.Padding.Top = 1;
            txt_qh.RuntimeAnchoring = false;
            txt_qh.RuntimeMoving = true;
            txt_qh.RuntimeResizing = false;
            txt_qh.RuntimeRotation = false;
            txt_qh.Text = curve_name;
            txt_qh.TextColor = color;
            txt_qh.ShapePosition = position_qh;
            txt_qh.Visible = true;
            this.chartControl1.AnnotationRepository.Add(txt_qh);
            this.chartControl1.Series.Add(series_qh);
            if (qe != null)
            {
                var series_qe = new DevExpress.XtraCharts.Series();
                series_qe.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qe.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qe.Name = _tag_qe + id;
                series_qe.ShowInLegend = false;
                series_qe.CrosshairEnabled = DefaultBoolean.False;
                series_qe.Tag = id;
                var series_qe_view = new DevExpress.XtraCharts.LineSeriesView();
                series_qe_view.LineStyle.Thickness = 2;
                series_qe_view.LineStyle.DashStyle = DashStyle.Dash;
                series_qe_view.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;
                series_qe_view.Color = color;
                series_qe_view.AxisY = _axis_y_eff;
                series_qe_view.Pane = _default_pane;
                series_qe_view.EnableAntialiasing = DefaultBoolean.True;
                series_qe.SeriesPointsSorting = SortingMode.None;
                series_qe.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qe.View = series_qe_view;
                series_qe.Visible = _qe_visible;
                var pt_qe_list = qe.GetPointList(100);
                for (int i = 0; i < pt_qe_list.Count; i++)
                {
                    series_qe.Points.Add(new SeriesPoint(pt_qe_list[i].X, new double[] { pt_qe_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qe);
            }
            if (qp != null)
            {
                var series_qp = new DevExpress.XtraCharts.Series();
                series_qp.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qp.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qp.Name = _tag_qp + id;
                series_qp.ShowInLegend = false;
                series_qp.CrosshairEnabled = DefaultBoolean.False;
                series_qp.Tag = id;
                var series_qp_view = new DevExpress.XtraCharts.LineSeriesView();
                series_qp_view.LineStyle.Thickness = 2;
                series_qp_view.LineStyle.DashStyle = DashStyle.Dash;
                series_qp_view.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;
                series_qp_view.Color = color;
                series_qp_view.AxisY = _axis_y_power;
                series_qp_view.Pane = _bottom_pane;
                series_qp_view.EnableAntialiasing = DefaultBoolean.True;
                series_qp.SeriesPointsSorting = SortingMode.None;
                series_qp.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qp.View = series_qp_view;
                series_qp.Visible = _qp_visible;
                var pt_qp_list = qp.GetPointList(100);
                for (int i = 0; i < pt_qp_list.Count; i++)
                {
                    series_qp.Points.Add(new SeriesPoint(pt_qp_list[i].X, new double[] { pt_qp_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qp);
            }
        }
        /// <summary>
        /// åˆ›å»ºçº¿ç³»åˆ—
        /// </summary>
        private void CreateCurrentLineSeries(string id, Color color, string curve_name, Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp)
        {
            var series_qh = new DevExpress.XtraCharts.Series();
            series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            series_qh.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
            series_qh.Name = _tag_qh + id;
            series_qh.ShowInLegend = false;
            series_qh.CrosshairEnabled = DefaultBoolean.False;
            series_qh.LegendTextPattern = curve_name;
            var series_qh_view = new DevExpress.XtraCharts.SplineSeriesView();
            series_qh_view.LineStyle.Thickness = 2;
            series_qh_view.Color = color;
            series_qh_view.EnableAntialiasing = DefaultBoolean.True;
            series_qh_view.LineTensionPercent = 50;
            series_qh.SeriesPointsSorting = SortingMode.None;
            series_qh.SeriesPointsSortingKey = SeriesPointKey.Value_1;
            series_qh.View = series_qh_view;
            series_qh.Visible = true;
            var pt_qh_list = qh.GetPointList(100);
            for (int i = 0; i < pt_qh_list.Count; i++)
            {
                series_qh.Points.Add(new SeriesPoint(pt_qh_list[i].X, new double[] { pt_qh_list[i].Y }));
            }
            var point_qh = pt_qh_list[pt_qh_list.Count() - 1];
            var anchor_qh_pt = new DevExpress.XtraCharts.PaneAnchorPoint();
            anchor_qh_pt.Pane = _default_pane;
            anchor_qh_pt.AxisXCoordinate.AxisValue = point_qh.X.ToString();
            anchor_qh_pt.AxisYCoordinate.AxisValue = point_qh.Y.ToString();
            var position_qh = new DevExpress.XtraCharts.RelativePosition();
            position_qh.Angle = -50;
            position_qh.ConnectorLength = 10;
            var txt_qh = new TextAnnotation();
            txt_qh.Border.Visibility = DefaultBoolean.False;
            txt_qh.AnchorPoint = anchor_qh_pt;
            txt_qh.AutoHeight = true;
            txt_qh.AutoWidth = true;
            txt_qh.BackColor = System.Drawing.Color.Transparent;
            txt_qh.Border.Color = color;
            txt_qh.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.Line;
            txt_qh.DXFont = PumpChartDisplay.AnnoFontQH;
            txt_qh.Name = _tag_qh + id;
            txt_qh.Padding.Bottom = 1;
            txt_qh.Padding.Left = 1;
            txt_qh.Padding.Right = 1;
            txt_qh.Padding.Top = 1;
            txt_qh.RuntimeAnchoring = false;
            txt_qh.RuntimeMoving = true;
            txt_qh.RuntimeResizing = false;
            txt_qh.RuntimeRotation = false;
            txt_qh.Text = curve_name;
            txt_qh.TextColor = color;
            txt_qh.ShapePosition = position_qh;
            txt_qh.Visible = true;
            this.chartControl1.AnnotationRepository.Add(txt_qh);
            this.chartControl1.Series.Add(series_qh);
            if (qe != null)
            {
                var series_qe = new DevExpress.XtraCharts.Series();
                series_qe.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qe.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qe.Name = _tag_qe + id;
                series_qe.ShowInLegend = false;
                series_qe.CrosshairEnabled = DefaultBoolean.False;
                series_qe.Tag = id;
                var series_qe_view = new DevExpress.XtraCharts.SplineSeriesView();
                series_qe_view.LineStyle.Thickness = 2;
                series_qe_view.Color = color;
                series_qe_view.AxisY = _axis_y_eff;
                series_qe_view.Pane = _default_pane;
                series_qe_view.EnableAntialiasing = DefaultBoolean.True;
                series_qe_view.LineTensionPercent = 50;
                series_qe.SeriesPointsSorting = SortingMode.None;
                series_qe.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qe.View = series_qe_view;
                series_qe.Visible = _qe_visible;
                var pt_qe_list = qe.GetPointList(100);
                for (int i = 0; i < pt_qe_list.Count; i++)
                {
                    series_qe.Points.Add(new SeriesPoint(pt_qe_list[i].X, new double[] { pt_qe_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qe);
            }
            if (qp != null)
            {
                var series_qp = new DevExpress.XtraCharts.Series();
                series_qp.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qp.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qp.Name = _tag_qp + id;
                series_qp.ShowInLegend = false;
                series_qp.CrosshairEnabled = DefaultBoolean.False;
                series_qp.Tag = id;
                var series_qp_view = new DevExpress.XtraCharts.SplineSeriesView();
                series_qp_view.LineStyle.Thickness = 2;
                series_qp_view.Color = color;
                series_qp_view.AxisY = _axis_y_power;
                series_qp_view.Pane = _bottom_pane;
                series_qp_view.EnableAntialiasing = DefaultBoolean.True;
                series_qp_view.LineTensionPercent = 50;
                series_qp.SeriesPointsSorting = SortingMode.None;
                series_qp.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qp.View = series_qp_view;
                series_qp.Visible = _qp_visible;
                var pt_qp_list = qp.GetPointList(100);
                for (int i = 0; i < pt_qp_list.Count; i++)
                {
                    series_qp.Points.Add(new SeriesPoint(pt_qp_list[i].X, new double[] { pt_qp_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qp);
            }
        }
        #endregion
        #region Right Click Menu
        /// <summary>
        /// è®¾ç½®åæ ‡è½´
        /// </summary>
        public void SetChartAxis()
        {
            var dlg = new PumpChartCoordinateDlg();
            dlg.SetBindingData(_coordinate);
            dlg.OnChangedCoord += (rhs) =>
            {
                _coordinate = rhs;
                CalcChartAxis();
                this.CoordinateChangedEvent?.Invoke(_coordinate);
            };
            dlg.ShowDialog();
        }
        /// <summary>
        /// è®¾ç½®è¿è¡Œç‚¹æ˜¾ç¤º
        /// </summary>
        public void SetEQVisible(bool visible)
        {
            _run_point_visible = visible;
        }
        /// <summary>
        /// è®¾ç½®æ•ˆçŽ‡æ˜¾ç¤º
        /// </summary>
        public void SetQEVisible(bool visible)
        {
            _qe_visible = visible;
            UpdateChart();
        }
        /// <summary>
        /// è®¾ç½®åŠŸçŽ‡æ˜¾ç¤º
        /// </summary>
        public void SetQPVisible(bool visible)
        {
            _qp_visible = visible;
            _bottom_pane.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
            UpdateChart();
        }
        #endregion
    }
}
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart - ¸´ÖÆ.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Version 2.0
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
    Example:
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
    There are any number of "resheader" rows that contain simple
    name/value pairs.
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
</root>
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewChart.cs
@@ -1,7 +1,6 @@
using DevExpress.Office.Utils;
using DevExpress.PivotGrid.OLAP.AdoWrappers;
using DevExpress.Utils;
using DevExpress.Utils;
using DevExpress.Utils.Drawing;
using DevExpress.Utils.Html.Internal;
using DevExpress.XtraCharts;
namespace Yw.WinFrmUI.Phart
@@ -16,6 +15,8 @@
            InitializeComponent();
            InitialChart();
            this.chartControl1.RuntimeHitTesting = true;
            this.chartControl1.SelectionMode = ElementSelectionMode.Extended;
            this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Point;
        }
        #region Private Variable 
@@ -34,11 +35,55 @@
        private bool _qe_visible = true;
        private bool _qp_visible = true;
        private bool _run_visible = true;
        private bool _run_point_visible = true;
        private bool _initial_data = false;
        private PumpRunViewViewModel _vm = null;
        #endregion
        #region Public Variable
        /// <summary>
        /// æ•ˆçŽ‡æ˜¾ç¤º
        /// </summary>
        public bool QEVisible
        {
            get => _qe_visible;
            set
            {
                _qe_visible = value;
                SetQEVisible(_qe_visible);
            }
        }
        /// <summary>
        /// åŠŸçŽ‡æ˜¾ç¤º
        /// </summary>
        public bool QPVisble
        {
            get => _qp_visible;
            set
            {
                _qp_visible = value;
                SetQPVisible(_qp_visible);
            }
        }
        /// <summary>
        /// è¿è¡Œç‚¹æ˜¾ç¤º
        /// </summary>
        public bool RunPointVisible
        {
            get => _run_point_visible;
            set
            {
                _run_point_visible = value;
            }
        }
        #endregion
@@ -53,7 +98,9 @@
        /// <summary>
        /// è¿è¡Œç‚¹é€‰æ‹©äº‹ä»¶
        /// </summary>
        public event Action<PumpCoordinate> RunPointSelectedEvent = null;
        public event Action<PumpRunViewItemViewModel> RunPointSelectedEvent = null;
        #endregion
        #region Initial
@@ -91,46 +138,32 @@
            _axis_y_power.Visibility = DefaultBoolean.False;
            _axis_y_power.GridLines.Visible = false;
            this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseUp);
            this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseMove);
            this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseDown);
            this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseDown);
            this.chartControl1.CustomPaint += ChartControl1_CustomPaint;
        }
        private List<Tuple<Rectangle, Color, PumpRunViewItemViewModel>> _rect_list = new();
        private Point? _rect_point = null;
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
                return;
            if (!_run_point_visible)
                return;
            if (_rect_list == null || !_rect_list.Any())
                return;
            foreach (var rect in _rect_list)
            {
                if (rect.Item1.Contains(e.Location))
                {
                    _rect_sel = new Rectangle(rect.Item1.X, rect.Item1.Y, 12, 12);
                    _rect_color_sel = rect.Item2;
                    _rect_point = new Point(rect.Item1.X + 5, rect.Item1.Y + 5);
                    this.RunPointSelectedEvent?.Invoke(rect.Item3);
                    break;
                }
            }
        }
        private void chartControl1_MouseMove(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            if (_rect_list == null || !_rect_list.Any())
                return;
        }
        private void chartControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            if (_rect_list == null || !_rect_list.Any())
                return;
        }
        private void ChartControl1_CustomPaint(object sender, CustomPaintEventArgs e)
        {
            if (e is not DXCustomPaintEventArgs dxArgs)
@@ -138,8 +171,8 @@
            if (_vm == null)
                return;
            _rect_list.Clear();
            if (_vm.Items != null && _vm.Items.Any() && _run_visible)
            {
            if (_vm.Items != null && _vm.Items.Any() && _run_point_visible)
            {
                foreach (var vm in _vm.Items)
                {
                    var color = vm.Color;
@@ -153,7 +186,7 @@
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                        _rect_list.Add(new Tuple<Rectangle, Color>(new Rectangle(dg_x, dg_y, 10, 10),color));
                        _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                    }
                    if (eff.HasValue && _qe_visible)
                    {
@@ -161,6 +194,7 @@
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                        _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                    }
                    if (power.HasValue && _qp_visible)
@@ -169,32 +203,21 @@
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                    }
                        _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                    }
                }
                if (_rect_sel.HasValue)
                if (_rect_point.HasValue)
                {
                    using Brush brush = new SolidBrush(_rect_color_sel.Value);
                    dxArgs.Cache.FillEllipse(brush, _rect_sel.Value);
                    var x = _rect_point.Value.X;
                    var y = _rect_point.Value.Y;
                    var length = 20;
                    using Pen pen = new Pen(Color.Magenta, 2);
                    dxArgs.Cache.DrawLine(pen, new Point(x - length, y), new Point(x + length, y));
                    dxArgs.Cache.DrawLine(pen, new Point(x, y - length), new Point(x, y + length));
                    dxArgs.Cache.DrawEllipse(pen, new Rectangle(x - 10, y - 10, length, length));
                }
            }
        }
        private List<Tuple<Rectangle,Color>> _rect_list = new List<Tuple<Rectangle, Color>>();
        private Rectangle? _rect_sel = null;
        private Color? _rect_color_sel = null;
        private Rectangle DrawWorkPoint(GraphicsCache cache, Color color, AxisYBase axis_y, double x, double y)
        {
            var dg_pt = _diagram.DiagramToPoint(x, y, _axis_x_flow, axis_y);
            var dg_x = dg_pt.Point.X - 5;
            var dg_y = dg_pt.Point.Y - 5;
            cache.FillEllipse(dg_x, dg_y, 10, 10, color);
            return new Rectangle(dg_x, dg_y, 10, 10);
        }
         
        /// <summary>
        /// åˆå§‹åŒ–图表数据
@@ -202,8 +225,7 @@
        public void InitialChartData()
        {
            _initial_data = false;
            _coordinate = null;
            _coordinate = null;
            UpdateChart(false);
        }
@@ -237,9 +259,8 @@
        /// </summary>
        public void UpdateChart(bool calc_coordinate = false)
        {
            _rect_sel = null;
            _rect_color_sel = null;
            _rect_list = new List<Tuple<Rectangle, Color>>();
            _rect_point = null;
            _rect_list = new ();
            if (calc_coordinate || _coordinate == null)
            {
                //不强迫计算,就用上次更新的坐标系
@@ -809,7 +830,7 @@
        /// </summary> 
        public void SetEQVisible(bool visible)
        {
            _run_visible = visible;
            _run_point_visible = visible;
        }
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-run-view/PumpRunViewViewModel.cs
@@ -17,10 +17,12 @@
            this.RatedP = rhs.RatedP;
            this.RatedN = rhs.RatedN;
            this.RatedHz = rhs.RatedHz;
            this.CurveQH = rhs.CurveQH;
            this.CurveQE = rhs.CurveQE;
            this.CurveQP = rhs.CurveQP;
            this.CurveQP = rhs.CurveQP;
            this.Items = rhs.Items;
        }
@@ -68,7 +70,7 @@
        /// é¢å®šé¢‘率
        /// </summary>
        public double RatedHz { get; set; }
        /// <summary>
        /// æµé‡æ‰¬ç¨‹çº¿
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewChart.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,177 @@
namespace Yw.WinFrmUI.Phart
{
    partial class PumpWorkingViewChart
    {
        /// <summary>
        /// Requipuired designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        #region Component Designer generated code
        /// <summary>
        /// Requipuired method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            DevExpress.XtraCharts.XYDiagram xyDiagram1 = new DevExpress.XtraCharts.XYDiagram();
            DevExpress.XtraCharts.LayoutDefinition layoutDefinition1 = new DevExpress.XtraCharts.LayoutDefinition();
            DevExpress.XtraCharts.LayoutDefinition layoutDefinition2 = new DevExpress.XtraCharts.LayoutDefinition();
            DevExpress.XtraCharts.LayoutDefinition layoutDefinition3 = new DevExpress.XtraCharts.LayoutDefinition();
            DevExpress.XtraCharts.XYDiagramPane xyDiagramPane1 = new DevExpress.XtraCharts.XYDiagramPane();
            DevExpress.XtraCharts.SecondaryAxisY secondaryAxisy1 = new DevExpress.XtraCharts.SecondaryAxisY();
            DevExpress.XtraCharts.SecondaryAxisY secondaryAxisy2 = new DevExpress.XtraCharts.SecondaryAxisY();
            DevExpress.XtraCharts.Series series1 = new DevExpress.XtraCharts.Series();
            DevExpress.XtraCharts.SplineSeriesView splineSeriesView1 = new DevExpress.XtraCharts.SplineSeriesView();
            DevExpress.XtraCharts.Series series2 = new DevExpress.XtraCharts.Series();
            DevExpress.XtraCharts.SplineSeriesView splineSeriesView2 = new DevExpress.XtraCharts.SplineSeriesView();
            DevExpress.XtraCharts.Series series3 = new DevExpress.XtraCharts.Series();
            DevExpress.XtraCharts.SplineSeriesView splineSeriesView3 = new DevExpress.XtraCharts.SplineSeriesView();
            chartControl1 = new DevExpress.XtraCharts.ChartControl();
            bar1 = new DevExpress.XtraBars.Bar();
            ((System.ComponentModel.ISupportInitialize)chartControl1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)xyDiagram1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)xyDiagramPane1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy2).BeginInit();
            ((System.ComponentModel.ISupportInitialize)series1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)series2).BeginInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView2).BeginInit();
            ((System.ComponentModel.ISupportInitialize)series3).BeginInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView3).BeginInit();
            SuspendLayout();
            //
            // chartControl1
            //
            chartControl1.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False;
            xyDiagram1.AxisX.Title.Text = "流量 ï¼ˆm³/h)";
            xyDiagram1.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            xyDiagram1.AxisX.VisibleInPanesSerializable = "-1";
            xyDiagram1.AxisY.Color = Color.DodgerBlue;
            xyDiagram1.AxisY.Label.TextColor = Color.DodgerBlue;
            xyDiagram1.AxisY.Title.Alignment = StringAlignment.Far;
            xyDiagram1.AxisY.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.False;
            xyDiagram1.AxisY.Title.Text = "扬程/m";
            xyDiagram1.AxisY.Title.TextColor = Color.DodgerBlue;
            xyDiagram1.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            xyDiagram1.AxisY.VisibleInPanesSerializable = "-1";
            xyDiagram1.DefaultPane.BorderVisible = false;
            xyDiagram1.DefaultPane.Title.Text = "无数据";
            xyDiagram1.PaneLayout.AutoLayoutMode = DevExpress.XtraCharts.PaneAutoLayoutMode.Grid;
            xyDiagram1.PaneLayout.RowDefinitions.AddRange(new DevExpress.XtraCharts.LayoutDefinition[] { layoutDefinition1, layoutDefinition2, layoutDefinition3 });
            xyDiagramPane1.BorderVisible = false;
            xyDiagramPane1.LayoutOptions.Column = 0;
            xyDiagramPane1.LayoutOptions.Row = 2;
            xyDiagramPane1.Name = "BottomPanel";
            xyDiagramPane1.PaneID = 1;
            xyDiagramPane1.RuntimeCollapse = DevExpress.Utils.DefaultBoolean.False;
            xyDiagramPane1.SelectionRectangle.BorderVisible = false;
            xyDiagram1.Panes.AddRange(new DevExpress.XtraCharts.XYDiagramPane[] { xyDiagramPane1 });
            secondaryAxisy1.AxisID = 0;
            secondaryAxisy1.Color = Color.Green;
            secondaryAxisy1.Label.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
            secondaryAxisy1.Label.TextColor = Color.Green;
            secondaryAxisy1.Name = "AxisYQE";
            secondaryAxisy1.Title.Text = "效率/%";
            secondaryAxisy1.Title.TextColor = Color.Green;
            secondaryAxisy1.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            secondaryAxisy1.VisibleInPanesSerializable = "-1";
            secondaryAxisy2.Alignment = DevExpress.XtraCharts.AxisAlignment.Near;
            secondaryAxisy2.AxisID = 1;
            secondaryAxisy2.Label.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
            secondaryAxisy2.Label.TextColor = Color.Crimson;
            secondaryAxisy2.Name = "AxisYQP";
            secondaryAxisy2.NumericScaleOptions.AutoGrid = false;
            secondaryAxisy2.NumericScaleOptions.GridSpacing = 2D;
            secondaryAxisy2.Title.Alignment = StringAlignment.Near;
            secondaryAxisy2.Title.Text = "功率/kW";
            secondaryAxisy2.Title.TextColor = Color.Crimson;
            secondaryAxisy2.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default;
            secondaryAxisy2.VisibleInPanesSerializable = "1";
            xyDiagram1.SecondaryAxesY.AddRange(new DevExpress.XtraCharts.SecondaryAxisY[] { secondaryAxisy1, secondaryAxisy2 });
            chartControl1.Diagram = xyDiagram1;
            chartControl1.Dock = DockStyle.Fill;
            chartControl1.Legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Right;
            chartControl1.Legend.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
            chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.LeftToRight;
            chartControl1.Legend.LegendID = -1;
            chartControl1.Legend.MarkerMode = DevExpress.XtraCharts.LegendMarkerMode.CheckBoxAndMarker;
            chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
            chartControl1.Location = new Point(0, 0);
            chartControl1.Name = "chartControl1";
            series1.Name = "SeriesQH";
            series1.SeriesID = 0;
            splineSeriesView1.Color = Color.FromArgb(84, 141, 212);
            series1.View = splineSeriesView1;
            series2.Name = "SeriesQE";
            series2.SeriesID = 1;
            splineSeriesView2.AxisYName = "AxisYQE";
            splineSeriesView2.Color = Color.FromArgb(155, 187, 89);
            series2.View = splineSeriesView2;
            series3.Name = "SeriesQP";
            series3.SeriesID = 2;
            splineSeriesView3.AxisYName = "AxisYQP";
            splineSeriesView3.Color = Color.FromArgb(192, 0, 0);
            splineSeriesView3.PaneName = "BottomPanel";
            series3.View = splineSeriesView3;
            chartControl1.SeriesSerializable = new DevExpress.XtraCharts.Series[]
    {
    series1,
    series2,
    series3
    };
            chartControl1.Size = new Size(1023, 857);
            chartControl1.TabIndex = 0;
            //
            // bar1
            //
            bar1.BarName = "Custom 2";
            bar1.DockCol = 0;
            bar1.DockRow = 0;
            bar1.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
            bar1.OptionsBar.MultiLine = true;
            bar1.OptionsBar.UseWholeRow = true;
            bar1.Text = "Custom 2";
            //
            // PumpWorkingViewChart
            //
            AutoScaleDimensions = new SizeF(10F, 22F);
            AutoScaleMode = AutoScaleMode.Font;
            Controls.Add(chartControl1);
            Name = "PumpWorkingViewChart";
            Size = new Size(1023, 857);
            ((System.ComponentModel.ISupportInitialize)xyDiagramPane1).EndInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy1).EndInit();
            ((System.ComponentModel.ISupportInitialize)secondaryAxisy2).EndInit();
            ((System.ComponentModel.ISupportInitialize)xyDiagram1).EndInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView1).EndInit();
            ((System.ComponentModel.ISupportInitialize)series1).EndInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView2).EndInit();
            ((System.ComponentModel.ISupportInitialize)series2).EndInit();
            ((System.ComponentModel.ISupportInitialize)splineSeriesView3).EndInit();
            ((System.ComponentModel.ISupportInitialize)series3).EndInit();
            ((System.ComponentModel.ISupportInitialize)chartControl1).EndInit();
            ResumeLayout(false);
        }
        #endregion
        private DevExpress.XtraCharts.ChartControl chartControl1;
        private DevExpress.XtraBars.Bar bar1;
    }
}
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewChart.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,838 @@
using DevExpress.Utils;
using DevExpress.XtraCharts;
namespace Yw.WinFrmUI.Phart
{
    /// <summary>
    /// æ³µå·¥å†µè§†å›¾å›¾è¡¨
    /// </summary>
    public partial class PumpWorkingViewChart : DevExpress.XtraEditors.XtraUserControl
    {
        public PumpWorkingViewChart()
        {
            InitializeComponent();
            InitialChart();
            this.chartControl1.RuntimeHitTesting = true;
        }
        #region Private Variable
        private readonly string _tag_qh = "QH", _tag_qe = "QE", _tag_qp = "QP";
        private XYDiagram _diagram;
        private XYDiagramDefaultPane _default_pane;
        private XYDiagramPane _bottom_pane;
        private AxisX _axis_x_flow;
        private AxisY _axis_y_head;
        private SecondaryAxisY _axis_y_eff, _axis_y_power;
        private PumpCoordinate _coordinate;
        private bool _qe_visible = true;
        private bool _qp_visible = true;
        private bool _run_point_visible = true;
        private bool _equip_visible = true;
        private bool _initial_data = false;
        private PumpWorkingViewViewModel _vm = null;
        #endregion
        #region Public Variable
        /// <summary>
        /// æ•ˆçŽ‡æ˜¾ç¤º
        /// </summary>
        public bool QEVisible
        {
            get => _qe_visible;
            set
            {
                _qe_visible = value;
                SetQEVisible(_qe_visible);
            }
        }
        /// <summary>
        /// åŠŸçŽ‡æ˜¾ç¤º
        /// </summary>
        public bool QPVisble
        {
            get => _qp_visible;
            set
            {
                _qp_visible = value;
                SetQPVisible(_qp_visible);
            }
        }
        /// <summary>
        /// è¿è¡Œç‚¹æ˜¾ç¤º
        /// </summary>
        public bool RunPointVisible
        {
            get => _run_point_visible;
            set
            {
                _run_point_visible = value;
            }
        }
        /// <summary>
        /// ç®¡é“特性线显示
        /// </summary>
        public bool EquipVisible
        {
            get => _equip_visible;
            set
            {
                _equip_visible = value;
            }
        }
        #endregion
        #region Public Evnet
        /// <summary>
        /// åæ ‡å˜æ¢äº‹ä»¶
        /// </summary>
        public event Action<PumpCoordinate> CoordinateChangedEvent = null;
        /// <summary>
        /// è¿è¡Œç‚¹é€‰æ‹©äº‹ä»¶
        /// </summary>
        public event Action<PumpWorkingViewItemViewModel> RunPointSelectedEvent = null;
        #endregion
        #region Initial
        /// <summary>
        /// åˆå§‹åŒ–图表
        /// </summary>
        private void InitialChart()
        {
            this.chartControl1.SetChartDisplay();
            this.chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.TopToBottom;
            _diagram = (XYDiagram)this.chartControl1.Diagram;
            _default_pane = _diagram.DefaultPane;
            _bottom_pane = (XYDiagramPane)_diagram.FindPaneByName("BottomPanel");
            _axis_x_flow = _diagram.AxisX;
            _axis_x_flow.SetAxisXQDisplay();
            _axis_y_head = _diagram.AxisY;
            _axis_y_head.SetAxisYQHDisplay();
            _axis_y_eff = _diagram.SecondaryAxesY.GetAxisByName("AxisYQE");
            _axis_y_eff.SetSecondaryAxisYQEDisplay();
            _axis_y_eff.Alignment = AxisAlignment.Far;
            _axis_y_power = _diagram.SecondaryAxesY.GetAxisByName("AxisYQP");
            _axis_y_power.SetSecondaryAxisYQPDisplay();
            this.chartControl1.SetChartMonoColorDisplay();
            _axis_x_flow.Visibility = DefaultBoolean.False;
            _axis_x_flow.GridLines.Visible = false;
            _axis_y_head.Visibility = DefaultBoolean.False;
            _axis_y_head.GridLines.Visible = false;
            _axis_y_eff.Visibility = DefaultBoolean.False;
            _axis_y_eff.GridLines.Visible = false;
            _axis_y_power.Visibility = DefaultBoolean.False;
            _axis_y_power.GridLines.Visible = false;
            this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseDown);
            this.chartControl1.CustomPaint += ChartControl1_CustomPaint;
        }
        private List<Tuple<Rectangle, Color, PumpWorkingViewItemViewModel>> _rect_list = new();
        private Point? _rect_point = null;
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            if (!_run_point_visible)
                return;
            if (_rect_list == null || !_rect_list.Any())
                return;
            foreach (var rect in _rect_list)
            {
                if (rect.Item1.Contains(e.Location))
                {
                    _rect_point = new Point(rect.Item1.X + 5, rect.Item1.Y + 5);
                    this.RunPointSelectedEvent?.Invoke(rect.Item3);
                    break;
                }
            }
        }
        private void ChartControl1_CustomPaint(object sender, CustomPaintEventArgs e)
        {
            if (e is not DXCustomPaintEventArgs dxArgs)
                return;
            if (_vm == null)
                return;
            _rect_list.Clear();
            if (_vm.Items != null && _vm.Items.Any() && _run_point_visible)
            {
                foreach (var vm in _vm.Items)
                {
                    var color = vm.Color;
                    var flow = vm.Q;
                    var head = vm.H;
                    var eff = vm.E;
                    var power = vm.P;
                    {
                        var dg_pt = _diagram.DiagramToPoint(flow, head, _axis_x_flow, _axis_y_head);
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                        _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                    }
                    if (eff.HasValue && _qe_visible)
                    {
                        var dg_pt = _diagram.DiagramToPoint(flow, eff.Value, _axis_x_flow, _axis_y_eff);
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                        _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                    }
                    if (power.HasValue && _qp_visible)
                    {
                        var dg_pt = _diagram.DiagramToPoint(flow, power.Value, _axis_x_flow, _axis_y_power);
                        var dg_x = dg_pt.Point.X - 5;
                        var dg_y = dg_pt.Point.Y - 5;
                        dxArgs.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                        _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                    }
                }
                if (_rect_point.HasValue)
                {
                    var x = _rect_point.Value.X;
                    var y = _rect_point.Value.Y;
                    var length = 20;
                    using Pen pen = new Pen(Color.Magenta, 2);
                    dxArgs.Cache.DrawLine(pen, new Point(x - length, y), new Point(x + length, y));
                    dxArgs.Cache.DrawLine(pen, new Point(x, y - length), new Point(x, y + length));
                    dxArgs.Cache.DrawEllipse(pen, new Rectangle(x - 10, y - 10, length, length));
                }
            }
        }
        /// <summary>
        /// åˆå§‹åŒ–图表数据
        /// </summary>
        public void InitialChartData()
        {
            _initial_data = false;
            _coordinate = null;
            UpdateChart(false);
        }
        #endregion
        #region Set
        /// <summary>
        /// ç»‘定数据
        /// </summary>
        public void SetBindingData(PumpWorkingViewViewModel vm)
        {
            _vm = vm;
            _initial_data = vm != null;
            UpdateChart(true);
        }
        /// <summary>
        /// æ¸…空曲线
        /// </summary>
        public void Clear()
        {
            _vm = null;
            _initial_data = false;
            UpdateChart(true);
        }
        /// <summary>
        /// æ›´æ–°å›¾è¡¨
        /// </summary>
        public void UpdateChart(bool calc_coordinate = false)
        {
            _rect_point = null;
            _rect_list = new ();
            if (calc_coordinate || _coordinate == null)
            {
                //不强迫计算,就用上次更新的坐标系
                CalcCoordinate();
            }
            CalcSeries();
            CalcChartAxis();
        }
        #endregion
        #region Calc
        private double _min_flow, _max_flow;
        private double _max_head = 0, _min_head = 10000;
        private double _max_eff = 0, _min_eff = 0;
        private double _max_power = 0, _min_power = 1000;
        /// <summary>
        /// è®¡ç®—坐标
        /// </summary>
        private void CalcCoordinate()
        {
            if (_vm == null)
            {
                //设置成白板坐标
                _coordinate = new PumpCoordinate();
                _coordinate.GridNumberX = 30;
                _coordinate.GridNumberY = 16;
                //显示的坐标线号
                _coordinate.StartLineNoH = 10;
                _coordinate.EndLineNoH = 15;
                _coordinate.StartLineNoE = 0;
                _coordinate.EndLineNoE = 10;
                _coordinate.StartLineNoP = 2;
                _coordinate.EndLineNoP = 9;
                //坐标最小值和间隔
                _coordinate.CoordMinQ = 0; _coordinate.CoordSpaceQ = 1000;
                _coordinate.CoordMinH = 10; _coordinate.CoordSpaceH = 100;
                _coordinate.CoordMinE = 0; _coordinate.CoordSpaceE = 100;
                _coordinate.CoordMinP = 10; _coordinate.CoordSpaceP = 100;
                return;
            }
            _max_flow = 0; _min_flow = 10000;
            _max_head = 0; _min_head = 10000;
            _max_eff = 0; _min_eff = 0;
            _max_power = 0; _min_power = 1000;
            double _scaleMinH = 1, _scaleMaxH = 1;
            if (_vm.Items != null && _vm.Items.Any())
            {
                foreach (var vm in _vm.Items)
                {
                    {
                        var qh_pt_list = vm.CurveQH.GetPointList();
                        var xxx = qh_pt_list.Select(x => x.X);
                        var yyy = qh_pt_list.Select(x => x.Y);
                        _min_flow = Math.Min(_min_flow, xxx.Min());
                        _max_flow = Math.Max(_max_flow, xxx.Max());
                        _min_head = Math.Min(_min_head, yyy.Min());
                        _max_head = Math.Max(_max_head, yyy.Max());
                    }
                    if (vm.CurveQE != null)
                    {
                        var qe_pt_list = vm.CurveQE.GetPointList();
                        var yyy = qe_pt_list.Select(x => x.Y);
                        _min_eff = Math.Min(_min_eff, yyy.Min());
                        _max_eff = Math.Max(_max_eff, yyy.Max());
                    }
                    if (vm.CurveQP != null)
                    {
                        var yyy = vm.CurveQP.GetPointList().Select(x => x.Y);
                        _min_power = Math.Min(_min_power, yyy.Min());
                        _max_power = Math.Max(_max_power, yyy.Max());
                    }
                }
            }
            _coordinate = PumpCoordinate.CalcCoordinate(_min_flow,
                                                                         _max_flow,
                                                                         _min_head * _scaleMinH,
                                                                         _max_head * _scaleMaxH,
                                                                         _min_eff,
                                                                         _max_eff,
                                                                         _min_power,
                                                                         _max_power);
            if (_coordinate == null)
                return;
            if (_coordinate.CoordMinQ + _coordinate.CoordSpaceQ * this._coordinate.GridNumberX < _max_flow * 1.05)
            {
                _coordinate.GridNumberX++;
            }
        }
        /// <summary>
        /// è®¡ç®—图表轴
        /// </summary>
        private void CalcChartAxis()
        {
            _axis_x_flow.Visibility = DefaultBoolean.False;
            _axis_x_flow.GridLines.Visible = false;
            _axis_y_head.Visibility = DefaultBoolean.False;
            _axis_y_head.GridLines.Visible = false;
            _axis_y_eff.Visibility = DefaultBoolean.False;
            _axis_y_eff.GridLines.Visible = false;
            _axis_y_power.Visibility = DefaultBoolean.False;
            _axis_y_power.GridLines.Visible = false;
            _bottom_pane.Visibility = ChartElementVisibility.Hidden;
            _bottom_pane.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
            //计算刻度 Q
            var axisQLabels = new List<CustomAxisLabel>();
            var disQ = _coordinate.CoordMinQ;
            for (int i = 0; i < _coordinate.GridNumberX + 1; i++)
            {
                axisQLabels.Add(new CustomAxisLabel(disQ.ToString("N0"), disQ));
                disQ = disQ + _coordinate.CoordSpaceQ;
            }
            _axis_x_flow.CustomLabels.Clear();
            _axis_x_flow.CustomLabels.AddRange(axisQLabels.ToArray());
            _axis_x_flow.Visibility = DefaultBoolean.True;
            _axis_x_flow.GridLines.Visible = true;
            //计算刻度
            var axis_head_labels = new List<CustomAxisLabel>();
            var display_head = _coordinate.CoordMinH + _coordinate.CoordSpaceH * _coordinate.StartLineNoH;
            for (int i = _coordinate.StartLineNoH; i < _coordinate.EndLineNoH + 1; i++)
            {
                axis_head_labels.Add(new CustomAxisLabel(display_head.ToString(), display_head));
                display_head = display_head + _coordinate.CoordSpaceH;
            }
            _axis_y_head.CustomLabels.Clear();
            _axis_y_head.CustomLabels.AddRange(axis_head_labels.ToArray());
            _axis_y_head.Visibility = DefaultBoolean.True;
            _axis_y_head.GridLines.Visible = true;
            //效率
            if (_max_eff > _min_eff && _qe_visible)
            {
                //计算刻度
                var labels = new List<CustomAxisLabel>();
                var display_eff = _coordinate.CoordMinE + _coordinate.CoordSpaceE * _coordinate.StartLineNoE;
                for (int i = _coordinate.StartLineNoE; i < _coordinate.EndLineNoE + 1; i++)
                {
                    labels.Add(new CustomAxisLabel(display_eff.ToString(), display_eff));
                    display_eff = display_eff + _coordinate.CoordSpaceE;
                }
                _axis_y_eff.CustomLabels.Clear();
                _axis_y_eff.CustomLabels.AddRange(labels.ToArray());
                _axis_y_eff.Visibility = DefaultBoolean.True;
                _axis_y_eff.GridLines.Visible = true;
            }
            //功率
            if (_max_power > _min_power && _qp_visible)
            {
                //计算刻度
                var labels = new List<CustomAxisLabel>();
                double display_power = _coordinate.CoordMinP + _coordinate.CoordSpaceP * _coordinate.StartLineNoP;
                for (int i = _coordinate.StartLineNoP; i < _coordinate.EndLineNoP + 1; i++)
                {
                    labels.Add(new CustomAxisLabel(display_power.ToString(), display_power));
                    display_power = display_power + _coordinate.CoordSpaceP;
                }
                _axis_y_power.CustomLabels.Clear();
                _axis_y_power.CustomLabels.AddRange(labels.ToArray());
                _axis_y_power.Visibility = DefaultBoolean.True;
                _axis_y_power.GridLines.Visible = true;
            }
            var min_flow = _coordinate.CoordMinQ;
            var max_flow = _coordinate.DispMaxQ();
            _axis_x_flow.SetAxisRange(min_flow, max_flow);
            var grid_count_head = _coordinate.EndLineNoH - _coordinate.StartLineNoH;
            var grid_count_eff = _coordinate.EndLineNoE - _coordinate.StartLineNoE;
            int grid_count_up = Math.Max(grid_count_head, grid_count_eff);
            if (_qe_visible)
            {
                grid_count_up += 2;//多两条
            }
            var max_axis_head = _coordinate.CoordMinH + _coordinate.EndLineNoH * _coordinate.CoordSpaceH;
            var min_axis_head = max_axis_head - grid_count_up * _coordinate.CoordSpaceH;
            _axis_y_head.SetAxisRange(min_axis_head, max_axis_head);
            var min_axis_eff = _coordinate.CoordMinE + _coordinate.StartLineNoE * _coordinate.CoordSpaceE;
            var max_axis_eff = min_axis_eff + grid_count_up * _coordinate.CoordSpaceE;
            _axis_y_eff.SetAxisRange(min_axis_eff, max_axis_eff);
            var grid_count_power = _coordinate.EndLineNoP - _coordinate.StartLineNoP;
            var min_axis_power = _coordinate.CoordMinP + _coordinate.StartLineNoP * _coordinate.CoordSpaceP;
            var max_axis_power = min_axis_power + grid_count_power * _coordinate.CoordSpaceP;
            _axis_y_power.SetAxisRange(min_axis_power, max_axis_power);
        }
        /// <summary>
        /// è®¡ç®—系列
        /// </summary>
        private void CalcSeries()
        {
            this.chartControl1.BeginInit();
            this.chartControl1.Series.Clear();
            this.chartControl1.AnnotationRepository.Clear();
            this.chartControl1.Legend.CustomItems.Clear();
            if (_vm != null)
            {
                if (_vm.Items != null && _vm.Items.Any())
                {
                    for (int i = 0; i < _vm.Items.Count; i++)
                    {
                        var vm = _vm.Items[i];
                        CreateCurrentLineSeries(vm.Id, vm.Color, vm.CurveName, vm.CurveQH, vm.CurveQE, vm.CurveQP);
                    }
                }
            }
            this.chartControl1.EndInit();
        }
        /// <summary>
        /// åˆ›å»ºçº¿ç³»åˆ—
        /// </summary>
        private void CreateLineSeries(string id, Color color, string curve_name, Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp)
        {
            var series_qh = new DevExpress.XtraCharts.Series();
            series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            series_qh.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
            series_qh.Name = _tag_qh + id;
            series_qh.ShowInLegend = false;
            series_qh.CrosshairEnabled = DefaultBoolean.False;
            series_qh.LegendTextPattern = curve_name;
            var series_qh_view = new DevExpress.XtraCharts.LineSeriesView();
            series_qh_view.LineStyle.Thickness = 2;
            series_qh_view.LineStyle.DashStyle = DashStyle.Dash;
            series_qh_view.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;
            series_qh_view.Color = color;
            series_qh_view.EnableAntialiasing = DefaultBoolean.True;
            series_qh.SeriesPointsSorting = SortingMode.None;
            series_qh.SeriesPointsSortingKey = SeriesPointKey.Value_1;
            series_qh.View = series_qh_view;
            series_qh.Visible = true;
            var pt_qh_list = qh.GetPointList(100);
            for (int i = 0; i < pt_qh_list.Count; i++)
            {
                series_qh.Points.Add(new SeriesPoint(pt_qh_list[i].X, new double[] { pt_qh_list[i].Y }));
            }
            var point_qh = pt_qh_list[pt_qh_list.Count - 1];
            var anchor_qh_pt = new DevExpress.XtraCharts.PaneAnchorPoint();
            anchor_qh_pt.Pane = _default_pane;
            anchor_qh_pt.AxisXCoordinate.AxisValue = point_qh.X.ToString();
            anchor_qh_pt.AxisYCoordinate.AxisValue = point_qh.Y.ToString();
            var position_qh = new DevExpress.XtraCharts.RelativePosition();
            position_qh.Angle = -50;
            position_qh.ConnectorLength = 10;
            var txt_qh = new TextAnnotation();
            txt_qh.Border.Visibility = DefaultBoolean.False;
            txt_qh.AnchorPoint = anchor_qh_pt;
            txt_qh.AutoHeight = true;
            txt_qh.AutoWidth = true;
            txt_qh.BackColor = System.Drawing.Color.Transparent;
            txt_qh.Border.Color = color;
            txt_qh.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.Line;
            txt_qh.DXFont = PumpChartDisplay.AnnoFontQH;
            txt_qh.Name = _tag_qh + id;
            txt_qh.Padding.Bottom = 1;
            txt_qh.Padding.Left = 1;
            txt_qh.Padding.Right = 1;
            txt_qh.Padding.Top = 1;
            txt_qh.RuntimeAnchoring = false;
            txt_qh.RuntimeMoving = true;
            txt_qh.RuntimeResizing = false;
            txt_qh.RuntimeRotation = false;
            txt_qh.Text = curve_name;
            txt_qh.TextColor = color;
            txt_qh.ShapePosition = position_qh;
            txt_qh.Visible = true;
            this.chartControl1.AnnotationRepository.Add(txt_qh);
            this.chartControl1.Series.Add(series_qh);
            if (qe != null)
            {
                var series_qe = new DevExpress.XtraCharts.Series();
                series_qe.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qe.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qe.Name = _tag_qe + id;
                series_qe.ShowInLegend = false;
                series_qe.CrosshairEnabled = DefaultBoolean.False;
                series_qe.Tag = id;
                var series_qe_view = new DevExpress.XtraCharts.LineSeriesView();
                series_qe_view.LineStyle.Thickness = 2;
                series_qe_view.LineStyle.DashStyle = DashStyle.Dash;
                series_qe_view.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;
                series_qe_view.Color = color;
                series_qe_view.AxisY = _axis_y_eff;
                series_qe_view.Pane = _default_pane;
                series_qe_view.EnableAntialiasing = DefaultBoolean.True;
                series_qe.SeriesPointsSorting = SortingMode.None;
                series_qe.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qe.View = series_qe_view;
                series_qe.Visible = _qe_visible;
                var pt_qe_list = qe.GetPointList(100);
                for (int i = 0; i < pt_qe_list.Count; i++)
                {
                    series_qe.Points.Add(new SeriesPoint(pt_qe_list[i].X, new double[] { pt_qe_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qe);
            }
            if (qp != null)
            {
                var series_qp = new DevExpress.XtraCharts.Series();
                series_qp.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qp.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qp.Name = _tag_qp + id;
                series_qp.ShowInLegend = false;
                series_qp.CrosshairEnabled = DefaultBoolean.False;
                series_qp.Tag = id;
                var series_qp_view = new DevExpress.XtraCharts.LineSeriesView();
                series_qp_view.LineStyle.Thickness = 2;
                series_qp_view.LineStyle.DashStyle = DashStyle.Dash;
                series_qp_view.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;
                series_qp_view.Color = color;
                series_qp_view.AxisY = _axis_y_power;
                series_qp_view.Pane = _bottom_pane;
                series_qp_view.EnableAntialiasing = DefaultBoolean.True;
                series_qp.SeriesPointsSorting = SortingMode.None;
                series_qp.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qp.View = series_qp_view;
                series_qp.Visible = _qp_visible;
                var pt_qp_list = qp.GetPointList(100);
                for (int i = 0; i < pt_qp_list.Count; i++)
                {
                    series_qp.Points.Add(new SeriesPoint(pt_qp_list[i].X, new double[] { pt_qp_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qp);
            }
        }
        /// <summary>
        /// åˆ›å»ºçº¿ç³»åˆ—
        /// </summary>
        private void CreateCurrentLineSeries(string id, Color color, string curve_name, Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp)
        {
            var series_qh = new DevExpress.XtraCharts.Series();
            series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            series_qh.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
            series_qh.Name = _tag_qh + id;
            series_qh.ShowInLegend = false;
            series_qh.CrosshairEnabled = DefaultBoolean.False;
            series_qh.LegendTextPattern = curve_name;
            var series_qh_view = new DevExpress.XtraCharts.SplineSeriesView();
            series_qh_view.LineStyle.Thickness = 2;
            series_qh_view.Color = color;
            series_qh_view.EnableAntialiasing = DefaultBoolean.True;
            series_qh_view.LineTensionPercent = 50;
            series_qh.SeriesPointsSorting = SortingMode.None;
            series_qh.SeriesPointsSortingKey = SeriesPointKey.Value_1;
            series_qh.View = series_qh_view;
            series_qh.Visible = true;
            var pt_qh_list = qh.GetPointList(100);
            for (int i = 0; i < pt_qh_list.Count; i++)
            {
                series_qh.Points.Add(new SeriesPoint(pt_qh_list[i].X, new double[] { pt_qh_list[i].Y }));
            }
            var point_qh = pt_qh_list[pt_qh_list.Count() - 1];
            var anchor_qh_pt = new DevExpress.XtraCharts.PaneAnchorPoint();
            anchor_qh_pt.Pane = _default_pane;
            anchor_qh_pt.AxisXCoordinate.AxisValue = point_qh.X.ToString();
            anchor_qh_pt.AxisYCoordinate.AxisValue = point_qh.Y.ToString();
            var position_qh = new DevExpress.XtraCharts.RelativePosition();
            position_qh.Angle = -50;
            position_qh.ConnectorLength = 10;
            var txt_qh = new TextAnnotation();
            txt_qh.Border.Visibility = DefaultBoolean.False;
            txt_qh.AnchorPoint = anchor_qh_pt;
            txt_qh.AutoHeight = true;
            txt_qh.AutoWidth = true;
            txt_qh.BackColor = System.Drawing.Color.Transparent;
            txt_qh.Border.Color = color;
            txt_qh.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.Line;
            txt_qh.DXFont = PumpChartDisplay.AnnoFontQH;
            txt_qh.Name = _tag_qh + id;
            txt_qh.Padding.Bottom = 1;
            txt_qh.Padding.Left = 1;
            txt_qh.Padding.Right = 1;
            txt_qh.Padding.Top = 1;
            txt_qh.RuntimeAnchoring = false;
            txt_qh.RuntimeMoving = true;
            txt_qh.RuntimeResizing = false;
            txt_qh.RuntimeRotation = false;
            txt_qh.Text = curve_name;
            txt_qh.TextColor = color;
            txt_qh.ShapePosition = position_qh;
            txt_qh.Visible = true;
            this.chartControl1.AnnotationRepository.Add(txt_qh);
            this.chartControl1.Series.Add(series_qh);
            if (qe != null)
            {
                var series_qe = new DevExpress.XtraCharts.Series();
                series_qe.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qe.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qe.Name = _tag_qe + id;
                series_qe.ShowInLegend = false;
                series_qe.CrosshairEnabled = DefaultBoolean.False;
                series_qe.Tag = id;
                var series_qe_view = new DevExpress.XtraCharts.SplineSeriesView();
                series_qe_view.LineStyle.Thickness = 2;
                series_qe_view.Color = color;
                series_qe_view.AxisY = _axis_y_eff;
                series_qe_view.Pane = _default_pane;
                series_qe_view.EnableAntialiasing = DefaultBoolean.True;
                series_qe_view.LineTensionPercent = 50;
                series_qe.SeriesPointsSorting = SortingMode.None;
                series_qe.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qe.View = series_qe_view;
                series_qe.Visible = _qe_visible;
                var pt_qe_list = qe.GetPointList(100);
                for (int i = 0; i < pt_qe_list.Count; i++)
                {
                    series_qe.Points.Add(new SeriesPoint(pt_qe_list[i].X, new double[] { pt_qe_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qe);
            }
            if (qp != null)
            {
                var series_qp = new DevExpress.XtraCharts.Series();
                series_qp.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
                series_qp.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
                series_qp.Name = _tag_qp + id;
                series_qp.ShowInLegend = false;
                series_qp.CrosshairEnabled = DefaultBoolean.False;
                series_qp.Tag = id;
                var series_qp_view = new DevExpress.XtraCharts.SplineSeriesView();
                series_qp_view.LineStyle.Thickness = 2;
                series_qp_view.Color = color;
                series_qp_view.AxisY = _axis_y_power;
                series_qp_view.Pane = _bottom_pane;
                series_qp_view.EnableAntialiasing = DefaultBoolean.True;
                series_qp_view.LineTensionPercent = 50;
                series_qp.SeriesPointsSorting = SortingMode.None;
                series_qp.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                series_qp.View = series_qp_view;
                series_qp.Visible = _qp_visible;
                var pt_qp_list = qp.GetPointList(100);
                for (int i = 0; i < pt_qp_list.Count; i++)
                {
                    series_qp.Points.Add(new SeriesPoint(pt_qp_list[i].X, new double[] { pt_qp_list[i].Y }));
                }
                this.chartControl1.Series.Add(series_qp);
            }
        }
        #endregion
        #region Right Click Menu
        /// <summary>
        /// è®¾ç½®åæ ‡è½´
        /// </summary>
        public void SetChartAxis()
        {
            var dlg = new PumpChartCoordinateDlg();
            dlg.SetBindingData(_coordinate);
            dlg.OnChangedCoord += (rhs) =>
            {
                _coordinate = rhs;
                CalcChartAxis();
                this.CoordinateChangedEvent?.Invoke(_coordinate);
            };
            dlg.ShowDialog();
        }
        /// <summary>
        /// è®¾ç½®è¿è¡Œç‚¹æ˜¾ç¤º
        /// </summary>
        public void SetEQVisible(bool visible)
        {
            _run_point_visible = visible;
        }
        /// <summary>
        /// è®¾ç½®æ•ˆçŽ‡æ˜¾ç¤º
        /// </summary>
        public void SetQEVisible(bool visible)
        {
            _qe_visible = visible;
            UpdateChart();
        }
        /// <summary>
        /// è®¾ç½®åŠŸçŽ‡æ˜¾ç¤º
        /// </summary>
        public void SetQPVisible(bool visible)
        {
            _qp_visible = visible;
            _bottom_pane.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
            UpdateChart();
        }
        #endregion
    }
}
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewChart.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Version 2.0
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
    Example:
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
    There are any number of "resheader" rows that contain simple
    name/value pairs.
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
</root>
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewItemViewModel.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,95 @@
namespace Yw.WinFrmUI.Phart
{
    /// <summary>
    /// æ³µè¿è¡Œè§†å›¾ Item ViewModel
    /// </summary>
    public class PumpWorkingViewItemViewModel
    {
        public PumpWorkingViewItemViewModel() { }
        public PumpWorkingViewItemViewModel(PumpWorkingViewItemViewModel rhs)
        {
            this.Id = rhs.Id;
            this.Name = rhs.Name;
            this.CurveName = rhs.CurveName;
            this.Color = rhs.Color;
            this.Q = rhs.Q;
            this.H = rhs.H;
            this.P = rhs.P;
            this.N = rhs.N;
            this.Hz = rhs.Hz;
            this.CurveQH = rhs.CurveQH;
            this.CurveQE = rhs.CurveQE;
            this.CurveQP = rhs.CurveQP;
        }
        /// <summary>
        /// æ ‡è¯†
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// åç§°
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// åç§°
        /// </summary>
        public string CurveName { get; set; }
        /// <summary>
        /// é¢œè‰²
        /// </summary>
        public Color Color { get; set; }
        /// <summary>
        /// æµé‡
        /// </summary>
        public double Q { get; set; }
        /// <summary>
        /// æ‰¬ç¨‹
        /// </summary>
        public double H { get; set; }
        /// <summary>
        /// åŠŸçŽ‡
        /// </summary>
        public double? P { get; set; }
        /// <summary>
        /// æ•ˆçއ
        /// </summary>
        public double? E { get; set; }
        /// <summary>
        /// è½¬é€Ÿ
        /// </summary>
        public double N { get; set; }
        /// <summary>
        /// é¢‘率
        /// </summary>
        public double Hz { get; set; }
        /// <summary>
        /// æµé‡æ‰¬ç¨‹çº¿
        /// </summary>
        public Yw.Geometry.CubicSpline2d CurveQH { get; set; }
        /// <summary>
        /// æµé‡æ•ˆçŽ‡çº¿
        /// </summary>
        public Yw.Geometry.CubicSpline2d CurveQE { get; set; }
        /// <summary>
        /// æµé‡åŠŸçŽ‡çº¿
        /// </summary>
        public Yw.Geometry.CubicSpline2d CurveQP { get; set; }
    }
}
WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/05-working-view/PumpWorkingViewViewModel.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,64 @@
namespace Yw.WinFrmUI.Phart
{
    /// <summary>
    /// æ³µè¿è¡Œè§†å›¾ViewModel
    /// </summary>
    public class PumpWorkingViewViewModel
    {
        public PumpWorkingViewViewModel() { }
        public PumpWorkingViewViewModel(PumpWorkingViewViewModel rhs)
        {
            this.Id = rhs.Id;
            this.Name = rhs.Name;
            this.CurveName = rhs.CurveName;
            this.Color = rhs.Color;
            this.Items = rhs.Items;
        }
        /// <summary>
        /// æ ‡è¯†
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// åç§°
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// åç§°
        /// </summary>
        public string CurveName { get; set; }
        /// <summary>
        /// é¢œè‰²
        /// </summary>
        public Color Color { get; set; }
        /// <summary>
        /// èµ·å§‹ç‚¹æ‰¬ç¨‹
        /// </summary>
        public double StartH { get; set; }
        /// <summary>
        /// ç®¡é“流量
        /// </summary>
        public double PipeQ { get; set; }
        /// <summary>
        /// ç®¡é“扬程
        /// </summary>
        public double PipeH { get; set; }
        /// <summary>
        /// å˜é€Ÿé¡¹åˆ—表
        /// </summary>
        public List<PumpWorkingViewItemViewModel> Items { get; set; }
    }
}
WinFrmUI/Yw.WinFrmUI.Phart.Core/Yw.WinFrmUI.Phart.Core.csproj
@@ -39,7 +39,13 @@
    <Compile Remove="00-calc-helper\ThroughParaCurve.cs" />
    <Compile Remove="01-pump\01-single\03-variable-speed\PumpVariableSpeedViewItemViewModel.cs" />
    <Compile Remove="01-pump\01-single\03-variable-speed\PumpVariableSpeedViewModel.cs" />
    <Compile Remove="01-pump\01-single\04-run-view\PumpRunViewChart - å¤åˆ¶.cs" />
    <Compile Remove="01-pump\01-single\04-run-view\PumpRunViewChart - å¤åˆ¶.Designer.cs" />
    <Compile Remove="Title - å¤åˆ¶.cs" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Remove="01-pump\01-single\04-run-view\PumpRunViewChart - å¤åˆ¶.resx" />
  </ItemGroup>
  <ItemGroup>
@@ -54,6 +60,9 @@
  </ItemGroup>
  <ItemGroup>
    <Compile Update="01-pump\01-single\05-working-view\PumpWorkingViewChart.cs">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Update="01-pump\02-multi\01-parallel\PumpParallelChart.cs">
      <SubType>UserControl</SubType>
    </Compile>