| | |
| | | |
| | | #endregion |
| | | |
| | | #region Initial |
| | | #region Private Initial |
| | | |
| | | /// <summary> |
| | | /// 初始化图表 |
| | |
| | | _coordinate.CoordMinE = 0; _coordinate.CoordSpaceE = 100; |
| | | _coordinate.CoordMinP = 10; _coordinate.CoordSpaceP = 100; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #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.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; |
| | | AxisYBase axis_y = null; |
| | | if (_edit_curve_type == Yw.Ahart.eCurveType.QH) |
| | | axis_y = _axis_y_head; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QE) |
| | | axis_y = _axis_y_eff; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QP) |
| | | axis_y = _axis_y_power; |
| | | |
| | | var diagram_coordinates = _diagram.PointToDiagram(e.Location); |
| | | 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 (!_initial_data) |
| | | return; |
| | | if (_mouse_mode) |
| | | return; |
| | | if (_pick_point_index < 0) |
| | | return; |
| | | if (IsInvalidData()) |
| | | return; |
| | | double space_x = _coordinate.CoordSpaceQ / 50; |
| | | double space_y = 0; |
| | | if (_edit_curve_type == Yw.Ahart.eCurveType.QH) |
| | | space_y = _coordinate.CoordSpaceH / 50; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QE) |
| | | space_y = _coordinate.CoordSpaceE / 50; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QP) |
| | | space_y = _coordinate.CoordSpaceP / 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; |
| | | List<Yw.Geometry.Point2d> def_pt_list = null; |
| | | if (_edit_curve_type == Yw.Ahart.eCurveType.QH) |
| | | def_pt_list = _def_qh_pt_list; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QE) |
| | | def_pt_list = _def_qe_pt_list; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QP) |
| | | def_pt_list = _def_qp_pt_list; |
| | | |
| | | def_pt_list[index].X = x; |
| | | def_pt_list[index].Y = y; |
| | | this.DefinePointChangedEvent?.Invoke(_edit_curve_type, def_pt_list); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | |
| | | |
| | | #endregion |
| | | |
| | | #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.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; |
| | | AxisYBase axis_y = null; |
| | | if (_edit_curve_type == Yw.Ahart.eCurveType.QH) |
| | | axis_y = _axis_y_head; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QE) |
| | | axis_y = _axis_y_eff; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QP) |
| | | axis_y = _axis_y_power; |
| | | |
| | | var diagram_coordinates = _diagram.PointToDiagram(e.Location); |
| | | 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 (!_initial_data) |
| | | return; |
| | | if (_mouse_mode) |
| | | return; |
| | | if (_pick_point_index < 0) |
| | | return; |
| | | if (IsInvalidData()) |
| | | return; |
| | | double space_x = _coordinate.CoordSpaceQ / 50; |
| | | double space_y = 0; |
| | | if (_edit_curve_type == Yw.Ahart.eCurveType.QH) |
| | | space_y = _coordinate.CoordSpaceH / 50; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QE) |
| | | space_y = _coordinate.CoordSpaceE / 50; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QP) |
| | | space_y = _coordinate.CoordSpaceP / 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; |
| | | List<Yw.Geometry.Point2d> def_pt_list = null; |
| | | if (_edit_curve_type == Yw.Ahart.eCurveType.QH) |
| | | def_pt_list = _def_qh_pt_list; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QE) |
| | | def_pt_list = _def_qe_pt_list; |
| | | else if (_edit_curve_type == Yw.Ahart.eCurveType.QP) |
| | | def_pt_list = _def_qp_pt_list; |
| | | |
| | | def_pt_list[index].X = x; |
| | | def_pt_list[index].Y = y; |
| | | this.DefinePointChangedEvent?.Invoke(_edit_curve_type, def_pt_list); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |