I use a change of groupbox locations depending on the number of weeks in the month. Is there any possibility for me to improve the functionality of this code a little bit, is it slow to load on this part? Thank you all for your help.
FormWindowState LastWindowState = FormWindowState.Minimized;
private void Form1_Resize(object sender, EventArgs e)
{
// When window state changes
if (WindowState != LastWindowState)
{
LastWindowState = WindowState;
if (numberOfWeek == 4)
{
groupBoxFifthWeek.Hide();
groupBoxSixthWeek.Hide();
if (WindowState == FormWindowState.Maximized)
{
groupBoxFirstWeek.Location = new Point(1685, 140);
groupBoxSecondWeek.Location = new Point(1685, 325);
groupBoxThirdWeek.Location = new Point(1685, 510);
groupBoxFourthWeek.Location = new Point(1685, 700);
}
if (WindowState == FormWindowState.Normal)
{
groupBoxFirstWeek.Location = new Point(978, 105);
groupBoxSecondWeek.Location = new Point(978, 220);
groupBoxThirdWeek.Location = new Point(978, 345);
groupBoxFourthWeek.Location = new Point(978, 468);
}
}
else if (numberOfWeek == 5)
{
groupBoxFifthWeek.Show();
groupBoxSixthWeek.Hide();
if (WindowState == FormWindowState.Maximized)
{
groupBoxFirstWeek.Location = new Point(1685, 120);
groupBoxSecondWeek.Location = new Point(1685, 265);
groupBoxThirdWeek.Location = new Point(1685, 415);
groupBoxFourthWeek.Location = new Point(1685, 570);
groupBoxFifthWeek.Location = new Point(1685, 720);
}
if (WindowState == FormWindowState.Normal)
{
groupBoxFirstWeek.Location = new Point(978, 89);
groupBoxSecondWeek.Location = new Point(978, 187);
groupBoxThirdWeek.Location = new Point(978, 284);
groupBoxFourthWeek.Location = new Point(978, 383);
groupBoxFifthWeek.Location = new Point(978, 484);
}
}
else
{
groupBoxSixthWeek.Show();
if (WindowState == FormWindowState.Maximized)
{
groupBoxFirstWeek.Location = new Point(1685, 105);
groupBoxSecondWeek.Location = new Point(1685, 230);
groupBoxThirdWeek.Location = new Point(1685, 357);
groupBoxFourthWeek.Location = new Point(1685, 482);
groupBoxFifthWeek.Location = new Point(1685, 610);
groupBoxSixthWeek.Location = new Point(1685, 737);
}
if (WindowState == FormWindowState.Normal)
{
groupBoxFirstWeek.Location = new Point(978, 79);
groupBoxSecondWeek.Location = new Point(978, 162);
groupBoxThirdWeek.Location = new Point(978, 244);
groupBoxFourthWeek.Location = new Point(978, 328);
groupBoxFifthWeek.Location = new Point(978, 412);
groupBoxSixthWeek.Location = new Point(978, 496);
}
}
}
}