public void OnPointDragged(MovePointBehaviour.PointMoveEventArgs e) { var oldPoint = e.OldPoint; var newPoint = e.NewPoint; var index = Curve.IndexOf(e.OldPoint); var newCurve = Curve.Points.GetRange(0, Curve.Points.Count); newCurve[index] = newPoint; var firstPoint = newCurve[0]; var lastPoint = newCurve[newCurve.Count - 1]; var biggestValueForY = double.MinValue; if(ValidateCurve) for (double x = firstPoint.X + 0.01; x < lastPoint.X - 0.01; x++) { var y = CurveMath.SolveCubicSpline(newCurve, x); if (y < biggestValueForY || newPoint.X >= lastPoint.X || newPoint.X <= firstPoint.X) { newPoint = oldPoint; break; } if (y > biggestValueForY) biggestValueForY = y; } e.NewPoint = newPoint; Curve.Points[index] = e.NewPoint; Points = CalculateNewPoints(); UpdateSelectedPoint(); }
public void OnPointSelected(MovePointBehaviour.PointSelectedEventArgs e) { var index = Curve.IndexOf(e.Point); selectedPointIndex = index; UpdateSelectedPoint(); CanSetDefault = selectedPointIndex == Curve.Points.Count - 1; NotifyOfPropertyChange(() => HasSelectedPoint); }
public void OnPointDragged(MovePointBehaviour.PointMoveEventArgs e) { var oldPoint = e.OldPoint; var newPoint = e.NewPoint; var index = Curve.IndexOf(e.OldPoint); var prevPoint = Curve.Points[index - 1]; var biggestValueForY = double.MinValue; var newCurve = Curve.Points.GetRange(0, Curve.Points.Count); newCurve[index] = newPoint; var lastPoint = newCurve[newCurve.Count - 1]; for (double x = 0; x < lastPoint.X; x++) { var y = CurveMath.SolveCubicSpline(newCurve, x); if (biggestValueForY > y) { newPoint = oldPoint; break; } if (y > biggestValueForY) biggestValueForY = y; } e.NewPoint = newPoint; Curve.Points[index] = e.NewPoint; Points = CalculateNewPoints(); }
public void OnPointSelected(MovePointBehaviour.PointSelectedEventArgs e) { var index = Curve.IndexOf(e.Point); if(index != selectedPointIndex) SetDefault = false; selectedPointIndex = index; CanSetDefault = selectedPointIndex == Curve.Points.Count - 1; NotifyOfPropertyChange(() => HasSelectedPoint); NotifyOfPropertyChange(() => SelectedPointX); NotifyOfPropertyChange(() => SelectedPointY); }
private void OnPointSelected(object sender, MovePointBehaviour.PointSelectedEventArgs e) { (DataContext as CurveViewModel).OnPointSelected(e); }