Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 private void OnPointSelected(object sender, MovePointBehaviour.PointSelectedEventArgs e)
 {
     (DataContext as CurveViewModel).OnPointSelected(e);
 }