private bool CanMove(SKPoint controlPosition)
        {
            var mapPoint = CalculatePointHelper.ToMapPoint(MapSettings, controlPosition);
            var radius   = CalculatePointHelper.ToMapDistance(_mapSettingsController.Value, SelectRadius);
            var elements = _selectableObjects.GetElements(mapPoint, radius);

            return(!elements.Any());
        }
        private bool CanMove(SKPoint controlPosition)
        {
            if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
            {
                var selectedElements = _selectableController.Value;
                var moveElements     = _selectableObjects.GetElements(
                    selectedElements,
                    ToMapPoint(controlPosition),
                    _calculateHelper.ToMapDistance(_operationOptions.Value.MoveToleranceRadius)
                    );
                if (moveElements.Any())
                {
                    //_managerCursor.SetCursor(CursorType.ArrowMove);
                    return(true);
                }
            }

            _managerCursor.SetCursor(CursorType.Arrow);
            return(false);
        }
Пример #3
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);
        }