예제 #1
0
            internal void ResolvePeerRelationships(Dictionary <int, DockableCollection> dockableCollections, DockableCollection dockableCollection)
            {
                LayoutContext dockableCollectionLayoutContext = DockingPanel.GetLayoutContext(dockableCollection);

                dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Bottom].PhysicalNeighbors.Clear();
                foreach (int internalId in BottomPeers)
                {
                    DockableCollection peer = dockableCollections[internalId];
                    LayoutContext      peerLayoutContext = DockingPanel.GetLayoutContext(peer);
                    dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Bottom].PhysicalNeighbors.AddLast(peerLayoutContext);
                }
                dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Left].PhysicalNeighbors.Clear();
                foreach (int internalId in LeftPeers)
                {
                    DockableCollection peer = dockableCollections[internalId];
                    LayoutContext      peerLayoutContext = DockingPanel.GetLayoutContext(peer);
                    dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Left].PhysicalNeighbors.AddLast(peerLayoutContext);
                }
                dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Right].PhysicalNeighbors.Clear();
                foreach (int internalId in RightPeers)
                {
                    DockableCollection peer = dockableCollections[internalId];
                    LayoutContext      peerLayoutContext = DockingPanel.GetLayoutContext(peer);
                    dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Right].PhysicalNeighbors.AddLast(peerLayoutContext);
                }
                dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Top].PhysicalNeighbors.Clear();
                foreach (int internalId in TopPeers)
                {
                    DockableCollection peer = dockableCollections[internalId];
                    LayoutContext      peerLayoutContext = DockingPanel.GetLayoutContext(peer);
                    dockableCollectionLayoutContext.Edges[System.Windows.Controls.Dock.Top].PhysicalNeighbors.AddLast(peerLayoutContext);
                }
            }
예제 #2
0
            private void SavePeerLinkages()
            {
                //  Load the DockableCollections into a dictionary for fast access

                Dictionary <DockableCollection, int> dockableCollections = new Dictionary <DockableCollection, int>();

                foreach (DockableCollectionDescriptor desc in DockedCollections)
                {
                    dockableCollections.Add(desc.DockableCollection, desc.InternalId);
                }

                //  Now save the peer linkages for each DockableCollection

                foreach (DockableCollectionDescriptor desc in DockedCollections)
                {
                    foreach (LayoutContext layoutContext in DockingPanel.GetLayoutContext(desc.DockableCollection).Edges[System.Windows.Controls.Dock.Bottom].PhysicalNeighbors)
                    {
                        desc.BottomPeers.Add(dockableCollections[layoutContext.DockableCollection as DockableCollection]);
                    }
                    foreach (LayoutContext layoutContext in DockingPanel.GetLayoutContext(desc.DockableCollection).Edges[System.Windows.Controls.Dock.Left].PhysicalNeighbors)
                    {
                        desc.LeftPeers.Add(dockableCollections[layoutContext.DockableCollection as DockableCollection]);
                    }
                    foreach (LayoutContext layoutContext in DockingPanel.GetLayoutContext(desc.DockableCollection).Edges[System.Windows.Controls.Dock.Right].PhysicalNeighbors)
                    {
                        desc.RightPeers.Add(dockableCollections[layoutContext.DockableCollection as DockableCollection]);
                    }
                    foreach (LayoutContext layoutContext in DockingPanel.GetLayoutContext(desc.DockableCollection).Edges[System.Windows.Controls.Dock.Top].PhysicalNeighbors)
                    {
                        desc.TopPeers.Add(dockableCollections[layoutContext.DockableCollection as DockableCollection]);
                    }
                }
            }
예제 #3
0
            internal DockableCollection Create(Dock dock, DockableContextContentCreator contentCreator)
            {
                DockableCollection newCollection = new DockableCollection()
                {
                    Description = this.Description,
                    HorizontalContentAlignment = this.HorizontalContentAlignment,
                    State       = this.State,
                    TabPosition = this.TabPosition,
                    VerticalContentAlignment = this.VerticalContentAlignment,
                };

                DockingPanel.SetDockPosition(newCollection, this.DockPosition);

                if (newCollection.IsCollapsed)
                {
                    newCollection.CollapsedTabPosition = this.CollapsedTabPosition;
                }

                foreach (DockableContentDescriptor desc in Content)
                {
                    FrameworkElement content = desc.RestoreDockedLayout(newCollection, contentCreator);
                    if (content != null && desc.InternalId == CurrentTab)
                    {
                        newCollection.SetVisibleContent(content);
                    }
                }
                dock.Items.Add(newCollection);

                if (!newCollection.IsCollapsed)
                {
                    LayoutContext layoutContext = DockingPanel.GetLayoutContext(newCollection);
                    layoutContext.Left = Left;
                    layoutContext.Top  = Top;
                    if (IsHeightSplitterActive)
                    {
                        layoutContext.Size.Height.SetSplitter(LayoutHeight.Value);
                    }
                    else
                    {
                        layoutContext.Size.Height.SetInternalValue(LayoutHeight);
                    }
                    if (IsWidthSplitterActive)
                    {
                        layoutContext.Size.Width.SetSplitter(LayoutWidth.Value);
                    }
                    else
                    {
                        layoutContext.Size.Width.SetInternalValue(LayoutWidth);
                    }
                    layoutContext.Size.Height.SetUserValue(Height.Value);
                    layoutContext.Size.Width.SetUserValue(Width.Value);
                }

                return(newCollection);
            }
예제 #4
0
            public DockableCollectionDescriptor(DockableCollection dockableCollection, DockDescriptor dock, int internalId)
            {
                DockableCollection = dockableCollection;
                Description        = dockableCollection.Description;
                DockPosition       = DockingPanel.GetDockPosition(dockableCollection);
                State       = dockableCollection.State;
                TabPosition = dockableCollection.TabPosition;
                HorizontalContentAlignment = dockableCollection.HorizontalContentAlignment;
                VerticalContentAlignment   = dockableCollection.VerticalContentAlignment;

                if (dockableCollection.IsCollapsed)
                {
                    CollapsedTabPosition = dockableCollection.CollapsedTabPosition;
                }
                else
                {
                    LayoutContext layoutContext = DockingPanel.GetLayoutContext(dockableCollection);
                    Left                   = layoutContext.Left.Value;
                    Top                    = layoutContext.Top.Value;
                    LayoutHeight           = layoutContext.Size.Height.HasInternalValue ? layoutContext.Size.Height.InternalValue : (double?)null;
                    LayoutWidth            = layoutContext.Size.Width.HasInternalValue ? layoutContext.Size.Width.InternalValue : (double?)null;
                    Height                 = layoutContext.Size.Height.UserValue;
                    Width                  = layoutContext.Size.Width.UserValue;
                    IsHeightSplitterActive = layoutContext.Size.Height.IsSplitterActive;
                    IsWidthSplitterActive  = layoutContext.Size.Width.IsSplitterActive;
                }

                BottomPeers = new List <int>();
                LeftPeers   = new List <int>();
                RightPeers  = new List <int>();
                TopPeers    = new List <int>();
                Content     = new List <DockableContentDescriptor>();

                InternalId = internalId;

                dock.DockedCollections.Add(this);

                int contentId = 1;

                foreach (FrameworkElement dockableContent in dockableCollection.Items)
                {
                    if (dockableCollection.VisibleContent == dockableContent)
                    {
                        CurrentTab = contentId;
                    }
                    new DockableContentDescriptor(dockableContent, this, contentId++);
                }
            }
예제 #5
0
            internal FrameworkElement RestoreDockedLayout(DockableCollection newCollection, DockableContextContentCreator contentCreator)
            {
                FrameworkElement content = null;

                if (contentCreator != null)
                {
                    content = contentCreator.Invoke(TypeName, Description);
                    if (content == null)
                    {
                        return(null);
                    }
                }

                SetContentColors(content, this.Background, this.Foreground);

                DockingPanel.SetTabText(content, TabText);
                DockingPanel.SetDescriptiveText(content, Description);

                newCollection.Items.Add(content);

                return(content);
            }
예제 #6
0
            public DockableContentDescriptor(FrameworkElement content, DockableCollectionDescriptor dockableCollection, int internalId)
            {
                TabText    = DockingPanel.GetTabText(content);
                InternalId = internalId;

                SerializableColor?backgroundColor = GetColorFromContent(content, "Background");
                SerializableColor?foregroundColor = GetColorFromContent(content, "Foreground");

                if (backgroundColor.HasValue)
                {
                    Background = backgroundColor.Value;
                }
                if (foregroundColor.HasValue)
                {
                    Foreground = foregroundColor.Value;
                }

                TypeName    = content.GetType().ToString();
                Description = DockingPanel.GetDescriptiveText(content);

                dockableCollection.Content.Add(this);
            }
예제 #7
0
 internal Activity(DockingPanel dockingPanel)
 {
     DockingPanel = dockingPanel;
     DockingPanel.StartActivity();
 }
예제 #8
0
        internal static void InvalidateNeighbors(DockingPanel dockingPanel, LayoutContext root, System.Windows.Controls.Dock edge)
        {
#if true
            DockableCollectionEdge workingEdge = root.Edges[edge];
            if (workingEdge.LogicalReplacements != null)
            {
                foreach (LayoutContext layoutContext in workingEdge.LogicalReplacements)
                {
                    layoutContext.InvalidatePositioning(LayoutContext.DockPositionToPositionClass[edge]);
                }
            }
#else
            HashSet <LayoutContext> neighbors                      = new HashSet <LayoutContext>(root.Edges[edge].PhysicalNeighbors);
            HashSet <LayoutContext> preceedingNeighbors            = new HashSet <LayoutContext>();
            HashSet <LayoutContext> rootsClockwiseNeighbors        = new HashSet <LayoutContext>(root.Edges[LayoutContext.ClockwisePeers[edge]].PhysicalNeighbors);
            HashSet <LayoutContext> rootsCounterClockwiseNeighbors = new HashSet <LayoutContext>(root.Edges[LayoutContext.CounterClockwisePeers[edge]].PhysicalNeighbors);

            preceedingNeighbors.Add(root);

            for (LayoutContext clockwiseNeighbor = root.Edges[LayoutContext.ClockwisePeers[edge]].PhysicalNeighbors.FirstOrDefault();
                 clockwiseNeighbor != null && clockwiseNeighbor.DockableCollection.IsCollapsed;
                 clockwiseNeighbor = clockwiseNeighbor.Edges[LayoutContext.ClockwisePeers[edge]].PhysicalNeighbors.FirstOrDefault())
            {
                HashSet <LayoutContext> neighborsPeers = new HashSet <LayoutContext>(clockwiseNeighbor.Edges[edge].PhysicalNeighbors);
                if (neighbors.SetEquals(neighborsPeers))
                {
                    preceedingNeighbors.Add(clockwiseNeighbor);
                    rootsClockwiseNeighbors = new HashSet <LayoutContext>(clockwiseNeighbor.Edges[LayoutContext.ClockwisePeers[edge]].PhysicalNeighbors);
                }
                else
                {
                    break;
                }
            }

            for (LayoutContext counterClockwiseNeighbor = root.Edges[LayoutContext.CounterClockwisePeers[edge]].PhysicalNeighbors.FirstOrDefault();
                 counterClockwiseNeighbor != null && counterClockwiseNeighbor.DockableCollection.IsCollapsed;
                 counterClockwiseNeighbor = counterClockwiseNeighbor.Edges[LayoutContext.CounterClockwisePeers[edge]].PhysicalNeighbors.FirstOrDefault())
            {
                HashSet <LayoutContext> neighborsPeers = new HashSet <LayoutContext>(counterClockwiseNeighbor.Edges[edge].PhysicalNeighbors);
                if (neighbors.SetEquals(neighborsPeers))
                {
                    preceedingNeighbors.Add(counterClockwiseNeighbor);
                    rootsCounterClockwiseNeighbors = new HashSet <LayoutContext>(counterClockwiseNeighbor.Edges[LayoutContext.CounterClockwisePeers[edge]].PhysicalNeighbors);
                }
                else
                {
                    break;
                }
            }

            int neighborCount = root.Edges[edge].PhysicalNeighbors.Count();

            while (neighborCount > 0)
            {
                //  First, check if the neighbors are members of the silo

                int collapsedNeighbors    = 0;
                int noncollapsedNeighbors = 0;


                foreach (LayoutContext neighbor in neighbors)
                {
                    HashSet <LayoutContext> opposingPeers = new HashSet <LayoutContext>(neighbor.Edges[LayoutContext.OpposingNeighbors[edge]].PhysicalNeighbors);
                    if (!opposingPeers.IsSubsetOf(preceedingNeighbors))
                    {
                        return(false);
                    }

                    HashSet <LayoutContext> clockwiseNeighbors = new HashSet <LayoutContext>(neighbor.Edges[LayoutContext.ClockwisePeers[edge]].PhysicalNeighbors);
                    if (!clockwiseNeighbors.IsSubsetOf(rootsClockwiseNeighbors))
                    {
                        return(false);
                    }

                    HashSet <LayoutContext> counterClockwiseNeighbors = new HashSet <LayoutContext>(neighbor.Edges[LayoutContext.CounterClockwisePeers[edge]].PhysicalNeighbors);
                    if (!counterClockwiseNeighbors.IsSubsetOf(rootsCounterClockwiseNeighbors))
                    {
                        return(false);
                    }

                    //  The neighbor is a member of the silo

                    if (neighbor.DockableCollection.IsCollapsed)
                    {
                        collapsedNeighbors++;
                    }
                    else
                    {
                        noncollapsedNeighbors++;
                    }
                }

                //  If all the neighbors are collapsed, continue the scan with their neighbors

                if (collapsedNeighbors == neighborCount)
                {
                    preceedingNeighbors = neighbors;
                    neighbors           = new HashSet <LayoutContext>();
                    foreach (LayoutContext neighbor in preceedingNeighbors)
                    {
                        neighbors.UnionWith(neighbor.Edges[edge].PhysicalNeighbors);
                    }
                    neighborCount = neighbors.Count();
                }
                else if (noncollapsedNeighbors == neighborCount)
                {
                    // Non of the peers are collapsed, so all can be invalidated

                    foreach (LayoutContext neighbor in neighbors)
                    {
                        neighbor.InvalidatePositioning(LayoutContext.DockPositionToPositionClass[edge]);
                    }
                    return(true);
                }
                else
                {
                    //  Some neighbors are collapsed, some are not

                    return(false);
                }
            }

            return(false);
#endif
        }