public bool MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return(false); } bool handled = false; if (_creating) { if (_creatingEle.IsValid()) { _shapeList.Add(_creatingEle); ShapeCreatedEvt(_creatingEle); } _creating = false; _creatingEle = null; _vb.Invalidate(); handled = true; } if (_cmd != null) { _cmd.EndCmd(); handled = true; } _cmd = null; return(handled); }
public bool MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return(false); } bool handled = false; _mouseDownPos = new Point(e.X, e.Y); var p = new Point(e.X, e.Y); if (CurrentInteractContext == InteractContext.Create && NewElementType != null) { _creatingEle = CreateNewElement(NewElementType, p, _vb.matClientToImage); ShapeCreatingEvt(_creatingEle); _creating = true; NewElementType = null; handled = true; } else { // first check if we can pick ctrl pt of selected items var ctrlP = PickCtrlPts(Client2Img(p)); if (ctrlP != null) { _cmd = new DragCtrlPtCommand(ctrlP.Item1, ctrlP.Item2, p, this); } else { var shape = PickShape(p); if (shape != null) { if (_selection.IsSelected(shape)) { // move _cmd = new MoveCommand(shape, p, this); } else { _selection.ClearSelection(); _selection.AddToSelection(shape); } handled = true; } else { if (_selection.SelectedShapes.Count > 0) { _selection.ClearSelection(); handled = true; } } _vb.Invalidate(); } } return(handled); }
private void OnShapeChanged_Undo(Shape shape, ManipCommand cmd) { var undoEvt = new ShapeEvent(); undoEvt.shape = shape; undoEvt.EvtType = ShapeEvent.ShapeEventType.Change; undoEvt.SnapshotData = cmd.InitSnapshot; PushEvent(undoEvt); }