示例#1
0
        private void AddTabControl(DockingControl control, int index)
        {
            System.Diagnostics.Debug.Assert(!control.AutoHide, "Can't dock auto hidden controls");

            TabPage page = null;

            if (_dockingControlToPageMap.ContainsKey(control))
            {
                System.Diagnostics.Debug.Fail("Can't add a tab page multiple times");
            }
            else
            {
                page = new TabPage(control.Title);
                _dockingControlToPageMap.Add(control, page);
            }

            if (index < 0 || index >= _tabControl.TabPages.Count)
            {
                _tabControl.TabPages.Add(page);
            }
            else
            {
                _tabControl.TabPages.Insert(index, page);
            }

            _tabControl.SelectedTab = page;

            control.Parent = page;
            control.Dock   = DockStyle.Fill;
        }
示例#2
0
 protected virtual void OnAddControl(DockingControl control)
 {
     if (ControlAdded != null)
     {
         ControlAdded(this, control);
     }
 }
示例#3
0
 protected virtual void OnDockingControlCancelled(DockingControl control)
 {
     if (!control.AutoHide)
     {
         _dockControlContainerHandler.OnDockingControlCancelled(control);
     }
 }
示例#4
0
        public AutoResizeControl(DockingControl control, DockControlContainer container)
        {
            InitializeComponent();

            this.Width  = control.Width;
            this.Height = control.Height;

            _animator = new ControlResizeAnimator(this, control.Width);

            _inner     = control;
            _container = container;

            _inner.Parent = this;
            _inner.Dock   = DockStyle.Fill;

            DragHandler dragHandler = new DragHandler(this, new DragHandlerHitTester(HitTestSizeArea));

            _dragHandler = new SplitterDragHandler(dragHandler, SplitterDragHandlerDirection.EastWest);

            _dragHandler.EndSplitterDrag += new SplitterDragEndHandler(_dragHandler_EndSplitterDrag);

            _autoHideHandler       = new AutoHideControlHandler(this);
            _autoHideHandler.Hide += new Darwen.Windows.Forms.General.AutoHideHandler(_autoHideHandler_Hide);

            _paddingDrawHandler = new PaddingDrawHandler(this);
        }
示例#5
0
        private void AddControlHelper(DockingControl control, int index)
        {
            int controlIndex = _dockingControls.IndexOf(control);

            if (!_inExternalAddControl && controlIndex >= 0)
            {
                if (controlIndex == index)
                {
                    control.Child.Focus();
                    control.Child.Select();
                    return;
                }
                else
                {
                    DockingControlMovedHelper(control, controlIndex, index);
                }
            }
            else
            {
                if (controlIndex >= 0)
                {
                    if (index >= controlIndex)
                    {
                        index -= 1;
                    }
                }

                _dockingControls.Remove(control);
                _dockingControls.Insert(index, control);
                OnDockingControlAdded(control, index);
            }

            control.Child.Select();
            Manager.PerformLayout();
        }
示例#6
0
 protected virtual void OnDockingControlAdded(DockingControl control, int index)
 {
     if (!control.Cancelled && !control.AutoHide)
     {
         _dockControlContainerHandler.OnDockingControlAdded(control, index);
     }
 }
示例#7
0
 protected virtual void OnDockingControlMoved(DockingControl control, int oldIndex, int newIndex)
 {
     if (!control.Cancelled && !control.AutoHide)
     {
         _dockControlContainerHandler.OnDockingControlMoved(control, oldIndex, newIndex);
     }
 }
示例#8
0
 protected virtual void OnDockingControlRemoved(DockingControl control)
 {
     if (!control.Cancelled)
     {
         _dockControlContainerHandler.OnDockingControlRemoved(control);
     }
 }
示例#9
0
        private void RemoveTabControl(DockingControl control)
        {
            TabPage page = _dockingControlToPageMap[control];

            _tabControl.TabPages.Remove(page);
            _dockingControlToPageMap.Remove(control);
        }
示例#10
0
        public void OnDockingControlAdded(DockingControl control, int index)
        {
            if (!_container.Controls.Contains(control))
            {
                _container.Controls.Add(control);
            }

            RepositionControls();
        }
示例#11
0
 public void OnDockingControlCancelled(DockingControl control)
 {
     if (control.Cancelled)
     {
         RemoveTabControl(control);
     }
     else
     {
         AddTabControl(control, -1);
     }
 }
示例#12
0
 public void OnDockingControlAutoHide(DockingControl control)
 {
     if (control.AutoHide)
     {
         RemoveTabControl(control);
     }
     else
     {
         AddTabControl(control, -1);
     }
 }
示例#13
0
        public IDockingControl Add(string title, Control control)
        {
            System.Diagnostics.Debug.Assert(_manager != null, "Manager has not been set");

            DockingControl dockingControl = new DockingControl(control, _manager);

            Add(dockingControl);

            dockingControl.Title = title;
            OnAddControl(dockingControl);
            return(dockingControl);
        }
示例#14
0
        private void DockingControl_CancelledChanged(DockingControl control)
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(this.Parent, true))
            {
                Manager.SuspendLayout();

                CancelControl(control);

                OnDockingControlCancelled(control);

                Manager.ResumeLayout(true);
            }
        }
示例#15
0
        public void OnDockingControlCancelled(DockingControl control)
        {
            if (control.Cancelled)
            {
                _container.Controls.Remove(control);
            }
            else
            {
                OnDockingControlAdded(control, 0);
            }

            RepositionControls();
        }
示例#16
0
        private void DockingControlMovedHelper(DockingControl control, int oldIndex, int newIndex)
        {
            if (oldIndex != newIndex)
            {
                _dockingControls.RemoveAt(oldIndex);
                _dockingControls.Insert((newIndex > oldIndex) ? newIndex - 1 : newIndex, control);

                if (!control.AutoHide && !control.Cancelled)
                {
                    OnDockingControlMoved(control, oldIndex, newIndex);
                }
            }
        }
示例#17
0
        public void OnDockingControlAutoHide(DockingControl control)
        {
            if (control.AutoHide)
            {
                _container.Controls.Remove(control);
            }
            else
            {
                OnDockingControlAdded(control, 0);
            }

            RepositionControls();
        }
示例#18
0
        private void AddControl(DockingControl control, int dockIndex, int dimension)
        {
            Manager.SuspendLayout();

            if (!_mapDockingControlToData.ContainsKey(control))
            {
                DockingControlData dockingControlData = new DockingControlData(null,
                                                                               new AutoHideChangedHandler(DockingControl_AutoHideChanged),
                                                                               new CancelledChangedHandler(DockingControl_CancelledChanged));

                _mapDockingControlToData.Add(control, dockingControlData);

                control.AutoHideChanged  += dockingControlData.AutoHideChangedHandler;
                control.CancelledChanged += dockingControlData.CancelledChangedHandler;
            }

            switch (Dock)
            {
            case DockStyle.Left:
            case DockStyle.Right:
                if (_dockingControls.Count == 0)
                {
                    this.Width = Math.Min(MaxInitialDockSize, PaddingWidth + dimension);
                }

                break;

            case DockStyle.Top:
            case DockStyle.Bottom:
                if (_dockingControls.Count == 0)
                {
                    this.Height = Math.Min(MaxInitialDockSize, PaddingWidth + dimension);
                }

                break;
            }

            if (dockIndex < 0 || dockIndex >= _dockingControls.Count)
            {
                AddControlHelper(control, _dockingControls.Count);
            }
            else
            {
                AddControlHelper(control, dockIndex);
            }

            Manager.ResumeLayout(true);

            CheckVisibility();
        }
示例#19
0
        private void DockingControl_AutoHideChanged(DockingControl control)
        {
            Manager.SuspendLayout();

            if (control.AutoHide)
            {
                AutoHideControl(control);
            }
            else
            {
                ShowControl(control);
            }

            Manager.ResumeLayout(true);
        }
示例#20
0
        private static DockingControl GetControlBefore(DockControlContainer container, int index)
        {
            DockingControl controlBefore = null;

            for (int indexBefore = index - 1; controlBefore == null && indexBefore >= 0; indexBefore -= 1)
            {
                controlBefore = container.DockedControlList[indexBefore];

                if (controlBefore.AutoHide || controlBefore.Cancelled)
                {
                    controlBefore = null;
                }
            }

            return(controlBefore);
        }
示例#21
0
        private void SetupZOrder(List <DockingControl> dockingControls)
        {
            System.Diagnostics.Debug.Assert(dockingControls.Count == _splitters.Count + 1);

            for (int dockingControlIndex = 0; dockingControlIndex < dockingControls.Count; dockingControlIndex += 1)
            {
                DockingControl control = dockingControls[dockingControlIndex];
                control.BringToFront();

                if (dockingControlIndex < _splitters.Count)
                {
                    Splitter splitter = _splitters[dockingControlIndex];
                    splitter.BringToFront();
                }
            }
        }
示例#22
0
        public void DockControl(DockingControl control, int dockAtIndex, int dimension)
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(this))
            {
                DockControlContainer oldContainer = ControlHelpers.FindParentControl <DockControlContainer>(control);

                if (oldContainer != null && oldContainer != this)
                {
                    oldContainer.RemoveControl(control);
                }

                AddControl(control, dockAtIndex, dimension);
            }

            Invalidate(true);
        }
示例#23
0
        private static DockingControl GetControlAfter(DockControlContainer container, int index)
        {
            DockingControl controlAfter = null;

            for (int indexAfter = index + 1; controlAfter == null && indexAfter < container.DockedControlList.Count; indexAfter += 1)
            {
                controlAfter = container.DockedControlList[indexAfter];

                if (controlAfter.AutoHide || controlAfter.Cancelled)
                {
                    controlAfter = null;
                }
            }

            return(controlAfter);
        }
示例#24
0
        public FloatingForm(DockingControl inner, DockingManagerControl manager)
        {
            InitializeComponent();

            _manager = manager;
            _inner   = inner;
            _cancelledChangedHandler = new CancelledChangedHandler(Inner_CancelledChanged);
            _inner.CancelledChanged += _cancelledChangedHandler;

            this.SuspendLayout();
            this.Controls.Add(inner);
            inner.Dock   = DockStyle.Fill;
            this.Padding = new Padding(PaddingSize, PaddingSize, PaddingSize, PaddingSize);
            this.ResumeLayout(true);

            _dragSizer = new ControlDragSizer(this);
        }
示例#25
0
        private void _toolStripCaption_CaptionDrag(object sender, MouseEventArgs e)
        {
            Point pointInScreen            = this.PointToScreen(e.Location);
            DockControlContainer container = _manager.GetContainerAtPoint(_manager.PointToClient(pointInScreen));

            if (container == null)
            {
                Rectangle dragRectangle = DockControlHelpers.GetDropXorDragRect(_manager, pointInScreen, DockingBarSize);

                if (!dragRectangle.IsEmpty)
                {
                    _dragger.SetRectangle(_manager.RectangleToScreen(dragRectangle));
                    return;
                }
            }
            else
            {
                Rectangle rectangleToDraw = GetContainerDragDrawRectangle(container, pointInScreen);

                if (!rectangleToDraw.IsEmpty)
                {
                    _dragger.SetRectangle(rectangleToDraw);
                    return;
                }

                if (container.Tabbed)
                {
                    _dragger.SetRectangle(container.RectangleToScreen(container.ClientRectangle));
                    return;
                }
                else
                {
                    DockingControl control = container.GetDockingControlAtPoint(container.PointToClient(pointInScreen));

                    if (control != null)
                    {
                        Point pointInControl = control.PointToClient(pointInScreen);
                        rectangleToDraw = GetContolDragDrawRectangle(container, control, pointInControl);
                        _dragger.SetRectangle(control.RectangleToScreen(rectangleToDraw));
                        return;
                    }
                }
            }

            _dragger.MoveTo(e.Location);
        }
示例#26
0
 private void Inner_CancelledChanged(DockingControl control)
 {
     if (control == _inner)
     {
         if (_inner.Cancelled)
         {
             this.Visible = false;
         }
         else if (Loaded)
         {
             this.Visible = true;
         }
         else
         {
             this.Show(_manager.ParentForm);
         }
     }
 }
示例#27
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;
                }
            }
        }
示例#28
0
        private void TestCursor(Point location)
        {
            foreach (ToolStripItem item in this.Items)
            {
                if (item is ToolStripButton && item.Bounds.Contains(location))
                {
                    DisposeCursor();
                    return;
                }
            }

            DockingControl parent = Parent as DockingControl;

            if (parent != null && !parent.AutoHide)
            {
                if (_setCursor == null)
                {
                    _setCursor = new SetCursor(this, Cursors.SizeAll);
                }
            }
        }
示例#29
0
        public void RemoveControl(DockingControl control)
        {
            Manager.SuspendLayout();

            DockingControlData data = _mapDockingControlToData[control];

            control.AutoHideChanged  -= data.AutoHideChangedHandler;
            control.CancelledChanged -= data.CancelledChangedHandler;

            _mapDockingControlToData.Remove(control);

            if (data.Button != null)
            {
                _mapButtonToControl.Remove(data.Button);
            }

            _dockingControls.Remove(control);
            OnDockingControlRemoved(control);

            CheckVisibility();

            Manager.ResumeLayout(true);
        }
示例#30
0
 public void OnDockingControlMoved(DockingControl control, int oldIndex, int newIndex)
 {
     RemoveTabControl(control);
     AddTabControl(control, (oldIndex <= newIndex) ? newIndex : newIndex - 1);
 }