示例#1
0
        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();
        }
示例#2
0
        public void OnPointSelected(MovePointBehaviour.PointSelectedEventArgs e)
        {
            var index = Curve.IndexOf(e.Point);

            selectedPointIndex = index;

            UpdateSelectedPoint();

            CanSetDefault = selectedPointIndex == Curve.Points.Count - 1;
            NotifyOfPropertyChange(() => HasSelectedPoint);
        }
示例#3
0
        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();
        }
示例#4
0
        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);
        }
示例#5
0
 private void OnPointSelected(object sender, MovePointBehaviour.PointSelectedEventArgs e)
 {
     (DataContext as CurveViewModel).OnPointSelected(e);
 }