Пример #1
0
        protected virtual void SetupForm(
            WinSupport.BaseEditUserControl editUserControl,
            WinSupport.BaseSelectUserControl selectUserControl,
            System.Type businessobjecttype,
            System.Windows.Forms.Form parent,
            string title,
            bool showToolbar,
            int openingWidth,
            int openingHeight)
        {
            bool showSelectUC = false;
            int  iWidth       = 0;
            int  iHeight      = 0;

            this.mEditUserControl              = editUserControl;
            this.mEditUserControl.DataChanged += new BaseEditUserControl.DataChangedHandler(this.uc_DataChanged);
            this.mEditUserControl.BringToFront();
            this.mSelectUserControl = selectUserControl;
            this.mSelectUserControl.SelectionMade += new BaseSelectUserControl.SelectionMadeHandler(this.selectUC_SelectionMade);
            this.mBusinessObjectType  = businessobjecttype;
            selectUserControl.Visible = false;
            this.pnlEdit.Controls.Add(editUserControl);
            if ((title == null) || (title.Trim().Length == 0))
            {
                this.Text = selectUserControl.Caption;
            }
            else
            {
                this.Text = title;
            }
            this.cboSelect.ValueMember   = "UniqueKey";
            this.cboSelect.DisplayMember = "DisplayText";
            this.MdiParent       = parent;
            this.ToolBar.Visible = showToolbar;
            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.MdiParent.ClientSize.Height)
            {
                iHeight = this.MdiParent.ClientSize.Height;
            }
            this.ClientSize = new System.Drawing.Size(iWidth, iHeight);
            SetState();
        }
Пример #2
0
        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);
        }