BinaryToolTip
A tool tip component that gives controls a tip with a title, an icon and text, drawn as a rectangle or as a rounded balloon pointing at the mouse pointer, with a soft drop shadow and colours of your choosing.
public sealed partial class BinaryToolTip : Component, IExtenderProvider
Inherits from / implements: Component, IExtenderProvider
Remarks
Drop one on a form and every control on it gains BinaryToolTipText,
BinaryToolTipTitle, BinaryToolTipIcon and BinaryToolTipStyle properties "on
binaryToolTip1" in the Properties window; in code, call SetBinaryToolTipText and its
companions with the control.
When tips show
A control shows a tip once it has text. The tip appears when the pointer has rested on the
control for ToolTipHoverDelay, just below the pointer, and closes after
ToolTipHideDelay, or as soon as the pointer moves, leaves the control or presses a button.
Moving on to another control within ToolTipReshowDelay shows that control's tip at once.
A tip that would run off the screen is moved above the pointer or to the left.
Appearance
Each control's tip is a BinaryToolTipStyle.Standard rectangle or a
BinaryToolTipStyle.BalloonType balloon (ToolTipTipStyle, or
SetBinaryToolTipStyle per control). The colours, fonts, shadow and wrapping are set once on
the component and shared by all its tips: BackColor, BorderColor,
TitleForeColor, TextForeColor, ToolTipTextFont,
ShadowOffset, ShadowColor, CustomWidth.
Examples
Balloon tips on a customer form's fields, in a cool blue.
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.Popups;
public class CustomerForm : Form
{
private readonly BinaryToolTip _tips;
private readonly TextBox _vatNumber = new TextBox { Location = new Point(120, 16), Width = 160 };
private readonly TextBox _creditLimit = new TextBox { Location = new Point(120, 48), Width = 100 };
public CustomerForm()
{
_tips = new BinaryToolTip
{
ToolTipTipStyle = BinaryToolTipStyle.BalloonType,
BackColor = Color.AliceBlue,
BorderColor = Color.SteelBlue,
TitleForeColor = Color.MidnightBlue,
CustomWidth = 240,
ToolTipHoverDelay = 400
};
_tips.SetBinaryToolTipTitle(_vatNumber, "VAT number");
_tips.SetBinaryToolTipText(_vatNumber, "The customer's VAT registration number, for example GB123456789. Leave blank for private customers.");
_tips.SetBinaryToolTipIcon(_vatNumber, SystemIcons.Information.ToBitmap());
_tips.SetBinaryToolTipTitle(_creditLimit, "Credit limit");
_tips.SetBinaryToolTipText(_creditLimit, "The most the customer may owe at any time, in pounds sterling.");
Controls.Add(_vatNumber);
Controls.Add(_creditLimit);
}
}See also
Members at a glance
| Constructors | |
|---|---|
BinaryToolTip | Initialises a new tool tip component with standard rectangular tips in light yellow with a brown outline. |
BinaryToolTip | Initialises a new tool tip component, as the Windows Forms designer creates it. |
| Properties | |
AutomaticMultiLineSupport | Gets or sets whether long text wraps at CustomWidth rather than running on in one line. |
BackColor | Gets or sets the colour that fills the tip. |
BalloonEdgeCurveFactor | Gets or sets how rounded the corners of a balloon tip are. |
BorderColor | Gets or sets the colour of the line round the tip. |
CustomWidth | Gets or sets the width at which the tip's text wraps onto a new line. |
ShadowColor | Gets or sets the colour the tip's drop shadow is drawn in. |
ShadowOffset | Gets or sets how far the tip's drop shadow falls to the right and below the tip. |
TextForeColor | Gets or sets the colour of the tip's main text. |
TitleForeColor | Gets or sets the colour of the tip's title. |
TitleWillBeBold | Gets or sets whether the tip's title is bold. |
TitleWillBeUnderlined | Gets or sets whether the tip's title is underlined. |
ToolTipHideDelay | Gets or sets how long a tip stays on screen if the pointer stays still. |
ToolTipHoverDelay | Gets or sets how long the mouse pointer must rest on a control before its tip appears. |
ToolTipReshowDelay | Gets or sets how long after one tip closes the pointer can move onto another control and see its tip
at once, without waiting for ToolTipHoverDelay. |
ToolTipTextFont | Gets or sets the font of the tip's main text. |
ToolTipTipStyle | Gets or sets the shape of tips for controls that have not been given a style of their own. |
| Methods | |
Dispose | Closes any open tip and releases the resources the component holds. |
GetBinaryToolTipIcon | Gets the picture shown in a control's tip. |
GetBinaryToolTipStyle | Gets the shape of a control's tip. |
GetBinaryToolTipText | Gets the main text of a control's tip. |
GetBinaryToolTipTitle | Gets the title of a control's tip. |
SetBinaryToolTipIcon | Sets a small picture shown at the start of a control's tip, beside the title. |
SetBinaryToolTipStyle | Sets the shape of one control's tip, overriding ToolTipTipStyle. |
SetBinaryToolTipText | Sets the main text of a control's tip, and so gives the control a tip. |
SetBinaryToolTipTitle | Sets the title shown above the text of a control's tip. |
Constructors
BinaryToolTip
Initialises a new tool tip component with standard rectangular tips in light yellow with a brown outline.
BinaryToolTip
Initialises a new tool tip component, as the Windows Forms designer creates it.
Parameters
ic- The form's component container.
Properties
AutomaticMultiLineSupport
Gets or sets whether long text wraps at CustomWidth rather than running on in one line.
- Value
trueto wrap the text atCustomWidth. The default istrue.
Remarks
With wrapping off, the tip is as wide as the longest line, and lines break only where the text has line breaks.
BackColor
Gets or sets the colour that fills the tip.
- Value
- The fill colour. The default is
Color.LightYellow.
See also
BalloonEdgeCurveFactor
Gets or sets how rounded the corners of a balloon tip are.
- Value
- The size of each rounded corner as a percentage of the balloon's width and height. The default is 15.
- Designer category
- Appearance"), Description("Gets or sets the Edge curve factor when the style is Balloon style!
Remarks
Used only by the BinaryToolTipStyle.BalloonType style; a standard tip has square
corners. Larger values give a rounder, more pill-like balloon. Being a percentage, it looks the same at
every display scale.
BorderColor
Gets or sets the colour of the line round the tip.
- Value
- The outline colour. The default is
Color.Brown.
Remarks
A balloon tip's outline, including its pointer, is two pixels wide; a standard tip's is one.
CustomWidth
Gets or sets the width at which the tip's text wraps onto a new line.
- Value
- The wrap width in logical pixels. The default is 100; values below 100 are raised to 100.
Remarks
Used only while AutomaticMultiLineSupport is on. Line breaks in the text always
start a new line.
Example
tip.AutomaticMultiLineSupport = true;
tip.CustomWidth = 260; // wrap long hints at about 260 logical pixelsShadowColor
Gets or sets the colour the tip's drop shadow is drawn in.
- Value
- The shadow colour. The default is
Color.Black. - Designer category
- Appearance"), Description("Gets or sets the colour the tip's drop shadow is drawn in"), DefaultValue(typeof(Color), "Black
Remarks
The shadow is drawn partly transparent and faded at its edge, so black darkens whatever is behind the tip on any theme. A light colour shows only over a background darker than itself.
See also
ShadowOffset
Gets or sets how far the tip's drop shadow falls to the right and below the tip.
- Value
- The horizontal and vertical offset in logical pixels. The default is (7, 7).
- Designer category
- Appearance"), Description("Gets or sets the dropshadow position
Remarks
A larger offset makes the tip seem to float higher. The shadow's soft edge widens with the offset, between 2 and 24 pixels. Negative values cast the shadow up or to the left.
See also
TextForeColor
Gets or sets the colour of the tip's main text.
- Value
- The text colour. The default is
SystemColors.WindowText.
See also
TitleForeColor
Gets or sets the colour of the tip's title.
- Value
- The title colour. The default is
SystemColors.WindowText.
See also
TitleWillBeBold
Gets or sets whether the tip's title is bold.
- Value
truefor a bold title. The default istrue.
Remarks
The title is drawn in the family of the system message box font at 8 points.
See also
TitleWillBeUnderlined
Gets or sets whether the tip's title is underlined.
- Value
trueto underline the title. The default isfalse.
Remarks
The title is drawn in the family of the system message box font at 8 points.
See also
ToolTipHideDelay
Gets or sets how long a tip stays on screen if the pointer stays still.
- Value
- The time in milliseconds. The default is 5000.
- Designer category
- Behavior"), Description("Gets or sets the delay, in milliseconds, before when the tooltip will appear while the mouse is stationary over the target control"), DefaultValue(5000
Remarks
The tip closes sooner when the pointer moves, leaves the control or presses a button.
See also
ToolTipHoverDelay
Gets or sets how long the mouse pointer must rest on a control before its tip appears.
- Value
- The delay in milliseconds. The default is 500.
- Designer category
- Behavior"), Description("Gets or sets the delay, in milliseconds, before when the tooltip will appear while the mouse is stationary over the target control"), DefaultValue(500
Remarks
Moving the pointer starts the wait again.
See also
ToolTipReshowDelay
Gets or sets how long after one tip closes the pointer can move onto another control and see its tip
at once, without waiting for ToolTipHoverDelay.
- Value
- The time in milliseconds. The default is 100.
- Designer category
- Behavior"), Description("Gets or sets the time, in milliseconds, when to reshow the tooltip as the mouse moves to another target control"), DefaultValue(100
Remarks
Lets a user run the pointer along a row of toolbar buttons and read each tip in turn.
ToolTipTextFont
Gets or sets the font of the tip's main text.
- Value
- The font. When none has been set, the family of the system message box font at 8 points.
- Designer category
- Appearance"), Description("Gets or sets the font used to display the tooltip's text!"), Editor("FontEditor", typeof(System.Drawing.Design.UITypeEditor)
Remarks
The tip is sized to fit its text in this font each time it is shown. The title's font is set
separately, with TitleWillBeBold and TitleWillBeUnderlined.
ToolTipTipStyle
Gets or sets the shape of tips for controls that have not been given a style of their own.
- Value
BinaryToolTipStyle.Standardfor a rectangle, orBinaryToolTipStyle.BalloonTypefor a rounded balloon pointing at the mouse pointer. The default isBinaryToolTipStyle.Standard.- Designer category
- Appearance"), Description("Gets or sets the style used to display the tooltip."), DefaultValue(BinaryToolTipStyle.Standard
Remarks
A style set for one control with SetBinaryToolTipStyle wins over this.
Methods
Dispose
Closes any open tip and releases the resources the component holds.
Parameters
disposingtruewhen called fromDispose();falsewhen called from a finaliser.
GetBinaryToolTipIcon
Gets the picture shown in a control's tip.
Parameters
theAttachedObject- The control the tip belongs to.
Returns
The tip's copy of the picture, or null when there is none.
GetBinaryToolTipStyle
Gets the shape of a control's tip.
Parameters
theAttachedObject- The control the tip belongs to.
Returns
The style set for the control, or ToolTipTipStyle when none has been.
GetBinaryToolTipText
Gets the main text of a control's tip.
Parameters
theAttachedObject- The control the tip belongs to.
Returns
The text, or an empty string when the control has no tip.
See also
GetBinaryToolTipTitle
Gets the title of a control's tip.
Parameters
theAttachedObject- The control the tip belongs to.
Returns
The title, or an empty string when the control's tip has none.
SetBinaryToolTipIcon
Sets a small picture shown at the start of a control's tip, beside the title.
Parameters
theAttachedObject- The control the tip belongs to.
anImage- The picture, ideally 16 by 16 pixels, or
nullto remove it.
Remarks
The tip keeps its own copy, in which the colour of the top-left pixel is made see-through, so a picture on a plain background needs no transparency of its own. The picture's pixel size is taken as logical pixels and scaled with the display.
Example
tips.SetBinaryToolTipIcon(deleteButton, SystemIcons.Warning.ToBitmap());SetBinaryToolTipStyle
Sets the shape of one control's tip, overriding ToolTipTipStyle.
Parameters
theAttachedObject- The control the tip belongs to.
theTipStyleBinaryToolTipStyle.Standardfor a rectangle, orBinaryToolTipStyle.BalloonTypefor a balloon pointing at the mouse pointer.
SetBinaryToolTipText
Sets the main text of a control's tip, and so gives the control a tip.
Parameters
theAttachedObject- The control the tip belongs to.
theTipText- The text. Long text wraps at
CustomWidth; line breaks start a new line. An empty string removes the control's tip.
Remarks
Calling it again replaces the text. A control's title and icon are shown only while it has text.
Example
tips.SetBinaryToolTipText(postcodeBox, "Enter the postcode and press Find to fill in the address.");See also
SetBinaryToolTipTitle
Sets the title shown above the text of a control's tip.
Parameters
theAttachedObject- The control the tip belongs to.
theTipText- The title. An empty string removes it.
Remarks
The title is drawn in TitleForeColor, bold unless TitleWillBeBold is
off, beside the icon if there is one. A title alone does not give a control a tip; set its text as
well.