Пример #1
0
        private void button_MouseEnter(object sender, EventArgs e)
        {
            ToolStripButton   button  = sender as ToolStripButton;
            AutoResizeControl control = _mapButtonToControl[button];

            if (control.Visible)
            {
                control.StopTrackMouse();
            }
        }
Пример #2
0
        private void button_Click(object sender, EventArgs e)
        {
            ToolStripButton   button  = sender as ToolStripButton;
            AutoResizeControl control = _mapButtonToControl[button];

            if (!control.Showing)
            {
                control.Show(false);
                control.BringToFront();
                control.Focus();
                control.StartTrackMouse();
            }
        }
Пример #3
0
        private void CancelControl(DockingControl control)
        {
            DockingControlData data = _mapDockingControlToData[control];

            if (control.Cancelled)
            {
                if (data.Button == null)
                {
                    if (_dockingControls.GetVisibleDockedControlCount() == 0)
                    {
                        this.Visible = false;
                    }
                }
                else
                {
                    ToolStripButton button = _mapDockingControlToData[control].Button;
                    button.Visible = false;

                    AutoResizeControl autoResizeControl = _mapButtonToControl[button];
                    autoResizeControl.Visible = false;

                    if (ToolStripHelpers.GetVisibleButtonCount(_menuStrip) == 0)
                    {
                        _menuStrip.Visible = false;
                    }
                }
            }
            else
            {
                ToolStripButton button = _mapDockingControlToData[control].Button;

                if (button == null)
                {
                    this.Visible = true;
                }
                else
                {
                    button.Visible     = true;
                    _menuStrip.Visible = true;
                }
            }
        }
Пример #4
0
        private void button_MouseHover(object sender, EventArgs e)
        {
            ToolStripButton   button  = sender as ToolStripButton;
            AutoResizeControl control = _mapButtonToControl[button];

            if (!control.Visible && !control.Showing)
            {
                control.BringToFront();

                foreach (Control child in Parent.Controls)
                {
                    if (child is MenuStrip)
                    {
                        control.BringToFront();
                    }
                }

                control.Show(true);
            }
        }
Пример #5
0
        private void AutoHideControl(DockingControl control)
        {
            DockingControlData oldData = _mapDockingControlToData[control];

            if (oldData.Button == null)
            {
                Manager.SuspendLayout();

                _menuStrip.Visible = true;

                ToolStripButton button = new ToolStripButton(control.Title);
                button.MouseHover += new EventHandler(button_MouseHover);
                button.Click      += new EventHandler(button_Click);
                button.MouseEnter += new EventHandler(button_MouseEnter);
                button.MouseLeave += new EventHandler(button_MouseLeave);
                button.Visible     = !control.Cancelled;
                _menuStrip.Items.Add(button);

                if (_dockingControls.GetVisibleDockedControlCount() == 0)
                {
                    this.Visible = false;
                }

                AutoResizeControl autoResizeControl = new AutoResizeControl(control, this);
                autoResizeControl.Visible = false;
                autoResizeControl.Parent  = this.Parent;

                switch (this.Dock)
                {
                case DockStyle.Bottom:
                    autoResizeControl.DockDirection = DockingType.Bottom;
                    autoResizeControl.Padding       = new Padding(0, PaddingWidth, 0, 0);
                    break;

                case DockStyle.Fill:
                    break;

                case DockStyle.Left:
                    autoResizeControl.DockDirection = DockingType.Left;
                    autoResizeControl.Padding       = new Padding(0, 0, PaddingWidth, 0);
                    break;

                case DockStyle.None:
                    break;

                case DockStyle.Right:
                    autoResizeControl.DockDirection = DockingType.Right;
                    autoResizeControl.Padding       = new Padding(PaddingWidth, 0, 0, 0);
                    break;

                case DockStyle.Top:
                    autoResizeControl.DockDirection = DockingType.Top;
                    autoResizeControl.Padding       = new Padding(0, 0, 0, PaddingWidth);
                    break;

                default:
                    break;
                }

                _mapButtonToControl.Add(button, autoResizeControl);
                _mapDockingControlToData[control] = new DockingControlData(button, oldData.AutoHideChangedHandler, oldData.CancelledChangedHandler);

                control.DraggingEnabled = false;
                control.Visible         = true;

                OnDockingControlAutoHide(control);

                Manager.ResumeLayout(true);
            }
        }
Пример #6
0
        private void ShowControl(DockingControl control)
        {
            Form parentForm = this.ParentForm;

            using (RedrawStopper stopRedraws = new RedrawStopper(parentForm))
            {
                Manager.SuspendLayout();

                switch (this.Dock)
                {
                case DockStyle.Left:
                case DockStyle.Right:
                    this.Width = Math.Max(this.Width, PaddingWidth + control.Width);
                    break;

                case DockStyle.Top:
                case DockStyle.Bottom:
                    this.Height = Math.Max(this.Height, PaddingWidth + control.Height);
                    break;
                }

                this.Visible = true;

                control.Parent = this;

                ToolStripButton button = _mapDockingControlToData[control].Button;

                if (button != null)
                {
                    _menuStrip.Items.Remove(button);

                    AutoResizeControl autoResizeControl = _mapButtonToControl[button];
                    this.Controls.Remove(autoResizeControl);
                    autoResizeControl.Dispose();

                    _mapButtonToControl.Remove(button);
                }

                DockingControlData oldData = _mapDockingControlToData[control];
                _mapDockingControlToData[control] = new DockingControlData(null, oldData.AutoHideChangedHandler, oldData.CancelledChangedHandler);

                if (ToolStripHelpers.GetVisibleButtonCount(_menuStrip) == 0)
                {
                    _menuStrip.Visible = false;
                }

                _dockingControls.Remove(control);
                _dockingControls.Add(control);
                OnDockingControlAutoHide(control);

                if (control.Cancelled)
                {
                    CancelControl(control);
                }

                Manager.ResumeLayout(true);

                control.DraggingEnabled = true;
            }

            control.Focus();
            control.Select();

            if (parentForm != null)
            {
                parentForm.Invalidate(true);
            }
        }