public void Show( string title, string message, ToastTypes toastType, TimeSpan displayTime, Rect?parentContainer = null, bool isPersistent = false) { //Show the host window ShowHost(parentContainer); //Create a new toast control ToastNotification notification = new ToastNotification() { Title = title, Message = message, ToastType = toastType, IsPersistent = isPersistent }; //Create a toast and accompanying dispatcher timer. Toast toast = new Toast(notification); toast.ToastClosing += Toast_ToastClosing; //Add the toast to the host window _HOST.Toasts.Add(notification); //display it for X seconds toast.Show(displayTime); }
/// <summary> /// Show toast /// </summary> /// <param name="text">Text to be shown in the toast</param> /// <param name="type">Type of Toast. Could be info, success, warning or errors.</param> /// <param name="position">Position of Toast. Several options available</param> /// <remarks></remarks> public void New(string text, ToastTypes type, ToastPositions position) { t_Text = text; t_Type = type; t_Title = string.Empty; t_Position = position; }
/// <summary> /// Show toast at top right /// </summary> /// <param name="text">Text to be shown in the toast</param> /// <param name="type">Type of Toast. Could be info, success, warning or errors.</param> /// <remarks></remarks> public void New(string text, ToastTypes type) { t_Text = text; t_Type = type; t_Title = string.Empty; t_Position = ToastPositions.toast_top_right; }
public void Show( string title, string message, ToastTypes toastType, Rect?parentContainer = null, bool isPersistent = false) { Show(title, message, toastType, new TimeSpan(0, 0, 5), parentContainer, isPersistent); }
public void ClearToast(ToastTypes types) { if ((types & ToastTypes.ScheduleSummary) != 0) { ToastNotificationManager.History.RemoveGroup(ToastTypes.ScheduleSummary.ToString()); } if ((types & ToastTypes.ScoreChange) != 0) { ToastNotificationManager.History.RemoveGroup(ToastTypes.ScoreChange.ToString()); } }
//show alert dialog void alertMessage(string title, string message, ToastTypes type) { bool isPersistent = false; bool showInWindow = false; if (showInWindow) { Rect bounds = new Rect( this.Left, this.Top, this.Width, this.Height); _Toaster.Show(title, message, type, bounds, isPersistent); } else { _Toaster.Show(title, message, type, isPersistent: isPersistent); } }
/// <summary> /// uses the peanutbutter.dll file to display toast notifications /// </summary> /// <param name="Error"></param> private void ShowToast(string Error) { var time = DateTime.Now; string title = "Title"; string message = "Message"; ToastTypes type = ToastTypes.Warning; TimeSpan span = time.Subtract(lastUsedTime); if (span.Minutes < 2) { return; } if (Error == "HighPing") { title = "High Ping"; message = "Ping is over 500"; type = ToastTypes.Warning; lastUsedTime = DateTime.Now; } else if (Error == "Failure") { title = "Ping Timeout"; message = "Ping Timed out"; type = ToastTypes.Error; lastUsedTime = DateTime.Now; } Toaster toaster = new Toaster(); try { toaster.Show(title, message, type); } catch (Exception ex) { MessageBox.Show(String.Concat("An error occured trying to show an alert, The alert was: ", message), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void toastRequested(object sender, RoutedEventArgs e) { ToastTypes type = GetChosenToastType((Button)sender); string title = txtTitle.Text; string message = txtMessage.Text; bool isPersistent = (bool)chkPersistent.IsChecked; bool showInWindow = (bool)chkShowInWindow.IsChecked; if (showInWindow) { Rect bounds = new Rect( this.Left, this.Top, this.Width, this.Height); _Toaster.Show(title, message, type, bounds, isPersistent); } else { _Toaster.Show(title, message, type, isPersistent: isPersistent); } }
public void SetMessage(ToastTypes type, string msg, string title = "Error") { this.Title = title; this.Message = msg; this.Type = type; }