private void selectionRequested(PathControlPointPiece piece, MouseButtonEvent e)
 {
     if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
     {
         piece.IsSelected.Toggle();
     }
     else
     {
         SetSelectionTo(piece.ControlPoint);
     }
 }
Example #2
0
 private void selectPiece(PathControlPointPiece piece, MouseButtonEvent e)
 {
     if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
     {
         piece.IsSelected.Toggle();
     }
     else
     {
         foreach (var p in Pieces)
         {
             p.IsSelected.Value = p == piece;
         }
     }
 }
        private void addControlPoints(IEnumerable <PathControlPoint> controlPoints)
        {
            foreach (var point in controlPoints)
            {
                var piece = new PathControlPointPiece(slider, point);

                if (allowSelection)
                {
                    piece.RequestSelection = selectPiece;
                }

                Pieces.Add(piece);
            }
        }
Example #4
0
        protected override void Update()
        {
            base.Update();

            while (slider.Path.ControlPoints.Count > Pieces.Count)
            {
                var piece = new PathControlPointPiece(slider, Pieces.Count);

                if (allowSelection)
                {
                    piece.RequestSelection = selectPiece;
                }

                Pieces.Add(piece);
            }

            while (slider.Path.ControlPoints.Count < Pieces.Count)
            {
                Pieces.Remove(Pieces[Pieces.Count - 1]);
            }
        }
        /// <summary>
        /// Attempts to set the given control point piece to the given path type.
        /// If that would fail, try to change the path such that it instead succeeds
        /// in a UX-friendly way.
        /// </summary>
        /// <param name="piece">The control point piece that we want to change the path type of.</param>
        /// <param name="type">The path type we want to assign to the given control point piece.</param>
        private void updatePathType(PathControlPointPiece piece, PathType?type)
        {
            int indexInSegment = piece.PointsInSegment.IndexOf(piece.ControlPoint);

            switch (type)
            {
            case PathType.PerfectCurve:
                // Can't always create a circular arc out of 4 or more points,
                // so we split the segment into one 3-point circular arc segment
                // and one segment of the previous type.
                int thirdPointIndex = indexInSegment + 2;

                if (piece.PointsInSegment.Count > thirdPointIndex + 1)
                {
                    piece.PointsInSegment[thirdPointIndex].Type = piece.PointsInSegment[0].Type;
                }

                break;
            }

            piece.ControlPoint.Type = type;
        }
        protected override void Update()
        {
            base.Update();

            while (slider.Path.ControlPoints.Length > Pieces.Count)
            {
                var piece = new PathControlPointPiece(slider, Pieces.Count)
                {
                    ControlPointsChanged = c => ControlPointsChanged?.Invoke(c),
                };

                if (allowSelection)
                {
                    piece.RequestSelection = selectPiece;
                }

                Pieces.Add(piece);
            }

            while (slider.Path.ControlPoints.Length < Pieces.Count)
            {
                Pieces.Remove(Pieces[Pieces.Count - 1]);
            }
        }