Esempio n. 1
0
        /// <summary>
        /// Hide the currently selected content.
        /// </summary>
        public void HideCurrentContent()
        {
            DotNetMagic.Controls.TabPage tp = _tabControl.SelectedTab;

            int count = _tabControl.TabPages.Count;

            // Find currently selected tab
            int index = _tabControl.SelectedIndex;

            // Decide which other tab to make selected instead
            if (count > 1)
            {
                // Move to the next control along
                int newSelect = index + 1;

                // Wrap around to first tab if at end
                if (newSelect == count)
                {
                    newSelect = 0;
                }

                // Change selection
                _tabControl.SelectedIndex = newSelect;
            }
            else
            {
                // Hide myself as am about to die
                this.Hide();

                // Ensure the focus goes somewhere else
                DockingManager.Container.Focus();
            }

            if (tp != null)
            {
                Content c = tp.Tag as Content;

                // Have the manager perform the Hide operation for us
                DockingManager.HideContent(c);

                // Do we also remove the content?
                if (c.CloseOnHide)
                {
                    // Remove the content from the collection
                    DockingManager.Contents.Remove(c);

                    // Dispose of the contained control/form
                    if (c.Control != null)
                    {
                        c.Control.Dispose();
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Process the inserting of a new content.
        /// </summary>
        /// <param name="index">Position of new content.</param>
        /// <param name="value">New content instance.</param>
        protected override void OnContentInserted(int index, object value)
        {
            base.OnContentInserted(index, value);

            Content content = value as Content;

            // Create TabPage to represent the Content
            DotNetMagic.Controls.TabPage newPage = new DotNetMagic.Controls.TabPage();

            // Reflect the Content properties int the TabPage
            newPage.Title      = content.Title;
            newPage.ImageList  = content.ImageList;
            newPage.ImageIndex = content.ImageIndex;
            newPage.Icon       = content.Icon;
            newPage.Control    = content.Control;
            newPage.Tag        = content;

            // Reflect same order in TabPages collection as Content collection
            _tabControl.TabPages.Insert(index, newPage);
        }
Esempio n. 3
0
        private void OnDoubleClickTab(DotNetMagic.Controls.TabControl tc, DotNetMagic.Controls.TabPage page)
        {
            // Is the user allowed to redock?
            if (DockingManager.AllowRedocking)
            {
                Content c = (Content)page.Tag;

                // Make Content record its current position and remember it for the future
                c.RecordRestore();

                // Invert docked status
                c.Docked = (c.Docked == false);

                // Remove from current WindowContent and restore its position
                DockingManager.HideContent(c, false, true);
                DockingManager.ShowContent(c);

                // Raise event to indicate a double click occured
                DockingManager.OnDoubleClickDock();
            }
        }