public void Show (string text, IWin32Window window, int duration)
{
if (window == null)
throw new ArgumentNullException ("window");
if (duration < 0)
throw new ArgumentOutOfRangeException ("duration", "duration cannot be less than zero");
if (!Active)
return;
timer.Stop ();
Control c = (Control)window;
//XplatUI.SetOwner (tooltip_window.Handle, c.TopLevelControl.Handle);
// If the mouse is in the requested window, use that position
// Else, center in the requested window
if (c.ClientRectangle.Contains (c.PointToClient (Control.MousePosition))) {
tooltip_window.Location = Control.MousePosition;
tooltip_strings[c] = text;
HookupControlEvents (c);
}
else
tooltip_window.Location = c.PointToScreen (new Point (c.Width / 2, c.Height / 2));
// We need to hide our tooltip if the form loses focus, is closed, or is minimized
HookupFormEvents ((Form)c.TopLevelControl);
tooltip_window.PresentModal ((Control)window, text);
state = TipState.Show;
if (duration > 0) {
timer.Interval = duration;
timer.Start ();
}
}