示例#1
0
            private void _addRemoveButtonsMenuItem_Click(object sender, EventArgs e)
            {
                NuGenNavigationButton navigationButton = (NuGenNavigationButton)((ToolStripMenuItem)sender).Tag;

                navigationButton.Visible = !navigationButton.Visible;
                this.Invalidate();
            }
示例#2
0
            /*
             * OnMouseClick
             */

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

                _rightClickedButton = null;
                NuGenNavigationButton currentButton = _buttons[e.Location];

                if (currentButton != null)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        this.SelectedButton = currentButton;
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        _rightClickedButton = currentButton;
                        this.Invalidate();
                    }
                }
                else
                {
                    if (this.GetDropDownRectangle().Contains(e.Location))
                    {
                        this.CreateContextMenu();
                    }
                }
            }
示例#3
0
            public void RemoveNavigationButton(NuGenNavigationButton navigationButtonToRemove)
            {
                Debug.Assert(navigationButtonToRemove != null, "navigationButtonToRemove != null");

                navigationButtonToRemove.AllowedChanged -= _navigationButton_Refresh;
                navigationButtonToRemove.ImageChanged   -= _navigationButton_Refresh;
                navigationButtonToRemove.TextChanged    -= _navigationButton_Refresh;
                navigationButtonToRemove.VisibleChanged -= _navigationButton_Refresh;

                int selectedIndex = _buttons.IndexOf(navigationButtonToRemove);

                _buttons.Remove(navigationButtonToRemove);

                if (navigationButtonToRemove == this.SelectedButton)
                {
                    if (_buttons.Count < 1)
                    {
                        this.SelectedButton = null;
                        return;
                    }

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

                    this.SelectedButton = _buttons[selectedIndex];
                }
            }
示例#4
0
        /*
         * Add
         */

        /// <summary>
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="item"/> is <see langword="null"/>.</para>
        /// </exception>
        public int Add(NuGenNavigationButton item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            return(this.List.Add(item));
        }
示例#5
0
        /*
         * Insert
         */

        /// <summary>
        /// </summary>
        /// <param name="index"></param>
        /// <param name="item"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="item"/> is <see langword="null"/>.</para>
        /// </exception>
        public void Insert(int index, NuGenNavigationButton item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            this.List.Insert(index, item);
        }
示例#6
0
            public void AddNavigationButton(NuGenNavigationButton navigationButtonToAdd)
            {
                Debug.Assert(navigationButtonToAdd != null, "navigationButtonToAdd != null");

                navigationButtonToAdd.AllowedChanged += _navigationButton_Refresh;
                navigationButtonToAdd.ImageChanged   += _navigationButton_Refresh;
                navigationButtonToAdd.TextChanged    += _navigationButton_Refresh;
                navigationButtonToAdd.VisibleChanged += _navigationButton_Refresh;

                _buttons.Add(navigationButtonToAdd);
            }
            /*
             * SetSelectedButton
             */

            /// <summary>
            /// </summary>
            /// <param name="selectedButton">Can be <see langword="null"/>.</param>
            public void SetSelectedButton(NuGenNavigationButton selectedButton)
            {
                if (selectedButton != null)
                {
                    this.Text = selectedButton.Text;
                }
                else
                {
                    this.Text = "";
                }
            }
			/*
			 * SetSelectedButton
			 */

			/// <summary>
			/// </summary>
			/// <param name="selectedButton">Can be <see langword="null"/>.</param>
			public void SetSelectedButton(NuGenNavigationButton selectedButton)
			{
				if (selectedButton != null)
				{
					this.Text = selectedButton.Text;
				}
				else
				{
					this.Text = "";
				}
			}
示例#9
0
        /*
         * OnMouseLeave
         */

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

            if (_rightClickedButton == null)
            {
                _hoveringButton   = null;
                _dropDownHovering = false;
                this.Invalidate();
            }
        }
示例#10
0
        /*
         * OnMouseMove
         */

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

            _hoveringButton   = null;
            _dropDownHovering = false;

            int buttonHeight = this.GetButtonHeight();

            if (_isResizing)
            {
                if (e.Y < -buttonHeight && _canGrow)
                {
                    this.Height += buttonHeight;
                }
                else if (e.Y > buttonHeight && _canShrink)
                {
                    this.Height -= buttonHeight;
                }
            }
            else
            {
                NuGenNavigationButton buttonUnderCursor = null;

                if (this.GetGripRectangle().Contains(e.Location))
                {
                    this.Cursor = Cursors.SizeNS;
                }
                else if (this.GetDropDownRectangle().Contains(e.Location))
                {
                    this.Cursor       = Cursors.Hand;
                    _dropDownHovering = true;
                    this.Invalidate();

                    // TODO: Adjust tooltip.
                }
                else if ((buttonUnderCursor = this.Buttons[e.Location]) != null)
                {
                    this.Cursor     = Cursors.Hand;
                    _hoveringButton = buttonUnderCursor;
                    this.Invalidate();

                    // TODO: Adjust tooltip.
                }
                else
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
示例#11
0
        private void _navigationPane_TextChanged(object sender, EventArgs e)
        {
            Debug.Assert(sender is NuGenNavigationPane, "sender is NuGenNavigationPane");
            NuGenNavigationPane navigationPane = (NuGenNavigationPane)sender;

            Debug.Assert(_paneButtonDictionary != null, "_paneButtonDictionary != null");
            Debug.Assert(_paneButtonDictionary.ContainsKey(navigationPane), "_paneButtonDictionary.ContainsKey(navigationPane)");
            NuGenNavigationButton navigationButton = _paneButtonDictionary[navigationPane];

            navigationButton.Text = navigationPane.Text;

            if (navigationButton == _buttonBlock.SelectedButton)
            {
                _title.SetSelectedButton(navigationButton);
            }
        }
示例#12
0
            /*
             * DrawButton
             */

            private void DrawButton(Graphics g, NuGenNavigationButton button)
            {
                Debug.Assert(g != null, "g != null");
                Debug.Assert(button != null, "button != null");

                NuGenControlState buttonState = this.StateTracker.GetControlState();

                if (button == _hoveringButton)
                {
                    buttonState = button == _selectedButton ? NuGenControlState.Pressed : NuGenControlState.Hot;
                }
                else
                {
                    if (button == _selectedButton)
                    {
                        buttonState = NuGenControlState.Pressed;
                    }
                }

                NuGenPaintParams paintParams = new NuGenPaintParams(g);

                paintParams.Bounds = button.Bounds;
                paintParams.State  = buttonState;

                this.Renderer.DrawBackground(paintParams);

                if (button.IsLarge)
                {
                    NuGenItemPaintParams itemPaintParams = new NuGenItemPaintParams(paintParams);

                    itemPaintParams.ContentAlign = ContentAlignment.MiddleLeft;
                    itemPaintParams.Font         = this.Font;
                    itemPaintParams.ForeColor    = this.ForeColor;
                    itemPaintParams.Image        = button.Image;
                    itemPaintParams.Text         = button.Text;

                    this.Renderer.DrawLargeButtonBody(itemPaintParams);
                    this.Renderer.DrawButtonBorder(paintParams);
                }
                else
                {
                    NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);
                    imagePaintParams.Image = button.Image;

                    this.Renderer.DrawSmallButtonBody(imagePaintParams);
                }
            }
示例#13
0
        private void _buttonBlock_SelectedButtonChanged(object sender, EventArgs e)
        {
            NuGenNavigationButton selectedButton = _buttonBlock.SelectedButton;

            _title.SetSelectedButton(selectedButton);

            if (selectedButton != null)
            {
                Debug.Assert(_buttonPaneDictionary != null, "_buttonPaneDictionary != null");
                Debug.Assert(_buttonPaneDictionary.ContainsKey(selectedButton), "_buttonPaneDictionary.ContainsKey(selectedButton)");
                NuGenNavigationPane activeNavigationPane = _buttonPaneDictionary[selectedButton];
                Debug.Assert(activeNavigationPane != null, "activeNavigationPane != null");
                activeNavigationPane.BringToFront();
            }

            this.OnSelectedButtonChanged(e);
        }
示例#14
0
        /*
         * RemoveNavigationPane
         */

        private void RemoveNavigationPane(NuGenNavigationPane navigationPaneToRemove)
        {
            Debug.Assert(navigationPaneToRemove != null, "navigationPaneToRemove != null");
            Debug.Assert(_buttonPaneDictionary != null, "_buttonPaneDictionary != null");
            Debug.Assert(_paneButtonDictionary != null, "_paneButtonDictionary != null");

            NuGenNavigationButton associatedButton = _paneButtonDictionary[navigationPaneToRemove];

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

            navigationPaneToRemove.NavigationButtonImageChanged -= _navigationPane_NavigationButtonImageChanged;
            navigationPaneToRemove.TextChanged -= _navigationPane_TextChanged;

            _buttonPaneDictionary.Remove(associatedButton);
            _paneButtonDictionary.Remove(navigationPaneToRemove);

            this.RemoveNavigationButton(associatedButton);
        }
示例#15
0
        /*
         * InitializeNavigationPane
         */

        private NuGenNavigationButton InitializeNavigationPane(NuGenNavigationPane navigationPaneToInitialize)
        {
            Debug.Assert(navigationPaneToInitialize != null, "navigationPaneToInitialize != null");
            NuGenNavigationButton navigationButtonToAssociate = new NuGenNavigationButton();

            navigationButtonToAssociate.Image = navigationPaneToInitialize.NavigationButtonImage;
            navigationButtonToAssociate.Text  = navigationPaneToInitialize.Text;

            Debug.Assert(_buttonPaneDictionary != null, "_buttonPaneDictionary != null");
            Debug.Assert(_paneButtonDictionary != null, "_paneButtonDictionary != null");
            _buttonPaneDictionary.Add(navigationButtonToAssociate, navigationPaneToInitialize);
            _paneButtonDictionary.Add(navigationPaneToInitialize, navigationButtonToAssociate);

            navigationPaneToInitialize.NavigationButtonImageChanged += _navigationPane_NavigationButtonImageChanged;
            navigationPaneToInitialize.TextChanged += _navigationPane_TextChanged;

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

            return(navigationButtonToAssociate);
        }
示例#16
0
            /// <summary>
            /// </summary>
            /// <param name="pointToTest">Screen coordinates expected.</param>
            public NuGenNavigationBarHitResult HitTest(Point pointToTest)
            {
                Point pt = this.PointToClient(pointToTest);

                if (this.ClientRectangle.Contains(pt))
                {
                    if (this.GetGripRectangle().Contains(pt))
                    {
                        return(NuGenNavigationBarHitResult.Grip);
                    }

                    NuGenNavigationButton button = _buttons[pt];

                    if (button != null)
                    {
                        return(NuGenNavigationBarHitResult.Buttons);
                    }

                    return(NuGenNavigationBarHitResult.Body);
                }

                return(NuGenNavigationBarHitResult.Nowhere);
            }
示例#17
0
        /*
         * OnMouseClick
         */

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

            _rightClickedButton = null;
            NuGenNavigationButton currentButton = this.Buttons[e.Location];

            if (currentButton != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    this.SelectedButton = currentButton;
                }
                else if (e.Button == MouseButtons.Right)
                {
                    _rightClickedButton = currentButton;
                    this.Invalidate();
                }
            }
            else
            {
                // TODO: Context menu creation here.
            }
        }
			public void RemoveNavigationButton(NuGenNavigationButton navigationButtonToRemove)
			{
				Debug.Assert(navigationButtonToRemove != null, "navigationButtonToRemove != null");
				
				navigationButtonToRemove.AllowedChanged -= _navigationButton_Refresh;
				navigationButtonToRemove.ImageChanged -= _navigationButton_Refresh;
				navigationButtonToRemove.TextChanged -= _navigationButton_Refresh;
				navigationButtonToRemove.VisibleChanged -= _navigationButton_Refresh;

				int selectedIndex = _buttons.IndexOf(navigationButtonToRemove);
				_buttons.Remove(navigationButtonToRemove);

				if (navigationButtonToRemove == this.SelectedButton)
				{
					if (_buttons.Count < 1)
					{
						this.SelectedButton = null;
						return;
					}

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

					this.SelectedButton = _buttons[selectedIndex];
				}
			}
		/*
		 * Remove
		 */

		/// <summary>
		/// </summary>
		/// <param name="item"></param>
		public void Remove(NuGenNavigationButton item)
		{
			this.List.Remove(item);
		}
示例#20
0
        /*
         * InitializeNavigationButton
         */

        private void InitializeNavigationButton(NuGenNavigationButton navigationButtonToInitialize)
        {
            Debug.Assert(navigationButtonToInitialize != null, "navigationButtonToInitialize != null");
            _buttonBlock.SelectedButton = navigationButtonToInitialize;
        }
示例#21
0
            /*
             * OnPaint
             */

            /// <summary>
            /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
            /// </summary>
            /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
            protected override void OnPaint(PaintEventArgs e)
            {
                int bottomContainerHeight = this.GetBottomContainerRectangle().Height;
                int buttonHeight          = this.GetButtonHeight();
                int gripHeight            = this.GetGripRectangle().Height;

                _maxLargeButtonCount = (int)Math.Floor(
                    (double)((this.Height - bottomContainerHeight - gripHeight) / buttonHeight)
                    );

                int visibleCount = _buttons.GetVisibleCount();

                if (visibleCount < _maxLargeButtonCount)
                {
                    _maxLargeButtonCount = visibleCount;
                }

                _canShrink = _maxLargeButtonCount != 0;
                _canGrow   = _maxLargeButtonCount < visibleCount;

                this.Height = _maxLargeButtonCount * buttonHeight + gripHeight + bottomContainerHeight;

                int bottomContainerLeftMargin = this.GetBottomContainerLeftMargin();
                int dropDownWidth             = this.GetDropDownRectangle().Width;
                int smallButtonWidth          = this.GetSmallButtonWidth();

                _maxSmallButtonCount = (int)Math.Floor(
                    (double)((this.Width - dropDownWidth - bottomContainerLeftMargin) / smallButtonWidth)
                    );

                if (visibleCount - _maxLargeButtonCount <= 0)
                {
                    _maxSmallButtonCount = 0;
                }

                if (_maxSmallButtonCount > (visibleCount - _maxLargeButtonCount))
                {
                    _maxSmallButtonCount = visibleCount - _maxLargeButtonCount;
                }

                Graphics          g            = e.Graphics;
                Rectangle         bounds       = this.ClientRectangle;
                NuGenControlState currentState = this.StateTracker.GetControlState();
                NuGenPaintParams  paintParams  = new NuGenPaintParams(g);

                paintParams.State = currentState;

                /* Border */

                paintParams.Bounds = bounds;
                this.Renderer.DrawBorder(paintParams);

                /* Grip */

                paintParams.Bounds = this.GetGripRectangle();
                this.Renderer.DrawGrip(paintParams);

                /* Large buttons */

                int syncLargeButtons = 0;
                int iterateLargeButtons;

                for (iterateLargeButtons = 0; iterateLargeButtons < _buttons.Count; iterateLargeButtons++)
                {
                    NuGenNavigationButton button = _buttons[iterateLargeButtons];

                    if (button.Visible)
                    {
                        Rectangle rect = new Rectangle(0, syncLargeButtons * this.GetButtonHeight() + this.GetGripHeight(), this.ClientRectangle.Width, this.GetButtonHeight());
                        button.Bounds  = rect;
                        button.IsLarge = true;
                        this.DrawButton(g, button);

                        if (syncLargeButtons == _maxLargeButtonCount)
                        {
                            break;
                        }

                        syncLargeButtons++;
                    }
                }

                /* Bottom container */

                paintParams.Bounds = this.GetBottomContainerRectangle();
                this.Renderer.DrawBackground(paintParams);

                /* Small buttons */

                int startX           = this.ClientRectangle.Width - this.GetDropDownRectangle().Width - _maxSmallButtonCount * this.GetSmallButtonWidth();
                int syncSmallButtons = 0;
                int iterateSmallButtons;

                for (iterateSmallButtons = iterateLargeButtons; iterateSmallButtons < _buttons.Count; iterateSmallButtons++)
                {
                    if (syncSmallButtons == _maxSmallButtonCount)
                    {
                        break;
                    }

                    NuGenNavigationButton button = _buttons[iterateSmallButtons];

                    if (button.Visible)
                    {
                        Rectangle rect = new Rectangle(startX + (syncSmallButtons * this.GetSmallButtonWidth()), this.GetBottomContainerRectangle().Y, this.GetSmallButtonWidth(), this.GetBottomContainerRectangle().Height);
                        button.Bounds  = rect;
                        button.IsLarge = false;
                        this.DrawButton(g, button);
                        syncSmallButtons++;
                    }
                }

                for (int i = iterateSmallButtons; i < _buttons.Count; i++)
                {
                    _buttons[i].Bounds = Rectangle.Empty;
                }

                /* DropDown */

                this.DrawDropDown(g);

                /* Bottom container border */

                this.Renderer.DrawBorder(paintParams);
            }
示例#22
0
        /*
         * AddNavigationButton
         */

        private void AddNavigationButton(NuGenNavigationButton navigationButtonToAdd)
        {
            Debug.Assert(navigationButtonToAdd != null, "navigationButtonToAdd != null");
            _buttonBlock.AddNavigationButton(navigationButtonToAdd);
            this.InitializeNavigationButton(navigationButtonToAdd);
        }
		/*
		 * OnMouseMove
		 */

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

			_hoveringButton = null;
			_dropDownHovering = false;

			int buttonHeight = this.GetButtonHeight();

			if (_isResizing)
			{
				if (e.Y < -buttonHeight && _canGrow)
				{
					this.Height += buttonHeight;
				}
				else if (e.Y > buttonHeight && _canShrink)
				{
					this.Height -= buttonHeight;
				}
			}
			else
			{
				NuGenNavigationButton buttonUnderCursor = null;

				if (this.GetGripRectangle().Contains(e.Location))
				{
					this.Cursor = Cursors.SizeNS;
				}
				else if (this.GetDropDownRectangle().Contains(e.Location))
				{
					this.Cursor = Cursors.Hand;
					_dropDownHovering = true;
					this.Invalidate();

					// TODO: Adjust tooltip.
				}
				else if ((buttonUnderCursor = this.Buttons[e.Location]) != null)
				{
					this.Cursor = Cursors.Hand;
					_hoveringButton = buttonUnderCursor;
					this.Invalidate();

					// TODO: Adjust tooltip.
				}
				else
				{
					this.Cursor = Cursors.Default;
				}
			}
		}
示例#24
0
            /*
             * OnMouseMove
             */

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

                _hoveringButton   = null;
                _dropDownHovering = false;

                int buttonHeight = this.GetButtonHeight();

                if (_isResizing)
                {
                    if (e.Y < -buttonHeight && _canGrow)
                    {
                        this.Height += buttonHeight;
                    }
                    else if (e.Y > buttonHeight && _canShrink)
                    {
                        this.Height -= buttonHeight;
                    }
                }
                else
                {
                    NuGenNavigationButton buttonUnderCursor = null;
                    NuGenToolTipInfo      tooltipInfo       = null;

                    if (this.GetGripRectangle().Contains(e.Location))
                    {
                        this.Cursor = Cursors.SizeNS;
                    }
                    else if (this.GetDropDownRectangle().Contains(e.Location))
                    {
                        this.Cursor       = Cursors.Hand;
                        _dropDownHovering = true;
                        this.Invalidate();

                        tooltipInfo = new NuGenToolTipInfo(null, null, Resources.Text_NavigationBar_ConfigureButtons);
                    }
                    else if ((buttonUnderCursor = _buttons[e.Location]) != null)
                    {
                        this.Cursor     = Cursors.Hand;
                        _hoveringButton = buttonUnderCursor;
                        this.Invalidate();

                        if (!buttonUnderCursor.IsLarge)
                        {
                            tooltipInfo = new NuGenToolTipInfo(null, null, buttonUnderCursor.Text);
                        }
                    }
                    else
                    {
                        this.Cursor = Cursors.Default;
                    }

                    if (tooltipInfo != null)
                    {
                        _tooltip.Show(this, tooltipInfo);
                    }
                    else
                    {
                        _tooltip.Hide();
                    }
                }
            }
示例#25
0
        /*
         * Remove
         */

        /// <summary>
        /// </summary>
        /// <param name="item"></param>
        public void Remove(NuGenNavigationButton item)
        {
            this.List.Remove(item);
        }
		/*
		 * AddNavigationButton
		 */

		private void AddNavigationButton(NuGenNavigationButton navigationButtonToAdd)
		{
			Debug.Assert(navigationButtonToAdd != null, "navigationButtonToAdd != null");
			_buttonBlock.AddNavigationButton(navigationButtonToAdd);
			this.InitializeNavigationButton(navigationButtonToAdd);
		}
示例#27
0
        /*
         * IndexOf
         */

        /// <summary>
        /// Returns -1 if the specified <paramref name="item"/> was not found within this collection.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int IndexOf(NuGenNavigationButton item)
        {
            return(this.List.IndexOf(item));
        }
		/*
		 * Insert
		 */

		/// <summary>
		/// </summary>
		/// <param name="index"></param>
		/// <param name="item"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="item"/> is <see langword="null"/>.</para>
		/// </exception>
		public void Insert(int index, NuGenNavigationButton item)
		{
			if (item == null)
			{
				throw new ArgumentNullException("item");
			}

			this.List.Insert(index, item);
		}
示例#29
0
        /*
         * InsertNavigationButton
         */

        private void InsertNavigationButton(int index, NuGenNavigationButton navigationButtonToInsert)
        {
            Debug.Assert(navigationButtonToInsert != null, "navigationButtonToInsert != null");
            _buttonBlock.AddNavigationButton(navigationButtonToInsert);
            this.InitializeNavigationButton(navigationButtonToInsert);
        }
			public void AddNavigationButton(NuGenNavigationButton navigationButtonToAdd)
			{
				Debug.Assert(navigationButtonToAdd != null, "navigationButtonToAdd != null");
				
				navigationButtonToAdd.AllowedChanged += _navigationButton_Refresh;
				navigationButtonToAdd.ImageChanged += _navigationButton_Refresh;
				navigationButtonToAdd.TextChanged += _navigationButton_Refresh;
				navigationButtonToAdd.VisibleChanged += _navigationButton_Refresh;
				
				_buttons.Add(navigationButtonToAdd);
			}
示例#31
0
        /*
         * RemoveNavigationButton
         */

        private void RemoveNavigationButton(NuGenNavigationButton navigationButtonToRemove)
        {
            Debug.Assert(navigationButtonToRemove != null, "navigationButtonToRemove != null");
            _buttonBlock.RemoveNavigationButton(navigationButtonToRemove);
        }
示例#32
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics          g            = e.Graphics;
            Rectangle         bounds       = this.ClientRectangle;
            NuGenControlState currentState = this.StateTracker.GetControlState();

            /* Border */

            NuGenPaintParams borderPaintParams = new NuGenPaintParams(this, g, bounds, currentState);

            this.Renderer.DrawBorder(borderPaintParams);

            /* Grip */

            NuGenPaintParams gripPaintParams = new NuGenPaintParams(this, g, this.GetGripRectangle(), currentState);

            this.Renderer.DrawGrip(gripPaintParams);

            /* Large buttons */

            int syncLargeButtons = 0;
            int iterateLargeButtons;

            for (iterateLargeButtons = 0; iterateLargeButtons < this.Buttons.Count; iterateLargeButtons++)
            {
                NuGenNavigationButton button = this.Buttons[iterateLargeButtons];

                if (button.Visible)
                {
                    Rectangle rect = new Rectangle(0, syncLargeButtons * this.GetButtonHeight() + this.GetGripHeight(), this.ClientRectangle.Width, this.GetButtonHeight());
                    button.Bounds  = rect;
                    button.IsLarge = true;
                    this.DrawButton(g, button);

                    if (syncLargeButtons == _maxLargeButtonCount)
                    {
                        break;
                    }

                    syncLargeButtons++;
                }
            }

            /* Bottom container */

            NuGenPaintParams bottomContainerPaintParams = new NuGenPaintParams(this, g, this.GetBottomContainerRectangle(), currentState);

            this.Renderer.DrawBackground(bottomContainerPaintParams);

            /* Small buttons */

            int startX           = this.ClientRectangle.Width - this.GetDropDownRectangle().Width - _maxSmallButtonCount * this.GetSmallButtonWidth();
            int syncSmallButtons = 0;
            int iterateSmallButtons;

            for (iterateSmallButtons = iterateLargeButtons; iterateSmallButtons < this.Buttons.Count; iterateSmallButtons++)
            {
                if (syncSmallButtons == _maxSmallButtonCount)
                {
                    break;
                }

                NuGenNavigationButton button = this.Buttons[iterateSmallButtons];

                if (button.Visible)
                {
                    Rectangle rect = new Rectangle(startX + (syncSmallButtons * this.GetSmallButtonWidth()), this.GetBottomContainerRectangle().Y, this.GetSmallButtonWidth(), this.GetBottomContainerRectangle().Height);
                    button.Bounds  = rect;
                    button.IsLarge = false;
                    this.DrawButton(g, button);
                    syncSmallButtons++;
                }
            }

            for (int i = iterateSmallButtons; i < this.Buttons.Count; i++)
            {
                this.Buttons[i].Bounds = Rectangle.Empty;
            }

            /* DropDown */

            this.DrawDropDown(g);

            /* Bottom container border */

            this.Renderer.DrawBorder(bottomContainerPaintParams);
        }
			/*
			 * DrawButton
			 */

			private void DrawButton(Graphics g, NuGenNavigationButton button)
			{
				Debug.Assert(g != null, "g != null");
				Debug.Assert(button != null, "button != null");

				NuGenControlState buttonState = this.StateTracker.GetControlState();

				if (button == _hoveringButton)
				{
					buttonState = button == _selectedButton ? NuGenControlState.Pressed : NuGenControlState.Hot;
				}
				else
				{
					if (button == _selectedButton)
					{
						buttonState = NuGenControlState.Pressed;
					}
				}

				NuGenPaintParams paintParams = new NuGenPaintParams(g);
				paintParams.Bounds = button.Bounds;
				paintParams.State = buttonState;

				this.Renderer.DrawBackground(paintParams);

				if (button.IsLarge)
				{
					NuGenItemPaintParams itemPaintParams = new NuGenItemPaintParams(paintParams);

					itemPaintParams.ContentAlign = ContentAlignment.MiddleLeft;
					itemPaintParams.Font = this.Font;
					itemPaintParams.ForeColor = this.ForeColor;
					itemPaintParams.Image = button.Image;
					itemPaintParams.Text = button.Text;

					this.Renderer.DrawLargeButtonBody(itemPaintParams);
					this.Renderer.DrawButtonBorder(paintParams);
				}
				else
				{
					NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);
					imagePaintParams.Image = button.Image;

					this.Renderer.DrawSmallButtonBody(imagePaintParams);
				}
			}
示例#34
0
        /*
         * Contains
         */

        /// <summary>
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool Contains(NuGenNavigationButton item)
        {
            return(this.List.Contains(item));
        }
		/*
		 * RemoveNavigationButton
		 */

		private void RemoveNavigationButton(NuGenNavigationButton navigationButtonToRemove)
		{
			Debug.Assert(navigationButtonToRemove != null, "navigationButtonToRemove != null");
			_buttonBlock.RemoveNavigationButton(navigationButtonToRemove);
		}
		/*
		 * IndexOf
		 */

		/// <summary>
		/// Returns -1 if the specified <paramref name="item"/> was not found within this collection.
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public int IndexOf(NuGenNavigationButton item)
		{
			return this.List.IndexOf(item);
		}
		/*
		 * Contains
		 */

		/// <summary>
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public bool Contains(NuGenNavigationButton item)
		{
			return this.List.Contains(item);
		}
		/*
		 * InitializeNavigationButton
		 */

		private void InitializeNavigationButton(NuGenNavigationButton navigationButtonToInitialize)
		{
			Debug.Assert(navigationButtonToInitialize != null, "navigationButtonToInitialize != null");
			_buttonBlock.SelectedButton = navigationButtonToInitialize;
		}
		/*
		 * OnMouseClick
		 */

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

			_rightClickedButton = null;
			NuGenNavigationButton currentButton = this.Buttons[e.Location];

			if (currentButton != null)
			{
				if (e.Button == MouseButtons.Left)
				{
					this.SelectedButton = currentButton;
				}
				else if (e.Button == MouseButtons.Right)
				{
					_rightClickedButton = currentButton;
					this.Invalidate();
				}
			}
			else
			{
				// TODO: Context menu creation here.
			}
		}
		/*
		 * InsertNavigationButton
		 */

		private void InsertNavigationButton(int index, NuGenNavigationButton navigationButtonToInsert)
		{
			Debug.Assert(navigationButtonToInsert != null, "navigationButtonToInsert != null");
			_buttonBlock.AddNavigationButton(navigationButtonToInsert);
			this.InitializeNavigationButton(navigationButtonToInsert);
		}
		/*
		 * OnMouseLeave
		 */

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

			if (_rightClickedButton == null)
			{
				_hoveringButton = null;
				_dropDownHovering = false;
				this.Invalidate();
			}
		}
		/*
		 * InitializeNavigationPane
		 */

		private NuGenNavigationButton InitializeNavigationPane(NuGenNavigationPane navigationPaneToInitialize)
		{
			Debug.Assert(navigationPaneToInitialize != null, "navigationPaneToInitialize != null");
			NuGenNavigationButton navigationButtonToAssociate = new NuGenNavigationButton();
			navigationButtonToAssociate.Image = navigationPaneToInitialize.NavigationButtonImage;
			navigationButtonToAssociate.Text = navigationPaneToInitialize.Text;

			Debug.Assert(_buttonPaneDictionary != null, "_buttonPaneDictionary != null");
			Debug.Assert(_paneButtonDictionary != null, "_paneButtonDictionary != null");
			_buttonPaneDictionary.Add(navigationButtonToAssociate, navigationPaneToInitialize);
			_paneButtonDictionary.Add(navigationPaneToInitialize, navigationButtonToAssociate);

			navigationPaneToInitialize.NavigationButtonImageChanged += _navigationPane_NavigationButtonImageChanged;
			navigationPaneToInitialize.TextChanged += _navigationPane_TextChanged;

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

			return navigationButtonToAssociate;
		}
		/*
		 * Add
		 */

		/// <summary>
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="item"/> is <see langword="null"/>.</para>
		/// </exception>
		public int Add(NuGenNavigationButton item)
		{
			if (item == null)
			{
				throw new ArgumentNullException("item");
			}

			return this.List.Add(item);
		}