/// <inheritdoc/> public override async void LeftDown(double x, double y) { base.LeftDown(x, y); double sx = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(x, _editor.Project.Options.SnapX) : x; double sy = _editor.Project.Options.SnapToGrid ? ProjectEditor.Snap(y, _editor.Project.Options.SnapY) : y; switch (_currentState) { case ToolState.None: { if (_editor.GetImageKey == null) { return; } var key = await _editor.GetImageKey(); if (key == null || string.IsNullOrEmpty(key)) { return; } var style = _editor.Project.CurrentStyleLibrary.Selected; _image = XImage.Create( sx, sy, _editor.Project.Options.CloneStyle ? style.Clone() : style, _editor.Project.Options.PointShape, key); var result = _editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _image.TopLeft = result; } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_image); _editor.Project.CurrentContainer.WorkingLayer.Invalidate(); ToStateOne(); Move(_image); _currentState = ToolState.One; _editor.CancelAvailable = true; } break; case ToolState.One: { if (_image != null) { _image.BottomRight.X = sx; _image.BottomRight.Y = sy; var result = _editor.TryToGetConnectionPoint(sx, sy); if (result != null) { _image.BottomRight = result; } _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_image); Remove(); base.Finalize(_image); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, _image); _currentState = ToolState.None; _editor.CancelAvailable = false; } } break; } }