Infragistics.Win.ToolTip - determining whether or not the close button was clicked

Infragistics offers a nice-looking desktop alert control (more info here). However, it is slightly lacking in terms of functionality, namely the ability to notify us when the close button was clicked, i.e. when the user is not interested in this particular announcement for whatever reason.

Wanted: An event: DesktopAlertCloseButtonClicked.

... but since it's missing, here's how you do it:

private Rectangle desktopAlertCloseRect;

...

desktopAlert.DesktopAlertClosed += desktopAlert_DesktopAlertClosed;
desktopAlertCloseRect = new Rectangle(
  Screen.PrimaryScreen.Bounds.Width - 19,
  Screen.PrimaryScreen.Bounds.Height - 110,
  17, 17
);

...

private void desktopAlert_DesktopAlertClosed(object sender, DesktopAlertClosedEventArgs e)
{
  if(desktopAlertCloseRect.Contains(Cursor.Position))
    //Close button was clicked
}

To resolve whether or not the alert closed due to the user clicking your link, simply attach an event handler to DesktopAlertLinkClicked where you set a variable, which you then read in the Closed event (above). This is to avoid getting two events - one for the link, and another one for the tool tip closing.

Example:

desktopAlert.DesktopAlertLinkClicked += delegate { linkClicked = true; };

Added code in the event handler:

if(linkClicked)
  // Link was clicked

Enjoy!

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints