my main window fit all resolution expect 1280X600.my some control location(Y-axis) is above 600. help me.
What I have tried:
if(Screen.PrimaryScreen.Bounds.Width==1280 && Screen.PrimaryScreen.Bounds.Height==600)
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newWidth = (int)(600 * xRatio);
int newHeight = (int)(400 * yRatio);
int newInspectionWidth = (int)(201 * xRatio);
int newInspectionHeight = (int)(136 * yRatio);
int newshiftWidth = (int)(368 * xRatio);
int newshiftHeight = (int)(134 * yRatio);
int newgb1Width = (int)(24 * xRatio);
int newgb1Height = (int)(134 * yRatio);
pictureBox1.Size = new Size(newWidth, newHeight);
gb_InspectionStatistics.Size = new Size(newInspectionWidth, newInspectionHeight);
groupBoxShift.Size = new Size(newshiftWidth, newshiftHeight);
groupBox1.Size = new Size(newgb1Width, newgb1Height);
}
private void btnsettings()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(22 * xRatio);
int newY = (int)(21 * yRatio);
btnSettings.Size = new Size(147, 47);
btnSettings.Location = new Point(newX + 192, newY);
}
private void TeachModuleResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(22 * xRatio);
int newY = (int)(21 * yRatio);
TeachModule.Size = new Size(147, 47);
TeachModule.Location = new Point(newX + 383, newY);
}
private void btnModelResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(22 * xRatio);
int newY = (int)(21 * yRatio);
btnModel.Size = new Size(147, 47);
btnModel.Location = new Point(newX + 569, newY);
}
private void btnStartResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(22 * xRatio);
int newY = (int)(95 * yRatio);
btnStart.Size = new Size(147, 47);
btnStart.Location = new Point(newX, newY);
}
private void btnnewUserResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(22 * xRatio);
int newY = (int)(95 * yRatio);
btnnewuser.Size = new Size(147, 47);
btnnewuser.Location = new Point(newX + 192, newY);
}
private void btnReportResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(22 * xRatio);
int newY = (int)(95 * yRatio);
btnReport.Size = new Size(147, 47);
btnReport.Location = new Point(newX + 383, newY);
}
private void btnExitResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(22 * xRatio);
int newY = (int)(95 * yRatio);
btnExit.Size = new Size(147, 47);
btnExit.Location = new Point(newX + 569, newY);
}
private void picturebox2Resize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(772 * xRatio);
int newY = (int)(53 * yRatio);
pictureBox2.Size = new Size(240, 122);
pictureBox2.Location = new Point(newX, newY);
}
private void picturebox3Resize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(639 * xRatio);
int newY = (int)(675 * yRatio);
pictureBox3.Size = new Size(132, 77);
pictureBox3.Location = new Point(newX, newY);
}
private void picturebox4Resize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(639 * xRatio);
int newY = (int)(675 * yRatio);
pictureBox4.Size = new Size(132, 77);
pictureBox4.Location = new Point(newX, newY);
}
private void pieControlResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(784 * xRatio);
int newY = (int)(639 * yRatio);
pieChartControl2.Size = new Size(220, 115);
pieChartControl2.Location = new Point(newX, newY);
}
private void picturebox1Resize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(64 * xRatio);
int newY = (int)(182 * yRatio);
pictureBox1.Size = new Size(600, 400);
pictureBox1.Location = new Point(newX, newY);
}
private void UserAuthResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(771 * xRatio);
int newY = (int)(574 * yRatio);
UserAuth.Size = new Size(235, 52);
UserAuth.Location = new Point(newX, newY);
}
private void lable1Resize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(771 * xRatio);
int newY = (int)(218 * yRatio);
label1.Size = new Size(118, 23);
label1.Location = new Point(newX, newY);
}
private void lblmodelnameResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(886 * xRatio);
int newY = (int)(222 * yRatio);
lblModelNameFetched.Size = new Size(50, 19);
lblModelNameFetched.Location = new Point(newX, newY);
}
private void lbltimeResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(770 * xRatio);
int newY = (int)(3 * yRatio);
lblTime.Size = new Size(240, 47);
lblTime.Location = new Point(newX, newY);
}
private void groupbox1Resize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(593 * xRatio);
int newY = (int)(621 * yRatio);
groupBox1.Size = new Size(24, 134);
groupBox1.Location = new Point(newX, newY);
}
private void groupShiftResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(223 * xRatio);
int newY = (int)(618 * yRatio);
groupBoxShift.Size = new Size(368, 134);
groupBoxShift.Location = new Point(newX, newY);
}
private void groupInspectionResize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(16 * xRatio);
int newY = (int)(618 * yRatio);
gb_InspectionStatistics.Size = new Size(201, 136);
gb_InspectionStatistics.Location = new Point(newX, newY);
}
private void groupbox2Resize()
{
float xRatio = (float)(Screen.PrimaryScreen.Bounds.Width) / 1024f;
float yRatio = (float)(Screen.PrimaryScreen.Bounds.Height) / 768f;
int newX = (int)(772 * xRatio);
int newY = (int)(254 * yRatio);
groupBox2.Size = new Size(234, 300);
groupBox2.Location = new Point(newX, newY);
}