Shuxia Ning
2025-01-14 0f99d4d12f2eae29bbe343f4b3131f2faeccda5d
WinFrmUI/Yw.WinFrmUI.Phart.Core/03-valve/01-view/ValveViewChart.cs
@@ -1,6 +1,5 @@
using DevExpress.Utils;
using DevExpress.XtraCharts;
using DevExpress.XtraSpreadsheet.Model;
using Yw.Geometry;
namespace Yw.WinFrmUI.Phart
@@ -80,9 +79,9 @@
        /// 选中点
        /// </summary>
        public event Action<int> SelectedPointIndexChangedEvent;
        #endregion
        #endregion
        #region Initial
        #region Private Initial
        /// <summary>
        /// 初始化图表
@@ -191,8 +190,106 @@
        }
        #endregion Initial
        #region Private Chart Event
        #region SetBindingData
        private bool _on_move_x_flow_line = false;
        private bool _on_move_x_opening_line = false;
        private bool _on_move_y_k = false;
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            var hitInfo = chartControl1.CalcHitInfo(e.Location);
            if (e.Button == MouseButtons.Left)
            {
                if (hitInfo.InConstantLine)
                {
                    if (hitInfo.ConstantLine == _const_line_x_flow)
                    {
                        _on_move_x_flow_line = true;
                    }
                    else if (hitInfo.ConstantLine == _const_line_x_opening)
                    {
                        _on_move_x_opening_line = true;
                    }
                    else if (hitInfo.ConstantLine == _const_line_y_k)
                    {
                        _on_move_y_k = true;
                    }
                }
            }
        }
        private void chartControl1_MouseMove(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            if (_on_move_x_flow_line)
            {
                var diagram_coordinates = _diagram.PointToDiagram(e.Location);
                var axis_value = diagram_coordinates.GetAxisValue(_axis_x_flow);
                if (axis_value == null)
                    return;
                double x = axis_value.NumericalValue;
                SetAxisXFlowValue(x);
            }
            else if (_on_move_x_opening_line)
            {
                var diagram_coordinates = _diagram.PointToDiagram(e.Location);
                var axis_value = diagram_coordinates.GetAxisValue(_axis_x_opening);
                if (axis_value == null)
                    return;
                double x = axis_value.NumericalValue;
                SetAxisXOpeningValue(x);
            }
            else if (_on_move_y_k)
            {
                var diagram_coordinates = _diagram.PointToDiagram(e.Location);
                var axis_value = diagram_coordinates.GetAxisValue(_axis_y_k);
                if (axis_value == null)
                    return;
                double y = axis_value.NumericalValue;
                SetAxisYKValue(y);
            }
            else
            {
                var hitInfo = chartControl1.CalcHitInfo(e.Location);
                if (hitInfo.InConstantLine)
                {
                    this.chartControl1.Cursor = Cursors.Hand;
                }
                else if (hitInfo.InAnnotation)
                {
                    this.chartControl1.Cursor = Cursors.SizeAll;
                }
                else
                {
                    this.chartControl1.Cursor = Cursors.Default;
                }
            }
        }
        private void chartControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            _on_move_x_flow_line = false;
            _on_move_x_opening_line = false;
            _on_move_y_k = false;
        }
        private void chartControl1_Resize(object sender, EventArgs e)
        {
            SetTextAnchorPoint();
        }
        #endregion
        #region Set
        /// <summary>
        /// 绑定数据
@@ -203,8 +300,7 @@
            _coordinate = null;
            _vm_list = null;
            _exist_ql = false;
            _exist_ol = false;
            _exist_ol = false;
            this.chartControl1.BeginInit();
            this.chartControl1.Series.Clear();
            for (int i = this.chartControl1.AnnotationRepository.Count - 1; i > 0; i--)
@@ -625,105 +721,7 @@
        #endregion Calc
        #region Chart Event
        private bool _on_move_x_flow_line = false;
        private bool _on_move_x_opening_line = false;
        private bool _on_move_y_k = false;
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            var hitInfo = chartControl1.CalcHitInfo(e.Location);
            if (e.Button == MouseButtons.Left)
            {
                if (hitInfo.InConstantLine)
                {
                    if (hitInfo.ConstantLine == _const_line_x_flow)
                    {
                        _on_move_x_flow_line = true;
                    }
                    else if (hitInfo.ConstantLine == _const_line_x_opening)
                    {
                        _on_move_x_opening_line = true;
                    }
                    else if (hitInfo.ConstantLine == _const_line_y_k)
                    {
                        _on_move_y_k = true;
                    }
                }
            }
        }
        private void chartControl1_MouseMove(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            if (_on_move_x_flow_line)
            {
                var diagram_coordinates = _diagram.PointToDiagram(e.Location);
                var axis_value = diagram_coordinates.GetAxisValue(_axis_x_flow);
                if (axis_value == null)
                    return;
                double x = axis_value.NumericalValue;
                SetAxisXFlowValue(x);
            }
            else if (_on_move_x_opening_line)
            {
                var diagram_coordinates = _diagram.PointToDiagram(e.Location);
                var axis_value = diagram_coordinates.GetAxisValue(_axis_x_opening);
                if (axis_value == null)
                    return;
                double x = axis_value.NumericalValue;
                SetAxisXOpeningValue(x);
            }
            else if (_on_move_y_k)
            {
                var diagram_coordinates = _diagram.PointToDiagram(e.Location);
                var axis_value = diagram_coordinates.GetAxisValue(_axis_y_k);
                if (axis_value == null)
                    return;
                double y = axis_value.NumericalValue;
                SetAxisYKValue(y);
            }
            else
            {
                var hitInfo = chartControl1.CalcHitInfo(e.Location);
                if (hitInfo.InConstantLine)
                {
                    this.chartControl1.Cursor = Cursors.Hand;
                }
                else if (hitInfo.InAnnotation)
                {
                    this.chartControl1.Cursor = Cursors.SizeAll;
                }
                else
                {
                    this.chartControl1.Cursor = Cursors.Default;
                }
            }
        }
        private void chartControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (!_initial_data)
                return;
            _on_move_x_flow_line = false;
            _on_move_x_opening_line = false;
            _on_move_y_k = false;
        }
        private void chartControl1_Resize(object sender, EventArgs e)
        {
            SetTextAnchorPoint();
        }
        #endregion
        #region Set Axis Value
        /// <summary>