Ejemplo n.º 1
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();
            }

            PositionGroups();
        }
Ejemplo 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;
            }

            DarkDockRegion region = _regions[dockContent.DockArea];

            region.AddContent(dockContent, dockGroup);

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

            if (_contents.Count == 1)
            {
                dockContent.Select();
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        public void RestoreDockPanelState(DockPanelState state, Func <string, DarkDockContent> getContentBySerializationKey)
        {
            foreach (var region in state.Regions)
            {
                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;
                }

                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();
                    }
                }
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 6
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);
            Controls.Add(dockContent);

            dockContent.AparienciaCambiada += DockContent_AparienciaCambiada;

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

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

            var menuItem = new ToolStripMenuItem(dockContent.DockText);

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

            UpdateTabArea();
        }
Ejemplo n.º 7
0
        public void RemoveContent(DarkDockContent dockContent)
        {
            dockContent.DockGroup = null;

            int order = dockContent.Order;

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

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

            dockContent.AparienciaCambiada -= DockContent_AparienciaCambiada;

            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);

            UpdateTabArea();
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
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));

            if (_contents.Count == 1)
            {
                dockContent.Select();
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 11
0
 public void AddContent(DarkDockContent dockContent)
 {
     AddContent(dockContent, null);
 }
Ejemplo n.º 12
0
 public bool ContainsContent(DarkDockContent dockContent)
 {
     return(_contents.Contains(dockContent));
 }
Ejemplo n.º 13
0
 internal void AddContent(DarkDockContent dockContent)
 {
     AddContent(dockContent, null);
 }
Ejemplo n.º 14
0
 public void DragContent(DarkDockContent content)
 {
     DockContentDragFilter.StartDrag(content);
 }
Ejemplo n.º 15
0
 public DarkDockTab(DarkDockContent content) => DockContent = content;
Ejemplo n.º 16
0
 public DockContentEventArgs(DarkDockContent content)
 {
     Content = content;
 }
Ejemplo n.º 17
0
 public void get_Evento_Contenido_Cambiado(DarkDockContent contenido) => this.ContenidoCambiado?.Invoke(this, new DockContentEventArgs(contenido));
Ejemplo n.º 18
0
 private void DockContent_AparienciaCambiada(DarkDockContent contenido)
 {
     DockPanel.get_Evento_Contenido_Cambiado(contenido);
 }