public void AddDrawable(Drawable item) { drawabels.Push(item); }
protected override void OnMouseDown(MouseEventArgs e) { if (e.Button != MouseButtons.Left) return; mouseDown = true; Point mousePosition = new Point(e.Location.X + HorizontalScroll.Value, e.Location.Y + VerticalScroll.Value); start = mousePosition; switch (Tool) { case DrawTool.Brush: lastDrawable = new BrushStroke(Settings.Instance.ForeColor, Settings.Instance.BrushWidth); break; case DrawTool.Highlighter: lastDrawable = new Highlighter(Settings.Instance.ForeColor, Settings.Instance.BrushWidth); break; case DrawTool.Line: lastDrawable = new Line(Settings.Instance.ForeColor, Settings.Instance.BrushWidth, mousePosition); break; case DrawTool.Arrow: lastDrawable = new Arrow(Settings.Instance.ForeColor, Settings.Instance.BrushWidth, mousePosition); break; case DrawTool.Square: lastDrawable = new Square(Settings.Instance.ForeColor, Settings.Instance.BrushWidth, mousePosition); break; case DrawTool.FilledSquare: lastDrawable = new FilledSquare(Settings.Instance.ForeColor, Settings.Instance.BackColor, Settings.Instance.BrushWidth, mousePosition); break; case DrawTool.Ellipse: lastDrawable = new Ellipse(Settings.Instance.ForeColor, Settings.Instance.BrushWidth, mousePosition); break; case DrawTool.FilledEllipse: lastDrawable = new FilledEllipse(Settings.Instance.ForeColor, Settings.Instance.BackColor, Settings.Instance.BrushWidth, mousePosition); break; case DrawTool.Text: using (TextPreview tp = new TextPreview(Settings.Instance.TextFont, Thread.CurrentThread.CurrentUICulture)) { if (tp.ShowDialog() == DialogResult.OK) { if (!String.IsNullOrEmpty(tp.Content)) { lastDrawable = new Text(tp.Content, Settings.Instance.TextFont, Settings.Instance.ForeColor, mousePosition); } } } break; } drawabels.Push(lastDrawable); if(lastDrawable is Text) Invalidate(); base.OnMouseDown(e); }