Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 3
0
        public void RebuildMenu()
        {
            _tabMenu.Items.Clear();

            List <ToolStripMenuItem> orderedItems = new List <ToolStripMenuItem>();

            int index = 0;

            for (int i = 0; i < _menuItems.Count; i++)
            {
                foreach (ToolStripMenuItem item in _menuItems)
                {
                    CrownDockContent content = (CrownDockContent)item.Tag;
                    if (content.Order == index)
                    {
                        orderedItems.Add(item);
                    }
                }
                index++;
            }

            foreach (ToolStripMenuItem item in orderedItems)
            {
                _tabMenu.Items.Add(item);
            }
        }
Ejemplo n.º 4
0
        public void AddContent(CrownDockContent dockContent)
        {
            dockContent.DockGroup = this;
            dockContent.Dock      = DockStyle.Fill;

            dockContent.Order = 0;

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

                dockContent.Order = order;
            }

            _contents.Add(dockContent);
            Controls.Add(dockContent);

            dockContent.DockTextChanged += DockContent_DockTextChanged;

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

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

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

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

            UpdateTabArea();
        }
Ejemplo n.º 5
0
        private void TabMenuItem_Select(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            if (menuItem == null)
            {
                return;
            }

            CrownDockContent content = menuItem.Tag as CrownDockContent;

            if (content == null)
            {
                return;
            }

            DockPanel.ActiveContent = content;
        }
Ejemplo n.º 6
0
        public void RemoveContent(CrownDockContent dockContent)
        {
            dockContent.DockGroup = null;

            int order = dockContent.Order;

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

            foreach (CrownDockContent 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)
                {
                    CrownDockContent newContent = _contents[0];
                    newContent.Visible = true;
                    VisibleContent     = newContent;
                }
            }

            ToolStripMenuItem menuItem = _tabArea.GetMenuItem(dockContent);

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

            UpdateTabArea();
        }
Ejemplo n.º 7
0
        public ToolStripMenuItem GetMenuItem(CrownDockContent content)
        {
            ToolStripMenuItem menuItem = null;

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

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

            return(menuItem);
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
0
        public void SetVisibleContent(CrownDockContent content)
        {
            if (!_contents.Contains(content))
            {
                return;
            }

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

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

                Invalidate();
            }
        }
Ejemplo n.º 10
0
 internal void AddContent(CrownDockContent dockContent)
 {
     AddContent(dockContent, null);
 }
Ejemplo n.º 11
0
 public CrownDockTab(CrownDockContent content)
 {
     DockContent = content;
 }
Ejemplo n.º 12
0
 public DockContentEventArgs(CrownDockContent content)
 {
     Content = content;
 }