From a0bce3b366451b3ca94e676eb98dd7b415375c14 Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期五, 17 一月 2025 14:00:00 +0800
Subject: [PATCH] 代码修改

---
 WinFrmUI/Yw.WinFrmUI.Phart.Core/03-valve/02-edit/ValveEditChart.cs |  264 +++++++++++++++++++++++++++-------------------------
 1 files changed, 135 insertions(+), 129 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/03-valve/02-edit/ValveEditChart.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/03-valve/02-edit/ValveEditChart.cs
index 6db858d..e48c537 100644
--- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/03-valve/02-edit/ValveEditChart.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/03-valve/02-edit/ValveEditChart.cs
@@ -76,7 +76,7 @@
         public event Action<int> SelectedPointIndexChangedEvent;
         #endregion 
 
-        #region Initial
+        #region Private Initial
 
         /// <summary>
         /// 鍒濆鍖栧浘琛�
@@ -153,7 +153,135 @@
 
         #endregion Initial
 
-        #region SetBindingData
+        #region Private Chart Event
+
+        private int _pick_point_index = -1;
+        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
+        {
+            if (!_initial_data)
+                return;
+            var hitInfo = chartControl1.CalcHitInfo(e.Location);
+            _pick_point_index = -1;
+            if (e.Button == MouseButtons.Left)
+            {
+                if (hitInfo.InSeries && hitInfo.Series != _series_edit_pt)
+                {
+                    return;
+                }
+                if (hitInfo.InSeriesPoint && hitInfo.SeriesPoint.Tag is int index)
+                {
+                    _pick_point_index = index;
+                    this.SelectedPointIndexChangedEvent?.Invoke(_pick_point_index);
+                }
+            }
+
+        }
+
+        private void chartControl1_MouseMove(object sender, MouseEventArgs e)
+        {
+            if (!_mouse_mode)
+                return;
+            if (_pick_point_index < 0)
+                return;
+            if (IsInvalidData())
+                return;
+            var diagram_coordinates = _diagram.PointToDiagram(e.Location);
+            AxisYBase axis_y = null;
+            if (_edit_curve_type == Ahart.eCurveType.QL)
+            {
+                axis_y = _axis_y_head_loss;
+            }
+            else
+            {
+                axis_y = _axis_y_k_loss;
+            }
+            var axis_value = diagram_coordinates.GetAxisValue(axis_y);
+            if (axis_value == null)
+                return;
+            _series_edit_pt.Points[_pick_point_index].Values[0] = axis_value.NumericalValue;
+            _series_edit_pt.Points[_pick_point_index].NumericalArgument = diagram_coordinates.NumericalArgument;
+        }
+
+        private void chartControl1_MouseUp(object sender, MouseEventArgs e)
+        {
+            if (!_mouse_mode)
+                return;
+            if (_pick_point_index < 0)
+                return;
+            if (IsInvalidData())
+                return;
+            var x = _series_edit_pt.Points[_pick_point_index].NumericalArgument;
+            var y = _series_edit_pt.Points[_pick_point_index].Values[0];
+            x = Math.Round(x, 2);
+            y = Math.Round(y, 2);
+            SetPointValue(_pick_point_index, x, y);
+            _pick_point_index = -1;
+        }
+
+        private void chartControl1_KeyUp(object sender, KeyEventArgs e)
+        {
+            if (_mouse_mode)
+                return;
+            if (_pick_point_index < 0)
+                return;
+            if (IsInvalidData())
+                return;
+            double coord_space_x, coord_space_y;
+            if (_edit_curve_type == Ahart.eCurveType.QL)
+            {
+                coord_space_x = _coordinate.QL.CoordSpaceX;
+                coord_space_y = _coordinate.QL.CoordSpaceY;
+            }
+            else
+            {
+                coord_space_x = _coordinate.OL.CoordSpaceX;
+                coord_space_y = _coordinate.OL.CoordSpaceY;
+            }
+            double space_x = coord_space_x / 50;
+            double space_y = coord_space_y / 50;
+            double x = _series_edit_pt.Points[_pick_point_index].NumericalArgument;
+            double y = _series_edit_pt.Points[_pick_point_index].Values[0];
+            if (e.KeyCode == Keys.Up)
+            {
+                y += space_y;
+            }
+            else if (e.KeyCode == Keys.Down)
+            {
+                y -= space_y;
+            }
+            else if (e.KeyCode == Keys.Left)
+            {
+                x -= space_x;
+            }
+            else if (e.KeyCode == Keys.Right)
+            {
+                x += space_x;
+            }
+            x = Math.Round(x, 2);
+            y = Math.Round(y, 2);
+            _series_edit_pt.Points[_pick_point_index].NumericalArgument = x;
+            _series_edit_pt.Points[_pick_point_index].Values[0] = y;
+            SetPointValue(_pick_point_index, x, y);
+        }
+
+        /// <summary>
+        /// 鏇存柊鏁版嵁
+        /// </summary>
+        private void SetPointValue(int index, double x, double y)
+        {
+            if (IsInvalidData())
+                return;
+            var vm = _vm_list.Find(x => x.IsUpdate);
+            if (vm == null)
+                return;
+            vm.DefPointList[index].X = x;
+            vm.DefPointList[index].Y = y;
+            this.DefinePointChangedEvent?.Invoke(vm.DefPointList);
+        }
+
+        #endregion
+
+        #region Set
 
         /// <summary>
         /// 缁戝畾鏁版嵁
@@ -361,6 +489,11 @@
 
             foreach (var vm in _vm_list)
             {
+                if (vm.DefPointList == null || !vm.DefPointList.Any())
+                {
+                    continue;
+
+                }
                 if (vm.CurveType == Ahart.eCurveType.QL)
                 {
                     _min_x_flow = Math.Min(vm.DefPointList.Min(x => x.X), _min_x_flow);
@@ -516,133 +649,6 @@
 
         #endregion Calc
 
-        #region Chart Event
-
-        private int _pick_point_index = -1;
-        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
-        {
-            if (!_initial_data)
-                return;
-            var hitInfo = chartControl1.CalcHitInfo(e.Location);
-            _pick_point_index = -1;
-            if (e.Button == MouseButtons.Left)
-            {
-                if (hitInfo.InSeries&& hitInfo.Series != _series_edit_pt)
-                {
-                    return;
-                }
-                if (hitInfo.InSeriesPoint && hitInfo.SeriesPoint.Tag is int index)
-                {
-                    _pick_point_index = index;
-                    this.SelectedPointIndexChangedEvent?.Invoke(_pick_point_index);
-                }
-            }
-
-        }
-
-        private void chartControl1_MouseMove(object sender, MouseEventArgs e)
-        {
-            if (!_mouse_mode)
-                return;
-            if (_pick_point_index < 0)
-                return;
-            if (IsInvalidData())
-                return;
-            var diagram_coordinates = _diagram.PointToDiagram(e.Location);
-            AxisYBase axis_y = null;
-            if (_edit_curve_type == Ahart.eCurveType.QL)
-            {
-                axis_y = _axis_y_head_loss;
-            }
-            else
-            {
-                axis_y = _axis_y_k_loss;
-            }
-            var axis_value = diagram_coordinates.GetAxisValue(axis_y);
-            if (axis_value == null)
-                return;
-            _series_edit_pt.Points[_pick_point_index].Values[0] = axis_value.NumericalValue;
-            _series_edit_pt.Points[_pick_point_index].NumericalArgument = diagram_coordinates.NumericalArgument;
-        }
-         
-        private void chartControl1_MouseUp(object sender, MouseEventArgs e)
-        {
-            if (!_mouse_mode)
-                return;
-            if (_pick_point_index < 0)
-                return;
-            if (IsInvalidData())
-                return;
-            var x = _series_edit_pt.Points[_pick_point_index].NumericalArgument;
-            var y = _series_edit_pt.Points[_pick_point_index].Values[0];
-            x = Math.Round(x, 2);
-            y = Math.Round(y, 2);
-            SetPointValue(_pick_point_index, x, y);
-            _pick_point_index = -1;
-        }
-
-        private void chartControl1_KeyUp(object sender, KeyEventArgs e)
-        {
-            if (_mouse_mode)
-                return;
-            if (_pick_point_index < 0)
-                return;
-            if (IsInvalidData())
-                return;
-            double coord_space_x, coord_space_y;
-            if (_edit_curve_type == Ahart.eCurveType.QL)
-            {
-                coord_space_x = _coordinate.QL.CoordSpaceX;
-                coord_space_y = _coordinate.QL.CoordSpaceY;
-            }
-            else
-            {
-                coord_space_x = _coordinate.OL.CoordSpaceX;
-                coord_space_y = _coordinate.OL.CoordSpaceY;
-            }
-            double space_x = coord_space_x / 50;
-            double space_y = coord_space_y / 50;
-            double x = _series_edit_pt.Points[_pick_point_index].NumericalArgument;
-            double y = _series_edit_pt.Points[_pick_point_index].Values[0];
-            if (e.KeyCode == Keys.Up)
-            {
-                y += space_y;
-            }
-            else if (e.KeyCode == Keys.Down)
-            {
-                y -= space_y;
-            }
-            else if (e.KeyCode == Keys.Left)
-            {
-                x -= space_x;
-            }
-            else if (e.KeyCode == Keys.Right)
-            {
-                x += space_x;
-            }
-            x = Math.Round(x, 2);
-            y = Math.Round(y, 2);
-            _series_edit_pt.Points[_pick_point_index].NumericalArgument = x;
-            _series_edit_pt.Points[_pick_point_index].Values[0] = y;
-            SetPointValue(_pick_point_index, x, y);
-        }
-         
-        /// <summary>
-        /// 鏇存柊鏁版嵁
-        /// </summary>
-        private void SetPointValue(int index, double x, double y)
-        {
-            if (IsInvalidData())
-                return;
-            var vm = _vm_list.Find(x => x.IsUpdate);
-            if (vm == null)
-                return;
-            vm.DefPointList[index].X = x;
-            vm.DefPointList[index].Y = y;
-            this.DefinePointChangedEvent?.Invoke(vm.DefPointList);
-        }
-
-        #endregion
 
     }
 

--
Gitblit v1.9.3