ToolLine.cs 829 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Drawing;
  4. namespace DrawTools
  5. {
  6. /// <summary>
  7. /// Line tool
  8. /// </summary>
  9. class ToolLine : DrawTools.ToolObject
  10. {
  11. public ToolLine()
  12. {
  13. Cursor = new Cursor(GetType(), "Line.cur");
  14. }
  15. public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
  16. {
  17. AddNewObject(drawArea, new DrawLine(e.X, e.Y, e.X + 1, e.Y + 1));
  18. }
  19. public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
  20. {
  21. drawArea.Cursor = Cursor;
  22. if ( e.Button == MouseButtons.Left )
  23. {
  24. Point point = new Point(e.X, e.Y);
  25. drawArea.GraphicsList[0].MoveHandleTo(point, 2);
  26. drawArea.Refresh();
  27. }
  28. }
  29. }
  30. }