protected void SetupForm( BaseEditUserControl editUserControl, CSLA.BusinessBase busObject, string parentPrimaryKey, System.Windows.Forms.Form parent, string title, int openingWidth, int openingHeight, bool isModal) { int iWidth = 0; int iHeight = 0; this.mEditUserControl = editUserControl; this.mEditUserControl.DataChanged += new BaseEditUserControl.DataChangedHandler(this.uc_DataChanged); this.mEditUserControl.BringToFront(); this.pnlEdit.Controls.Add(editUserControl); mObject = (BusinessObjectSupport.IBusinessObject)busObject; if ((title == null) || (title.Trim().Length == 0)) { this.Text = editUserControl.Caption; } else { this.Text = title; } if (!isModal && parent != null && parent.IsMdiContainer) { this.MdiParent = parent; } ((IEditUserControl)this.mEditUserControl).SetupControl(mObject, parentPrimaryKey); mCallingForm = parent; if (openingWidth == 0) { iWidth = this.ClientSize.Width + 1; } else { iWidth = openingWidth; } if (openingHeight == 0) { iHeight = this.ClientSize.Height + 1; } else { iHeight = openingHeight; } if (iHeight < this.CallingForm.ClientSize.Height) { iHeight = this.CallingForm.ClientSize.Height; } this.ClientSize = new System.Drawing.Size(iWidth, iHeight); SetState(); }
protected void ResizeForm( System.Windows.Forms.ToolBar toolBar, BaseSelectUserControl ucSelect, BaseEditUserControl ucEdit, System.Windows.Forms.Panel pnlBottom, System.Windows.Forms.Panel pnlButtons, System.Windows.Forms.Panel pnlSelect) { int height = 0; int top = 0; int width = this.ClientSize.Width; int vMargin = ((IEditUserControl)ucEdit).VerticalMargin; ucEdit.Width = this.ClientSize.Width - pnlButtons.Width; if (toolBar != null && toolBar.Visible) { height += toolBar.Height + vMargin; top += toolBar.Bottom + vMargin; } if (ucSelect != null && ucSelect.Visible) { height += ucSelect.Height + vMargin; ucSelect.Width = width; ucSelect.Top = top; top += ucSelect.Bottom + vMargin; } if (pnlSelect != null && pnlSelect.Visible) { height += pnlSelect.Height + vMargin; pnlSelect.Width = width; pnlSelect.Top = top; top += pnlSelect.Bottom + vMargin; } pnlBottom.Top = top; pnlBottom.Width = width; height = ucEdit.Height; if (height < mBtnLast.Bottom + vMargin) { height = mBtnLast.Bottom + vMargin; } else { height += 2 * vMargin; } pnlBottom.Height = height; top += pnlBottom.Bottom + vMargin; this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, height); }