public IMemento Clone() { var clone = new DrawLineMemento(Color, LineSize); foreach (var loc in Locations) { clone.Locations.Add(loc); } return(clone); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) { return; } _startLoc = e.Location; _holdMode = HoldMode.None; switch (Mode) { case DrawMode.Pen: _drawLine = new DrawLineMemento(Color, LineSize); break; case DrawMode.Highlighter: _drawLine = new DrawLineMemento(HighlightColor, LineSize); break; } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (e.Button != MouseButtons.Left) { return; } _holdMode = HoldMode.None; switch (Mode) { case DrawMode.Pen: case DrawMode.Highlighter: if (_drawLine != null && _drawLine.CanDraw()) { AddMemento(_drawLine); _drawLine = null; } break; } Invalidate(); }