| | |
| | | using DevExpress.Utils; |
| | | using DevExpress.XtraCharts; |
| | | using DevExpress.XtraSpreadsheet.Model; |
| | | using Yw.Geometry; |
| | | |
| | | namespace Yw.WinFrmUI.Phart |
| | |
| | | /// 选中点 |
| | | /// </summary> |
| | | public event Action<int> SelectedPointIndexChangedEvent; |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region Initial |
| | | #region Private Initial |
| | | |
| | | /// <summary> |
| | | /// 初始化图表 |
| | |
| | | } |
| | | |
| | | #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> |
| | | /// 绑定数据 |
| | |
| | | _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--) |
| | |
| | | |
| | | |
| | | #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> |