private void mnuMainWindowAdaptImage_Click(object sender, EventArgs e)
{
if (picMain.Image == null)
{
return;
}
Rectangle screen = Screen.FromControl(this).WorkingArea;
WindowState = FormWindowState.Normal;
//if image size is bigger than screen
if (picMain.Image.Width >= screen.Width || picMain.Height >= screen.Height)
{
Left = Top = 0;
Width = screen.Width;
Height = screen.Height;
}
else
{
Size = new Size(Width += picMain.Image.Width - picMain.Width,
Height += picMain.Image.Height - picMain.Height);
picMain.Bounds = new Rectangle(Point.Empty, picMain.Image.Size);
Top = (screen.Height - Height) / 2 + screen.Top;
Left = (screen.Width - Width) / 2 + screen.Left;
}
}