Пример #1
0
        internal void AddContent(DarkDockContent dockContent, DarkDockGroup 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 == DarkDockArea.Document && _groups.Count > 0)
                {
                    dockGroup = _groups[0];
                }
                else
                {
                    dockGroup = CreateGroup();
                }
            }

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

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

            RebuildGroupSplitters();
            PositionGroups();
        }
Пример #2
0
        internal void RemoveContent(DarkDockContent dockContent)
        {
            dockContent.DockRegion = null;

            var group = dockContent.DockGroup;

            group.RemoveContent(dockContent);

            dockContent.DockArea = DarkDockArea.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 != DarkDockArea.Document)
            {
                Visible = false;
                RemoveSplitter();
            }

            RebuildGroupSplitters();
            PositionGroups();
        }
Пример #3
0
        public void AddContent(DarkDockContent dockContent, DarkDockGroup dockGroup)
        {
            if (_contents.Contains(dockContent))
            {
                RemoveContent(dockContent);
            }

            dockContent.DockPanel = this;
            _contents.Add(dockContent);

            if (dockGroup != null)
            {
                dockContent.DockArea = dockGroup.DockArea;
            }

            if (dockContent.DockArea == DarkDockArea.None)
            {
                dockContent.DockArea = dockContent.DefaultDockArea;
            }

            var region = _regions[dockContent.DockArea];

            region.AddContent(dockContent, dockGroup);

            ContentAdded?.Invoke(this, new DockContentEventArgs(dockContent));

            dockContent.Select();
        }
Пример #4
0
        public void AddContent(DarkDockContent dockContent)
        {
            dockContent.DockGroup = this;
            dockContent.Dock      = DockStyle.Fill;

            dockContent.Order = 0;

            if (_contents.Count > 0)
            {
                var order = -1;
                foreach (var otherContent in _contents)
                {
                    if (otherContent.Order >= order)
                    {
                        order = otherContent.Order + 1;
                    }
                }

                dockContent.Order = order;
            }

            _contents.Add(dockContent);
            _tabs.Add(dockContent, new DarkDockTab(dockContent));

            var size = CalculateGroupSize();

            Controls.Add(dockContent);

            dockContent.DockTextChanged += DockContent_DockTextChanged;

            if (VisibleContent == null)
            {
                dockContent.Visible = true;
                VisibleContent      = dockContent;
            }
            else
            {
                dockContent.Visible = false;
            }

            var menuItem = new ToolStripMenuItem(dockContent.DockText)
            {
                Tag = dockContent
            };

            menuItem.Click += TabMenuItem_Select;
            menuItem.Image  = dockContent.Icon;
            _tabArea.AddMenuItem(menuItem);

            Size = size;

            UpdateTabArea();
        }
Пример #5
0
        public void RemoveContent(DarkDockContent dockContent)
        {
            if (!_contents.Contains(dockContent))
            {
                return;
            }

            dockContent.DockPanel = null;
            _contents.Remove(dockContent);

            var region = _regions[dockContent.DockArea];

            region.RemoveContent(dockContent);

            ContentRemoved?.Invoke(this, new DockContentEventArgs(dockContent));
        }
Пример #6
0
        public void RemoveContent(DarkDockContent dockContent)
        {
            dockContent.DockGroup = null;

            var order = dockContent.Order;

            _contents.Remove(dockContent);
            Controls.Remove(dockContent);

            foreach (var otherContent in _contents)
            {
                if (otherContent.Order > order)
                {
                    otherContent.Order--;
                }
            }

            dockContent.DockTextChanged -= DockContent_DockTextChanged;

            if (_tabs.ContainsKey(dockContent))
            {
                _tabs.Remove(dockContent);
            }

            if (VisibleContent == dockContent)
            {
                VisibleContent = null;

                if (_contents.Count > 0)
                {
                    var newContent = _contents[0];
                    newContent.Visible = true;
                    VisibleContent     = newContent;
                }
            }

            var menuItem = _tabArea.GetMenuItem(dockContent);

            menuItem.Click -= TabMenuItem_Select;
            _tabArea.RemoveMenuItem(menuItem);

            Size = CalculateGroupSize();

            UpdateTabArea();
        }
Пример #7
0
        public void InsertContent(DarkDockContent dockContent, DarkDockGroup dockGroup, DockInsertType insertType)
        {
            if (_contents.Contains(dockContent))
            {
                RemoveContent(dockContent);
            }

            dockContent.DockPanel = this;
            _contents.Add(dockContent);

            dockContent.DockArea = dockGroup.DockArea;

            var region = _regions[dockGroup.DockArea];

            region.InsertContent(dockContent, dockGroup, insertType);

            ContentAdded?.Invoke(this, new DockContentEventArgs(dockContent));

            dockContent.Select();
        }
Пример #8
0
        public ToolStripMenuItem GetMenuItem(DarkDockContent content)
        {
            ToolStripMenuItem menuItem = null;

            foreach (ToolStripMenuItem item in _menuItems)
            {
                var menuContent = item.Tag as DarkDockContent;
                if (menuContent == null)
                {
                    continue;
                }

                if (menuContent == content)
                {
                    menuItem = item;
                }
            }

            return(menuItem);
        }
Пример #9
0
        internal void InsertContent(DarkDockContent dockContent, DarkDockGroup dockGroup, DockInsertType insertType)
        {
            var order = dockGroup.Order;

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

            var newGroup = InsertGroup(order);

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

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

            RebuildGroupSplitters();
            PositionGroups();
        }
Пример #10
0
        public void SetVisibleContent(DarkDockContent content)
        {
            if (!_contents.Contains(content))
            {
                return;
            }

            if (VisibleContent != content)
            {
                VisibleContent  = content;
                content.Visible = true;

                foreach (var otherContent in _contents)
                {
                    if (otherContent != content)
                    {
                        otherContent.Visible = false;
                    }
                }

                Invalidate();
            }
        }
Пример #11
0
        public void RestoreDockPanelState(DockPanelState state, Func <string, DarkDockContent> getContentBySerializationKey)
        {
            SuspendLayout();

            foreach (var region in state.Regions.OrderByDescending(r => r.Area))
            {
                switch (region.Area)
                {
                case DarkDockArea.Left:
                    _regions[DarkDockArea.Left].Size = region.Size;
                    break;

                case DarkDockArea.Right:
                    _regions[DarkDockArea.Right].Size = region.Size;
                    break;

                case DarkDockArea.Bottom:
                    _regions[DarkDockArea.Bottom].Size = region.Size;
                    break;
                }

                region.Groups.Sort(delegate(DockGroupState a, DockGroupState b) { return(a.Order.CompareTo(b.Order)); });

                foreach (var group in region.Groups)
                {
                    DarkDockContent previousContent = null;
                    DarkDockContent visibleContent  = null;

                    foreach (var contentKey in group.Contents)
                    {
                        var content = getContentBySerializationKey(contentKey);

                        if (content == null)
                        {
                            continue;
                        }

                        content.DockArea = region.Area;

                        if (previousContent == null)
                        {
                            AddContent(content);
                        }
                        else
                        {
                            AddContent(content, previousContent.DockGroup);
                        }

                        previousContent = content;

                        if (group.VisibleContent == contentKey)
                        {
                            visibleContent = content;
                        }
                    }

                    if (visibleContent != null)
                    {
                        visibleContent.Select();
                        visibleContent.DockGroup.Size = group.Size;
                    }
                }
            }

            ResumeLayout();
        }
Пример #12
0
 public void DragContent(DarkDockContent content)
 {
     DockContentDragFilter.StartDrag(content);
 }
Пример #13
0
 public bool ContainsContent(DarkDockContent dockContent)
 {
     return(_contents.Contains(dockContent));
 }
Пример #14
0
 internal void AddContent(DarkDockContent dockContent)
 {
     AddContent(dockContent, null);
 }
Пример #15
0
 public void AddContent(DarkDockContent dockContent)
 {
     AddContent(dockContent, null);
 }
Пример #16
0
 public DockContentEventArgs(DarkDockContent content)
 {
     Content = content;
 }
Пример #17
0
 public DarkDockTab(DarkDockContent content)
 {
     DockContent = content;
 }