/// <summary> /// Update layout by UI /// </summary> /// <param name="layout"></param> private void UpdateLayout(FieldLayOut layout) { for (int row = 0; row < layout.ColumnsEachRow.Count; row++) { int nCols = layout.ColumnsEachRow[row]; for (int col = 0; col < nCols; col++) { Button btn = CustomSplit.GetButton(row, col); System.Diagnostics.Debug.Assert(btn != null); Field field = layout.FieldTable.GetField(row, col); if (field != null) { // System.Diagnostics.Debug.Assert(field != null); ButtonTags pctag = (ButtonTags)btn.Tag; field.Filter.Apply(pctag.filter); field.SetWidthRatio((float)btn.Width / this.LayoutPanelWidth); field.SetHeightRatio((float)btn.Height / this.LayoutPanelHeight); } } } }
public ConfigFieldPanelLayout() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); this.C_Buttons = new ArrayList(); this._ColsInRows = new Int32Collection(); this._LayOut = new FieldLayOut(); this._SectionFilters = new SectionFilterCollection(); this.SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.Opaque, true); // TODO: Add any initialization after the InitializeComponent call }
private float GetMaxRadio(FieldLayOut layout, int i) { float maxradio = 0f; if (i < 0 || i >= layout.ColumnsEachRow.Count) { return(0); } foreach (Field fld in layout.FieldTable[i]) { SizeF szf = fld.Ratio; if (maxradio < szf.Height) { maxradio = szf.Height; } } return(maxradio); }
private void CreateFieldTable(FieldLayOut layout) { layout.UpdateFields(); }
// public void LoadLayout(FieldLayOut layout, Control ctnControl, SectionFilterCollection sfcfilter, System.Windows.Forms.PropertyGrid propertyGrid) public void LoadLayout(FieldLayOut layout, SectionFilterCollection sections) { if (layout == null || layout.FieldTable == null) { return; } _layout = layout; Int32Collection nCols = _layout.ColumnsEachRow; int nRowCount = nCols.Count; if (nRowCount <= 0 || !LoadSectionFilters(nCols, sections)) { return; } mainControl.Controls.Clear(); Rectangle rect = mainControl.ClientRectangle; mainControl.BackColor = Control.DefaultBackColor; this.C_PropertyGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.C_PropertyGrid_PropertyValueChanged); Buttons = new Button[nRowCount][]; btnContainer = new Panel[nRowCount]; int sfcindex = 0; int panelLocX = rect.X; int panelLocY = rect.Y; int nButtonHeight = 0; for (int i = 0; i < nRowCount; i++) { panelLocY += nButtonHeight; nButtonHeight = (int)(rect.Height * this.GetMaxRadio(layout, i)); btnContainer[i] = new Panel(); btnContainer[i].Name = i.ToString(); btnContainer[i].Location = new Point(panelLocX, panelLocY); btnContainer[i].Size = new Size(rect.Width, nButtonHeight); btnContainer[i].BorderStyle = BorderStyle.None; int iColCount = nCols[i]; if (iColCount > 0) { Buttons[i] = new Button[iColCount]; } int buttonLocX = 0; int restWidth = this.GetRestWidth(i); //Added this code at 2008-12-12 13:58:28@Simon for (int j = 0; j < iColCount; j++) { Button newButton = new Button(); newButton.Location = new Point(buttonLocX, 0); newButton.Size = this.GetButtonSize(i, j); if (restWidth > 0) { newButton.Width += 1; restWidth--; } else if (restWidth < 0) { newButton.Width -= 1; restWidth++; } buttonLocX += newButton.Size.Width; newButton.BackColor = Control.DefaultBackColor; btntag = new ButtonTags(); btntag.RowIndex = i; btntag.ColIndex = j; btntag.RowMax = nRowCount - 1; btntag.ColMax = nRowCount - 1; btntag.btnLoc = new Point(newButton.Location.X, newButton.Location.X); btntag.btnSize = new Size(newButton.Width, newButton.Height); btntag.filter = sections[sfcindex]; sfcindex++; newButton.Name = string.Format("Button{0}", sfcindex); newButton.Text = btntag.filter.FilterName; newButton.Tag = btntag; newButton.MouseDown += new System.Windows.Forms.MouseEventHandler(MyMouseDown); newButton.MouseLeave += new System.EventHandler(MyMouseLeave); newButton.MouseMove += new System.Windows.Forms.MouseEventHandler(MyMouseMove); newButton.Click += new System.EventHandler(MyClick); Buttons[i][j] = newButton; btnContainer[i].Controls.Add(newButton); } this.mainControl.Controls.Add(btnContainer[i]); } }