Esempio n. 1
0
        /*
         * InitializeTabButton
         */

        private void InitializeTabButton(NuGenTabButton tabButtonToInitialize)
        {
            Debug.Assert(tabButtonToInitialize != null, "tabButtonToInitialize != null");

            tabButtonToInitialize.ShowCloseButton = this.CloseButtonOnTab;

            tabButtonToInitialize.Click           += _tabButton_Click;
            tabButtonToInitialize.Close           += _tabButton_Close;
            tabButtonToInitialize.DoubleClick     += _tabButton_DoubleClick;
            tabButtonToInitialize.DragDrop        += _tabButton_DragDrop;
            tabButtonToInitialize.DragEnter       += _tabButton_DragEnter;
            tabButtonToInitialize.DragLeave       += _tabButton_DragLeave;
            tabButtonToInitialize.MouseDown       += _tabButton_MouseDown;
            tabButtonToInitialize.MouseEnter      += _tabButton_MouseEnter;
            tabButtonToInitialize.MouseHover      += _tabButton_MouseHover;
            tabButtonToInitialize.MouseLeave      += _tabButton_MouseLeave;
            tabButtonToInitialize.MouseMove       += _tabButton_MouseMove;
            tabButtonToInitialize.MouseUp         += _tabButton_MouseUp;
            tabButtonToInitialize.SelectedChanged += _tabButton_SelectedChanged;

            if (this.Enabled)
            {
                this.SelectedTabButton = tabButtonToInitialize;
            }
            else
            {
                this.SelectedTabButton = null;
            }

            this.LayoutBuilder.RebuildLayout(this.TabStripBounds);
        }
Esempio n. 2
0
        /*
         * InsertTabButton
         */

        private void InsertTabButton(int index, NuGenTabButton tabButtonToInsert)
        {
            Debug.Assert(tabButtonToInsert != null, "tabButtonToInsert != null");
            Debug.Assert(_tabButtons != null, "_tabButtons != null");

            _tabButtons.Insert(index, tabButtonToInsert);
            this.Controls.Add(tabButtonToInsert);
            this.InitializeTabButton(tabButtonToInsert);
        }
Esempio n. 3
0
        /*
         * AddTabButton
         */

        private void AddTabButton(NuGenTabButton tabButtonToAdd)
        {
            Debug.Assert(tabButtonToAdd != null, "tabButtonToAdd != null");
            Debug.Assert(_tabButtons != null, "_tabButtons != null");

            _tabButtons.Add(tabButtonToAdd);
            this.Controls.Add(tabButtonToAdd);
            this.InitializeTabButton(tabButtonToAdd);
        }
Esempio n. 4
0
        private void _tabButton_SelectedChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenTabButton, "sender is NuGenTabButton");
            NuGenTabButton tabButton = (NuGenTabButton)sender;

            if (tabButton.Selected)
            {
                Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
                Debug.Assert(_buttonPageDictionary.ContainsKey(tabButton), "_buttonPageDictionary.ContainsKey(tabButton)");
                NuGenTabPage activeTabPage = _buttonPageDictionary[tabButton];
                Debug.Assert(activeTabPage != null, "activeTabPage != null");
                activeTabPage.BringToFront();
            }
        }
Esempio n. 5
0
        /*
         * RemoveTabPage
         */

        private void RemoveTabPage(NuGenTabPage tabPageToRemove)
        {
            Debug.Assert(tabPageToRemove != null, "tabPageToRemove != null");
            Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
            Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");

            NuGenTabButton associatedTabButton = _pageButtonDictionary[tabPageToRemove];

            Debug.Assert(associatedTabButton != null, "associatedTabButton != null");

            tabPageToRemove.EnabledChanged        -= _tabPage_EnabledChanged;
            tabPageToRemove.TabButtonImageChanged -= _tabPage_TabButtonImageChanged;
            tabPageToRemove.TextChanged           -= _tabPage_TextChanged;

            _buttonPageDictionary.Remove(associatedTabButton);
            _pageButtonDictionary.Remove(tabPageToRemove);

            this.RemoveTabButton(associatedTabButton);
        }
Esempio n. 6
0
        private void _tabPage_EnabledChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenTabPage, "sender is NuGenTabPage");
            NuGenTabPage tabPage = (NuGenTabPage)sender;

            Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");
            Debug.Assert(_pageButtonDictionary.ContainsKey(tabPage), "_pageButtonDictionary.ContainsKey(tabPage)");
            NuGenTabButton tabButton = _pageButtonDictionary[tabPage];

            tabButton.Enabled = tabPage.Enabled;
            tabButton.Invalidate(true);

            if (
                !tabPage.Enabled &&
                tabPage == this.SelectedTab
                )
            {
                NuGenTabPage newSelectedTabPage = null;

                for (int i = this.SelectedIndex - 1; i > -1; i--)
                {
                    if (this.TabPages[i].Enabled)
                    {
                        newSelectedTabPage = this.TabPages[i];
                    }
                }

                if (newSelectedTabPage == null)
                {
                    for (int i = this.SelectedIndex + 1; i < this.TabPages.Count; i++)
                    {
                        if (this.TabPages[i].Enabled)
                        {
                            newSelectedTabPage = this.TabPages[i];
                        }
                    }
                }

                this.SelectedTab = newSelectedTabPage;
            }
        }
Esempio n. 7
0
        /*
         * RemoveTabButton
         */

        private void RemoveTabButton(NuGenTabButton tabButtonToRemove)
        {
            Debug.Assert(tabButtonToRemove != null, "tabButtonToRemove != null");

            tabButtonToRemove.Click           -= _tabButton_Click;
            tabButtonToRemove.Close           -= _tabButton_Close;
            tabButtonToRemove.DoubleClick     -= _tabButton_DoubleClick;
            tabButtonToRemove.DragDrop        -= _tabButton_DragDrop;
            tabButtonToRemove.DragEnter       -= _tabButton_DragEnter;
            tabButtonToRemove.DragLeave       -= _tabButton_DragLeave;
            tabButtonToRemove.MouseDown       -= _tabButton_MouseDown;
            tabButtonToRemove.MouseEnter      -= _tabButton_MouseEnter;
            tabButtonToRemove.MouseHover      -= _tabButton_MouseHover;
            tabButtonToRemove.MouseLeave      -= _tabButton_MouseLeave;
            tabButtonToRemove.MouseMove       -= _tabButton_MouseMove;
            tabButtonToRemove.MouseUp         -= _tabButton_MouseUp;
            tabButtonToRemove.SelectedChanged -= _tabButton_SelectedChanged;

            Debug.Assert(_tabButtons != null, "_tabButtons != null");
            int selectedIndex = _tabButtons.IndexOf(tabButtonToRemove);

            _tabButtons.Remove(tabButtonToRemove);
            this.Controls.Remove(tabButtonToRemove);

            if (_tabButtons.Count < 1)
            {
                this.SelectedTabButton = null;
                return;
            }

            if (selectedIndex >= _tabButtons.Count)
            {
                selectedIndex = _tabButtons.Count - 1;
            }

            this.SelectedTabButton = _tabButtons[selectedIndex];
            this.LayoutBuilder.RebuildLayout(this.TabStripBounds);
        }
Esempio n. 8
0
        /*
         * InitializeTabPage
         */

        private NuGenTabButton InitializeTabPage(NuGenTabPage tabPageToInitialize)
        {
            Debug.Assert(tabPageToInitialize != null, "tabPageToInitialize != null");
            Debug.Assert(this.ServiceProvider != null, "this.ServiceProvider != null");

            NuGenTabButton tabButtonToAssociate = new NuGenTabButton(this.ServiceProvider);

            tabButtonToAssociate.Image = tabPageToInitialize.TabButtonImage;
            tabButtonToAssociate.Text  = tabPageToInitialize.Text;

            Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
            Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");
            _buttonPageDictionary.Add(tabButtonToAssociate, tabPageToInitialize);
            _pageButtonDictionary.Add(tabPageToInitialize, tabButtonToAssociate);

            tabPageToInitialize.EnabledChanged        += _tabPage_EnabledChanged;
            tabPageToInitialize.TabButtonImageChanged += _tabPage_TabButtonImageChanged;
            tabPageToInitialize.TextChanged           += _tabPage_TextChanged;

            this.Controls.Add(tabPageToInitialize);
            tabPageToInitialize.BringToFront();

            return(tabButtonToAssociate);
        }
Esempio n. 9
0
		/*
		 * InitializeTabPage
		 */

		private NuGenTabButton InitializeTabPage(NuGenTabPage tabPageToInitialize)
		{
			Debug.Assert(tabPageToInitialize != null, "tabPageToInitialize != null");
			Debug.Assert(this.ServiceProvider != null, "this.ServiceProvider != null");

			NuGenTabButton tabButtonToAssociate = new NuGenTabButton(this.ServiceProvider);
			tabButtonToAssociate.Image = tabPageToInitialize.TabButtonImage;
			tabButtonToAssociate.Text = tabPageToInitialize.Text;

			Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
			Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");
			_buttonPageDictionary.Add(tabButtonToAssociate, tabPageToInitialize);
			_pageButtonDictionary.Add(tabPageToInitialize, tabButtonToAssociate);

			tabPageToInitialize.EnabledChanged += _tabPage_EnabledChanged;
			tabPageToInitialize.TabButtonImageChanged += _tabPage_TabButtonImageChanged;
			tabPageToInitialize.TextChanged += _tabPage_TextChanged;

			this.Controls.Add(tabPageToInitialize);
			tabPageToInitialize.BringToFront();

			return tabButtonToAssociate;
		}
Esempio n. 10
0
		/*
		 * RemoveTabButton
		 */

		private void RemoveTabButton(NuGenTabButton tabButtonToRemove)
		{
			Debug.Assert(tabButtonToRemove != null, "tabButtonToRemove != null");

			tabButtonToRemove.Click -= _tabButton_Click;
			tabButtonToRemove.Close -= _tabButton_Close;
			tabButtonToRemove.DoubleClick -= _tabButton_DoubleClick;
			tabButtonToRemove.DragDrop -= _tabButton_DragDrop;
			tabButtonToRemove.DragEnter -= _tabButton_DragEnter;
			tabButtonToRemove.DragLeave -= _tabButton_DragLeave;
			tabButtonToRemove.MouseDown -= _tabButton_MouseDown;
			tabButtonToRemove.MouseEnter -= _tabButton_MouseEnter;
			tabButtonToRemove.MouseHover -= _tabButton_MouseHover;
			tabButtonToRemove.MouseLeave -= _tabButton_MouseLeave;
			tabButtonToRemove.MouseMove -= _tabButton_MouseMove;
			tabButtonToRemove.MouseUp -= _tabButton_MouseUp;
			tabButtonToRemove.SelectedChanged -= _tabButton_SelectedChanged;

			Debug.Assert(_tabButtons != null, "_tabButtons != null");
			int selectedIndex = _tabButtons.IndexOf(tabButtonToRemove);
			_tabButtons.Remove(tabButtonToRemove);
			this.Controls.Remove(tabButtonToRemove);

			if (_tabButtons.Count < 1)
			{
				this.SelectedTabButton = null;
				return;
			}

			if (selectedIndex >= _tabButtons.Count)
			{
				selectedIndex = _tabButtons.Count - 1;
			}

			this.SelectedTabButton = _tabButtons[selectedIndex];
			this.LayoutBuilder.RebuildLayout(this.TabStripBounds);
		}
Esempio n. 11
0
		/*
		 * InsertTabButton
		 */

		private void InsertTabButton(int index, NuGenTabButton tabButtonToInsert)
		{
			Debug.Assert(tabButtonToInsert != null, "tabButtonToInsert != null");
			Debug.Assert(_tabButtons != null, "_tabButtons != null");

			_tabButtons.Insert(index, tabButtonToInsert);
			this.Controls.Add(tabButtonToInsert);
			this.InitializeTabButton(tabButtonToInsert);
		}
Esempio n. 12
0
		/*
		 * AddTabButton
		 */

		private void AddTabButton(NuGenTabButton tabButtonToAdd)
		{
			Debug.Assert(tabButtonToAdd != null, "tabButtonToAdd != null");
			Debug.Assert(_tabButtons != null, "_tabButtons != null");

			_tabButtons.Add(tabButtonToAdd);
			this.Controls.Add(tabButtonToAdd);
			this.InitializeTabButton(tabButtonToAdd);
		}
Esempio n. 13
0
		/*
		 * InitializeTabButton
		 */

		private void InitializeTabButton(NuGenTabButton tabButtonToInitialize)
		{
			Debug.Assert(tabButtonToInitialize != null, "tabButtonToInitialize != null");

			tabButtonToInitialize.ShowCloseButton = this.CloseButtonOnTab;

			tabButtonToInitialize.Click += _tabButton_Click;
			tabButtonToInitialize.Close += _tabButton_Close;
			tabButtonToInitialize.DoubleClick += _tabButton_DoubleClick;
			tabButtonToInitialize.DragDrop += _tabButton_DragDrop;
			tabButtonToInitialize.DragEnter += _tabButton_DragEnter;
			tabButtonToInitialize.DragLeave += _tabButton_DragLeave;
			tabButtonToInitialize.MouseDown += _tabButton_MouseDown;
			tabButtonToInitialize.MouseEnter += _tabButton_MouseEnter;
			tabButtonToInitialize.MouseHover += _tabButton_MouseHover;
			tabButtonToInitialize.MouseLeave += _tabButton_MouseLeave;
			tabButtonToInitialize.MouseMove += _tabButton_MouseMove;
			tabButtonToInitialize.MouseUp += _tabButton_MouseUp;
			tabButtonToInitialize.SelectedChanged += _tabButton_SelectedChanged;

			if (this.Enabled)
			{
				this.SelectedTabButton = tabButtonToInitialize;
			}
			else
			{
				this.SelectedTabButton = null;
			}

			this.LayoutBuilder.RebuildLayout(this.TabStripBounds);
		}