private void OnShowToolTip(object sender, ToolTipEventArgs e)
{
if (!IsDisposed)
{
// Do not show tooltips when the form we are in does not have focus
Form topForm = _calendar.CalendarControl.FindForm();
if ((topForm != null) && !topForm.ContainsFocus)
{
return;
}
// Never show tooltips are design time
if (!_calendar.InDesignMode)
{
IContentValues sourceContent = null;
LabelStyle toolTipStyle = LabelStyle.ToolTip;
// Find the button spec associated with the tooltip request
ButtonSpec buttonSpec = _buttonManager.ButtonSpecFromView(e.Target);
// If the tooltip is for a button spec
if (buttonSpec != null)
{
// Are we allowed to show page related tooltips
if (AllowButtonSpecToolTips)
{
// Create a helper object to provide tooltip values
ButtonSpecToContent buttonSpecMapping = new ButtonSpecToContent(_redirector, buttonSpec);
// Is there actually anything to show for the tooltip
if (buttonSpecMapping.HasContent)
{
sourceContent = buttonSpecMapping;
toolTipStyle = buttonSpec.ToolTipStyle;
}
}
}
if (sourceContent != null)
{
// Remove any currently showing tooltip
_visualPopupToolTip?.Dispose();
// Create the actual tooltip popup object
_visualPopupToolTip = new VisualPopupToolTip(_redirector,
sourceContent,
_calendar.GetRenderer(),
PaletteBackStyle.ControlToolTip,
PaletteBorderStyle.ControlToolTip,
CommonHelper.ContentStyleFromLabelStyle(toolTipStyle));
_visualPopupToolTip.Disposed += new EventHandler(OnVisualPopupToolTipDisposed);
// Show relative to the provided screen rectangle
_visualPopupToolTip.ShowCalculatingSize(_calendar.CalendarControl.RectangleToScreen(e.Target.ClientRectangle));
}
}
}
}