if (panelBottom.Height < 750)
{
//自适应做一个基础运算
//首先获取对应窗体的高度 得到对应的每一个高度
int Heighttotal = panelBottom.Height;
int EveryOneHeight = Convert.ToInt32((panelBottom.Height - 20) / 7);
double Xishu = Convert.ToDouble(EveryOneHeight) / 70;
panelBR.Height = Heighttotal;
panelBR.Width = Convert.ToInt32(125 * (Convert.ToDouble(Heighttotal) / 750));
panelBR.Padding = new Padding(0, 0, 0, 0);
pictureBoxLock.Location = new Point(panelBR.Width - 20, 5);
pictureBoxLock.Width = 15;
pictureBoxLock.Height = 15;
pictureBoxLock.Padding = new Padding(0, 0, 0, 0);
pictureBoxL1.Location = new Point(10, 15);
pictureBoxL1.Width = Convert.ToInt32(64 * Xishu);
pictureBoxL1.Height = Convert.ToInt32(47 * Xishu);
pictureBoxL1.Padding = new Padding(2, 2, 2, 2);
labelL1.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu));
labelL1.Width = Convert.ToInt32(64 * Xishu);
labelL1.Height = Convert.ToInt32(24 * Xishu);
labelL1.Padding = new Padding(0, 0, 0, 0);
pictureBoxL4.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu + 24 * Xishu));
pictureBoxL4.Width = Convert.ToInt32(64 * Xishu);
pictureBoxL4.Height = Convert.ToInt32(47 * Xishu);
pictureBoxL4.Padding = new Padding(2, 2, 2, 2);
labelL4.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 2 + 24 * Xishu));
labelL4.Width = Convert.ToInt32(64 * Xishu);
labelL4.Height = Convert.ToInt32(24 * Xishu);
labelL4.Padding = new Padding(0, 0, 0, 0);
pictureBoxL6.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 2 + 24 * Xishu * 2));
pictureBoxL6.Width = Convert.ToInt32(64 * Xishu);
pictureBoxL6.Height = Convert.ToInt32(47 * Xishu);
pictureBoxL6.Padding = new Padding(2, 2, 2, 2);
labelL6.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 3 + 24 * Xishu * 2));
labelL6.Width = Convert.ToInt32(64 * Xishu);
labelL6.Height = Convert.ToInt32(24 * Xishu);
labelL6.Padding = new Padding(0, 0, 0, 0);
pictureBoxL62.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 3 + 24 * Xishu * 3));
pictureBoxL62.Width = Convert.ToInt32(64 * Xishu);
pictureBoxL62.Height = Convert.ToInt32(47 * Xishu);
pictureBoxL62.Padding = new Padding(2, 2, 2, 2);
labelL62.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 4 + 24 * Xishu * 3));
labelL62.Width = Convert.ToInt32(64 * Xishu);
labelL62.Height = Convert.ToInt32(24 * Xishu);
labelL62.Padding = new Padding(0, 0, 0, 0);
pictureBoxL63.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 4 + 24 * Xishu * 4));
pictureBoxL63.Width = Convert.ToInt32(64 * Xishu);
pictureBoxL63.Height = Convert.ToInt32(47 * Xishu);
pictureBoxL63.Padding = new Padding(2, 2, 2, 2);
labelL63.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 5 + 24 * Xishu * 4));
labelL63.Width = Convert.ToInt32(64 * Xishu);
labelL63.Height = Convert.ToInt32(24 * Xishu);
labelL63.Padding = new Padding(0, 0, 0, 0);
pictureBoxL9.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 5 + 24 * Xishu * 5));
pictureBoxL9.Width = Convert.ToInt32(64 * Xishu);
pictureBoxL9.Height = Convert.ToInt32(47 * Xishu);
pictureBoxL9.Padding = new Padding(2, 2, 2, 2);
labelL9.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 6 + 24 * Xishu * 5));
labelL9.Width = Convert.ToInt32(64 * Xishu);
labelL9.Height = Convert.ToInt32(24 * Xishu);
labelL9.Padding = new Padding(0, 0, 0, 0);
pictureBoxL16.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 6 + 24 * Xishu * 6));
pictureBoxL16.Width = Convert.ToInt32(64 * Xishu);
pictureBoxL16.Height = Convert.ToInt32(47 * Xishu);
pictureBoxL16.Padding = new Padding(2, 2, 2, 2);
labelL16.Location = new Point(10, 15 + Convert.ToInt32(47 * Xishu * 7 + 24 * Xishu * 6));
labelL16.Width = Convert.ToInt32(64 * Xishu);
labelL16.Height = Convert.ToInt32(24 * Xishu);
labelL16.Padding = new Padding(0, 0, 0, 0);
}
else {
panelBR.Height = panelBottom.Height;
}
根据首先要一个对比对象:
1、对比对象panelBottom
2、需要一个基础不变值的固定。
然后获取转变系数这样就能做到自适应了。