Beispiel #1
0
        protected override bool OnEnd(object[] args)
        {
            _operationLayer.RemoveDraw(DrawRect);
            if (!_selectRectangle)
            {
                var intersectObjects = _selectableObjects
                                       .GetElements(_currentPointMap, SelectRadiusMap);
                if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
                {
                    var selectable = _selectableController.Value
                                     .ToArray();
                    if (selectable.Any(v => intersectObjects.Contains(v)))
                    {
                        selectable = selectable
                                     .Where(v => !intersectObjects.Contains(v))
                                     .ToArray();
                    }
                    else
                    {
                        selectable = selectable
                                     .Concat(intersectObjects.Take(1))
                                     .Distinct()
                                     .ToArray();
                    }
                    _selectableController.Select(selectable);
                }
                else
                {
                    var selectedObject = _selectableController.Value.FirstOrDefault();

                    if (!intersectObjects.Any() || intersectObjects.Count == 1 && intersectObjects.First() == selectedObject)
                    {
                        _selectableController.ClearSelect();
                    }
                    else
                    {
                        var index = intersectObjects.IndexOf(selectedObject);
                        if (index == -1 || intersectObjects.Count == index + 1)
                        {
                            _selectableController.Select(intersectObjects.First());
                        }
                        else
                        {
                            _selectableController.Select(intersectObjects.ElementAt(index + 1));
                        }
                    }
                }
            }
            else
            {
                var intersectObjects = _selectableObjects.GetElements(SelectRect());
                if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
                {
                    var selectable = _selectableController.Value;
                    if (intersectObjects.All(v => selectable.Contains(v)))
                    {
                        selectable = selectable
                                     .Where(v => !intersectObjects.Contains(v))
                                     .ToArray();
                    }
                    else
                    {
                        selectable = selectable
                                     .Concat(intersectObjects)
                                     .Distinct()
                                     .ToArray();
                    }

                    _selectableController.Select(selectable);
                }
                else
                {
                    if (!intersectObjects.Any())
                    {
                        _selectableController.ClearSelect();
                    }
                    else
                    {
                        _selectableController.Select(intersectObjects);
                    }
                }
            }

            _managerCursor.SetCursor(CursorType.Arrow);
            _selectRectangle = false;
            return(true);
        }
 protected override bool OnEnd(object[] args)
 {
     _operationLayer.RemoveDraw(MoveDraw);
     return(true);
 }