Esempio n. 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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        internal DockDropArea(DarkDockPanel dockPanel, DarkDockGroup group, DockInsertType insertType)
        {
            DockPanel  = dockPanel;
            DockGroup  = group;
            InsertType = insertType;

            BuildAreas();
        }
Esempio n. 4
0
        private bool CropLargestGroup(int spaceToCut)
        {
            DarkDockGroup largestGroup = null;

            if (_groups.Count <= 1 || spaceToCut == 0 || DockArea == DarkDockArea.Document)
            {
                return(false);
            }

            int maxSize = 0;

            switch (DockArea)
            {
            default:
                return(false);

            case DarkDockArea.Left:
            case DarkDockArea.Right:
                foreach (var group in _groups)
                {
                    if (group.Height > maxSize && group.Height > group.MinimumSize.Height)
                    {
                        maxSize      = group.Height;
                        largestGroup = group;
                    }
                }
                if (largestGroup != null && largestGroup.Size.Height > spaceToCut && largestGroup.Size.Height > largestGroup.MinimumSize.Height)
                {
                    largestGroup.Size = new Size(largestGroup.Size.Width, largestGroup.Size.Height - spaceToCut);
                    return(true);
                }
                break;

            case DarkDockArea.Bottom:
                foreach (var group in _groups)
                {
                    if (group.Width > maxSize && group.Width > group.MinimumSize.Width)
                    {
                        maxSize      = group.Width;
                        largestGroup = group;
                    }
                }
                if (largestGroup != null && largestGroup.Size.Width > spaceToCut && largestGroup.Size.Width > largestGroup.MinimumSize.Width)
                {
                    largestGroup.Size = new Size(largestGroup.Size.Width - spaceToCut, largestGroup.Size.Height);
                    return(true);
                }
                break;
            }

            return(false);
        }
Esempio n. 5
0
        private void RemoveGroup(DarkDockGroup group)
        {
            var lastOrder = group.Order;

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

            group.RemoveSplitter();

            foreach (var otherGroup in _groups)
            {
                if (otherGroup.Order > lastOrder)
                {
                    otherGroup.Order--;
                }
            }
        }
Esempio n. 6
0
        private DarkDockGroup InsertGroup(int order)
        {
            foreach (var group in _groups)
            {
                if (group.Order >= order)
                {
                    group.Order++;
                }
            }

            var newGroup = new DarkDockGroup(DockPanel, this, order);

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

            return(newGroup);
        }
Esempio n. 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();
        }
Esempio n. 8
0
        private DarkDockGroup CreateGroup()
        {
            var order = 0;

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

            var newGroup = new DarkDockGroup(DockPanel, this, order);

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

            return(newGroup);
        }
Esempio n. 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();
        }