对应关于Winfrom制作自适应的panel内部所有控件

  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、需要一个基础不变值的固定。

然后获取转变系数这样就能做到自适应了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

明仔丶

谢谢大家

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值