Exemple #1
0
 public void Show(NuGenToolTipInfo tooltipInfo, Point location)
 {
     if (tooltipInfo != null)
     {
         _tooltip.Show(tooltipInfo, location);
     }
 }
Exemple #2
0
 private void AddTooltip(Control targetControl, NuGenToolTipInfo tooltipInfo)
 {
     Debug.Assert(targetControl != null, "targetControl != null");
     targetControl.MouseHover += _targetControl_MouseHover;
     targetControl.MouseLeave += _targetControl_MouseLeave;
     this.Tooltips.Add(targetControl, tooltipInfo);
 }
            public void Show(NuGenToolTipInfo tooltipInfo, Point location)
            {
                if (tooltipInfo == null)
                {
                    throw new ArgumentNullException("tooltipInfo");
                }

                base.Show(location);
            }
		public void GetConstructorInfoTest()
		{
			_tooltipInfo = new NuGenToolTipInfo();
			object[] values;
			MemberInfo ctorInfo = this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(0, values.Length);

			_tooltipInfo.Header = _sampleStr;
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(3, values.Length);

			_tooltipInfo.Remarks = _sampleStr;
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(7, values.Length);

			_tooltipInfo = new NuGenToolTipInfo();
			_tooltipInfo.Image = _sampleImg;
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(3, values.Length);

			_tooltipInfo = new NuGenToolTipInfo();
			_tooltipInfo.RemarksImage = _sampleImg;
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(7, values.Length);

			_tooltipInfo = new NuGenToolTipInfo();
			_tooltipInfo.Text = _sampleStr;
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(3, values.Length);

			_tooltipInfo.RemarksHeader = _sampleStr;
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(7, values.Length);

			_tooltipInfo = new NuGenToolTipInfo();
			_tooltipInfo.CustomSize = Size.Empty;
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(0, values.Length);
			_tooltipInfo.CustomSize = new Size(1, 1);
			this.GetConstructorInfo(out values);
			Assert.IsNotNull(ctorInfo);
			Assert.AreEqual(7, values.Length);
		}
Exemple #5
0
        public void ShowToolTip(Control targetControl, Point location)
        {
            NuGenToolTipInfo tooltipInfo = null;

            if (this.Tooltips.ContainsKey(targetControl))
            {
                tooltipInfo = this.Tooltips[targetControl];
            }

            if (tooltipInfo != null)
            {
                _tooltip.Show(tooltipInfo, location);
            }
        }
            public void Show(NuGenToolTipInfo tooltipInfo, Point location)
            {
                if (tooltipInfo == null)
                {
                    throw new ArgumentNullException("tooltipInfo");
                }

                _tooltipInfo = tooltipInfo;

                using (Graphics g = Graphics.FromHwnd(this.Handle))
                {
                    this.LayoutManager.SetMinimumTooltipSize(this.MinimumSize);
                    _layoutDescriptor = this.LayoutManager.BuildLayoutDescriptor(g, _tooltipInfo, _headerFont, _textFont);
                }

                this.Size = _layoutDescriptor.TooltipSize;
                base.Show(location);
            }
Exemple #7
0
        /// <summary>
        /// Associates a tooltip with the specified <see cref="Control"/>.
        /// </summary>
        /// <param name="targetControl"></param>
        /// <param name="tooltipInfo">
        /// Specify <see langword="null"/> to remove a tooltip for the specified <paramref name="targetControl"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="targetControl"/> is <see langword="null"/>.</para>
        /// </exception>
        public void SetToolTip(Control targetControl, NuGenToolTipInfo tooltipInfo)
        {
            if (targetControl == null)
            {
                throw new ArgumentNullException("targetControl");
            }

            if (tooltipInfo == null)
            {
                this.RemoveTooltip(targetControl);
            }

            if (this.Tooltips.ContainsKey(targetControl))
            {
                this.Tooltips[targetControl] = tooltipInfo;
            }
            else
            {
                this.AddTooltip(targetControl, tooltipInfo);
            }
        }
        /*
         * ConvertTo
         */

        /// <summary>
        /// Converts the given value object to the specified type, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
        /// <param name="culture">A <see cref="T:System.Globalization.CultureInfo"></see>. If null is passed, the current culture is assumed.</param>
        /// <param name="value">The <see cref="T:System.Object"></see> to convert.</param>
        /// <param name="destinationType">The <see cref="T:System.Type"></see> to convert the value parameter to.</param>
        /// <returns>
        /// An <see cref="T:System.Object"></see> that represents the converted value.
        /// </returns>
        /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
        /// <exception cref="T:System.ArgumentNullException">The destinationType parameter is null. </exception>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == null)
            {
                throw new ArgumentNullException("destinationType");
            }

            if (destinationType == typeof(InstanceDescriptor) && value is NuGenToolTipInfo)
            {
                NuGenToolTipInfo tooltipInfo = (NuGenToolTipInfo)value;
                object[]         constructorValues;
                MemberInfo       constructorInfo = this.GetConstructorInfo(
                    tooltipInfo,
                    out constructorValues
                    );

                return(new InstanceDescriptor(constructorInfo, constructorValues));
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
			public void Show(NuGenToolTipInfo tooltipInfo, Point location)
			{
				if (tooltipInfo == null)
				{
					throw new ArgumentNullException("tooltipInfo");
				}

				_tooltipInfo = tooltipInfo;

				using (Graphics g = Graphics.FromHwnd(this.Handle))
				{
					this.LayoutManager.SetMinimumTooltipSize(this.MinimumSize);
					_layoutDescriptor = this.LayoutManager.BuildLayoutDescriptor(g, _tooltipInfo, _headerFont, _textFont);
				}

				this.Size = _layoutDescriptor.TooltipSize;
				base.Show(location);
			}
		/// <summary>
		/// Associates a tooltip with the specified <see cref="Control"/>.
		/// </summary>
		/// <param name="targetControl"></param>
		/// <param name="tooltipInfo">
		/// Specify <see langword="null"/> to remove a tooltip for the specified <paramref name="targetControl"/>.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="targetControl"/> is <see langword="null"/>.</para>
		/// </exception>
		public void SetToolTip(Control targetControl, NuGenToolTipInfo tooltipInfo)
		{
			if (targetControl == null)
			{
				throw new ArgumentNullException("targetControl");
			}

			if (tooltipInfo == null)
			{
				this.RemoveTooltip(targetControl);
			}

			if (this.Tooltips.ContainsKey(targetControl))
			{
				this.Tooltips[targetControl] = tooltipInfo;
			}
			else
			{
				this.AddTooltip(targetControl, tooltipInfo);
			}
		}
Exemple #11
0
 public void Show(Control targetControl, NuGenToolTipInfo tooltipInfo)
 {
     this.Show(tooltipInfo, this.GetToolTipLocation(targetControl));
 }
		public void Show(Control targetControl, NuGenToolTipInfo tooltipInfo)
		{
			this.Show(tooltipInfo, this.GetToolTipLocation(targetControl));
		}
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="tooltipInfo"/> is <see langword="null"/>.</para>
        /// </exception>
        internal MemberInfo GetConstructorInfo(
            NuGenToolTipInfo tooltipInfo,
            out object[] constructorValues
            )
        {
            if (tooltipInfo == null)
            {
                throw new ArgumentNullException("tooltipInfo");
            }

            Type tooltipInfoType = tooltipInfo.GetType();

            Type[] constructorTypes;

            if (
                tooltipInfo.IsRemarksHeaderVisible ||
                tooltipInfo.IsRemarksImageVisible ||
                tooltipInfo.IsRemarksVisible ||
                tooltipInfo.IsCustomSize
                )
            {
                constructorValues = new object[] {
                    tooltipInfo.Header,
                    tooltipInfo.Image,
                    tooltipInfo.Text,
                    tooltipInfo.RemarksHeader,
                    tooltipInfo.RemarksImage,
                    tooltipInfo.Remarks,
                    tooltipInfo.CustomSize
                };

                constructorTypes = new Type[] {
                    typeof(string),
                    typeof(Image),
                    typeof(string),
                    typeof(string),
                    typeof(Image),
                    typeof(string),
                    typeof(Size)
                };
            }
            else if (
                tooltipInfo.IsTextVisible ||
                tooltipInfo.IsHeaderVisible ||
                tooltipInfo.IsImageVisible
                )
            {
                constructorValues = new object[] {
                    tooltipInfo.Header,
                    tooltipInfo.Image,
                    tooltipInfo.Text
                };

                constructorTypes = new Type[] {
                    typeof(string),
                    typeof(Image),
                    typeof(string)
                };
            }
            else
            {
                constructorValues = new object[] { };
                constructorTypes  = new Type[] { };
            }

            return(tooltipInfoType.GetConstructor(constructorTypes));
        }
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="tooltipInfo"/> is <see langword="null"/>.</para>
		/// </exception>
		internal static MemberInfo GetConstructorInfo(
			NuGenToolTipInfo tooltipInfo,
			out object[] constructorValues
			)
		{
			if (tooltipInfo == null)
			{
				throw new ArgumentNullException("tooltipInfo");
			}

			Type tooltipInfoType = tooltipInfo.GetType();
			Type[] constructorTypes;

			if (
				tooltipInfo.IsRemarksHeaderVisible
				|| tooltipInfo.IsRemarksImageVisible
				|| tooltipInfo.IsRemarksVisible
				|| tooltipInfo.IsCustomSize
				)
			{
				constructorValues = new object[] { 
					tooltipInfo.Header,
					tooltipInfo.Image,
					tooltipInfo.Text,
					tooltipInfo.RemarksHeader,
					tooltipInfo.RemarksImage,
					tooltipInfo.Remarks,
					tooltipInfo.CustomSize
				};

				constructorTypes = new Type[] { 
					typeof(string),
					typeof(Image),
					typeof(string),
					typeof(string),
					typeof(Image),
					typeof(string),
					typeof(Size)
				};
			}
			else if (
				tooltipInfo.IsTextVisible
				|| tooltipInfo.IsHeaderVisible
				|| tooltipInfo.IsImageVisible
				)
			{
				constructorValues = new object[] {
					tooltipInfo.Header,
					tooltipInfo.Image,
					tooltipInfo.Text
				};

				constructorTypes = new Type[] {
					typeof(string),
					typeof(Image),
					typeof(string) 
				};
			}
			else
			{
				constructorValues = new object[] { };
				constructorTypes = new Type[] { };
			}

			return tooltipInfoType.GetConstructor(constructorTypes);
		}
			public void Show(NuGenToolTipInfo tooltipInfo, Point location)
			{
				if (tooltipInfo == null)
				{
					throw new ArgumentNullException("tooltipInfo");
				}

				base.Show(location);
			}
Exemple #16
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();
                    }
                }
            }
			/*
			 * 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();
					}
				}
			}
		private void AddTooltip(Control targetControl, NuGenToolTipInfo tooltipInfo)
		{
			Debug.Assert(targetControl != null, "targetControl != null");
			targetControl.MouseHover += _targetControl_MouseHover;
			targetControl.MouseLeave += _targetControl_MouseLeave;
			this.Tooltips.Add(targetControl, tooltipInfo);
		}
		public void Show(NuGenToolTipInfo tooltipInfo, Point location)
		{
			if (tooltipInfo != null)
			{
				_tooltip.Show(tooltipInfo, location);
			}
		}