Beispiel #1
0
        /// <summary>
        /// Restore docking layout reading a xml string which is previously generated by a call to GetLayoutState
        /// </summary>
        /// <param name="xml">Xml containing layout state</param>
        /// <param name="getContentHandler">Delegate used by serializer to get user defined dockable contents</param>
        public void RestoreLayoutFromXml(string xml, GetContentFromTypeString getContentHandler)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            gridDocking.Deserialize(this, doc.ChildNodes[0], getContentHandler);

            List <Pane> addedPanes = new List <Pane>();

            foreach (DockableContent content in Contents)
            {
                DockablePane pane = content.ContainerPane as DockablePane;
                if (pane != null && !addedPanes.Contains(pane))
                {
                    if (pane.State == PaneState.AutoHide)
                    {
                        addedPanes.Add(pane);
                        AddPaneDockingButtons(pane);
                    }
                }
            }

            _currentButton = null;
        }
Beispiel #2
0
        /// <summary>
        /// Hide temporay pane and reset current docking button
        /// </summary>
        /// <param name="smooth">True if resize animation is enabled</param>
        private void HideTempPane(bool smooth)
        {
            if (_tempPane != null)
            {
                DockablePane pane       = gridDocking.GetPaneFromContent(_tempPane.Contents[0]) as DockablePane;
                bool         right_left = false;
                double       length     = 0.0;

                switch (_currentButton.DockingButtonGroup.Dock)
                {
                case Dock.Left:
                case Dock.Right:
                    if (_tempPaneAnimation != null)
                    {
                        pane.PaneWidth = _lengthAnimation;
                    }
                    else
                    {
                        pane.PaneWidth = _tempPane.Width;
                    }
                    length     = _tempPane.Width;
                    right_left = true;
                    break;

                case Dock.Top:
                case Dock.Bottom:
                    if (_tempPaneAnimation != null)
                    {
                        pane.PaneHeight = _lengthAnimation;
                    }
                    else
                    {
                        pane.PaneHeight = _tempPane.Height;
                    }
                    length     = _tempPane.Height;
                    right_left = false;
                    break;
                }

                _tempPane.OnStateChanged -= new EventHandler(_tempPane_OnStateChanged);

                if (smooth)
                {
                    HideOverlayPanel(length, right_left);
                }
                else
                {
                    ForceHideOverlayPanel();
                    panelFront.BeginAnimation(DockPanel.OpacityProperty, null);
                    panelFront.Children.Clear();
                    panelFront.Opacity = 0.0;
                    _tempPane.Close();
                }

                _currentButton = null;
                _tempPane      = null;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Event handler which show a temporary pane with a single content attached to a docking button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnShowAutoHidePane(object sender, MouseEventArgs e)
        {
            if (_currentButton == sender)
                return;

            HideTempPane(true);

            _currentButton = sender as DockingButton;

            ShowTempPane(true);
        }
Beispiel #4
0
        /// <summary>
        /// Add a group of docking buttons for a pane docked to a dockingmanager border
        /// </summary>
        /// <param name="pane"></param>
        private void AddPaneDockingButtons(DockablePane pane)
        {
            DockingButtonGroup buttonGroup = new DockingButtonGroup();
            buttonGroup.Dock = pane.Dock;

            foreach (DockableContent content in pane.Contents)
            {
                DockingButton btn = new DockingButton();
                btn.DockableContent = content;
                btn.DockingButtonGroup = buttonGroup;

                if (_currentButton == null)
                    _currentButton = btn;

                buttonGroup.Buttons.Add(btn);
            }

            _dockingBtnGroups.Add(buttonGroup);

            AddDockingButtons(buttonGroup);
        }
        /// <summary>
        /// Event handler which show a temporary pane with a single content attached to a docking button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnShowAutoHidePane(object sender, MouseEventArgs e)
        {
            if (_currentButton == sender)
                return;

            HideTempPane(true);

            _currentButton = sender as DockingButton;

            ShowTempPane(true);
        }
        /// <summary>
        /// Hide temporay pane and reset current docking button
        /// </summary>
        /// <param name="smooth">True if resize animation is enabled</param>
        private void HideTempPane(bool smooth)
        {
            if (_tempPane != null)
            {
                DockablePane pane = gridDocking.GetPaneFromContent(_tempPane.Contents[0]) as DockablePane;
                bool right_left = false;
                double length = 0.0;

                switch (_currentButton.DockingButtonGroup.Dock)
                {
                    case Dock.Left:
                    case Dock.Right:
                        if (_tempPaneAnimation != null)
                            pane.PaneWidth = _lengthAnimation;
                        else
                            pane.PaneWidth = _tempPane.Width;
                        length = _tempPane.Width;
                        right_left = true;
                        break;
                    case Dock.Top:
                    case Dock.Bottom:
                        if (_tempPaneAnimation != null)
                            pane.PaneHeight = _lengthAnimation;
                        else
                            pane.PaneHeight = _tempPane.Height;
                        length = _tempPane.Height;
                        right_left = false;
                        break;
                }

                _tempPane.OnStateChanged-=new EventHandler(_tempPane_OnStateChanged);

                if (smooth)
                {
                    HideOverlayPanel(length, right_left);
                }
                else
                {
                    ForceHideOverlayPanel();
                    panelFront.BeginAnimation(DockPanel.OpacityProperty, null);
                    panelFront.Children.Clear();
                    panelFront.Opacity = 0.0;
                    _tempPane.Close();
                }

                _currentButton = null;
                _tempPane = null;
            }
        }
        /// <summary>
        /// Add a group of docking buttons for a pane docked to a dockingmanager border
        /// </summary>
        /// <param name="pane"></param>
        private void AddPaneDockingButtons(DockablePane pane)
        {
            DockingButtonGroup buttonGroup = new DockingButtonGroup();
            buttonGroup.Dock = pane.Dock;

            foreach (DockableContent content in pane.Contents)
            {
                DockingButton btn = new DockingButton();
                btn.DockableContent = content;
                btn.DockingButtonGroup = buttonGroup;

                if (_currentButton == null)
                    _currentButton = btn;

                buttonGroup.Buttons.Add(btn);
            }

            _dockingBtnGroups.Add(buttonGroup);

            AddDockingButtons(buttonGroup);
        }
        /// <summary>
        /// Restore docking layout reading a xml string which is previously generated by a call to GetLayoutState
        /// </summary>
        /// <param name="xml">Xml containing layout state</param>
        /// <param name="getContentHandler">Delegate used by serializer to get user defined dockable contents</param>
        public void RestoreLayoutFromXml(string xml, GetContentFromTypeString getContentHandler)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            gridDocking.Deserialize(this, doc.ChildNodes[0], getContentHandler);

            List<Pane> addedPanes = new List<Pane>();
            foreach (DockableContent content in Contents)
            {
                DockablePane pane = content.ContainerPane as DockablePane;
                if (pane != null && !addedPanes.Contains(pane))
                {
                    if (pane.State == PaneState.AutoHide)
                    {
                        addedPanes.Add(pane);
                        AddPaneDockingButtons(pane);
                    }
                }
            }

            _currentButton = null;
        }