Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. private void Form1_Resize(object sender, EventArgs e)
  2. {
  3. int new_form_height = 0;
  4. int new_form_width = 0;
  5.  
  6. if(this.WindowState == FormWindowState.Maximized)
  7. {
  8. new_form_height = this.Height - old_form_height;
  9. new_form_width = this.Width - old_form_width;
  10.  
  11. pictureBox1.Width += new_form_width;
  12. pictureBox1.Height += new_form_height;
  13.  
  14. int x = panel1.Location.X;
  15. int y = panel1.Location.Y;
  16. panel1.SetBounds(x + new_form_width / 2, y + new_form_height, panel1.Width, panel1.Height);
  17. old_form_width = new_form_width;
  18. old_form_height = new_form_height;
  19. }
  20. else
  21. {
  22. pictureBox1.Width -= old_form_width;
  23. pictureBox1.Height -= old_form_height;
  24.  
  25. int x = panel1.Location.X;
  26. int y = panel1.Location.Y;
  27. panel1.SetBounds(x - old_form_width / 2, y - old_form_height, panel1.Width, panel1.Height);
  28. old_form_width = this.Width;
  29. old_form_height = this.Height;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement