示例#1
0
        /*
         * InsertSwitchPage
         */

        private void InsertSwitchPage(int index, NuGenSwitchPage switchPageToInsert)
        {
            Debug.Assert(switchPageToInsert != null, "switchPageToInsert != null");
            this.InsertSwitchButton(index, this.InitializeSwitchPage(switchPageToInsert));
            this.OnSwitchPageAdded(
                new NuGenCollectionEventArgs <NuGenSwitchPage>(index, switchPageToInsert)
                );
        }
示例#2
0
        /*
         * AddSwitchPage
         */

        private void AddSwitchPage(NuGenSwitchPage switchPageToAdd)
        {
            Debug.Assert(switchPageToAdd != null, "switchPageToAdd != null");
            this.AddSwitchButton(this.InitializeSwitchPage(switchPageToAdd));
            this.OnSwitchPageAdded(
                new NuGenCollectionEventArgs <NuGenSwitchPage>(this.SwitchPages.Count - 1, switchPageToAdd)
                );
        }
示例#3
0
        private void _switchPage_TextChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenSwitchPage, "sender is NuGenSwitchPage");
            NuGenSwitchPage switchPage = (NuGenSwitchPage)sender;

            Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");
            Debug.Assert(_pageButtonDictionary.ContainsKey(switchPage), "_pageButtonDictionary.ContainsKey(switchPage)");
            _pageButtonDictionary[switchPage].Text = switchPage.Text;
        }
示例#4
0
            /// <summary>
            /// </summary>
            /// <exception cref="ArgumentNullException">
            /// <para>
            ///		<paramref name="switchPageToInsert"/> 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, NuGenSwitchPage switchPageToInsert)
            {
                if (switchPageToInsert == null)
                {
                    throw new ArgumentNullException("switchPageToInsert");
                }

                Debug.Assert(_switcher != null, "_switcher != null");
                _list.Insert(index, switchPageToInsert);
                _switcher.InsertSwitchPage(index, switchPageToInsert);
            }
示例#5
0
            /// <summary>
            /// </summary>
            /// <param name="index"></param>
            /// <param name="text"></param>
            /// <param name="switchButtonImage">Can be <see langword="null"/>.</param>
            /// <exception cref="ArgumentOutOfRangeException">
            /// <para>
            ///		<paramref name="index"/> must be within the bounds of the collection.
            /// </para>
            /// </exception>
            public NuGenSwitchPage Insert(int index, string text, Image switchButtonImage)
            {
                Debug.Assert(_switcher != null, "_switcher != null");

                NuGenSwitchPage switchPage = new NuGenSwitchPage();

                switchPage.SwitchButtonImage = switchButtonImage;
                this.Insert(index, switchPage);
                switchPage.Text = text;

                return(switchPage);
            }
示例#6
0
        private void _switchPanel_SelectedSwitchButtonChanged(object sender, EventArgs e)
        {
            if (_switchPanel.SelectedSwitchButton != null)
            {
                Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
                NuGenSwitchPage activeSwitchPage = _buttonPageDictionary[_switchPanel.SelectedSwitchButton];
                Debug.Assert(activeSwitchPage != null, "activeSwitchPage != null");
                activeSwitchPage.BringToFront();
            }

            this.OnSelectedSwitchPageChanged(e);
        }
示例#7
0
            /*
             * Remove
             */

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

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

                return(false);
            }
示例#8
0
            /// <summary>
            /// </summary>
            /// <param name="switchPageToAdd"></param>
            /// <returns></returns>
            /// <exception cref="ArgumentNullException">
            /// <para><paramref name="switchPageToAdd"/> is <see langword="null"/>.</para>
            /// </exception>
            public int Add(NuGenSwitchPage switchPageToAdd)
            {
                if (switchPageToAdd == null)
                {
                    throw new ArgumentNullException("switchPageToAdd");
                }

                Debug.Assert(_switcher != null, "_switcher != null");
                _list.Add(switchPageToAdd);
                _switcher.AddSwitchPage(switchPageToAdd);

                return(_list.Count - 1);
            }
示例#9
0
        /// <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 NuGenSwitchPage)
            {
                NuGenSwitchPage switchPage = (NuGenSwitchPage)e.Control;
                int             index      = this.SwitchPages.IndexOf(switchPage);
                this.RemoveSwitchPage(switchPage);

                if (this.SwitchPages.ListInternal.Remove(switchPage))
                {
                    this.OnSwitchPageRemoved(new NuGenCollectionEventArgs <NuGenSwitchPage>(index, switchPage));
                }
            }
        }
示例#10
0
        /*
         * RemoveSwitchPage
         */

        private void RemoveSwitchPage(NuGenSwitchPage switchPageToRemove)
        {
            Debug.Assert(switchPageToRemove != null, "switchPageToRemove != null");
            Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
            Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");

            NuGenSwitchButton associatedSwitchButton = _pageButtonDictionary[switchPageToRemove];

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

            switchPageToRemove.EnabledChanged           -= _switchPage_EnabledChanged;
            switchPageToRemove.SwitchButtonImageChanged -= _switchPage_SwitchButtonImageChanged;
            switchPageToRemove.TextChanged -= _switchPage_TextChanged;

            _buttonPageDictionary.Remove(associatedSwitchButton);
            _pageButtonDictionary.Remove(switchPageToRemove);

            this.RemoveSwitchButton(associatedSwitchButton);
        }
示例#11
0
        private void _switchPage_EnabledChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenSwitchPage, "sender is NuGenSwitchPage");
            NuGenSwitchPage switchPage = (NuGenSwitchPage)sender;

            Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");
            Debug.Assert(_pageButtonDictionary.ContainsKey(switchPage), "_pageButtonDictionary.ContainsKey(switchPage)");
            NuGenSwitchButton switchButton = _pageButtonDictionary[switchPage];

            switchButton.Enabled = switchPage.Enabled;
            switchButton.Invalidate();

            if (
                !switchPage.Enabled &&
                switchPage == this.SelectedSwitchPage
                )
            {
                NuGenSwitchPage newSelectedSwitchPage = null;

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

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

                this.SelectedSwitchPage = newSelectedSwitchPage;
            }
        }
示例#12
0
        /*
         * InitializeSwitchPage
         */

        private NuGenSwitchButton InitializeSwitchPage(NuGenSwitchPage switchPageToInitialize)
        {
            Debug.Assert(switchPageToInitialize != null, "switchPageToInitialize != null");
            Debug.Assert(this.ServiceProvider != null, "this.ServiceProvider != null");

            NuGenSwitchButton switchButtonToAssociate = new NuGenSwitchButton(this.ServiceProvider);

            switchButtonToAssociate.Image = switchPageToInitialize.SwitchButtonImage;
            switchButtonToAssociate.Text  = switchPageToInitialize.Text;

            Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
            Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");
            _buttonPageDictionary.Add(switchButtonToAssociate, switchPageToInitialize);
            _pageButtonDictionary.Add(switchPageToInitialize, switchButtonToAssociate);

            switchPageToInitialize.EnabledChanged           += _switchPage_EnabledChanged;
            switchPageToInitialize.SwitchButtonImageChanged += _switchPage_SwitchButtonImageChanged;
            switchPageToInitialize.TextChanged += _switchPage_TextChanged;

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

            return(switchButtonToAssociate);
        }
			/*
			 * IndexOf
			 */

			/// <summary>
			/// </summary>
			/// <returns></returns>
			public int IndexOf(NuGenSwitchPage switchPage)
			{
				return _list.IndexOf(switchPage);
			}
			/// <summary>
			/// </summary>
			/// <param name="index"></param>
			/// <param name="text"></param>
			/// <param name="switchButtonImage">Can be <see langword="null"/>.</param>
			/// <exception cref="ArgumentOutOfRangeException">
			/// <para>
			///		<paramref name="index"/> must be within the bounds of the collection.
			/// </para>
			/// </exception>
			public NuGenSwitchPage Insert(int index, string text, Image switchButtonImage)
			{
				Debug.Assert(_switcher != null, "_switcher != null");

				NuGenSwitchPage switchPage = new NuGenSwitchPage();
				switchPage.SwitchButtonImage = switchButtonImage;
				this.Insert(index, switchPage);
				switchPage.Text = text;

				return switchPage;
			}
			/*
			 * Contains
			 */

			/// <summary>
			/// </summary>
			public bool Contains(NuGenSwitchPage switchPage)
			{
				return _list.Contains(switchPage);
			}
			/*
			 * 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(NuGenSwitchPage[] destination, int zeroBasedIndexToStartAt)
			{
				_list.CopyTo(destination, zeroBasedIndexToStartAt);
			}
示例#17
0
		/*
		 * InsertSwitchPage
		 */

		private void InsertSwitchPage(int index, NuGenSwitchPage switchPageToInsert)
		{
			Debug.Assert(switchPageToInsert != null, "switchPageToInsert != null");
			this.InsertSwitchButton(index, this.InitializeSwitchPage(switchPageToInsert));
			this.OnSwitchPageAdded(
				new NuGenCollectionEventArgs<NuGenSwitchPage>(index, switchPageToInsert)
			);
		}
			/// <summary>
			/// </summary>
			/// <param name="switchPageToAdd"></param>
			/// <returns></returns>
			/// <exception cref="ArgumentNullException">
			/// <para><paramref name="switchPageToAdd"/> is <see langword="null"/>.</para>
			/// </exception>
			public int Add(NuGenSwitchPage switchPageToAdd)
			{
				if (switchPageToAdd == null)
				{
					throw new ArgumentNullException("switchPageToAdd");
				}

				Debug.Assert(_switcher != null, "_switcher != null");
				_list.Add(switchPageToAdd);
				_switcher.AddSwitchPage(switchPageToAdd);

				return _list.Count - 1;
			}
示例#19
0
		/*
		 * RemoveSwitchPage
		 */

		private void RemoveSwitchPage(NuGenSwitchPage switchPageToRemove)
		{
			Debug.Assert(switchPageToRemove != null, "switchPageToRemove != null");
			Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
			Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");

			NuGenSwitchButton associatedSwitchButton = _pageButtonDictionary[switchPageToRemove];
			Debug.Assert(associatedSwitchButton != null, "associatedSwitchButton != null");

			switchPageToRemove.EnabledChanged -= _switchPage_EnabledChanged;
			switchPageToRemove.SwitchButtonImageChanged -= _switchPage_SwitchButtonImageChanged;
			switchPageToRemove.TextChanged -= _switchPage_TextChanged;

			_buttonPageDictionary.Remove(associatedSwitchButton);
			_pageButtonDictionary.Remove(switchPageToRemove);

			this.RemoveSwitchButton(associatedSwitchButton);
		}
示例#20
0
            /*
             * Contains
             */

            /// <summary>
            /// </summary>
            public bool Contains(NuGenSwitchPage switchPage)
            {
                return(_list.Contains(switchPage));
            }
示例#21
0
            /*
             * IndexOf
             */

            /// <summary>
            /// </summary>
            /// <returns></returns>
            public int IndexOf(NuGenSwitchPage switchPage)
            {
                return(_list.IndexOf(switchPage));
            }
			/// <summary>
			/// </summary>
			/// <exception cref="ArgumentNullException">
			/// <para>
			///		<paramref name="switchPageToInsert"/> 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, NuGenSwitchPage switchPageToInsert)
			{
				if (switchPageToInsert == null)
				{
					throw new ArgumentNullException("switchPageToInsert");
				}

				Debug.Assert(_switcher != null, "_switcher != null");
				_list.Insert(index, switchPageToInsert);
				_switcher.InsertSwitchPage(index, switchPageToInsert);
			}
示例#23
0
		/*
		 * AddSwitchPage
		 */

		private void AddSwitchPage(NuGenSwitchPage switchPageToAdd)
		{
			Debug.Assert(switchPageToAdd != null, "switchPageToAdd != null");
			this.AddSwitchButton(this.InitializeSwitchPage(switchPageToAdd));
			this.OnSwitchPageAdded(
				new NuGenCollectionEventArgs<NuGenSwitchPage>(this.SwitchPages.Count - 1, switchPageToAdd)
			);
		}
			/*
			 * Remove
			 */

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

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

				return false;
			}
示例#25
0
		/*
		 * InitializeSwitchPage
		 */

		private NuGenSwitchButton InitializeSwitchPage(NuGenSwitchPage switchPageToInitialize)
		{
			Debug.Assert(switchPageToInitialize != null, "switchPageToInitialize != null");
			Debug.Assert(this.ServiceProvider != null, "this.ServiceProvider != null");

			NuGenSwitchButton switchButtonToAssociate = new NuGenSwitchButton(this.ServiceProvider);
			switchButtonToAssociate.Image = switchPageToInitialize.SwitchButtonImage;
			switchButtonToAssociate.Text = switchPageToInitialize.Text;

			Debug.Assert(_buttonPageDictionary != null, "_buttonPageDictionary != null");
			Debug.Assert(_pageButtonDictionary != null, "_pageButtonDictionary != null");
			_buttonPageDictionary.Add(switchButtonToAssociate, switchPageToInitialize);
			_pageButtonDictionary.Add(switchPageToInitialize, switchButtonToAssociate);

			switchPageToInitialize.EnabledChanged += _switchPage_EnabledChanged;
			switchPageToInitialize.SwitchButtonImageChanged += _switchPage_SwitchButtonImageChanged;
			switchPageToInitialize.TextChanged += _switchPage_TextChanged;

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

			return switchButtonToAssociate;
		}