Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. public Form1()
  2. {
  3.  
  4. InitializeComponent();
  5. g = panel1.CreateGraphics();
  6. }
  7. public enum FigType
  8. {
  9. circle, rect, triangle //nbg lfyysq[
  10. }
  11.  
  12. FigType typeF; // == circle
  13. Graphics g;
  14. int xOLD; int yOLD;
  15.  
  16. private void panel1_MouseDown(object sender, MouseEventArgs e)
  17. {
  18. xOLD = e.X;
  19. yOLD = e.Y;
  20. }
  21.  
  22. private void rect_Click(object sender, EventArgs e)
  23. {
  24. typeF = FigType.rect;
  25. }
  26.  
  27. private void circle_Click(object sender, EventArgs e)
  28. {
  29. typeF = FigType.circle;
  30. }
  31.  
  32. private void traingle_Click(object sender, EventArgs e)
  33. {
  34. typeF = FigType.triangle;
  35. }
  36.  
  37. private void panel1_MouseUp(object sender, MouseEventArgs e)
  38. {
  39. int width; int height;
  40. if (xOLD > e.X && yOLD > e.Y)
  41. {
  42.  
  43. width = xOLD - e.X;
  44. height = yOLD - e.Y;
  45. }
  46. else
  47. {
  48. width = e.X - xOLD;
  49. height = e.Y - yOLD;
  50. }
  51.  
  52. if (typeF == FigType.rect)
  53. {
  54. Rectangle rect = new Rectangle(xOLD, yOLD, width, height, colorDialog1.Color, colorDialog2.Color);
  55. rect.Draw(g);
  56. }
  57.  
  58. if (typeF == FigType.circle)
  59. {
  60. Cirkle cirk = new Cirkle(xOLD, yOLD, width, height, colorDialog1.Color, colorDialog2.Color);
  61. cirk.Draw(g);
  62. }
  63.  
  64. if (typeF == FigType.triangle)
  65. {
  66. Traingle cirk = new Traingle(xOLD, yOLD, width, height, colorDialog1.Color, colorDialog2.Color);
  67. cirk.Draw(g);
  68. }
  69.  
  70.  
  71. }
  72.  
  73. private void button3_Click(object sender, EventArgs e)
  74. {
  75. if (colorDialog1.ShowDialog() == DialogResult.OK)
  76. Color.BackColor = colorDialog1.Color;
  77. }
  78.  
  79. private void zalivka_Click(object sender, EventArgs e) // не так фурычит
  80. {
  81. if (colorDialog2.ShowDialog() == DialogResult.OK)
  82. Color.BackColor = colorDialog2.Color;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement