Exemple #1
0
        private void Select(WindowsRect selectionRect, bool isSingleSelection)
        {
            var editableCurve = SelectedCurve as IEditableCurveViewModel;

            if (editableCurve == null)
            {
                return;
            }

            // TODO: move this to the curve (especially hit testing)
            IList <ControlPointViewModelBase> selectedPoints = editableCurve.ControlPoints.Where(c => selectionRect.Contains(c.ActualPoint)).ToList();

            if (selectedPoints.Count > 1 && isSingleSelection)
            {
                var rectCenter = new WindowsPoint(selectionRect.Left + selectionRect.Width * 0.5, selectionRect.Top + selectionRect.Height * 0.5);
                var closest    = CurveHelper.GetClosestPoint(selectedPoints, rectCenter);
                selectedPoints = new[] { closest };
            }
            switch (Keyboard.Modifiers)
            {
            case ModifierKeys.None:
                ClearPointSelection();
                goto case ModifierKeys.Shift;

            case ModifierKeys.Shift:
                // FIXME: do this atomically in the curve
                foreach (var p in selectedPoints.Where(p => !p.IsSelected))
                {
                    SelectedControlPoints.Add(p);
                    p.IsSelected = true;
                }
                break;

            case ModifierKeys.Control:
                // FIXME: do this atomically in the curve
                foreach (var p in selectedPoints.Where(p => p.IsSelected))
                {
                    SelectedControlPoints.Remove(p);
                    p.IsSelected = false;
                }
                break;
            }
        }
 public ControlPointViewModelBase GetClosestPoint(WindowsPoint position, double maximumDistance)
 {
     return(CurveHelper.GetClosestPoint(ControlPoints, position, maximumDistance));
 }