Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. private void pictureBox1_Paint(object sender, PaintEventArgs e)
  2.         {
  3.             if (paint)
  4.             {
  5.                 if (rect != null)
  6.                 {
  7.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleFirstDigit());
  8.                 }
  9.  
  10.                 if (rect2 != null)
  11.                 {
  12.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleOtherDigits());
  13.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleOtherDigits());
  14.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleOtherDigits());
  15.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleOtherDigits());
  16.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleOtherDigits());
  17.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleOtherDigits());
  18.                     e.Graphics.DrawRectangle(Pens.Blue, GetRectangleOtherDigits());
  19.                 }
  20.             }
  21.         }
  22.  
  23. private Rectangle GetRectangleFirstDigit()
  24.         {
  25.             rect = new Rectangle();
  26.             rect.X = Math.Min(StartLocation.X, EndLcation.X);
  27.             x = rect.X;
  28.             rect.Y = Math.Min(StartLocation.Y, EndLcation.Y);
  29.             y = rect.Y;
  30.             rect.Width = Math.Abs(StartLocation.X - EndLcation.X);
  31.             w = rect.Width;
  32.             rect.Height = Math.Abs(StartLocation.Y - EndLcation.Y);
  33.             h = rect.Height;
  34.  
  35.             //MessageBox.Show("Coordinate rettangolo: \n\n X : " + x + "\n Y : " + y + "\n W : " + w + "\n H : " + h);
  36.             rectangles.Add(rect);
  37.             return rect;
  38.         }
  39.  
  40. private Rectangle GetRectangleOtherDigits()
  41.         {
  42.             rect2 = new Rectangle();
  43.             x -= w;
  44.             rect2.X = x;
  45.             rect2.Y = y;
  46.             rect2.Width = w;
  47.             rect2.Height = h;
  48.             rectangles.Add(rect2);
  49.             return rect2;
  50.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement