示例#1
0
        internal void AddContent(CrownDockContent dockContent, CrownDockGroup dockGroup)
        {
            // If no existing group is specified then create a new one
            if (dockGroup == null)
            {
                // If this is the document region, then default to first group if it exists
                if (DockArea == DockArea.Document && _groups.Count > 0)
                {
                    dockGroup = _groups[0];
                }
                else
                {
                    dockGroup = CreateGroup();
                }
            }

            dockContent.DockRegion = this;
            dockGroup.AddContent(dockContent);

            if (!Visible)
            {
                Visible = true;
                CreateSplitter();
            }

            PositionGroups();
        }
示例#2
0
        internal void RemoveContent(CrownDockContent dockContent)
        {
            dockContent.DockRegion = null;

            CrownDockGroup group = dockContent.DockGroup;

            group.RemoveContent(dockContent);

            dockContent.DockArea = DockArea.None;

            // If that was the final content in the group then remove the group
            if (group.ContentCount == 0)
            {
                RemoveGroup(group);
            }

            // If we just removed the final group, and this isn't the document region, then hide
            if (_groups.Count == 0 && DockArea != DockArea.Document)
            {
                Visible = false;
                RemoveSplitter();
            }

            PositionGroups();
        }
示例#3
0
        internal DockDropArea(CrownDockPanel dockPanel, CrownDockGroup group, DockInsertType insertType)
        {
            DockPanel  = dockPanel;
            DockGroup  = group;
            InsertType = insertType;

            BuildAreas();
        }
示例#4
0
        private void RemoveGroup(CrownDockGroup group)
        {
            int lastOrder = group.Order;

            _groups.Remove(group);
            Controls.Remove(group);

            foreach (CrownDockGroup otherGroup in _groups)
            {
                if (otherGroup.Order > lastOrder)
                {
                    otherGroup.Order--;
                }
            }
        }
示例#5
0
        private void PositionGroups()
        {
            DockStyle dockStyle;

            switch (DockArea)
            {
            default:
            case DockArea.Document:
                dockStyle = DockStyle.Fill;
                break;

            case DockArea.Left:
            case DockArea.Right:
                dockStyle = DockStyle.Top;
                break;

            case DockArea.Bottom:
                dockStyle = DockStyle.Left;
                break;
            }

            if (_groups.Count == 1)
            {
                _groups[0].Dock = DockStyle.Fill;
                return;
            }

            if (_groups.Count > 1)
            {
                CrownDockGroup lastGroup = _groups.OrderByDescending(g => g.Order).First();

                foreach (CrownDockGroup group in _groups.OrderByDescending(g => g.Order))
                {
                    group.SendToBack();

                    if (group.Order == lastGroup.Order)
                    {
                        group.Dock = DockStyle.Fill;
                    }
                    else
                    {
                        group.Dock = dockStyle;
                    }
                }

                SizeGroups();
            }
        }
示例#6
0
        private CrownDockGroup InsertGroup(int order)
        {
            foreach (CrownDockGroup group in _groups)
            {
                if (group.Order >= order)
                {
                    group.Order++;
                }
            }

            CrownDockGroup newGroup = new CrownDockGroup(DockPanel, this, order);

            _groups.Add(newGroup);
            Controls.Add(newGroup);

            return(newGroup);
        }
示例#7
0
        internal void InsertContent(CrownDockContent dockContent, CrownDockGroup dockGroup, DockInsertType insertType)
        {
            int order = dockGroup.Order;

            if (insertType == DockInsertType.After)
            {
                order++;
            }

            CrownDockGroup newGroup = InsertGroup(order);

            dockContent.DockRegion = this;
            newGroup.AddContent(dockContent);

            if (!Visible)
            {
                Visible = true;
                CreateSplitter();
            }

            PositionGroups();
        }
示例#8
0
        private CrownDockGroup CreateGroup()
        {
            int order = 0;

            if (_groups.Count >= 1)
            {
                order = -1;
                foreach (CrownDockGroup group in _groups)
                {
                    if (group.Order >= order)
                    {
                        order = group.Order + 1;
                    }
                }
            }

            CrownDockGroup newGroup = new CrownDockGroup(DockPanel, this, order);

            _groups.Add(newGroup);
            Controls.Add(newGroup);

            return(newGroup);
        }
示例#9
0
        private void PositionGroups()
        {
            DockStyle dockStyle = DockArea switch
            {
                DockArea.Left or DockArea.Right => DockStyle.Top,
                      DockArea.Bottom => DockStyle.Left,
                      _ => DockStyle.Fill,
            };

            if (_groups.Count == 1)
            {
                _groups[0].Dock = DockStyle.Fill;
                return;
            }

            if (_groups.Count > 1)
            {
                CrownDockGroup lastGroup = _groups.OrderByDescending(g => g.Order).First();

                foreach (CrownDockGroup group in _groups.OrderByDescending(g => g.Order))
                {
                    group.SendToBack();

                    if (group.Order == lastGroup.Order)
                    {
                        group.Dock = DockStyle.Fill;
                    }
                    else
                    {
                        group.Dock = dockStyle;
                    }
                }

                SizeGroups();
            }
        }
示例#10
0
 internal DockDropCollection(CrownDockPanel dockPanel, CrownDockGroup group)
 {
     DropArea         = new DockDropArea(dockPanel, group, DockInsertType.None);
     InsertBeforeArea = new DockDropArea(dockPanel, group, DockInsertType.Before);
     InsertAfterArea  = new DockDropArea(dockPanel, group, DockInsertType.After);
 }