Пример #1
0
 public DockContainerTitleBar(DockContainerForm containerForm)
 {
     this.InitializeComponent();
     this.mContainerForm = containerForm;
     this.Dock = DockStyle.Fill;
     this._ContainerForm_DockedChanged = new EventHandler(this.ContainerForm_DockedChanged);
     this.ContainerForm.Docked += this._ContainerForm_DockedChanged;
     this.ContainerForm.Undocked += this._ContainerForm_DockedChanged;
     this.ResizeImages();
     base.SetStyle(ControlStyles.ResizeRedraw, true);
 }
Пример #2
0
 public void Undock()
 {
     if (this.IsDocked)
     {
         this.ContainerForm.OnUndocked(this);
         this.mContainerForm = null;
         if (this.ContainerControl is SplitterPanel)
         {
             this.DockStyle = DockStyles.Floating;
             Control parent = this.ContainerControl.Parent;
             while ((parent != null) && !(parent is DockSplitter))
             {
                 parent = parent.Parent;
             }
             if (parent == null)
             {
                 throw new InvalidOperationException(string.Format("Unable to locate the parent (DockSplitter) of the containing control for {0}", this));
             }
             DockSplitter splitter = parent as DockSplitter;
             Control topLevelControl = splitter.Parent;
             if ((topLevelControl == null) && (base.TopLevelControl != null))
             {
                 topLevelControl = base.TopLevelControl;
             }
             else if ((topLevelControl == null) && (base.TopLevelControl == null))
             {
                 throw new InvalidOperationException(string.Format("Unable to locate the parent of the DockSplitter containing panel {0}", this));
             }
             Control control3 = splitter.Panel2;
             if (this.ContainerControl.Equals(control3))
             {
                 control3 = splitter.Panel1;
             }
             if (control3.Controls.Count < 1)
             {
                 throw new ArgumentOutOfRangeException("Sibling panel to the target undocking has no child controls.");
             }
             Control control4 = control3.Controls[0];
             topLevelControl.Controls.Clear();
             topLevelControl.Controls.Add(control4);
             if ((control4 is DockPanel) && (topLevelControl is SplitterPanel))
             {
                 DockPanel panel = control4 as DockPanel;
                 panel.ContainerControl = topLevelControl;
                 parent = topLevelControl.Parent;
                 while ((parent != null) && !(parent is DockSplitter))
                 {
                     parent = parent.Parent;
                 }
                 if (parent == null)
                 {
                     throw new InvalidOperationException(string.Format("Unable to locate the parent (DockSplitter) of the containing control for {0}", this));
                 }
                 splitter = parent as DockSplitter;
                 bool flag = false;
                 if (splitter.Panel1.Equals(topLevelControl))
                 {
                     flag = true;
                 }
                 if (flag && (splitter.Orientation == Orientation.Horizontal))
                 {
                     panel.DockStyle = DockStyles.Top;
                 }
                 else if (flag && (splitter.Orientation == Orientation.Vertical))
                 {
                     panel.DockStyle = DockStyles.Left;
                 }
                 else if (!flag && (splitter.Orientation == Orientation.Horizontal))
                 {
                     panel.DockStyle = DockStyles.Bottom;
                 }
                 else
                 {
                     if (flag || (splitter.Orientation != Orientation.Vertical))
                     {
                         throw new InvalidOperationException("Unable to determing the DockStyle of the sibling panel of the undocking panel");
                     }
                     panel.DockStyle = DockStyles.Right;
                 }
             }
             else if ((control4 is DockPanel) && (topLevelControl is DockContainerRootPanel))
             {
                 DockPanel panel2 = control4 as DockPanel;
                 panel2.ContainerControl = topLevelControl;
                 panel2.DockStyle = DockStyles.Floating;
             }
         }
         else if (this.ContainerControl is DockTabGroup)
         {
             DockTabGroup containerControl = this.ContainerControl as DockTabGroup;
             containerControl.RemoveTab(this);
             base.Show();
             if (containerControl.Panels.Count == 1)
             {
                 Control control5 = containerControl.ContainerControl;
                 DockPanel panel3 = containerControl.Panels[0];
                 control5.Controls.Remove(containerControl);
                 control5.Controls.Add(panel3);
                 if (control5 is SplitterPanel)
                 {
                     panel3.ContainerControl = control5;
                     Control control6 = control5.Parent;
                     while ((control6 != null) && !(control6 is DockSplitter))
                     {
                         control6 = control6.Parent;
                     }
                     if (control6 == null)
                     {
                         throw new InvalidOperationException(string.Format("Unable to locate the parent (DockSplitter) of the containing control for {0}", this));
                     }
                     DockSplitter splitter2 = control6 as DockSplitter;
                     bool flag2 = false;
                     if (splitter2.Panel1.Equals(control5))
                     {
                         flag2 = true;
                     }
                     if (flag2 && (splitter2.Orientation == Orientation.Horizontal))
                     {
                         panel3.DockStyle = DockStyles.Top;
                     }
                     else if (flag2 && (splitter2.Orientation == Orientation.Vertical))
                     {
                         panel3.DockStyle = DockStyles.Left;
                     }
                     else if (!flag2 && (splitter2.Orientation == Orientation.Horizontal))
                     {
                         panel3.DockStyle = DockStyles.Bottom;
                     }
                     else
                     {
                         if (flag2 || (splitter2.Orientation != Orientation.Vertical))
                         {
                             throw new InvalidOperationException("Unable to determing the DockStyle of the sibling panel of the undocking panel");
                         }
                         panel3.DockStyle = DockStyles.Right;
                     }
                 }
                 else if (control5 is DockContainerRootPanel)
                 {
                     panel3.ContainerControl = control5;
                     panel3.DockStyle = DockStyles.Floating;
                 }
             }
         }
         else if (this.ContainerControl is DockContainerRootPanel)
         {
             throw new Exception("Undocking panel is the direct child of a DockContainer form, but is attempting to undock from a sibling panel");
         }
     }
     else if (this.IsFloating && (this.ContainerForm != null))
     {
         this.ContainerForm.Panels.Clear();
         this.ContainerForm.Controls.Clear();
         this.ContainerForm.Close();
     }
 }
Пример #3
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         int num = this.UndockStart.X - e.X;
         if (num < 0)
         {
             num = -num;
         }
         int num2 = this.UndockStart.Y - e.Y;
         if (num2 < 0)
         {
             num2 = -num2;
         }
         this.UndockMove = Math.Max(num, num2);
         if (this.ContainerPanel.IsFloating && this.Dragging)
         {
             this.ContainerPanel.ContainerForm.DragMove(e.Location);
         }
         else if (this.ContainerPanel.IsDocked && (this.UndockMove >= this.UndockMovementThreshhold))
         {
             this.ContainerPanel.Undock();
             DockContainerForm form = new DockContainerForm(this.Controller, this.ContainerPanel);
             form.Show();
             form.Activate();
             this.mDragging = true;
             this.ContainerPanel.ContainerForm.BeginDrag(e.Location);
         }
     }
     base.OnMouseMove(e);
 }