Beispiel #1
0
        /*
         * InsertTabPage
         */

        private void InsertTabPage(int index, NuGenTabPage tabPageToInsert)
        {
            Debug.Assert(tabPageToInsert != null, "tabPageToInsert != null");
            this.InsertTabButton(index, this.InitializeTabPage(tabPageToInsert));
            this.OnTabPageAdded(
                new NuGenCollectionEventArgs <NuGenTabPage>(index, tabPageToInsert)
                );
        }
Beispiel #2
0
        /*
         * AddTabPage
         */

        private void AddTabPage(NuGenTabPage tabPageToAdd)
        {
            Debug.Assert(tabPageToAdd != null, "tabPageToAdd != null");
            this.AddTabButton(this.InitializeTabPage(tabPageToAdd));
            this.OnTabPageAdded(
                new NuGenCollectionEventArgs <NuGenTabPage>(this.TabPages.Count - 1, tabPageToAdd)
                );
        }
Beispiel #3
0
        private void tabPage_TextChanged(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)");
            this.PageButtonDictionary[tabPage].Text = tabPage.Text;
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="tabPage"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public NuGenTabCancelEventArgs(NuGenTabPage tabPage, bool cancel)
		{
			if (tabPage == null)
			{
				throw new ArgumentNullException("tabPage");
			}

			_tabPage = tabPage;
			_cancel = cancel;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="tabPage"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public NuGenTabCancelEventArgs(NuGenTabPage tabPage, bool cancel)
        {
            if (tabPage == null)
            {
                throw new ArgumentNullException("tabPage");
            }

            _tabPage = tabPage;
            _cancel  = cancel;
        }
Beispiel #6
0
            /*
             * Remove
             */

            /// <summary>
            /// </summary>
            /// <param name="tabPageToRemove"></param>
            /// <returns></returns>
            public bool Remove(NuGenTabPage tabPageToRemove)
            {
                if (_list.Contains(tabPageToRemove))
                {
                    Debug.Assert(_tabControl != null, "_tabControl != null");
                    _tabControl.Controls.Remove(tabPageToRemove);
                    return(_list.Remove(tabPageToRemove));
                }

                return(false);
            }
Beispiel #7
0
            /// <summary>
            /// </summary>
            /// <param name="text"></param>
            /// <param name="tabButtonImage">Can be <see langword="null"/>.</param>
            /// <returns></returns>
            /// <exception cref="ArgumentNullException">
            ///	<para>
            ///		<paramref name="text"/> is <see langword="null"/>.
            /// </para>
            /// </exception>
            public NuGenTabPage Add(string text, Image tabButtonImage)
            {
                Debug.Assert(_tabControl != null, "_tabControl != null");
                Debug.Assert(_tabControl.ServiceProvider != null, "_tabControl.ServiceProvider != null");

                NuGenTabPage tabPage = new NuGenTabPage(_tabControl.ServiceProvider);

                tabPage.TabButtonImage = tabButtonImage;
                this.Add(tabPage);
                tabPage.Text = text;

                return(tabPage);
            }
Beispiel #8
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();
            }
        }
Beispiel #9
0
            /// <summary>
            /// </summary>
            /// <exception cref="ArgumentNullException">
            /// <para>
            ///		<paramref name="tabPageToAdd"/> is <see langword="null"/>.
            /// </para>
            /// </exception>
            public int Add(NuGenTabPage tabPageToAdd)
            {
                if (tabPageToAdd == null)
                {
                    throw new ArgumentNullException("tabPageToAdd");
                }

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

                _list.Add(tabPageToAdd);
                _tabControl.AddTabPage(tabPageToAdd);

                return(_list.Count - 1);
            }
Beispiel #10
0
        private void tabButton_Close(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenTabButton, "sender is NuGenTabButton");
            Debug.Assert(this.ButtonPageDictionary.ContainsKey((NuGenTabButton)sender), "this.ButtonPageDictionary.ContainsKey((NuGenTabButton)sender)");

            NuGenTabPage            tabPage   = this.ButtonPageDictionary[(NuGenTabButton)sender];
            NuGenTabCancelEventArgs eventArgs = new NuGenTabCancelEventArgs(tabPage);

            this.OnTabCloseButtonClick(eventArgs);

            if (!eventArgs.Cancel)
            {
                this.TabPages.Remove(this.ButtonPageDictionary[(NuGenTabButton)sender]);
            }
        }
Beispiel #11
0
        /*
         * OnControlRemoved
         */

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.ControlRemoved"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.ControlEventArgs"></see> that contains the event data.</param>
        protected override void OnControlRemoved(ControlEventArgs e)
        {
            base.OnControlRemoved(e);

            if (e.Control is NuGenTabPage)
            {
                NuGenTabPage tabPage = (NuGenTabPage)e.Control;
                int          index   = this.TabPages.IndexOf(tabPage);

                this.RemoveTabPage(tabPage);
                if (this.TabPages.ListInternal.Remove(tabPage))
                {
                    this.OnTabPageRemoved(new NuGenCollectionEventArgs <NuGenTabPage>(index, tabPage));
                }
            }
        }
Beispiel #12
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);
        }
Beispiel #13
0
        /*
         * AddTabPage
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="pageContent"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="text"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public NuGenTabPage AddTabPage(Control pageContent, string text, Image tabButtonImage)
        {
            if (pageContent == null)
            {
                throw new ArgumentNullException("pageContent");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            NuGenTabPage tabPage = this.TabPages.Add(text, tabButtonImage);

            tabPage.Controls.Add(pageContent);
            return(tabPage);
        }
Beispiel #14
0
            /*
             * Indexer
             */

            /// <summary>
            /// </summary>
            /// <param name="zeroBasedIndex"></param>
            /// <returns></returns>
            /// <exception cref="ArgumentOutOfRangeException">
            ///		<paramref name="zeroBasedIndex"/> should be within the bounds of the collection.
            /// </exception>
            public NuGenTabPage this[int zeroBasedIndex]
            {
                get
                {
                    NuGenTabPage tabPage = null;

                    try
                    {
                        tabPage = _list[zeroBasedIndex];
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        throw e;
                    }

                    return(tabPage);
                }
            }
Beispiel #15
0
            /// <summary>
            /// </summary>
            /// <param name="index"></param>
            /// <param name="text"></param>
            /// <param name="tabButtonImage"></param>
            /// <returns></returns>
            /// <exception cref="ArgumentNullException">
            /// <para>
            ///		<paramref name="text"/> is <see langword="null"/>.
            /// </para>
            /// </exception>
            /// <exception cref="ArgumentOutOfRangeException">
            /// <para>
            ///		<paramref name="index"/> must be within the bounds of the collection.
            /// </para>
            /// </exception>
            public NuGenTabPage Insert(int index, string text, Image tabButtonImage)
            {
                if (text == null)
                {
                    throw new ArgumentNullException("text");
                }

                Debug.Assert(_tabControl != null, "_tabControl != null");
                Debug.Assert(_tabControl.ServiceProvider != null, "_tabControl.ServiceProvider != null");

                NuGenTabPage tabPage = new NuGenTabPage(_tabControl.ServiceProvider);

                tabPage.TabButtonImage = tabButtonImage;
                this.Insert(index, tabPage);
                tabPage.Text = text;

                return(tabPage);
            }
Beispiel #16
0
            /// <summary>
            /// </summary>
            /// <param name="index"></param>
            /// <param name="tabPageToInsert"></param>
            /// <exception cref="ArgumentNullException">
            /// <para>
            ///		<paramref name="tabPageToInsert"/> is <see langword="null"/>.
            /// </para>
            /// </exception>
            /// <exception cref="ArgumentOutOfRangeException">
            /// <para>
            ///		<paramref name="index"/> must be within the bounds of the collection.
            /// </para>
            /// </exception>
            public void Insert(int index, NuGenTabPage tabPageToInsert)
            {
                if (tabPageToInsert == null)
                {
                    throw new ArgumentNullException("tabPageToInsert");
                }

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

                try
                {
                    _list.Insert(index, tabPageToInsert);
                    _tabControl.InsertTabPage(index, tabPageToInsert);
                }
                catch (ArgumentOutOfRangeException e)
                {
                    throw e;
                }
            }
Beispiel #17
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;
            }
        }
Beispiel #18
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);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.<para/>
 /// Cancel = <see langword="false"/>.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <para>
 ///		<paramref name="tabPage"/> is <see langword="null"/>.
 /// </para>
 /// </exception>
 public NuGenTabCancelEventArgs(NuGenTabPage tabPage)
     : this(tabPage, false)
 {
 }
			/// <summary>
			/// </summary>
			/// <param name="text"></param>
			/// <param name="tabButtonImage">Can be <see langword="null"/>.</param>
			/// <returns></returns>
			/// <exception cref="ArgumentNullException">
			///	<para>
			///		<paramref name="text"/> is <see langword="null"/>.
			/// </para>
			/// </exception>
			public NuGenTabPage Add(string text, Image tabButtonImage)
			{
				Debug.Assert(_tabControl != null, "_tabControl != null");
				Debug.Assert(_tabControl.ServiceProvider != null, "_tabControl.ServiceProvider != null");

				NuGenTabPage tabPage = new NuGenTabPage(_tabControl.ServiceProvider);
				tabPage.TabButtonImage = tabButtonImage;
				this.Add(tabPage);
				tabPage.Text = text;

				return tabPage;
			}
		/*
		 * 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);
		}
		/*
		 * InsertTabPage
		 */

		private void InsertTabPage(int index, NuGenTabPage tabPageToInsert)
		{
			Debug.Assert(tabPageToInsert != null, "tabPageToInsert != null");
			this.InsertTabButton(index, this.InitializeTabPage(tabPageToInsert));
			this.OnTabPageAdded(
				new NuGenCollectionEventArgs<NuGenTabPage>(index, tabPageToInsert)
			);
		}
		/*
		 * AddTabPage
		 */

		private void AddTabPage(NuGenTabPage tabPageToAdd)
		{
			Debug.Assert(tabPageToAdd != null, "tabPageToAdd != null");
			this.AddTabButton(this.InitializeTabPage(tabPageToAdd));
			this.OnTabPageAdded(
				new NuGenCollectionEventArgs<NuGenTabPage>(this.TabPages.Count - 1, tabPageToAdd)
			);
		}
			/*
			 * IndexOf
			 */

			/// <summary>
			/// </summary>
			/// <param name="tabPage"></param>
			/// <returns></returns>
			public int IndexOf(NuGenTabPage tabPage)
			{
				return _list.IndexOf(tabPage);
			}
			/*
			 * Remove
			 */

			/// <summary>
			/// </summary>
			/// <param name="tabPageToRemove"></param>
			/// <returns></returns>
			public bool Remove(NuGenTabPage tabPageToRemove)
			{
				if (_list.Contains(tabPageToRemove))
				{
					Debug.Assert(_tabControl != null, "_tabControl != null");
					_tabControl.Controls.Remove(tabPageToRemove);
					return _list.Remove(tabPageToRemove);
				}

				return false;
			}
			/// <summary>
			/// </summary>
			/// <param name="index"></param>
			/// <param name="tabPageToInsert"></param>
			/// <exception cref="ArgumentNullException">
			/// <para>
			///		<paramref name="tabPageToInsert"/> is <see langword="null"/>.
			/// </para>
			/// </exception>
			/// <exception cref="ArgumentOutOfRangeException">
			/// <para>
			///		<paramref name="index"/> must be within the bounds of the collection.
			/// </para>
			/// </exception>
			public void Insert(int index, NuGenTabPage tabPageToInsert)
			{
				if (tabPageToInsert == null)
				{
					throw new ArgumentNullException("tabPageToInsert");
				}

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

				try
				{
					_list.Insert(index, tabPageToInsert);
					_tabControl.InsertTabPage(index, tabPageToInsert);
				}
				catch (ArgumentOutOfRangeException e)
				{
					throw e;
				}
			}
			/// <summary>
			/// </summary>
			/// <exception cref="ArgumentNullException">
			/// <para>
			///		<paramref name="tabPageToAdd"/> is <see langword="null"/>.
			/// </para>
			/// </exception>
			public int Add(NuGenTabPage tabPageToAdd)
			{
				if (tabPageToAdd == null)
				{
					throw new ArgumentNullException("tabPageToAdd");
				}

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

				_list.Add(tabPageToAdd);
				_tabControl.AddTabPage(tabPageToAdd);

				return _list.Count - 1;
			}
			/*
			 * Contains
			 */

			/// <summary>
			/// </summary>
			/// <param name="tabPage"></param>
			/// <returns></returns>
			public bool Contains(NuGenTabPage tabPage)
			{
				return _list.Contains(tabPage);
			}
			/*
			 * CopyTo
			 */

			/// <summary>
			/// Copies the entire contents of this collection to a compatible one-dimensional
			/// <see cref="T:System.Array"></see>, starting at the specified index of the target array.
			/// </summary>
			/// <exception cref="T:System.InvalidCastException">
			/// The type of the source element cannot be cast automatically to the type of array.
			/// </exception>
			/// <exception cref="T:System.ArgumentOutOfRangeException">
			/// index is less than 0.
			/// </exception>
			/// <exception cref="T:System.ArgumentException">
			/// <para>
			///		<paramref name="destination"/> is multidimensional.
			/// </para>
			/// -or-
			/// <para>
			///		<paramref name="zeroBasedIndexToStartAt"/> is equal to or greater than the length of
			///		the destination array.
			/// </para>
			/// -or-
			/// <para>
			///		The number of elements in the source collection is greater
			///		than the available space from index to the end of the destination array.
			/// </para>
			/// </exception>
			/// <exception cref="T:System.ArgumentNullException">
			/// <paramref name="destination"/> is <see langword="null"/>.
			/// </exception>
			public void CopyTo(NuGenTabPage[] destination, int zeroBasedIndexToStartAt)
			{
				_list.CopyTo(destination, zeroBasedIndexToStartAt);
			}
Beispiel #30
0
            /*
             * Contains
             */

            /// <summary>
            /// </summary>
            /// <param name="tabPage"></param>
            /// <returns></returns>
            public bool Contains(NuGenTabPage tabPage)
            {
                return(_list.Contains(tabPage));
            }
		/*
		 * 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;
		}
Beispiel #32
0
            /*
             * IndexOf
             */

            /// <summary>
            /// </summary>
            /// <param name="tabPage"></param>
            /// <returns></returns>
            public int IndexOf(NuGenTabPage tabPage)
            {
                return(_list.IndexOf(tabPage));
            }
			/// <summary>
			/// </summary>
			/// <param name="index"></param>
			/// <param name="text"></param>
			/// <param name="tabButtonImage"></param>
			/// <returns></returns>
			/// <exception cref="ArgumentNullException">
			/// <para>
			///		<paramref name="text"/> is <see langword="null"/>.
			/// </para>
			/// </exception>
			/// <exception cref="ArgumentOutOfRangeException">
			/// <para>
			///		<paramref name="index"/> must be within the bounds of the collection.
			/// </para>
			/// </exception>
			public NuGenTabPage Insert(int index, string text, Image tabButtonImage)
			{
				if (text == null)
				{
					throw new ArgumentNullException("text");
				}

				Debug.Assert(_tabControl != null, "_tabControl != null");
				Debug.Assert(_tabControl.ServiceProvider != null, "_tabControl.ServiceProvider != null");

				NuGenTabPage tabPage = new NuGenTabPage(_tabControl.ServiceProvider);
				tabPage.TabButtonImage = tabButtonImage;
				this.Insert(index, tabPage);
				tabPage.Text = text;

				return tabPage;
			}
		/*
		 * SelectTab
		 */

		/// <summary>
		/// </summary>
		/// <param name="tabPageToSelect"></param>
		public void SelectTab(NuGenTabPage tabPageToSelect)
		{
			this.SelectedTab = tabPageToSelect;
		}
Beispiel #35
0
        /*
         * SelectTab
         */

        /// <summary>
        /// </summary>
        /// <param name="tabPageToSelect"></param>
        public void SelectTab(NuGenTabPage tabPageToSelect)
        {
            this.SelectedTab = tabPageToSelect;
        }
Beispiel #36
0
            /*
             * RemoveAt
             */

            /// <summary>
            /// </summary>
            /// <param name="zeroBasedIndex"></param>
            /// <exception cref="ArgumentOutOfRangeException">
            ///		<paramref name="zeroBasedIndex"/> should be within the bounds of the collection.
            /// </exception>
            public void RemoveAt(int zeroBasedIndex)
            {
                NuGenTabPage tabPage = this[zeroBasedIndex];

                this.Remove(tabPage);
            }
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.<para/>
		/// Cancel = <see langword="false"/>.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="tabPage"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public NuGenTabCancelEventArgs(NuGenTabPage tabPage)
			: this(tabPage, false)
		{
		}