Beispiel #1
0
        private void _Resize()
        {
            BeforeResizeEventArgs arg = new BeforeResizeEventArgs()
            {
                DisplayState = this.m_DisplayState
            };


            if (ParentForm == null)
            {
                return;
            }

            // 显示或者隐藏父窗口的所有控件
            // Hides/Shows all of the controls on the form
            foreach (Control c in ParentForm.Controls)
            {
                c.Visible = m_DisplayState.IsParentMinimized;
            }

            // Makes sure the control is visible
            this.Visible = true;



            // This is a fix related to placing the control into other container types such
            // as TabControls or Groupboxes.
            if (m_DisplayState.ActualParent == null)
            {
                m_DisplayState.ActualParent = this.Parent;
            }


            if (!m_DisplayState.IsParentMinimized)
            {
                // This is a fix related to placing the control into other container types such
                // as TabControls or Groupboxes.
                if (m_DisplayState.ActualParent.GetType() != typeof(Form))
                {
                    this.ParentForm.Controls.Add(this);
                }


                // Set the button's image to the minimized image
                this.btnState.Image = _propImageMinimized;

                // Store the current state of the form
                m_DisplayState.ParentClientSize     = ParentForm.ClientSize;
                m_DisplayState.ParentPrevBorder     = ParentForm.FormBorderStyle;
                m_DisplayState.ShowParentControlBox = ParentForm.ControlBox;

                // Store the current state of the control
                m_DisplayState.ControlPrevX  = this.Left;
                m_DisplayState.ControlPrevY  = this.Top;
                m_DisplayState.ControlAnchor = this.Anchor;

                // Set the new state minimized state of the form.
                ParentForm.ClientSize           = new Size(this.Width, this.Height);
                this.ParentForm.FormBorderStyle = FormBorderStyle.FixedDialog;
                this.ParentForm.ControlBox      = false;

                // Set the location of the control
                this.Anchor = AnchorStyles.Left;
                this.Left   = 0;
                this.Top    = 0;
            }
            else
            {
                // This is a fix related to placing the control into other container types such
                // as TabControls or Groupboxes.

                if (m_DisplayState.ActualParent.GetType() != typeof(Form))
                {
                    this.ParentForm.Controls.Remove(this);
                    m_DisplayState.ActualParent.Controls.Add(this);
                }

                // Set the button's image to the maximized image
                this.btnState.Image = _propImageMaximized;

                // Set the form to the stored state
                ParentForm.ClientSize      = m_DisplayState.ParentClientSize;
                ParentForm.FormBorderStyle = m_DisplayState.ParentPrevBorder;
                ParentForm.ControlBox      = m_DisplayState.ShowParentControlBox;

                // Set the control to the stored state
                this.Anchor = m_DisplayState.ControlAnchor;
                this.Left   = m_DisplayState.ControlPrevX;
                this.Top    = m_DisplayState.ControlPrevY;
            }

            // Set the display state of the parent
            m_DisplayState.IsParentMinimized = !m_DisplayState.IsParentMinimized;

            // Raises the AfterResize event
            AfterResize(this, new AfterResizeEventArgs()
            {
                DisplayState = m_DisplayState
            });
        }
Beispiel #2
0
 private void OnBeforeResize(BeforeResizeEventArgs e)
 {
     BeforeResize(this, e);
 }