Ejemplo n.º 1
0
        public override void PerformRestore(DockingManager dm)
        {
            // Get the correct target panel from state
            AutoHidePanel ahp = dm.AutoHidePanelForState(_state);

            ahp.AddContent(_content, _next, _previous, _nextAll, _previousAll);
        }
Ejemplo n.º 2
0
        public Content(XmlTextReader xmlIn, int formatVersion)
        {
            // Define the initial object state
            _control             = null;
            _title               = "";
            _fullTitle           = "";
            _imageList           = null;
            _icon                = null;
            _imageIndex          = -1;
            _manager             = null;
            _parentWindowContent = null;
            _displaySize         = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize        = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize        = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation     = new Point(_defaultLocation, _defaultLocation);
            _order               = _counter++;
            _tag             = null;
            _visible         = false;
            _defaultRestore  = null;
            _autoHideRestore = null;
            _floatingRestore = null;
            _dockingRestore  = null;
            _autoHidePanel   = null;
            _docked          = true;
            _captionBar      = true;
            _closeButton     = true;
            _hideButton      = true;
            _autoHidden      = false;
            _closeOnHide     = false;

            // Overwrite default with values read in
            LoadFromXml(xmlIn, formatVersion);
        }
Ejemplo n.º 3
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;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Hide restore containers
        /// </summary>
        /// <param name="panel">panel</param>
        public static void HideRestoreContainers(AutoHidePanel panel)
        {
            DockingContainer        parentContainer  = panel.RestoreParent;
            List <DockingContainer> containersToHide = new List <DockingContainer>();

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

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

            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;
            }
        }
Ejemplo n.º 5
0
        private void InternalConstruct(DockingManager manager,
                                       Control control,
                                       string title,
                                       ImageList imageList,
                                       int imageIndex,
                                       Icon icon)
        {
            // Must provide a valid manager instance
            if (manager == null)
            {
                throw new ArgumentNullException("DockingManager");
            }

            // Define the initial object state
            _control             = control;
            _title               = title;
            _uniqueName          = "";
            _imageList           = imageList;
            _imageIndex          = imageIndex;
            _icon                = icon;
            _manager             = manager;
            _parentWindowContent = null;
            _order               = _counter++;
            _visible             = false;
            _displaySize         = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize        = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize        = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation     = new Point(_defaultLocation, _defaultLocation);
            _defaultRestore      = new RestoreContentState(State.DockLeft, this);
            _floatingRestore     = new RestoreContentState(State.Floating, this);
            _autoHideRestore     = new RestoreAutoHideState(State.DockLeft, this);
            _dockingRestore      = _defaultRestore;
            _autoHidePanel       = null;
            _tag         = null;
            _docked      = true;
            _captionBar  = true;
            _closeButton = true;
            _hideButton  = true;
            _autoHidden  = false;
            _closeOnHide = false;
            _fullTitle   = title;

            // A control that is a Panel of Form should have its back color auto set
            if ((_control != null) && ((_control is Form) || (_control is Panel)))
            {
                _office2003BackColor = Office2003Color.Base;
            }
            else
            {
                _office2003BackColor = Office2003Color.Disable;
            }
        }
Ejemplo n.º 6
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;
                }
            }
        }
Ejemplo n.º 7
0
        /// <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 DockingContainer GetClosestDockableContainer(Form form)
        {
            if (form == null)
            {
                return(null);
            }

            FormsTabbedView tabbedView = GetTabbedView(form);

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

            return((DockingContainer)tabbedView.Parent);
        }
Ejemplo n.º 8
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;
                }
            }
        }
Ejemplo n.º 9
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;
            DockingContainer 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;
        }
Ejemplo n.º 10
0
        protected void InternalConstruct(DockingManager manager,
                                         Control control,
                                         string title,
                                         ImageList imageList,
                                         int imageIndex,
                                         Icon icon)
        {
            // Must provide a valid manager instance
            if (manager == null)
            {
                throw new ArgumentNullException("DockingManager");
            }

            // Define the initial object state
            _control             = control;
            _title               = title;
            _imageList           = imageList;
            _imageIndex          = imageIndex;
            _icon                = icon;
            _manager             = manager;
            _parentWindowContent = null;
            _order               = _counter++;
            _visible             = false;
            _displaySize         = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize        = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize        = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation     = new Point(_defaultLocation, _defaultLocation);
            _defaultRestore      = new RestoreContentState(State.DockLeft, this);
            _floatingRestore     = new RestoreContentState(State.Floating, this);
            _autoHideRestore     = new RestoreAutoHideState(State.DockLeft, this);
            _dockingRestore      = _defaultRestore;
            _autoHidePanel       = null;
            _tag         = null;
            _docked      = true;
            _captionBar  = true;
            _closeButton = true;
            _hideButton  = true;
            _autoHidden  = false;
            _closeOnHide = false;
            _fullTitle   = title;
        }
Ejemplo n.º 11
0
        public Restore RecordAutoHideRestore()
        {
            // Remove any existing restore object
            _autoHideRestore = null;

            // We should be inside a parent window
            if (_parentWindowContent != null)
            {
                // And in the auto hidden state
                if (_autoHidden)
                {
                    // Get access to the AutoHostPanel that contains use
                    AutoHidePanel ahp = _parentWindowContent.DockingManager.AutoHidePanelForContent(this);

                    // Request the ahp create a relevant restore object for us
                    _autoHideRestore = ahp.RestoreObjectForContent(this);
                }
            }

            return(_autoHideRestore);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Show restore containers
        /// </summary>
        /// <param name="panel">panel</param>
        private static void ShowRestoreContainers(AutoHidePanel panel)
        {
            DockingContainer parentContainer = panel.RestoreParent;

            ShowRestoreContainer(parentContainer);

            parentContainer = parentContainer.Parent as DockingContainer;

            while (parentContainer != null)
            {
                if (parentContainer.Visible == false)
                {
                    ShowRestoreContainer(parentContainer);
                    parentContainer = parentContainer.Parent as DockingContainer;
                }
                else
                {
                    break;
                }
            }
        }
        public void Execute( )
        {
            try
            {
                if (!CanExecute( ))
                {
                    return;
                }

                if (_parentForm.FormBorderStyle == FormBorderStyle.None)
                {
                    _parentForm.FormBorderStyle = FormBorderStyle.Sizable;

                    AutoHidePanel.ExpandTopLevelPanels( );
                }
                else
                {
                    _parentForm.SuspendLayout( );
                    _parentForm.FormBorderStyle = FormBorderStyle.None;

                    _parentForm.WindowState = FormWindowState.Normal;
                    _parentForm.WindowState = FormWindowState.Maximized;

                    AutoHidePanel.CollapseTopLevelPanels( );

                    _parentForm.ResumeLayout( );
                }

                OnCommandExecuted( );
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.Assert(false, exception.Message);

                throw;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Remove the container
        /// </summary>
        /// <param name="container">container to remove</param>
        private void RemoveContainer(DockingContainer container)
        {
            Debug.Assert(container.Parent != null, "Docked container must be hosted somewere");

            container.SetModeEmpty();

            DockingContainer containerParent = container.Parent as DockingContainer;

            if (containerParent == null)
            {
                Debug.Assert(container.Parent.Handle == _host.Handle, "Parents of FormsTabbedView should be only DockingContainer or _host");
            }
            else
            {
                DockingContainer 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)
                    {
                        DockingContainer leftPane  = otherContainer.LeftPane;
                        DockingContainer rightPane = otherContainer.RightPane;

                        otherContainer.SetModeEmpty();

                        containerParent.SetModeHSplit(leftPane, rightPane);
                    }
                    else if (otherContainer.TopPane != null)
                    {
                        DockingContainer topPane    = otherContainer.TopPane;
                        DockingContainer 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, DockableMode.None);
                    }
                }

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

            container.Parent          = null;
            container.Splitter.Parent = null;
            container.Dispose();
        }
Ejemplo n.º 15
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 = (DockingContainer)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();
        }