예제 #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ColorTabControl"/> class.
            /// </summary>
            /// <param name="serviceProvider">
            /// Requires:<para/>
            /// <see cref="INuGenButtonStateTracker"/><para/>
            /// <see cref="INuGenControlStateTracker"/><para/>
            /// <see cref="INuGenTabRenderer"/><para/>
            /// <see cref="INuGenTabStateTracker"/><para/>
            /// <see cref="INuGenTabLayoutManager"/><para/>
            /// <see cref="INuGenPanelRenderer"/><para/>
            /// <see cref="INuGenListBoxRenderer"/><para/>
            /// <see cref="INuGenImageListService"/><para/>
            /// <see cref="INuGenColorsProvider"/><para/>
            /// </param>
            /// <exception cref="ArgumentNullException">
            /// <para>
            ///		<paramref name="serviceProvider"/> is <see langword="null"/>.
            /// </para>
            /// </exception>
            public ColorTabControl(INuGenServiceProvider serviceProvider)
                : base(serviceProvider)
            {
                _customColorsPanel = new CustomColorsPanel(serviceProvider);
                _stdColorListBox   = new StdColorListBox(serviceProvider);
                _webColorListBox   = new WebColorListBox(serviceProvider);

                this.CloseButtonOnTab = false;
                this.Dock             = DockStyle.Fill;

                NuGenTabPage customColorsPage = new NuGenTabPage(serviceProvider);

                customColorsPage.Text = Resources.Text_ColorBoxPopup_Custom;
                customColorsPage.Controls.Add(_customColorsPanel);

                NuGenTabPage stdColorsPage = new NuGenTabPage(serviceProvider);

                stdColorsPage.Text = Resources.Text_ColorBoxPopup_System;
                stdColorsPage.Controls.Add(_stdColorListBox);

                NuGenTabPage webColorsPage = new NuGenTabPage(serviceProvider);

                webColorsPage.Text = Resources.Text_ColorBoxPopup_Web;
                webColorsPage.Controls.Add(_webColorListBox);

                this.TabPages.Add(customColorsPage);
                this.TabPages.Add(webColorsPage);
                this.TabPages.Add(stdColorsPage);

                _colorCollections = new Dictionary <IColorCollection, NuGenTabPage>();

                _colorCollections.Add(_stdColorListBox, stdColorsPage);
                _colorCollections.Add(_webColorListBox, webColorsPage);
                _colorCollections.Add(_customColorsPanel, customColorsPage);
            }
예제 #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)
                );
        }
예제 #3
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)
                );
        }
예제 #4
0
        private void _tabPage_TextChanged(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)");
            _pageButtonDictionary[tabPage].Text = tabPage.Text;
        }
예제 #5
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);
            }
            /// <summary>
            /// </summary>
            /// <param name="index"></param>
            /// <param name="text"></param>
            /// <param name="tabButtonImage">Can be <see langword="null"/>.</param>
            /// <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)
            {
                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);
            }
            /// <summary>
            /// </summary>
            /// <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(_list != null, "_list != null");
                Debug.Assert(_tabControl != null, "_tabControl != null");

                _list.Insert(index, tabPageToInsert);
                _tabControl.InsertTabPage(index, tabPageToInsert);
            }
예제 #8
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);
            }
예제 #9
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();
            }
        }
예제 #10
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));
                }
            }
        }
예제 #11
0
        private void _tabButton_Close(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenTabButton, "sender is NuGenTabButton");
            Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
            Debug.Assert(_buttonPageDictionary.ContainsKey((NuGenTabButton)sender), "_buttonPageDictionary.ContainsKey((NuGenTabButton)sender)");

            NuGenTabPage            tabPage   = _buttonPageDictionary[(NuGenTabButton)sender];
            NuGenTabCancelEventArgs eventArgs = new NuGenTabCancelEventArgs(tabPage);

            this.OnTabCloseButtonClick(eventArgs);

            if (!eventArgs.Cancel)
            {
                this.TabPages.Remove(_buttonPageDictionary[(NuGenTabButton)sender]);
            }
        }
예제 #12
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);
            }
예제 #13
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);
                }
            }
예제 #14
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;
                }
            }
예제 #15
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);
        }
예제 #16
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;
            }
        }
예제 #17
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);
        }
			/// <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;
			}
			/// <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;
				}
			}
예제 #20
0
            /*
             * Contains
             */

            /// <summary>
            /// </summary>
            /// <param name="tabPage"></param>
            /// <returns></returns>
            public bool Contains(NuGenTabPage tabPage)
            {
                return(_list.Contains(tabPage));
            }
예제 #21
0
            /*
             * IndexOf
             */

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

            /// <summary>
            /// </summary>
            /// <param name="tabPage"></param>
            /// <returns></returns>
            public bool Contains(NuGenTabPage tabPage)
            {
                Debug.Assert(_list != null, "_list != null");
                return(_list.Contains(tabPage));
            }
예제 #23
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>
			/// </summary>
			/// <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(_list != null, "_list != null");
				Debug.Assert(_tabControl != null, "_tabControl != null");

				_list.Insert(index, tabPageToInsert);
				_tabControl.InsertTabPage(index, tabPageToInsert);
			}
			/*
			 * Remove
			 */

			/// <summary>
			/// </summary>
			public bool Remove(NuGenTabPage tabPageToRemove)
			{
				Debug.Assert(_list != null, "_list != null");

				if (_list.Contains(tabPageToRemove))
				{
					Debug.Assert(_tabControl != null, "_tabControl != null");
					_tabControl.Controls.Remove(tabPageToRemove);
					return _list.Remove(tabPageToRemove);
				}

				return false;
			}
			/*
			 * 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);
			}
			/// <summary>
			/// </summary>
			/// <param name="index"></param>
			/// <param name="text"></param>
			/// <param name="tabButtonImage">Can be <see langword="null"/>.</param>
			/// <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)
			{
				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;
			}
예제 #28
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);
		}
예제 #29
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)
			);
		}
예제 #30
0
		/*
		 * SelectTab
		 */

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

			/// <summary>
			/// </summary>
			/// <param name="tabPage"></param>
			/// <returns></returns>
			public int IndexOf(NuGenTabPage tabPage)
			{
				return _list.IndexOf(tabPage);
			}
예제 #32
0
        /*
         * SelectTab
         */

        /// <summary>
        /// </summary>
        /// <param name="tabPageToSelect"></param>
        public void SelectTab(NuGenTabPage tabPageToSelect)
        {
            this.SelectedTab = tabPageToSelect;
        }
			/// <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");
				Debug.Assert(_list != null, "_list != null");

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

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

            /// <summary>
            /// </summary>
            /// <param name="tabPage"></param>
            /// <returns></returns>
            public int IndexOf(NuGenTabPage tabPage)
            {
                Debug.Assert(_list != null, "_list != null");
                return(_list.IndexOf(tabPage));
            }
			/// <summary>
			/// Initializes a new instance of the <see cref="ColorTabControl"/> class.
			/// </summary>
			/// <param name="serviceProvider">
			/// Requires:<para/>
			/// <see cref="INuGenButtonStateTracker"/><para/>
			/// <see cref="INuGenControlStateTracker"/><para/>
			/// <see cref="INuGenTabRenderer"/><para/>
			/// <see cref="INuGenTabStateTracker"/><para/>
			/// <see cref="INuGenTabLayoutManager"/><para/>
			/// <see cref="INuGenPanelRenderer"/><para/>
			/// <see cref="INuGenListBoxRenderer"/><para/>
			/// <see cref="INuGenImageListService"/><para/>
			/// <see cref="INuGenColorsProvider"/><para/>
			/// </param>
			/// <exception cref="ArgumentNullException">
			/// <para>
			///		<paramref name="serviceProvider"/> is <see langword="null"/>.
			/// </para>
			/// </exception>
			public ColorTabControl(INuGenServiceProvider serviceProvider)
				: base(serviceProvider)
			{
				_customColorsPanel = new CustomColorsPanel(serviceProvider);
				_stdColorListBox = new StdColorListBox(serviceProvider);
				_webColorListBox = new WebColorListBox(serviceProvider);

				this.CloseButtonOnTab = false;
				this.Dock = DockStyle.Fill;

				NuGenTabPage customColorsPage = new NuGenTabPage(serviceProvider);
				customColorsPage.Text = Resources.Text_ColorBoxPopup_Custom;
				customColorsPage.Controls.Add(_customColorsPanel);

				NuGenTabPage stdColorsPage = new NuGenTabPage(serviceProvider);
				stdColorsPage.Text = Resources.Text_ColorBoxPopup_System;
				stdColorsPage.Controls.Add(_stdColorListBox);

				NuGenTabPage webColorsPage = new NuGenTabPage(serviceProvider);
				webColorsPage.Text = Resources.Text_ColorBoxPopup_Web;
				webColorsPage.Controls.Add(_webColorListBox);

				this.TabPages.Add(customColorsPage);
				this.TabPages.Add(webColorsPage);
				this.TabPages.Add(stdColorsPage);

				_colorCollections = new Dictionary<IColorCollection, NuGenTabPage>();

				_colorCollections.Add(_stdColorListBox, stdColorsPage);
				_colorCollections.Add(_webColorListBox, webColorsPage);
				_colorCollections.Add(_customColorsPanel, customColorsPage);
			}
			/*
			 * Contains
			 */

			/// <summary>
			/// </summary>
			/// <param name="tabPage"></param>
			/// <returns></returns>
			public bool Contains(NuGenTabPage tabPage)
			{
				Debug.Assert(_list != null, "_list != null");
				return _list.Contains(tabPage);
			}
예제 #37
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;
		}
			/*
			 * 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)
			{
				Debug.Assert(_list != null, "_list != null");
				_list.CopyTo(destination, zeroBasedIndexToStartAt);
			}
예제 #39
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)
			);
		}
			/*
			 * IndexOf
			 */

			/// <summary>
			/// </summary>
			/// <param name="tabPage"></param>
			/// <returns></returns>
			public int IndexOf(NuGenTabPage tabPage)
			{
				Debug.Assert(_list != null, "_list != null");
				return _list.IndexOf(tabPage);
			}
예제 #41
0
		/*
		 * FindCanvasOnTabPage
		 */

		public Canvas FindCanvasOnTabPage(NuGenTabPage tabPage)
		{
			Canvas canvas = null;

			foreach (Control ctrl in tabPage.Controls)
			{
				if (ctrl is Canvas)
				{
					canvas = (Canvas)ctrl;
					break;
				}
			}

			return canvas;
		}
			/*
			 * Contains
			 */

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