Example #1
0
        /// <summary>
        /// Hide restore containers
        /// </summary>
        /// <param name="panel">panel</param>
        public static void HideRestoreContainers(AutoHidePanel panel)
        {
            DockableContainer        parentContainer  = panel.RestoreParent;
            List <DockableContainer> containersToHide = new List <DockableContainer>();

            while (parentContainer != null)
            {
                int visibleChildrenCount = GetVisibleChildrenCount(parentContainer);
                if (visibleChildrenCount > 1)
                {
                    break;
                }

                containersToHide.Add(parentContainer);
                parentContainer = parentContainer.Parent as DockableContainer;
            }

            for (int index = containersToHide.Count - 1; index >= 0; index--)
            {
                parentContainer = containersToHide[index];
                int splitterIndex  = parentContainer.Parent.Controls.IndexOf(parentContainer.Splitter);
                int containerIndex = parentContainer.Parent.Controls.IndexOf(parentContainer);
                parentContainer.Splitter.Visible = false;
                parentContainer.Visible          = false;
                parentContainer.SplitterBefore   = splitterIndex < containerIndex;
            }
        }
Example #2
0
        /// <summary>
        /// Start auto-show pane process
        /// </summary>
        /// <param name="panelToShow">panel to show</param>
        private void StartAutoShowPane(AutoHidePanel panelToShow)
        {
            if (_autoShowPanel != panelToShow)
            {
                _animationCommand.Handler = null;

                _autoHidePanel = _autoShowPanel;
                _autoShowPanel = panelToShow;

                if (_autoShowPanel != null)
                {
                    _host.MoveFirst(_autoShowPanel);
                }

                if (_autoHidePanel != null)
                {
                    _animationCommand.Handler = _autoHidePanel.AutoHideHandler;
                }
                else if (_autoShowPanel != null)
                {
                    _animationCommand.Handler = _autoShowPanel.AutoShowHandler;
                }
                else
                {
                    _animationCommand.Handler = HideAutoPaneWhenMouseExits;
                }
            }
        }
        /// <summary>
        /// Add autohide panel
        /// </summary>
        /// <param name="panel">panel to add</param>
        public void Add(AutoHidePanel panel)
        {
            for (int index = 0; index < panel.View.Count; index++)
            {
                AddButton(new TabButton(panel.View.GetPageAt(index)));
            }

            panel.View.FormAdded    += OnFormAddedToPanel;
            panel.View.FormRemoved  += OnFormRemovedFromPanel;
            panel.View.FormSelected += OnFormSelectedIntoView;
        }
        /// <summary>
        /// Checks if this panel contains give panel
        /// </summary>
        /// <param name="panel">panel to check</param>
        /// <returns>true if this panel contains given pane</returns>
        public bool ContainsPanel(AutoHidePanel panel)
        {
            for (int index = ButtonsCount - 1; index >= 0; index--)
            {
                TabButton button = GetButtonAt(index);

                FormsTabbedView view = HierarchyUtility.GetTabbedView((Form)button.Page);
                if (view.Parent == panel)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #5
0
        /// <summary>
        /// Hide auto pane when mouse exits
        /// </summary>
        public void HideAutoPaneWhenMouseExits()
        {
            Point mousePosition = Control.MousePosition;


            bool checkIfShouldHideAutoPane = false;
            bool checkIfShouldHidePreview  = _previewPane.Visible;

            if (checkIfShouldHidePreview)
            {
                checkIfShouldHidePreview = (_host.RectangleToScreen(_previewPane.Bounds).Contains(mousePosition) == false);
            }

            AutoHidePanel panel = _autoShowPanel;

            if (panel != null)
            {
                if (panel.Visible)
                {
                    checkIfShouldHideAutoPane = (panel.RectangleToScreen(panel.ClientRectangle).Contains(mousePosition) == false);
                }
                else
                {
                    _autoShowPanel = null;
                }
            }

            if (checkIfShouldHideAutoPane || checkIfShouldHidePreview)
            {
                Point clientPosition = _host.PointToClient(mousePosition);

                if (IsPointInSpacers(clientPosition))
                {
                    return;
                }

                if (checkIfShouldHideAutoPane)
                {
                    _autoHidePanel            = panel;
                    _animationCommand.Handler = panel.AutoHideHandler;
                }

                if (checkIfShouldHidePreview)
                {
                    _previewPane.Visible = false;
                }
            }
        }
        /// <summary>
        /// Get the closest dockable container (first parent of given form which is dockable container)
        /// </summary>
        /// <param name="form">form</param>
        /// <returns>dockable container</returns>
        public static DockableContainer GetClosestDockableContainer(Form form)
        {
            if (form == null)
            {
                return(null);
            }

            FormsTabbedView tabbedView = GetTabbedView(form);

            if (tabbedView.IsAutoHideMode)
            {
                AutoHidePanel panel = (AutoHidePanel)tabbedView.Parent;
                return(panel.RestoreParent);
            }

            return((DockableContainer)tabbedView.Parent);
        }
Example #7
0
        /// <summary>
        /// Show auto form
        /// </summary>
        /// <param name="form">form to be shown</param>
        public void ShowAutoForm(Form form)
        {
            FormsTabbedView view  = HierarchyUtility.GetTabbedView(form);
            AutoHidePanel   panel = view.Parent as AutoHidePanel;

            if (panel == null)
            {
                return;
            }

            if (_leftAutoHideButtons != null)
            {
                if (_leftAutoHideButtons.ContainsPanel(panel))
                {
                    OnLeftPaneSelectButton(this, new ControlEventArgs(form));
                    return;
                }
            }

            if (_rightAutoHideButtons != null)
            {
                if (_rightAutoHideButtons.ContainsPanel(panel))
                {
                    OnRightPaneSelectButton(this, new ControlEventArgs(form));
                    return;
                }
            }

            if (_topAutoHideButtons != null)
            {
                if (_topAutoHideButtons.ContainsPanel(panel))
                {
                    OnTopPaneSelectButton(this, new ControlEventArgs(form));
                    return;
                }
            }

            if (_bottomAutoHideButtons != null)
            {
                if (_bottomAutoHideButtons.ContainsPanel(panel))
                {
                    OnBottomPaneSelectButton(this, new ControlEventArgs(form));
                    return;
                }
            }
        }
Example #8
0
        /// <summary>
        /// Auto-show the given view
        /// </summary>
        /// <param name="view">view to show</param>
        public void UnsetAutoHideMode(FormsTabbedView view)
        {
            AutoHidePanel     panel     = (AutoHidePanel)view.Parent;
            DockableContainer container = panel.RestoreParent;

            DockStyle logicalDock = DockStyle.None;

            if (LeftAutohideButtons.Remove(panel))
            {
                logicalDock = DockStyle.Left;
            }
            else if (RightAutohideButtons.Remove(panel))
            {
                logicalDock = DockStyle.Right;
            }
            else if (TopAutohideButtons.Remove(panel))
            {
                logicalDock = DockStyle.Top;
            }
            else if (BottomAutohideButtons.Remove(panel))
            {
                logicalDock = DockStyle.Bottom;
            }
            else
            {
                Debug.Fail("Panel not found");
            }

            _host.Remove(panel);

            container.SetModeSingleChild(view);

            OnSetHostContainerDock(view, logicalDock);
            view.IsAutoHideMode        = false;
            view.PagesPanel.AutoHidden = false;

            ShowRestoreContainers(panel);

            ArrangeAutoButtonsPanels();

            _autoShowPanel = null;
        }
Example #9
0
        /// <summary>
        /// Show restore containers
        /// </summary>
        /// <param name="panel">panel</param>
        private static void ShowRestoreContainers(AutoHidePanel panel)
        {
            DockableContainer parentContainer = panel.RestoreParent;

            ShowRestoreContainer(parentContainer);

            parentContainer = parentContainer.Parent as DockableContainer;

            while (parentContainer != null)
            {
                if (parentContainer.Visible == false)
                {
                    ShowRestoreContainer(parentContainer);
                    parentContainer = parentContainer.Parent as DockableContainer;
                }
                else
                {
                    break;
                }
            }
        }
        /// <summary>
        /// Removes the panel if is contained here
        /// </summary>
        /// <param name="panel">panel to remove</param>
        /// <returns>true if is removed the panel</returns>
        public bool Remove(AutoHidePanel panel)
        {
            bool removed = false;

            for (int index = ButtonsCount - 1; index >= 0; index--)
            {
                TabButton button = GetButtonAt(index);

                FormsTabbedView view = HierarchyUtility.GetTabbedView((Form)button.Page);
                if (view.Parent == panel)
                {
                    RemoveButton(button);
                    removed = true;
                }
            }

            panel.View.FormAdded    -= OnFormAddedToPanel;
            panel.View.FormRemoved  -= OnFormRemovedFromPanel;
            panel.View.FormSelected -= OnFormSelectedIntoView;

            return(removed);
        }
Example #11
0
        /// <summary>
        /// Auto-hide the given view
        /// </summary>
        /// <param name="view">view to hide</param>
        public void SetAutoHideMode(FormsTabbedView view)
        {
            AutoHidePanel panel  = new AutoHidePanel();
             panel.RestoreParent  = (DockableContainer)view.Parent;
             panel.Size    = view.Size;
             panel.Visible = false;

             HideRestoreContainers(panel);

             panel.RestoreParent.SetModeLinked(view);
             view.Parent = panel;

             DockStyle logicalDock = view.HostContainerDock;

             OnSetHostContainerDock(view, Globals.DockAutoHide);

             view.Positioner = new ControlPositioner(panel);
             view.Positioner.CanMove = false;

             if (logicalDock == DockStyle.Left)
             {
            panel.Bounds = new Rectangle(LeftAutohideButtons.Right, LeftAutohideButtons.Top, view.Width, LeftAutohideButtons.Height);

            view.Positioner.CanSizeLeft   = false;
            view.Positioner.CanSizeTop    = false;
            view.Positioner.CanSizeBottom = false;

            panel.AutoHideHandler = AutoHideLeftPane;
            panel.AutoShowHandler = AutoShowLeftPane;

            LeftAutohideButtons.Add(panel);
             }
             else if (logicalDock == DockStyle.Right)
             {
            panel.Bounds = new Rectangle(RightAutohideButtons.Left - view.Width, RightAutohideButtons.Top, view.Width, RightAutohideButtons.Height);

            view.Positioner.CanSizeRight  = false;
            view.Positioner.CanSizeTop    = false;
            view.Positioner.CanSizeBottom = false;

            panel.AutoHideHandler = AutoHideRightPane;
            panel.AutoShowHandler = AutoShowRightPane;

            RightAutohideButtons.Add(panel);
             }
             else if (logicalDock == DockStyle.Top)
             {
            panel.Bounds = new Rectangle(TopAutohideButtons.Left, TopAutohideButtons.Bottom, TopAutohideButtons.Width, view.Height);

            view.Positioner.CanSizeLeft   = false;
            view.Positioner.CanSizeRight  = false;
            view.Positioner.CanSizeTop    = false;

            panel.AutoHideHandler = AutoHideTopPane;
            panel.AutoShowHandler = AutoShowTopPane;

            TopAutohideButtons.Add(panel);
             }
             else if (logicalDock == DockStyle.Bottom)
             {
            panel.Bounds = new Rectangle(BottomAutohideButtons.Left, BottomAutohideButtons.Top - view.Height, BottomAutohideButtons.Width, view.Height);

            view.Positioner.CanSizeLeft   = false;
            view.Positioner.CanSizeRight  = false;
            view.Positioner.CanSizeBottom = false;

            panel.AutoHideHandler = AutoHideBottomPane;
            panel.AutoShowHandler = AutoShowBottomPane;

            BottomAutohideButtons.Add(panel);
             }
             else
             {
            Debug.Fail("Autohide should be available only for docked left, right, top or bottom");
            return;
             }

             _host.AddFirst(panel);
             view.IsAutoHideMode = true;
             view.PagesPanel.AutoHidden = true;

             ArrangeAutoButtonsPanels();
        }
Example #12
0
        /// <summary>
        /// Hide auto pane when mouse exits
        /// </summary>
        public void HideAutoPaneWhenMouseExits()
        {
            Point mousePosition = Control.MousePosition;

             bool checkIfShouldHideAutoPane = false;
             bool checkIfShouldHidePreview  = _previewPane.Visible;

             if (checkIfShouldHidePreview)
             {
            checkIfShouldHidePreview = (_host.RectangleToScreen(_previewPane.Bounds).Contains(mousePosition) == false);
             }

             AutoHidePanel panel = _autoShowPanel;
             if (panel != null)
             {
            if (panel.Visible)
            {
               checkIfShouldHideAutoPane = (panel.RectangleToScreen(panel.ClientRectangle).Contains(mousePosition) == false);
            }
            else
            {
               _autoShowPanel = null;
            }
             }

             if (checkIfShouldHideAutoPane || checkIfShouldHidePreview)
             {
            Point clientPosition = _host.PointToClient(mousePosition);

            if (IsPointInSpacers(clientPosition))
            {
               return;
            }

            if (checkIfShouldHideAutoPane)
            {
               _autoHidePanel = panel;
               _animationCommand.Handler = panel.AutoHideHandler;
            }

            if (checkIfShouldHidePreview)
            {
               _previewPane.Visible = false;
            }
             }
        }
Example #13
0
        /// <summary>
        /// Hide restore containers
        /// </summary>
        /// <param name="panel">panel</param>
        public static void HideRestoreContainers(AutoHidePanel panel)
        {
            DockableContainer parentContainer = panel.RestoreParent;
             List<DockableContainer> containersToHide = new List<DockableContainer>();
             while (parentContainer != null)
             {
            int visibleChildrenCount = GetVisibleChildrenCount(parentContainer);
            if (visibleChildrenCount > 1)
            {
               break;
            }

            containersToHide.Add(parentContainer);
            parentContainer = parentContainer.Parent as DockableContainer;
             }

             for (int index = containersToHide.Count - 1; index >= 0; index--)
             {
            parentContainer = containersToHide[index];
            parentContainer.Splitter.Visible = false;
            parentContainer.Visible = false;
             }
        }
Example #14
0
        /// <summary>
        /// Start auto-show pane process
        /// </summary>
        /// <param name="panelToShow">panel to show</param>
        private void StartAutoShowPane(AutoHidePanel panelToShow)
        {
            if (_autoShowPanel != panelToShow)
             {
            _animationCommand.Handler = null;

            _autoHidePanel = _autoShowPanel;
            _autoShowPanel = panelToShow;

            if (_autoHidePanel != null)
            {
               _animationCommand.Handler = _autoHidePanel.AutoHideHandler;
            }
            else if (_autoShowPanel != null)
            {
               _animationCommand.Handler = _autoShowPanel.AutoShowHandler;
            }
            else
            {
               _animationCommand.Handler = HideAutoPaneWhenMouseExits;
            }
             }
        }
Example #15
0
        /// <summary>
        /// Removes the panel if is contained here
        /// </summary>
        /// <param name="panel">panel to remove</param>
        /// <returns>true if is removed the panel</returns>
        public bool Remove(AutoHidePanel panel)
        {
            bool removed = false;
             for (int index = ButtonsCount - 1; index >= 0; index--)
             {
            TabButton button = GetButtonAt(index);

            FormsTabbedView view = HierarchyUtility.GetTabbedView((Form)button.Page);
            if (view.Parent == panel)
            {
               RemoveButton(button);
               removed = true;
            }
             }

             panel.View.FormAdded    -= OnFormAddedToPanel;
             panel.View.FormRemoved  -= OnFormRemovedFromPanel;
             panel.View.FormSelected -= OnFormSelectedIntoView;

             return removed;
        }
Example #16
0
        /// <summary>
        /// Checks if this panel contains give panel
        /// </summary>
        /// <param name="panel">panel to check</param>
        /// <returns>true if this panel contains given pane</returns>
        public bool ContainsPanel(AutoHidePanel panel)
        {
            for (int index = ButtonsCount - 1; index >= 0; index--)
             {
            TabButton button = GetButtonAt(index);

            FormsTabbedView view = HierarchyUtility.GetTabbedView((Form)button.Page);
            if (view.Parent == panel)
            {
               return true;
            }
             }

             return false;
        }
Example #17
0
        /// <summary>
        /// Auto-hide the given view
        /// </summary>
        /// <param name="view">view to hide</param>
        public void SetAutoHideMode(FormsTabbedView view)
        {
            AutoHidePanel panel = new AutoHidePanel();

            panel.RestoreParent = (DockableContainer)view.Parent;
            panel.Size          = view.Size;
            panel.Visible       = false;

            HideRestoreContainers(panel);

            panel.RestoreParent.SetModeLinked(view);
            view.Parent = panel;

            DockStyle logicalDock = view.HostContainerDock;

            OnSetHostContainerDock(view, Globals.DockAutoHide);

            view.Positioner         = new ControlPositioner(panel);
            view.Positioner.CanMove = false;

            if (logicalDock == DockStyle.Left)
            {
                panel.Bounds = new Rectangle(LeftAutohideButtons.Right, LeftAutohideButtons.Top, view.Width, LeftAutohideButtons.Height);

                view.Positioner.CanSizeLeft   = false;
                view.Positioner.CanSizeTop    = false;
                view.Positioner.CanSizeBottom = false;

                panel.AutoHideHandler = AutoHideLeftPane;
                panel.AutoShowHandler = AutoShowLeftPane;

                LeftAutohideButtons.Add(panel);
            }
            else if (logicalDock == DockStyle.Right)
            {
                panel.Bounds = new Rectangle(RightAutohideButtons.Left - view.Width, RightAutohideButtons.Top, view.Width, RightAutohideButtons.Height);

                view.Positioner.CanSizeRight  = false;
                view.Positioner.CanSizeTop    = false;
                view.Positioner.CanSizeBottom = false;

                panel.AutoHideHandler = AutoHideRightPane;
                panel.AutoShowHandler = AutoShowRightPane;

                RightAutohideButtons.Add(panel);
            }
            else if (logicalDock == DockStyle.Top)
            {
                panel.Bounds = new Rectangle(TopAutohideButtons.Left, TopAutohideButtons.Bottom, TopAutohideButtons.Width, view.Height);

                view.Positioner.CanSizeLeft  = false;
                view.Positioner.CanSizeRight = false;
                view.Positioner.CanSizeTop   = false;

                panel.AutoHideHandler = AutoHideTopPane;
                panel.AutoShowHandler = AutoShowTopPane;

                TopAutohideButtons.Add(panel);
            }
            else if (logicalDock == DockStyle.Bottom)
            {
                panel.Bounds = new Rectangle(BottomAutohideButtons.Left, BottomAutohideButtons.Top - view.Height, BottomAutohideButtons.Width, view.Height);

                view.Positioner.CanSizeLeft   = false;
                view.Positioner.CanSizeRight  = false;
                view.Positioner.CanSizeBottom = false;

                panel.AutoHideHandler = AutoHideBottomPane;
                panel.AutoShowHandler = AutoShowBottomPane;

                BottomAutohideButtons.Add(panel);
            }
            else
            {
                Debug.Fail("Autohide should be available only for docked left, right, top or bottom");
                return;
            }

            _host.AddFirst(panel);
            view.IsAutoHideMode        = true;
            view.PagesPanel.AutoHidden = true;

            ArrangeAutoButtonsPanels();
        }
Example #18
0
        /// <summary>
        /// Auto-show the given view
        /// </summary>
        /// <param name="view">view to show</param>
        public void UnsetAutoHideMode(FormsTabbedView view)
        {
            AutoHidePanel panel         = (AutoHidePanel)view.Parent;
             DockableContainer container = panel.RestoreParent;

             DockStyle logicalDock = DockStyle.None;
             if (LeftAutohideButtons.Remove(panel))
             {
            logicalDock = DockStyle.Left;
             }
             else if (RightAutohideButtons.Remove(panel))
             {
            logicalDock = DockStyle.Right;
             }
             else if (TopAutohideButtons.Remove(panel))
             {
            logicalDock = DockStyle.Top;
             }
             else if (BottomAutohideButtons.Remove(panel))
             {
            logicalDock = DockStyle.Bottom;
             }
             else
             {
            Debug.Fail("Panel not found");
             }

             _host.Remove(panel);

             container.SetModeSingleChild(view);

             OnSetHostContainerDock(view, logicalDock);
             view.IsAutoHideMode = false;
             view.PagesPanel.AutoHidden = false;

             ShowRestoreContainers(panel);

             ArrangeAutoButtonsPanels();

             _autoShowPanel = null;
        }
Example #19
0
        /// <summary>
        /// Add autohide panel
        /// </summary>
        /// <param name="panel">panel to add</param>
        public void Add(AutoHidePanel panel)
        {
            for (int index = 0; index < panel.View.Count; index++)
             {
            AddButton(new TabButton(panel.View.GetPageAt(index)));
             }

             panel.View.FormAdded    += OnFormAddedToPanel;
             panel.View.FormRemoved  += OnFormRemovedFromPanel;
             panel.View.FormSelected += OnFormSelectedIntoView;
        }
Example #20
0
        /// <summary>
        /// Show restore containers
        /// </summary>
        /// <param name="panel">panel</param>
        private static void ShowRestoreContainers(AutoHidePanel panel)
        {
            DockableContainer parentContainer = panel.RestoreParent;
             parentContainer.Visible           = true;
             parentContainer.Splitter.Visible  = true;
             parentContainer = parentContainer.Parent as DockableContainer;

             while (parentContainer != null)
             {
            if (parentContainer.Visible == false)
            {
               parentContainer.Visible          = true;
               parentContainer.Splitter.Visible = true;

               parentContainer = parentContainer.Parent as DockableContainer;
            }
            else
            {
               break;
            }
             }
        }
Example #21
0
        /// <summary>
        /// Remove the container
        /// </summary>
        /// <param name="container">container to remove</param>
        private void RemoveContainer(DockableContainer container)
        {
            Debug.Assert(container.Parent != null, "Docked container must be hosted somewere");

            container.SetModeEmpty();

            DockableContainer containerParent = container.Parent as DockableContainer;

            if (containerParent == null)
            {
                Debug.Assert(container.Parent.Handle == _host.Handle, "Parents of FormsTabbedView should be only DockableContainer or _host");
            }
            else
            {
                DockableContainer otherContainer = containerParent.OtherPane(container);
                Debug.Assert(otherContainer != null, "Container in container means that parent container has contained two containers and a splitter");

                FormsTabbedView otherView  = otherContainer.SingleChild;
                FormsTabbedView linkedView = otherContainer.LinkedView;

                if (otherView == null && linkedView == null)
                {
                    if (otherContainer.LeftPane != null)
                    {
                        DockableContainer leftPane  = otherContainer.LeftPane;
                        DockableContainer rightPane = otherContainer.RightPane;

                        otherContainer.SetModeEmpty();

                        containerParent.SetModeHSplit(leftPane, rightPane);
                    }
                    else if (otherContainer.TopPane != null)
                    {
                        DockableContainer topPane    = otherContainer.TopPane;
                        DockableContainer bottomPane = otherContainer.BottomPane;

                        otherContainer.SetModeEmpty();

                        containerParent.SetModeVSplit(topPane, bottomPane);
                    }
                }
                else
                {
                    Debug.Assert((otherView == null || linkedView == null), "Other container must have a view");

                    otherContainer.SetModeEmpty();

                    if (otherView != null)
                    {
                        containerParent.SetModeSingleChild(otherView);
                    }
                    else
                    {
                        containerParent.SetModeLinked(linkedView);
                        AutoHidePanel linkedPanel = (AutoHidePanel)linkedView.Parent;
                        linkedPanel.RestoreParent = containerParent;
                        Autohide.HideRestoreContainers(linkedPanel);
                    }

                    // If floating container inside host
                    if (containerParent.Parent.Handle == _host.Handle && containerParent.Dock == DockStyle.None)
                    {
                        Debug.Assert(linkedView == null, "Can't have linked view in floating container");
                        SetViewDock(otherView, DockStyle.None, DockStyle.None, zDockMode.None);
                    }
                }

                otherContainer.Parent          = null;
                otherContainer.Splitter.Parent = null;
                otherContainer.Dispose();
            }

            container.Parent          = null;
            container.Splitter.Parent = null;
            container.Dispose();
        }