using System;
using System.Collections.Generic; using System.Text;
using System.Windows.Forms; namespace WindowsApplication1 {
class AutoSizeFormClass {
public struct controlRect {
public int Left; public int Top; public int Width; public int Height; }
public List oldCtrl;
public void controllInitializeSize(Form mForm) {
// if (ctrl_first == 0) {
// ctrl_first = 1; oldCtrl = new List(); controlRect cR;
cR.Left = mForm.Left; cR.Top = mForm.Top; cR.Width = mForm.Width; cR.Height = mForm.Height;
oldCtrl.Add(cR);
foreach (Control c in mForm.Controls) {
controlRect objCtrl;
objCtrl.Left = c.Left; objCtrl.Top = c.Top; objCtrl.Width = c.Width; objCtrl.Height = c.Height;
oldCtrl.Add(objCtrl); } }
// this.WindowState = (System.Windows.Forms.FormWindowState)(2);//
//0 - Normalize , 1 - Minimize,2- Maximize
}
public void controlAutoSize(Form mForm) {
//int wLeft0 = oldCtrl[0].Left; //int wTop0 = oldCtrl[0].Top; ////int wLeft1 = this.Left;
//int wTop1 = this.Top;
float wScale = (float)mForm.Width / (float)oldCtrl[0].Width;
float hScale = (float)mForm.Height / (float)oldCtrl[0].Height;//.Height; int ctrLeft0, ctrTop0, ctrWidth0, ctrHeight0; int ctrlNo = 1;
foreach (Control c in mForm.Controls) {
ctrLeft0 = oldCtrl[ctrlNo].Left; ctrTop0 = oldCtrl[ctrlNo].Top;
ctrWidth0 = oldCtrl[ctrlNo].Width; ctrHeight0 = oldCtrl[ctrlNo].Height;
//c.Left = (int)((ctrLeft0 - wLeft0) * wScale) + wLeft1; //c.Top = (int)((ctrTop0 - wTop0) * h) + wTop1; c.Left = (int)((ctrLeft0) * wScale); c.Top = (int)((ctrTop0) * hScale);// c.Width = (int)(ctrWidth0 * wScale); c.Height = (int)(ctrHeight0 * hScale);// ctrlNo += 1; } } } }
求帮助,谁能详细的介绍下每行代码的意思?
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- shangjiatang.cn 版权所有 湘ICP备2022005869号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务