BinaryPointTip
A tool tip you show yourself, at any point on the screen – to point out a field that needs attention,
confirm an action next to where it happened, or guide a user through a form – with a title, an icon,
text and the same rectangle or balloon look as BinaryToolTip.
public sealed partial class BinaryPointTip : Component
Inherits from / implements: Component
Remarks
Unlike BinaryToolTip, a point tip is not tied to a control or to the mouse: call
Show with the title, text, screen point and how long to show it, or
ShowForEver to keep it up until you call Hide. It also closes when the
pointer moves over it.
The tip's body appears a mouse-pointer's height below the point; a
BinaryToolTipStyle.BalloonType tip points back up at it. A tip that would run off the
screen is moved above the point or to the left. Colours, fonts, shadow and wrapping are set on the
component: BackColor, BorderColor, TitleForeColor,
TextForeColor, ToolTipTextFont, ShadowOffset,
CustomWidth.
Examples
Point at an invalid e-mail address when the user tries to save.
using System;
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.Popups;
private readonly BinaryPointTip _hint = new BinaryPointTip
{
BackColor = Color.MistyRose,
BorderColor = Color.Firebrick,
TitleForeColor = Color.Firebrick,
CustomWidth = 220
};
private void OnSaveClick(object sender, EventArgs e)
{
if (!emailBox.Text.Contains("@"))
{
// The middle of the box's bottom edge, in screen coordinates.
Point anchor = emailBox.PointToScreen(new Point(emailBox.Width / 2, emailBox.Height));
_hint.Show("Check the e-mail address",
"An e-mail address needs an @, as in orders@example.com.",
anchor, 4000, SystemIcons.Warning.ToBitmap(), BinaryToolTipStyle.BalloonType);
emailBox.Focus();
}
}See also
Members at a glance
| Constructors | |
|---|---|
BinaryPointTip | Initialises a new point tip with a standard rectangular look in light yellow with a brown outline. |
BinaryPointTip | Initialises a new point tip, 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. |
Image | Gets or sets a picture to keep with the component. |
PointTipText | Gets or sets the text of the tip, and updates the tip on screen if it is showing. |
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. |
ShowDelay | Gets or sets a display time in milliseconds. |
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 a display time in milliseconds, as on BinaryToolTip. |
ToolTipHoverDelay | Gets or sets a hover delay in milliseconds, as on BinaryToolTip. |
ToolTipReshowDelay | Gets or sets a reshow delay in milliseconds, as on BinaryToolTip. |
ToolTipTextFont | Gets or sets the font of the tip's main text. |
ToolTipTipStyle | Gets or sets the shape of the tip. |
| Methods | |
Dispose | Closes any open tip and releases the resources the component holds. |
Hide | Closes the tip, whether it was shown with Show or ShowForEver. |
Show | Shows the tip at a point on the screen for a set time. |
ShowForEver | Shows the tip at a point on the screen until Hide is called. |
Constructors
BinaryPointTip
Initialises a new point tip with a standard rectangular look in light yellow with a brown outline.
BinaryPointTip
Initialises a new point tip, 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 pixelsImage
Gets or sets a picture to keep with the component.
- Value
- A copy of the picture with the colour of its top-left pixel made see-through, or
null. The default isnull.
Remarks
Not used by Show or ShowForEver, which draw the picture passed to
them; pass this property's value there to use it.
Example
hint.Image = Properties.Resources.Lightbulb16;
hint.Show("Tip", "Double-click a row to open the order.", anchor, 5000, hint.Image, BinaryToolTipStyle.BalloonType);PointTipText
Gets or sets the text of the tip, and updates the tip on screen if it is showing.
- Value
- The text last shown or set. The default is
null.
Remarks
Setting it while the tip is up re-draws the tip with the new text at the same point – handy for
a progress or countdown message. While no tip is showing, the next call to Show or
ShowForEver replaces it with the text passed there.
ShadowColor
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
ShowDelay
Gets or sets a display time in milliseconds.
- Value
- The default is 5000.
Remarks
Has no effect: Show takes the display time as an argument.
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 a display time in milliseconds, as on BinaryToolTip.
- Value
- 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
Has no effect on a point tip: pass the display time to Show instead.
ToolTipHoverDelay
Gets or sets a hover delay in milliseconds, as on BinaryToolTip.
- Value
- 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
Has no effect on a point tip, which is shown and hidden only by Show,
ShowForEver and Hide. It is kept so that the same settings can be used on a
BinaryToolTip.
ToolTipReshowDelay
Gets or sets a reshow delay in milliseconds, as on BinaryToolTip.
- Value
- 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
Has no effect on a point tip, which is shown and hidden only by Show,
ShowForEver and Hide. It is kept so that the same settings can be used on a
BinaryToolTip.
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 the tip.
- Value
BinaryToolTipStyle.Standardfor a rectangle, orBinaryToolTipStyle.BalloonTypefor a rounded balloon with a pointer. The default isBinaryToolTipStyle.Standard.- Designer category
- Appearance"), Description("Gets or sets the style used to display the tooltip."), DefaultValue(BinaryToolTipStyle.Standard
Remarks
Show and ShowForEver set it to the style they are given.
Methods
Dispose
Closes any open tip and releases the resources the component holds.
Parameters
disposingtruewhen called fromDispose();falsewhen called from a finaliser.
Hide
Closes the tip, whether it was shown with Show or ShowForEver.
Remarks
Does nothing when no tip is showing.
Show
Shows the tip at a point on the screen for a set time.
Parameters
title- The title, drawn above the text (bold unless
TitleWillBeBoldis off);nullor an empty string for none. tiptext- The text of the tip. It wraps at
CustomWidthwhileAutomaticMultiLineSupportis on. pnt- The point to show the tip at, in screen coordinates – use
Control.PointToScreento convert from a control's coordinates. Delay- How long the tip stays up, in milliseconds.
img- A small picture shown beside the title, ideally 16 by 16 pixels, or
null. It must be aBitmap, and is drawn as it is, without the transparency thatImageapplies. style- The shape: a rectangle, or a balloon pointing at
pnt. It also becomesToolTipTipStyle.
Remarks
A tip already showing is replaced. The tip also closes when the pointer moves over it, or when
Hide is called.
See also
ShowForEver
Shows the tip at a point on the screen until Hide is called.
Parameters
title- The title, drawn above the text (bold unless
TitleWillBeBoldis off);nullor an empty string for none. tiptext- The text of the tip.
pnt- The point to show the tip at, in screen coordinates.
img- A small picture shown beside the title, or
null. It must be aBitmap. theTipStyle- The shape: a rectangle, or a balloon pointing at
pnt. It also becomesToolTipTipStyle.
Remarks
Use it for guidance that must stay until the user acts, such as the next step of a walkthrough. The tip still closes if the pointer moves over it.
Example
Point anchor = importButton.PointToScreen(new Point(importButton.Width / 2, importButton.Height));
hint.ShowForEver("Step 2 of 3", "Click Import to load the price list.", anchor, null, BinaryToolTipStyle.BalloonType);
importButton.Click += (s, e) => hint.Hide();