コード例 #1
0
        /*
         * InitializeTabButton
         */

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

            tabButtonToInitialize.ShowCloseButton = this.CloseButtonOnTab;

            tabButtonToInitialize.Click           += this.tabButton_Click;
            tabButtonToInitialize.Close           += this.tabButton_Close;
            tabButtonToInitialize.DoubleClick     += this.tabButton_DoubleClick;
            tabButtonToInitialize.DragDrop        += this.tabButton_DragDrop;
            tabButtonToInitialize.DragEnter       += this.tabButton_DragEnter;
            tabButtonToInitialize.DragLeave       += this.tabButton_DragLeave;
            tabButtonToInitialize.MouseDown       += this.tabButton_MouseDown;
            tabButtonToInitialize.MouseEnter      += this.tabButton_MouseEnter;
            tabButtonToInitialize.MouseHover      += this.tabButton_MouseHover;
            tabButtonToInitialize.MouseLeave      += this.tabButton_MouseLeave;
            tabButtonToInitialize.MouseMove       += this.tabButton_MouseMove;
            tabButtonToInitialize.MouseUp         += this.tabButton_MouseUp;
            tabButtonToInitialize.SelectedChanged += this.tabButton_SelectedChanged;

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

            this.LayoutBuilder.RebuildLayout(this.TabStripBounds);
        }
コード例 #2
0
        private void tabPage_TabButtonImageChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenTabPage, "sender is NuGenTabPage");
            NuGenTabPage tabPage = (NuGenTabPage)sender;

            Debug.Assert(this.PageButtonDictionary.ContainsKey(tabPage), "this.PageButtonDictionary.ContainsKey(tabPage)");
            NuGenTabButton tabButton = this.PageButtonDictionary[tabPage];

            tabButton.Image = tabPage.TabButtonImage;
        }
コード例 #3
0
        /*
         * InsertTabButton
         */

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

            Debug.Assert(this.TabButtons != null, "this.TabButtons != null");
            this.TabButtons.Insert(index, tabButtonToInsert);
            this.Controls.Add(tabButtonToInsert);

            this.InitializeTabButton(tabButtonToInsert);
        }
コード例 #4
0
        /*
         * AddTabButton
         */

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

            Debug.Assert(this.TabButtons != null, "this.TabButtons != null");
            this.TabButtons.Add(tabButtonToAdd);
            this.Controls.Add(tabButtonToAdd);

            this.InitializeTabButton(tabButtonToAdd);
        }
コード例 #5
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(this.ButtonPageDictionary.ContainsKey(tabButton), "this.ButtonPageDictionary.ContainsKey(tabButton)");
                NuGenTabPage activeTabPage = this.ButtonPageDictionary[tabButton];

                Debug.Assert(activeTabPage != null, "activeTabPage != null");
                activeTabPage.BringToFront();
            }
        }
コード例 #6
0
        /*
         * RemoveTabPage
         */

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

            NuGenTabButton associatedTabButton = this.PageButtonDictionary[tabPageToRemove];

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

            tabPageToRemove.EnabledChanged        -= this.tabPage_EnabledChanged;
            tabPageToRemove.TabButtonImageChanged -= this.tabPage_TabButtonImageChanged;
            tabPageToRemove.TextChanged           -= this.tabPage_TextChanged;

            this.ButtonPageDictionary.Remove(associatedTabButton);
            this.PageButtonDictionary.Remove(tabPageToRemove);

            this.RemoveTabButton(associatedTabButton);
        }
コード例 #7
0
        /// <summary>
        /// </summary>
        public void RebuildLayout(Rectangle tabStripBounds)
        {
            if (tabStripBounds == Rectangle.Empty)
            {
                return;
            }

            NuGenTabButton selectedTabButton = null;
            int            currentLeftOffset = tabStripBounds.Left;
            int            defaultWidth      = this.TabButtons.Count * this.DefaultTabButtonSize.Width;
            int            tabButtonWidth    = this.DefaultTabButtonSize.Width;

            if (defaultWidth > tabStripBounds.Width)
            {
                tabButtonWidth = tabStripBounds.Width / this.TabButtons.Count;
            }

            foreach (NuGenTabButton tabButton in this.TabButtons)
            {
                tabButton.Width  = tabButtonWidth;
                tabButton.Height = tabStripBounds.Height;
                tabButton.Top    = tabStripBounds.Top;
                tabButton.Left   = currentLeftOffset;

                currentLeftOffset += tabButton.Width;

                if (tabButton.Selected)
                {
                    Debug.Assert(selectedTabButton == null, "selectedTabButton == null");
                    selectedTabButton = tabButton;
                }
            }

            /* Selected */

            if (selectedTabButton != null && selectedTabButton.Enabled)
            {
                selectedTabButton.Top    += _selectedTabButtonOffset.Top;
                selectedTabButton.Left   += _selectedTabButtonOffset.Left;
                selectedTabButton.Width  += _selectedTabButtonOffset.Width;
                selectedTabButton.Height += _selectedTabButtonOffset.Height;

                selectedTabButton.BringToFront();
            }
        }
コード例 #8
0
        private void tabPage_EnabledChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenTabPage, "sender is NuGenTabPage");
            NuGenTabPage tabPage = (NuGenTabPage)sender;

            Debug.Assert(this.PageButtonDictionary.ContainsKey(tabPage), "this.PageButtonDictionary.ContainsKey(tabPage)");
            NuGenTabButton tabButton = this.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;
            }
        }
コード例 #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;

            this.ButtonPageDictionary.Add(tabButtonToAssociate, tabPageToInitialize);
            this.PageButtonDictionary.Add(tabPageToInitialize, tabButtonToAssociate);

            tabPageToInitialize.EnabledChanged        += this.tabPage_EnabledChanged;
            tabPageToInitialize.TabButtonImageChanged += this.tabPage_TabButtonImageChanged;
            tabPageToInitialize.TextChanged           += this.tabPage_TextChanged;

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

            return(tabButtonToAssociate);
        }
コード例 #10
0
        /*
         * RemoveTabButton
         */

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

            tabButtonToRemove.Click           -= this.tabButton_Click;
            tabButtonToRemove.Close           -= this.tabButton_Close;
            tabButtonToRemove.DoubleClick     -= this.tabButton_DoubleClick;
            tabButtonToRemove.DragDrop        -= this.tabButton_DragDrop;
            tabButtonToRemove.DragEnter       -= this.tabButton_DragEnter;
            tabButtonToRemove.DragLeave       -= this.tabButton_DragLeave;
            tabButtonToRemove.MouseDown       -= this.tabButton_MouseDown;
            tabButtonToRemove.MouseEnter      -= this.tabButton_MouseEnter;
            tabButtonToRemove.MouseHover      -= this.tabButton_MouseHover;
            tabButtonToRemove.MouseLeave      -= this.tabButton_MouseLeave;
            tabButtonToRemove.MouseMove       -= this.tabButton_MouseMove;
            tabButtonToRemove.MouseUp         -= this.tabButton_MouseUp;
            tabButtonToRemove.SelectedChanged -= this.tabButton_SelectedChanged;

            Debug.Assert(this.TabButtons != null, "this.TabButtons != null");

            int selectedIndex = this.TabButtons.IndexOf(tabButtonToRemove);

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

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

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

            this.SelectedTabButton = this.TabButtons[selectedIndex];
            this.LayoutBuilder.RebuildLayout(this.TabStripBounds);
        }
コード例 #11
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;

			this.ButtonPageDictionary.Add(tabButtonToAssociate, tabPageToInitialize);
			this.PageButtonDictionary.Add(tabPageToInitialize, tabButtonToAssociate);

			tabPageToInitialize.EnabledChanged += this.tabPage_EnabledChanged;
			tabPageToInitialize.TabButtonImageChanged += this.tabPage_TabButtonImageChanged;
			tabPageToInitialize.TextChanged += this.tabPage_TextChanged;

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

			return tabButtonToAssociate;
		}
コード例 #12
0
		/*
		 * RemoveTabButton
		 */

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

			tabButtonToRemove.Click	-= this.tabButton_Click;
			tabButtonToRemove.Close -= this.tabButton_Close;
			tabButtonToRemove.DoubleClick -= this.tabButton_DoubleClick;
			tabButtonToRemove.DragDrop -= this.tabButton_DragDrop;
			tabButtonToRemove.DragEnter -= this.tabButton_DragEnter;
			tabButtonToRemove.DragLeave -= this.tabButton_DragLeave;
			tabButtonToRemove.MouseDown -= this.tabButton_MouseDown;
			tabButtonToRemove.MouseEnter -= this.tabButton_MouseEnter;
			tabButtonToRemove.MouseHover -= this.tabButton_MouseHover;
			tabButtonToRemove.MouseLeave -= this.tabButton_MouseLeave;
			tabButtonToRemove.MouseMove -= this.tabButton_MouseMove;
			tabButtonToRemove.MouseUp -= this.tabButton_MouseUp;
			tabButtonToRemove.SelectedChanged -= this.tabButton_SelectedChanged;

			Debug.Assert(this.TabButtons != null, "this.TabButtons != null");

			int selectedIndex = this.TabButtons.IndexOf(tabButtonToRemove);

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

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

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

			this.SelectedTabButton = this.TabButtons[selectedIndex];
			this.LayoutBuilder.RebuildLayout(this.TabStripBounds);
		}
コード例 #13
0
		/*
		 * InsertTabButton
		 */

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

			Debug.Assert(this.TabButtons != null, "this.TabButtons != null");
			this.TabButtons.Insert(index, tabButtonToInsert);
			this.Controls.Add(tabButtonToInsert);

			this.InitializeTabButton(tabButtonToInsert);
		}
コード例 #14
0
		/*
		 * AddTabButton
		 */

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

			Debug.Assert(this.TabButtons != null, "this.TabButtons != null");
			this.TabButtons.Add(tabButtonToAdd);
			this.Controls.Add(tabButtonToAdd);

			this.InitializeTabButton(tabButtonToAdd);
		}
コード例 #15
0
		/*
		 * InitializeTabButton
		 */

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

			tabButtonToInitialize.ShowCloseButton = this.CloseButtonOnTab;

			tabButtonToInitialize.Click += this.tabButton_Click;
			tabButtonToInitialize.Close += this.tabButton_Close;
			tabButtonToInitialize.DoubleClick += this.tabButton_DoubleClick;
			tabButtonToInitialize.DragDrop += this.tabButton_DragDrop;
			tabButtonToInitialize.DragEnter += this.tabButton_DragEnter;
			tabButtonToInitialize.DragLeave += this.tabButton_DragLeave;
			tabButtonToInitialize.MouseDown += this.tabButton_MouseDown;
			tabButtonToInitialize.MouseEnter += this.tabButton_MouseEnter;
			tabButtonToInitialize.MouseHover += this.tabButton_MouseHover;
			tabButtonToInitialize.MouseLeave += this.tabButton_MouseLeave;
			tabButtonToInitialize.MouseMove += this.tabButton_MouseMove;
			tabButtonToInitialize.MouseUp += this.tabButton_MouseUp;
			tabButtonToInitialize.SelectedChanged += this.tabButton_SelectedChanged;

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

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