/// <summary> /// Stops the timer, disposes off the toast messasge /// </summary> private void stopTimer() { try { unsubscribeFromHookEvents(); if (_form != null) { _form.Invoke(new MethodInvoker(delegate { if (_toastForm != null) { _toastForm.Close(); _toastForm = null; } if (_timer != null) { _timer.Stop(); if (EvtAutoPostionScannerStopped != null) { EvtAutoPostionScannerStopped(this, EventArgs.Empty); } } })); } } catch { } }
/// <summary> /// Starts the timer that repositions the scanner on /// a timer tick /// </summary> public void Start() { _form.Invoke(new MethodInvoker(delegate() { _toastForm = new ToastForm("Click to stop", -1); Windows.SetWindowPosition(_toastForm, Windows.WindowPosition.CenterScreen); _toastForm.Show(); if (!_timer.Enabled) { subscribeToHookEvents(); startTimer(); } })); }
/// <summary> /// Displays a toast message centered in the parent form. /// </summary> /// <param name="message">message to display</param> /// <param name="timeout">how long to display</param> public static void Toast(String message, int timeout = 2000) { var toast = new ToastForm(message, timeout); var panel = Context.AppPanelManager.GetCurrentPanel() as Form; toast.StartPosition = FormStartPosition.CenterParent; toast.ShowDialog(panel); }