Beispiel #1
0
        protected virtual void OnStateChanged(DockableContentState oldState, DockableContentState newState)
        {
            RaiseStateChangedEvent(this);

            if (ContainerPane is DockablePane)
            {
                ((DockablePane)ContainerPane).UpdateCanAutohideProperty();
            }
        }
Beispiel #2
0
 /// <summary>
 /// IValueConverter.Convert
 /// </summary>
 /// <param name="value"></param>
 /// <param name="targetType"></param>
 /// <param name="parameter"></param>
 /// <param name="culture"></param>
 /// <returns></returns>
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value != null)
     {
         DockableContentState state = (DockableContentState)value;
         if (state == DockableContentState.Hidden)
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #3
0
 void ShowWindow(DockableContent contentToShow, DockableContentState desideredState)
 {
     if (desideredState == DockableContentState.AutoHide ||
         desideredState == DockableContentState.FloatingWindow)
     {
         _dockingManager.Show(contentToShow, desideredState);
     }
     else
     {
         _dockingManager.Show(contentToShow);
     }
 }
        internal void SetStateToFloatingWindow()
        {
            if (State == DockableContentState.FloatingWindow)
            {
                return;
            }

            Debug.Assert(
                State == DockableContentState.Document ||
                State == DockableContentState.Docked ||
                State == DockableContentState.DockableWindow);

            State = DockableContentState.FloatingWindow;
        }
Beispiel #5
0
 public DockableContentStateAndPosition(
     Guid containerPaneID,
     int childIndex,
     double width,
     double height,
     AnchorStyle anchor,
     DockableContentState state)
 {
     ContainerPaneID = containerPaneID;
     ChildIndex      = childIndex;
     Width           = Math.Max(width, 100.0);
     Height          = Math.Max(height, 100.0);
     Anchor          = anchor;
     State           = state;
 }
        public DockableContentStateAndPosition(
            DockableContent cntToSave)
        {
            ContainerPane = cntToSave.ContainerPane;
            ChildIndex    = ContainerPane.Items.IndexOf(cntToSave);
            Width         = Math.Max(ContainerPane.ActualWidth, 100.0);
            Height        = Math.Max(ContainerPane.ActualHeight, 100.0);
            State         = cntToSave.State;

            DockablePane dockablePane = ContainerPane as DockablePane;

            if (dockablePane != null)
            {
                Anchor = dockablePane.Anchor;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Shows a pad.  If it hasn't been shown before, it shows it
        /// docked to the right side.  Otherwise it restores it to the
        /// previous place that it was before hiding.  Doesn't work
        /// correctly for floating panes (yet).
        /// </summary>
        /// <param name="pad"></param>
        public void ShowPad(IPad pad, DockableContentState desideredState = DockableContentState.Docked)
        {
            if (!m_padLookup.ContainsKey(pad))
            {
                DockableContent content = new DockableContent();
                content.Content = pad;
                content.Title   = pad.Title;
                content.Name    = pad.Name;
                content.Icon    = pad.Icon;
                if (pad.DesideredState == DockableContentState.AutoHide)
                {
                    content.Loaded += new RoutedEventHandler(AutoHideAfterLoaded);
                }
                m_padLookup.Add(pad, content);
                DockablePane dp;
                switch (pad.Location)
                {
                case PadLocation.TopLeft:
                    dp = m_topLeftPane;
                    break;

                case PadLocation.TopRight:
                    dp = m_topRightPane;
                    break;

                case PadLocation.Bottom:
                default:
                    dp = m_bottomPane;
                    break;
                }
                dp.Items.Add(content);

                content.GotFocus  += new RoutedEventHandler(pad.OnGotFocus);
                content.LostFocus += new RoutedEventHandler(pad.OnLostFocus);
            }
            if (desideredState == DockableContentState.AutoHide ||
                desideredState == DockableContentState.FloatingWindow)
            {
                DockManager.Show(m_padLookup[pad], desideredState);
            }
            else
            {
                DockManager.Show(m_padLookup[pad]);
            }
        }
        /// <summary>
        /// Show a dockable content in its container with a desidered state
        /// </summary>
        /// <param name="content">Content to show</param>
        /// <param name="desideredState">State desidered</param>
        /// <param name="desideredAnchor">Border to which anchor the newly created container pane</param>
        /// <remarks></remarks>
        internal void Show(DockableContent content, DockableContentState desideredState, AnchorStyle desideredAnchor)
        {
            Debug.WriteLine(string.Format("Show Content={0}, desideredState={1}, desideredAnchor={2}", content.Name, desideredState, desideredAnchor));

            #region Dockable content

            if (desideredState == DockableContentState.Hidden)//??!!show hidden?
                Hide(content);

            if (content.State == DockableContentState.AutoHide)
            {
                //first redock the content
                (content.ContainerPane as DockablePane).ToggleAutoHide();
                //then show it as desidered
                Show(content, desideredState, desideredAnchor);
            }
            else if (content.State == DockableContentState.Docked ||
                content.State == DockableContentState.Document ||
                content.State == DockableContentState.None)
            {
                if (content.ContainerPane == null ||
                    content.State == DockableContentState.None)
                {
                    //Problem!? try to rescue
                    if (content.State == DockableContentState.Docked ||
                        content.State == DockableContentState.None)
                    {
                        //find the the pane which the desidered anchor style
                        //DockablePane foundPane = this.FindChildDockablePane(desideredAnchor != AnchorStyle.None ? desideredAnchor : AnchorStyle.Right);
                        //first search for a pane with other contents (avoiding empty panes which are containers for hidden contents)
                        ILinqToTree<DependencyObject> itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).IsDocked);

                        if (itemFound == null)//search for all panes (even empty)
                            itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).Items.Count == 0);

                        DockablePane foundPane = itemFound != null ? itemFound.Item as DockablePane : null;

                        if (foundPane != null)
                        {
                            content.SetStateToDock();
                            foundPane.Items.Add(content);
                            var containerPanel = foundPane.Parent as ResizingPanel;
                            if (containerPanel != null)
                                containerPanel.InvalidateMeasure();
                        }
                        else
                        {
                            //if no suitable pane was found create e new one on the fly
                            if (content.ContainerPane != null)
                            {
                                content.ContainerPane.RemoveContent(content);
                            }

                            DockablePane pane = new DockablePane();
                            pane.Items.Add(content);
                            Anchor(pane, desideredAnchor);
                        }
                    }
                    else
                    {
                        //add to main document pane
                        MainDocumentPane.Items.Add(content);
                    }

                }

                if (content.ContainerPane.GetManager() == null)
                {
                    //disconnect the parent pane from previous panel
                    //((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane);
                    if (content.ContainerPane.Parent != null)
                    {
                        ((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane);
                    }

                    Anchor(content.ContainerPane as DockablePane, desideredAnchor);
                }

                if (desideredState == DockableContentState.DockableWindow ||
                     desideredState == DockableContentState.FloatingWindow)
                {
                    var floatingWindow = new DockableFloatingWindow(this);
                    floatingWindow.Content = content;

                    var mainWindow = Window.GetWindow(this);
                    if (mainWindow.IsVisible)
                        floatingWindow.Owner = mainWindow;

                    //floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    //if (content.Content != null)
                    //{
                    //    floatingWindow.Width = Math.Min(((FrameworkElement)content.Content).ActualWidth, ResizingPanel.GetResizeWidth(content.ContainerPane));
                    //    floatingWindow.Height = Math.Min(((FrameworkElement)content.Content).ActualHeight, ResizingPanel.GetResizeHeight(content.ContainerPane));
                    //}
                    //else
                    ////{
                    //    floatingWindow.Width = 400;
                    //    floatingWindow.Height = 400;
                    //}

                    floatingWindow.Show();

                }
                else if (desideredState == DockableContentState.AutoHide)
                {
                    var paneContainer = content.ContainerPane as DockablePane;
                    Debug.Assert(paneContainer != null);

                    if (paneContainer != null)
                        paneContainer.ToggleAutoHide();

                    content.Activate();
                }
                else if (desideredState == DockableContentState.Document)
                {
                    DocumentPane docPane = MainDocumentPane;
                    if (docPane != null)
                    {
                        docPane.Items.Add(content.DetachFromContainerPane());
                        docPane.SelectedItem = content;
                        content.SetStateToDocument();
                    }
                }
                else
                {
                    content.ContainerPane.SelectedItem = content;
                    content.Activate();

                    DockablePane dockParent = content.ContainerPane as DockablePane;
                    if (content.ActualWidth == 0.0 && (
                        dockParent.Anchor == AnchorStyle.Left || dockParent.Anchor == AnchorStyle.Right))
                    {
                        ResizingPanel.SetResizeWidth(dockParent, new GridLength(200));
                        ResizingPanel.SetEffectiveSize(dockParent, new Size(200, 0.0));
                    }
                    else if (content.ActualWidth == 0.0 && (
                        dockParent.Anchor == AnchorStyle.Top || dockParent.Anchor == AnchorStyle.Bottom))
                    {
                        ResizingPanel.SetResizeHeight(dockParent, new GridLength(200));
                        ResizingPanel.SetEffectiveSize(dockParent, new Size(200, 0.0));
                    }

                }
            }
            else if (content.State == DockableContentState.Document)
            {
                if (content.ContainerPane != null)
                    content.ContainerPane.SelectedItem = this;
                content.Activate();
            }
            else if (content.State == DockableContentState.Hidden ||
                content.State == DockableContentState.DockableWindow ||
                content.State == DockableContentState.FloatingWindow)
            {
                if (content.State == DockableContentState.Hidden)
                {
                    //Debug.Assert(HiddenContents.Contains(content));
                    //HiddenContents.Remove(content);
                }
                else
                {
                    FloatingWindow floatingWindow = null;
                    floatingWindow = (content.ContainerPane as FloatingDockablePane).FloatingWindow;
                    content.DetachFromContainerPane();

                    if (floatingWindow.HostedPane.Items.Count == 0)
                        floatingWindow.Close();
                }

                if (desideredState == DockableContentState.Docked ||
                    desideredState == DockableContentState.AutoHide)
                {

                    if (content.SavedStateAndPosition != null &&
                        content.SavedStateAndPosition.ContainerPane != null &&
                        content.SavedStateAndPosition.ChildIndex >= 0 &&
                        content.SavedStateAndPosition.ContainerPane.GetManager() == this &&
                        desideredState == DockableContentState.Docked)
                    {
                        //ok previous container pane is here..
                        Pane prevPane = content.SavedStateAndPosition.ContainerPane;

                        if (content.SavedStateAndPosition.ChildIndex < prevPane.Items.Count)
                        {
                            prevPane.Items.Insert(content.SavedStateAndPosition.ChildIndex, content);
                        }
                        else
                        {
                            prevPane.Items.Add(content);
                        }

                        if (prevPane.Items.Count == 1)
                        {
                            if (!double.IsNaN(content.SavedStateAndPosition.Width) ||
                                !double.IsInfinity(content.SavedStateAndPosition.Width))
                            {
                                ResizingPanel.SetResizeWidth(content,
                                    new GridLength(content.SavedStateAndPosition.Width));
                            }
                        }

                        DockablePane prevDockablePane = prevPane as DockablePane;
                        if (prevDockablePane != null && prevDockablePane.IsAutoHidden)
                        {
                            prevDockablePane.ToggleAutoHide();
                        }

                        content.SetStateToDock();
                        content.Activate();

                        (prevPane.Parent as UIElement).InvalidateMeasure();
                    }
                    else
                    {
                        if (desideredAnchor == AnchorStyle.None &&
                            content.SavedStateAndPosition != null &&
                            content.SavedStateAndPosition.Anchor != AnchorStyle.None)
                            desideredAnchor = content.SavedStateAndPosition.Anchor;

                        if (desideredAnchor == AnchorStyle.None)
                            desideredAnchor = AnchorStyle.Right;

                        DockablePane foundPane = null;

                        if (desideredState == DockableContentState.Docked)
                        {
                            //first not empty panes
                            ILinqToTree<DependencyObject> itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).IsDocked);

                            if (itemFound == null)//look for all panes even empty
                                itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).Items.Count == 0);

                            foundPane = itemFound != null ? itemFound.Item as DockablePane : null;
                        }

                        if (foundPane != null)
                        {
                            content.SetStateToDock();
                            foundPane.Items.Add(content);

                            if ((foundPane.IsAutoHidden && desideredState == DockableContentState.Docked) ||
                                 (!foundPane.IsAutoHidden && desideredState == DockableContentState.AutoHide))
                                foundPane.ToggleAutoHide();
                        }
                        else
                        {
                            DockablePane newHostpane = new DockablePane();
                            newHostpane.Items.Add(content);

                            if (desideredAnchor == AnchorStyle.Left ||
                                desideredAnchor == AnchorStyle.Right)
                            {
                                double w = 200;
                                if (content.SavedStateAndPosition != null &&
                                    !double.IsInfinity(content.SavedStateAndPosition.Width) &&
                                    !double.IsNaN(content.SavedStateAndPosition.Width))
                                    w = content.SavedStateAndPosition.Width;

                                ResizingPanel.SetResizeWidth(newHostpane, new GridLength(w));
                                ResizingPanel.SetEffectiveSize(newHostpane, new Size(w, 0.0));
                            }
                            else
                            {
                                double h = 200;
                                if (content.SavedStateAndPosition != null &&
                                    !double.IsInfinity(content.SavedStateAndPosition.Height) &&
                                    !double.IsNaN(content.SavedStateAndPosition.Height))
                                    h = content.SavedStateAndPosition.Height;

                                ResizingPanel.SetResizeHeight(newHostpane, new GridLength(h));
                                ResizingPanel.SetEffectiveSize(newHostpane, new Size(0.0, h));
                            }

                            Anchor(newHostpane, desideredAnchor);

                            if (desideredState == DockableContentState.AutoHide)
                            {
                                ToggleAutoHide(newHostpane);
                            }
                        }
                    }

                    ActiveContent = content;
                }
                else if (desideredState == DockableContentState.DockableWindow ||
                    desideredState == DockableContentState.FloatingWindow)
                {
                    DockablePane newHostpane = null;
                    FloatingDockablePane prevHostpane = null;
                    if (content.SavedStateAndPosition != null && content.SavedStateAndPosition.ContainerPane != null && content.SavedStateAndPosition.ContainerPane is FloatingDockablePane)
                    {
                        prevHostpane = content.SavedStateAndPosition.ContainerPane as FloatingDockablePane;
                        if (!prevHostpane.Items.Contains(content))
                            prevHostpane.Items.Add(content);
                    }
                    else
                    {
                        newHostpane = new DockablePane();
                        newHostpane.Items.Add(content);

                    }

                    if (desideredState == DockableContentState.DockableWindow)
                        content.SetStateToDockableWindow();
                    else if (desideredState == DockableContentState.FloatingWindow)
                        content.SetStateToFloatingWindow();

                    if (prevHostpane != null)
                    {
                        //check to see if floating window that host prevHostPane is already loaded (hosting other contents)
                        var floatingWindow = prevHostpane.Parent as DockableFloatingWindow;
                        if (floatingWindow != null && floatingWindow.IsLoaded)
                        {
                            floatingWindow.Activate();
                        }
                        else
                        {
                            floatingWindow = new DockableFloatingWindow(this);
                            floatingWindow.Content = content;
                            floatingWindow.WindowStartupLocation = WindowStartupLocation.Manual;
                            floatingWindow.Top = prevHostpane.FloatingWindow.Top;
                            floatingWindow.Left = prevHostpane.FloatingWindow.Left;
                            floatingWindow.Width = prevHostpane.FloatingWindow.Width;
                            floatingWindow.Height = prevHostpane.FloatingWindow.Height;
                            //floatingWindow.Owner = Window.GetWindow(this);
                            var mainWindow = Window.GetWindow(this);
                            if (mainWindow.IsVisible)
                                floatingWindow.Owner = mainWindow;

                            //now I've created a new pane to host the hidden content
                            //if a an hidden content is shown that has prevHostpane as saved pane
                            //I want that it is relocated in this new pane that I've created right now
                            var hiddenContents = DockableContents.Where(c => c.State == DockableContentState.Hidden).ToArray();
                            foreach (var hiddenContent in hiddenContents)
                            {
                                if (hiddenContent.SavedStateAndPosition.ContainerPane == prevHostpane)
                                {
                                    hiddenContent.SavedStateAndPosition = new DockableContentStateAndPosition(
                                        (floatingWindow.Content as Pane),
                                        hiddenContent.SavedStateAndPosition.ChildIndex,
                                        hiddenContent.SavedStateAndPosition.Width,
                                        hiddenContent.SavedStateAndPosition.Height,
                                        hiddenContent.SavedStateAndPosition.Anchor,
                                        hiddenContent.SavedStateAndPosition.State);
                                }
                            }

                            floatingWindow.Show();
                        }
                    }
                    else if (newHostpane != null)
                    {
                        var floatingWindow = new DockableFloatingWindow(this);
                        floatingWindow.Content = newHostpane;
                        floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        floatingWindow.Width = 200;
                        floatingWindow.Height = 500;
                        //floatingWindow.Owner = Window.GetWindow(this);
                        var mainWindow = Window.GetWindow(this);
                        if (mainWindow.IsVisible)
                            floatingWindow.Owner = mainWindow;

                        floatingWindow.Show();
                    }

                }
                else if (desideredState == DockableContentState.Document)
                {
                    DocumentPane docPane = MainDocumentPane;
                    if (docPane != null)
                    {
                        docPane.Items.Add(content);
                        docPane.SelectedItem = content;
                        content.SetStateToDocument();
                    }
                }
            }

               #endregion
        }
 /// <summary>
 /// Show a dockable content in its container with a desidered state
 /// </summary>
 /// <param name="content">Content to show</param>
 /// <param name="desideredState">State desidered</param>
 internal void Show(DockableContent content, DockableContentState desideredState)
 {
     Show(content, desideredState, AnchorStyle.None);
 }
        protected virtual void OnStateChanged(DockableContentState oldState, DockableContentState newState)
        {
            RaiseStateChangedEvent(this);

            if (ContainerPane is DockablePane)
                ((DockablePane)ContainerPane).UpdateCanAutohideProperty();
        }
       public DockableContentStateAndPosition(
            DockableContent cntToSave)
        {
            ContainerPane = cntToSave.ContainerPane;
            ChildIndex = ContainerPane.Items.IndexOf(cntToSave);
            Width = Math.Max(ContainerPane.ActualWidth, 100.0);
            Height = Math.Max(ContainerPane.ActualHeight, 100.0);
            State = cntToSave.State;

            DockablePane dockablePane = ContainerPane as DockablePane;
            if (dockablePane != null)
            {
                Anchor = dockablePane.Anchor;
            }
        }
 public DockableContentStateAndPosition(
     Guid containerPaneID,
     int childIndex,
     double width,
     double height,
     AnchorStyle anchor,
     DockableContentState state)
 {
     ContainerPaneID = containerPaneID;
     ChildIndex = childIndex;
     Width = Math.Max(width, 100.0);
     Height = Math.Max(height, 100.0);
     Anchor = anchor;
     State = state;
 }
 internal void SetStateToAutoHide()
 {
     State = DockableContentState.AutoHide;
 }
 internal void SetStateToDock()
 {
     State = DockableContentState.Docked;
 }
Beispiel #15
0
 void ShowWindow(DockableContent contentToShow, DockableContentState desideredState)
 {
     if (desideredState == DockableContentState.AutoHide ||
         desideredState == DockableContentState.FloatingWindow)
     {
         _dockingManager.Show(contentToShow, desideredState);
     }
     else
         _dockingManager.Show(contentToShow);
 }
 internal void SetStateToHidden()
 {
     State = DockableContentState.Hidden;
 }
 internal void SetStateToDocument()
 {
     State = DockableContentState.Document;
 }
 public static void SetState(DockableContent element, DockableContentState value)
 {
     element.SetValue(StateProperty, value);
 }
Beispiel #19
0
 private void SetVisibilityOfDockableContents(DockableContent dc, DockableContentState state)
 {
     if (state == DockableContentState.Hidden)
     {
         dc.Visibility = Visibility.Hidden;
     }
 }