Exemplo n.º 1
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);

            if (ContentAdded != null)
            {
                ContentAdded(this, new DockContentEventArgs(dockContent));
            }

            dockContent.Select();
        }
Exemplo n.º 2
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();
            }

            PositionGroups();
        }
Exemplo n.º 3
0
        internal DockDropArea(DarkDockPanel dockPanel, DarkDockGroup group, DockInsertType insertType)
        {
            DockPanel = dockPanel;
            DockGroup = group;
            InsertType = insertType;

            BuildAreas();
        }
Exemplo n.º 4
0
        internal DockDropArea(DarkDockPanel dockPanel, DarkDockGroup group, DockInsertType insertType)
        {
            DockPanel  = dockPanel;
            DockGroup  = group;
            InsertType = insertType;

            BuildAreas();
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        private void RemoveGroup(DarkDockGroup group)
        {
            var lastOrder = group.Order;

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

            foreach (var otherGroup in _groups)
            {
                if (otherGroup.Order > lastOrder)
                {
                    otherGroup.Order--;
                }
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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();
        }
Exemplo 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();
            }

            PositionGroups();
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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();
            }

            PositionGroups();
        }
Exemplo n.º 12
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);

            if (ContentAdded != null)
                ContentAdded(this, new DockContentEventArgs(dockContent));

            dockContent.Select();
        }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
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);

            if (ContentAdded != null)
                ContentAdded(this, new DockContentEventArgs(dockContent));

            dockContent.Select();
        }
Exemplo n.º 15
0
        private void HandleDrag()
        {
            var location = Cursor.Position;

            _insertType = DockInsertType.None;

            _targetRegion = null;
            _targetGroup = null;

            // Check all region drop areas
            foreach (var area in _regionDropAreas.Values)
            {
                if (area.DropArea.Contains(location))
                {
                    _insertType = DockInsertType.None;
                    _targetRegion = area.DockRegion;
                    UpdateHighlightForm(area.HighlightArea);
                    return;
                }
            }

            // Check all group drop areas
            foreach (var collection in _groupDropAreas.Values)
            {
                var sameRegion = false;
                var sameGroup = false;
                var groupHasOtherContent = false;

                if (collection.DropArea.DockGroup == _dragContent.DockGroup)
                    sameGroup = true;

                if (collection.DropArea.DockGroup.DockRegion == _dragContent.DockRegion)
                    sameRegion = true;

                if (_dragContent.DockGroup.ContentCount > 1)
                    groupHasOtherContent = true;

                // If we're hovering over the group itself, only allow inserting before/after if multiple content is tabbed.
                if (!sameGroup || groupHasOtherContent)
                {
                    var skipBefore = false;
                    var skipAfter = false;

                    // Inserting before/after other content might cause the content to be dropped on to its own location.
                    // Check if the group above/below the hovered group contains our drag content.
                    if (sameRegion && !groupHasOtherContent)
                    {
                        if (collection.InsertBeforeArea.DockGroup.Order == _dragContent.DockGroup.Order + 1)
                            skipBefore = true;

                        if (collection.InsertAfterArea.DockGroup.Order == _dragContent.DockGroup.Order - 1)
                            skipAfter = true;
                    }

                    if (!skipBefore)
                    {
                        if (collection.InsertBeforeArea.DropArea.Contains(location))
                        {
                            _insertType = DockInsertType.Before;
                            _targetGroup = collection.InsertBeforeArea.DockGroup;
                            UpdateHighlightForm(collection.InsertBeforeArea.HighlightArea);
                            return;
                        }
                    }

                    if (!skipAfter)
                    {
                        if (collection.InsertAfterArea.DropArea.Contains(location))
                        {
                            _insertType = DockInsertType.After;
                            _targetGroup = collection.InsertAfterArea.DockGroup;
                            UpdateHighlightForm(collection.InsertAfterArea.HighlightArea);
                            return;
                        }
                    }
                }

                // Don't allow content to be dragged on to itself
                if (!sameGroup)
                {
                    if (collection.DropArea.DropArea.Contains(location))
                    {
                        _insertType = DockInsertType.None;
                        _targetGroup = collection.DropArea.DockGroup;
                        UpdateHighlightForm(collection.DropArea.HighlightArea);
                        return;
                    }
                }
            }

            // Not hovering over anything - hide the highlight
            if (_highlightForm.Visible)
                _highlightForm.Hide();

            // Show we can't drag here
            Cursor.Current = Cursors.No;
        }
Exemplo n.º 16
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();
            }

            PositionGroups();
        }
Exemplo n.º 17
0
        private void RemoveGroup(DarkDockGroup group)
        {
            var lastOrder = group.Order;

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

            foreach (var otherGroup in _groups)
            {
                if (otherGroup.Order > lastOrder)
                    otherGroup.Order--;
            }
        }
Exemplo n.º 18
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;
        }