/// <inheritdoc/> public override void LeftDown(double x, double y) { base.LeftDown(x, y); switch (_currentState) { case ToolState.None: { _editor.Dehover(_editor.Project.CurrentContainer.CurrentLayer); if (_editor.Renderers[0].State.SelectedShape == null && _editor.Renderers[0].State.SelectedShapes != null) { var result = ShapeHitTestPoint.HitTest(_editor.Project.CurrentContainer.CurrentLayer.Shapes, new Vector2(x, y), _editor.Project.Options.HitThreshold); if (result != null) { _startX = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; _startY = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; _historyX = _startX; _historyY = _startY; GenerateMoveSelectionCache(); _currentState = ToolState.One; _editor.CancelAvailable = true; break; } } if (_editor.TryToSelectShape(_editor.Project.CurrentContainer.CurrentLayer, x, y)) { _startX = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; _startY = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; _historyX = _startX; _historyY = _startY; GenerateMoveSelectionCache(); _currentState = ToolState.One; _editor.CancelAvailable = true; break; } _rectangle = XRectangle.Create( x, y, _editor.Project.Options.SelectionStyle, null, true, true); _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_rectangle); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); _currentState = ToolState.One; _editor.CancelAvailable = true; } break; case ToolState.One: { if (_rectangle != null) { _rectangle.BottomRight.X = x; _rectangle.BottomRight.Y = y; _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_rectangle); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); _currentState = ToolState.None; _editor.CancelAvailable = false; } } break; } }