using
System;
using
System.Drawing;
using
System.Linq;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
namespace
ExtensionMethods
{
public
static
class
MyExtensions
{
#region ////////// SCREENTIP ... ///////////////
/* TO USE, in your form or user control add a reference to this namespace (using ExtensionMethods;)
void btn_ScreenTipNeeded(object sender, Telerik.WinControls.ScreenTipNeededEventArgs e)
{
e.Item.PopupTip(e, "Format Painter (Ctrl+Shift+C)", null, "<html>Copy <b>formatting</b> from one place and apply it to another.");
}
*/
private
static
RadOffice2007ScreenTipElement screenTip =
new
RadOffice2007ScreenTipElement();
/// <summary>
/// Set to true to display or hide all PopupTips.
/// </summary>
public
static
bool
ShowPopupTips =
true
;
/// <summary>
/// Incapsulate ScreenTips in one location and closely follows Office 2007 Screen Tip popup convention/style.
/// </summary>
/// <param name="control"></param>
/// <param name="e">ScreenTipNeededEventArgs to allow a global (one location) config of Delay and Offset.</param>
/// <param name="titleText">Caption. Leave blank to hide the caption area.</param>
/// <param name="mainImage">Image shown middle-left of main text area or null if no image to display.</param>
/// <param name="mainText">Main text area. If the mainImage is null and mainText is empty, the main area is hidden.</param>
/// <param name="showFooter">Show/hide footer. Default is show it.</param>
public
static
void
PopupTip(
this
RadItem control, ScreenTipNeededEventArgs e,
string
titleText, Image mainImage =
null
,
string
mainText =
""
,
bool
showFooter =
true
)
{
if
(!ShowPopupTips)
return
;
e.Delay = 1;
e.Offset =
new
System.Drawing.Size(-32, 0);
screenTip =
null
;
screenTip =
new
RadOffice2007ScreenTipElement();
screenTip.CaptionLabel.Padding =
new
Padding(8, 8, 8, 2);
screenTip.CaptionLabel.Font =
new
Font(
"Tahoma"
, 8.5f, FontStyle.Bold);
screenTip.CaptionLabel.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
screenTip.CaptionLabel.Opacity = .8;
//screenTip.CaptionLabel.TextImageRelation = TextImageRelation.ImageBeforeText;
screenTip.CaptionLabel.TextAlignment = ContentAlignment.MiddleLeft;
//screenTip.CaptionLabel.ImageAlignment = ContentAlignment.MiddleLeft;
//screenTip.CaptionLabel.Image = myNamespace.Properties.Resources.help16;
if
(
string
.IsNullOrEmpty(titleText))
screenTip.CaptionLabel.Visibility = ElementVisibility.Hidden;
else
screenTip.CaptionLabel.Text = titleText;
screenTip.MainTextLabel.Padding =
new
Padding(8, 0, 8, 0);
screenTip.MainTextLabel.Font =
new
Font(
"Tahoma"
, 8.5f);
screenTip.MainTextLabel.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
screenTip.MainTextLabel.Opacity = .9;
screenTip.MainTextLabel.TextImageRelation = TextImageRelation.ImageBeforeText;
screenTip.MainTextLabel.TextAlignment = ContentAlignment.MiddleLeft;
screenTip.MainTextLabel.ImageAlignment = ContentAlignment.MiddleLeft;
if
(
string
.IsNullOrEmpty(mainText) && mainImage ==
null
)
screenTip.MainTextLabel.Visibility = ElementVisibility.Hidden;
screenTip.MainTextLabel.Image = mainImage;
if
(!
string
.IsNullOrEmpty(mainText))
screenTip.MainTextLabel.Text = mainText;
screenTip.FooterVisible = showFooter;
screenTip.FooterLine.Visibility = showFooter ? ElementVisibility.Visible : ElementVisibility.Hidden;
screenTip.FooterTextLabel.Padding =
new
Padding(8);
screenTip.FooterTextLabel.Font =
new
Font(
"Tahoma"
, 8.5f, FontStyle.Bold);
screenTip.FooterTextLabel.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
screenTip.FooterTextLabel.Opacity = .8;
screenTip.FooterTextLabel.TextImageRelation = TextImageRelation.ImageBeforeText;
screenTip.FooterTextLabel.TextAlignment = ContentAlignment.MiddleLeft;
screenTip.FooterTextLabel.ImageAlignment = ContentAlignment.MiddleLeft;
screenTip.FooterTextLabel.Image = SystemIcons.Question.ToBitmap().GetThumbnailImage(22, 22,
null
, IntPtr.Zero);
//myNamespace.Properties.Resources.help16;
screenTip.FooterTextLabel.Text =
" Press F1 for more help."
;
//The following line indicates that Office 2007 UI complient screen tip sizing should not be used.
screenTip.EnableCustomSize =
false
;
screenTip.AutoSizeMode = RadAutoSizeMode.Auto;
control.ScreenTip = screenTip;
}
#endregion //////// END SCREENTIP ////////////////
}
}
In your forms and user controls, add the reference to your Extension Methods Namespace: