⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layout.cs

📁 是一个模拟ATM的程序
💻 CS
字号:
// Layout.cs created with MonoDevelop// User: Estelle at 8:57 PM 5/9/2008//// To change standard headers go to Edit->Preferences->Coding->Standard Headers//using System;using System.Collections;using System.Windows.Forms;using System.Drawing;namespace ATM{		/**	 * In order to generate the user interface dynamically.	 * I didn't use the visual editor. Instead, I wrote a layout class to constraint the controls	 * just like Java does.	 */	public class TableLayout{		private Form host;		private int colWidth;		private int rowHeight;				private ArrayList cellConstraints;				public struct Space{					public int left;			public int right;			public int top;			public int buttom;									public Space(int tp,int bm,int lt,int rt){				top=tp;				buttom=bm;				left=lt;				right=rt;			}		}				public class CellConstraint:ICloneable{			private Point position;			public Point location{				set{					this.position=value;				}				get{					return position;				}			}						private Space _space;			public Space space{				set{					this._space=value;				}				get{					return _space;				}			}						private Size fill;			public Size size{				set{					this.fill=value;				}				get{					return this.fill;				}			}						public CellConstraint():this(0,0){}			public CellConstraint(int cp,int rp){				this.location=new Point(cp,rp);				this.size=new Size(1,1);			}						public Object Clone(){				CellConstraint cc=new CellConstraint(this.location.X,this.location.Y);				cc.space=this.space;				cc.size=this.size;				return cc;			}		}				public TableLayout(Form host,int col,int row){			this.host=host;			this.colWidth=(host.ClientSize.Width)/col;			this.rowHeight=(host.ClientSize.Height)/row;			this.cellConstraints=new ArrayList();		}				public void layout(){			int i=0;			foreach(CellConstraint cc in this.cellConstraints){				try{					Control ctl=host.Controls[i++];					Space sp=cc.space;					Size sz=cc.size;					Point pos=cc.location;					int x=pos.X*this.colWidth+sp.left;					int y=pos.Y*this.rowHeight+sp.top;					int width=this.colWidth*sz.Width-sp.left-sp.right;					int height=this.rowHeight*sz.Height-sp.top-sp.buttom;					ctl.Location=new Point(x,y);					ctl.Size=new Size(width,height);				}catch(ArgumentOutOfRangeException aoore){					Console.Error.WriteLine(aoore.Message);					break;				}			}		}				public void addCellConstraint(CellConstraint cc){			this.cellConstraints.Add(cc);		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -