Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Drawing;
  4. using op4;
  5.  
  6. namespace _figure
  7. {
  8. public class Figure
  9. {
  10. protected int x0, y0;
  11. protected Graphics g;
  12. //true - нечетное, false - четное нажатие
  13. protected bool click;
  14. public Figure()
  15. {
  16. x0 = 0; y0 = 0;
  17. click = true;
  18. }
  19. public virtual void Draw(Panel my_panel)
  20. {
  21.  
  22. }
  23. public virtual Graphics MyGraphic()
  24. {
  25. return g;
  26. }
  27. public virtual bool finder(int x, int y)
  28. {
  29. return false;
  30. }
  31. public virtual bool unreal()
  32. {
  33. return false;
  34. }
  35. public virtual void recolor()
  36. {
  37.  
  38. }
  39. public virtual void clicker()
  40. {
  41. click = !click;
  42. }
  43. }
  44.  
  45. public class Circle : Figure
  46. {
  47. private int x, y, ray;
  48. public Circle()
  49. {
  50. x = 0;
  51. y = 0;
  52. ray = 0;
  53. }
  54. public Circle(int x, int y, int ray)
  55. {
  56. this.x = x - ray;
  57. this.y = y - ray;
  58. this.ray = ray;
  59. x0 = x;
  60. y0 = y;
  61. }
  62.  
  63. public override string ToString()
  64. {
  65. string info = "";
  66. info = Convert.ToString(x) + " " + Convert.ToString(y) + " " + Convert.ToString(ray);
  67. return info;
  68. }
  69. public override void Draw(Panel my_panel)
  70. {
  71. g = my_panel.CreateGraphics();
  72. if (click) {
  73. g.DrawEllipse(Pens.Black, x, y, ray*2, ray*2);
  74. }
  75. else {
  76. g.DrawEllipse(Pens.Red, x, y, ray * 2, ray * 2);
  77. }
  78.  
  79. }
  80. public override Graphics MyGraphic()
  81. {
  82. return g;
  83. }
  84. public override bool finder(int x, int y)
  85. {
  86. if ((x - x0) * (x - x0) + (y - y0) * (y - y0) <= ray * ray)
  87. return true;
  88. return false;
  89. }
  90. public override void recolor()
  91. {
  92.  
  93. }
  94. }
  95.  
  96. public class NulFigure: Figure
  97. {
  98. public override bool unreal()
  99. {
  100. return true;
  101. }
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement