private static FLASHWINDOWINFO CreateFlashWindowInfo(WindowArgument window, Commands command) { FLASHWINDOWINFO info = new FLASHWINDOWINFO(); info.cbSize = Convert.ToUInt32(Marshal.SizeOf(info)); info.hwnd = window.Handle; info.dwFlags = (UInt32)command; info.uCount = command == Commands.FlashUntilExplicitlyStopped ? UInt32.MaxValue : 5; info.dwTimeout = 0; return info; }
public static void Invoke(WindowArgument window, bool audio, bool visual, string message) { if(audio) Beep(); bool flashUntilUserAcknowledgement = message != null && message.Length > 0; if(visual) FlashWindow(window, !flashUntilUserAcknowledgement); if(flashUntilUserAcknowledgement) { NotifyUser(message, window); if(visual) StopFlashingWindow(window); } }
private static void StopFlashingWindow(WindowArgument window) { FLASHWINDOWINFO info = CreateFlashWindowInfo(window, Commands.StopFlashing); FlashWindowEx(ref info); }
private static void NotifyUser(string message, WindowArgument alarmWindow) { MessageBox.Show(alarmWindow, message, Connect.addinName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
private static void FlashWindow(WindowArgument window, bool flashIndefinitely) { FLASHWINDOWINFO info = CreateFlashWindowInfo(window, flashIndefinitely ? Commands.FlashBriefly : Commands.FlashUntilExplicitlyStopped); FlashWindowEx(ref info); }