Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        private void ApplyNewSelectedPoint(Point newPoint)
        {
            var args = new MovePointBehaviour.PointMoveEventArgs
            {
                OldPoint = GetSelectedPoint(),
                NewPoint = newPoint
            };

            OnPointDragged(args);
            SetSelectablePoints();
        }
Exemplo n.º 3
0
        private void ApplyNewSelectedPoint(Point newPoint)
        {
            if (SetDefault)
            {
                Curve.Reset(newPoint.Y);
                InitCurve();
                return;
            }

            var args = new MovePointBehaviour.PointMoveEventArgs
            {
                OldPoint = GetSelectedPoint(),
                NewPoint = newPoint
            };

            OnPointDragged(args);
            SetSelectablePoints();
        }
Exemplo n.º 4
0
        public void OnPointDragged(MovePointBehaviour.PointMoveEventArgs e)
        {
            if (!Move || SelectedCurveIndex > 1)
            {
                return;
            }
            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.T1curves[SelectedCurveIndex](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();
        }
Exemplo n.º 5
0
        public void OnPointDragged(MovePointBehaviour.PointMoveEventArgs e)
        {
            var oldPoint = e.OldPoint;
            var newPoint = e.NewPoint;

            newPoint.X = oldPoint.X;
            newPoint.Y = Math.Round(newPoint.Y);

            var index = Model.IndexOf(e.OldPoint);

            e.NewPoint          = newPoint;
            Model.Points[index] = e.NewPoint;

            Points = CalculateNewPoints();
            UpdateSelectedPoint();

            timer.Stop();
            timer.Start();
        }
Exemplo n.º 6
0
        private void SetSelectedPoint(Point newPoint)
        {
            if (SetDefault)
            {
                Curve.Reset(newPoint.Y);
                InitCurve();
                return;
            }

            var args = new MovePointBehaviour.PointMoveEventArgs
            {
                OldPoint = GetSelectedPoint(),
                NewPoint = newPoint
            };

            OnPointDragged(args);
            SetSelectablePoints();
            NotifyOfPropertyChange(() => SelectedPointX);
            NotifyOfPropertyChange(() => SelectedPointY);
        }
Exemplo n.º 7
0
 private void OnPointDragged(object sender, MovePointBehaviour.PointMoveEventArgs e)
 {
     (DataContext as CurveViewModel).OnPointDragged(e);
 }