public static void HandleToastAction(ToastNotificationActivatedEventArgsCompat toastArgs) { try { // Obtain the arguments from the notification ToastArguments args = ToastArguments.Parse(toastArgs.Argument); // Obtain any user input (text boxes, menu selections) from the notification ValueSet userInput = toastArgs.UserInput; if (toastArgs.Argument.Length == 0) { return; } Logger.Debug("toast called with args: " + toastArgs.Argument); string[] arguments = toastArgs.Argument.Split(";"); foreach (string argumentString in arguments) { string[] argument = argumentString.Split("="); if (argument[0] == "action" && argument[1] == "update") { Logger.Info("updating app, caller toast"); Task.Run(() => UpdateHandler.Update(overrideSilent: true)).Wait(); } else if (argument[0] == "action" && argument[1] == "postpone") { Logger.Debug("update postponed"); return; } } } catch (Exception ex) { Logger.Error(ex, "updater failed, caller toast:"); } }
public static void ToastNotificationManagerCompatOnOnActivated(ToastNotificationActivatedEventArgsCompat e) { MainWindow.DispatcherQueue.TryEnqueue(() => { //Activate window MainWindow.Activate(); //Handle toast action ToastArguments args = ToastArguments.Parse(e.Argument); if (!args.Contains(ToastAction)) { return; } switch (args[ToastAction]) { case ToastActionConversation: { var chatId = args[ToastActionConversationChat]; if (ChatActivated != null) { ChatActivated.Invoke(null, chatId); } else { PendingChatId = chatId; } break; } } }); }
private void ToastNotifications_OnActivated(ToastNotificationActivatedEventArgsCompat e) { if (Activated != null) { Activated(this, new EventArgs()); } }
private void OnAppActivated(ToastNotificationActivatedEventArgsCompat e) { Debug.Assert(_launchActionPromise != null); var actionId = GetActionId(e.Argument); _launchActionPromise.SetResult(actionId); }
private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e) { var args = ToastArguments.Parse(e.Argument); Activator.Activate( args["type"], args.Contains("receivedAt") ? args["receivedAt"] : null, args.Contains("startedAt") ? args["startedAt"] : null ); }
private void Toast_OnActivated(ToastNotificationActivatedEventArgsCompat e) { var parsed = ToastArguments.Parse(e.Argument); switch (parsed["action"]) { case "viewRafflesWonPage": Process.Start("explorer.exe", "https://scrap.tf/raffles/won"); break; } }
private static void OnToastButtonClicked(ToastNotificationActivatedEventArgsCompat e) { switch (e.Argument) { case "kill": Program.Kill(); break; case "exit": Environment.Exit(0); break; } }
private void OnToastNotificationUserAction(ToastNotificationActivatedEventArgsCompat e) { ToastArguments args = ToastArguments.Parse(e.Argument); Application.Current.Dispatcher.Invoke(delegate { NotificationUserAction data = new() { Arguments = args.ToDictionary(p => p.Key, p => p.Value), UserInputs = e.UserInput.ToDictionary(p => p.Key, p => p.Value) }; _bootstrapper.OnToastNotificationUserAction(data); }); } }
private async static void Notifications_OnActivated(ToastNotificationActivatedEventArgsCompat e) { ToastArguments args = ToastArguments.Parse(e.Argument); var MainForm = Application.OpenForms["Main"] as Main; if (ToastNotificationManagerCompat.WasCurrentProcessToastActivated()) { if (MainForm.InvokeRequired) { MainForm.BeginInvoke(new Action(() => { MetroFramework.MetroMessageBox.Show(MainForm, "Process has been activated by toast notification trigger.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); })); } else { MetroFramework.MetroMessageBox.Show(MainForm, "Process has been activated by toast notification trigger.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } return; } if (!args.Contains("Choice")) { return; //No choice to select then no action required e.g. body tapped } NotificationChoice NotificationChoice = NotificationChoice.None; if (!Enum.TryParse <NotificationChoice>(args["Choice"], out NotificationChoice)) { return; //No valid choice, we return } switch (Enum.Parse(typeof(NotificationPurpose), args["Action"])) { case NotificationPurpose.NotificationsSuppression: { switch (NotificationChoice) { case NotificationChoice.Yes: Properties.Settings.Default.SuppressNotifications = 2; break; case NotificationChoice.No: Properties.Settings.Default.SuppressNotifications = 1; break; default: return; } Properties.Settings.Default.Save(); break; } case NotificationPurpose.TargetDiscovery: { switch (NotificationChoice) { case NotificationChoice.Show: { if (MainForm.InvokeRequired) { MainForm.BeginInvoke(new Action(() => { MainForm.Show(); MainForm.WindowState = FormWindowState.Normal; if (MainForm.TrayIcon.Visible) { MainForm.TrayIcon.Visible = false; } })); } else { MainForm.Show(); MainForm.WindowState = FormWindowState.Normal; if (MainForm.TrayIcon.Visible) { MainForm.TrayIcon.Visible = false; } } break; } case NotificationChoice.Block: { if (!string.IsNullOrEmpty(args["DeviceIP"]) && !string.IsNullOrEmpty(args["DeviceMAC"])) { if (MainForm.InvokeRequired) { MainForm.BeginInvoke(new Action(async() => { await MainForm.BlockDevice(args["DeviceIP"], args["DeviceMAC"]); })); } else { await MainForm.BlockDevice(args["DeviceIP"], args["DeviceMAC"]); } } break; } case NotificationChoice.Suppress: { Properties.Settings.Default.SuppressNotifications = 1; Properties.Settings.Default.Save(); break; } default: return; } break; } default: return; } }
private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e) { Dispatcher.Invoke(() => { // If arguments are empty, that means the app title within Action Center was clicked. if (e.Argument.Length == 0) { OpenWindowIfNeeded(); return; } // Parse the toast arguments ToastArguments args = ToastArguments.Parse(e.Argument); int conversationId = args.GetInt("conversationId"); // If no specific action, view the conversation if (args.TryGetValue("action", out MyToastActions action)) { switch (action) { // View conversation case MyToastActions.ViewConversation: // Make sure we have a window open and in foreground OpenWindowIfNeeded(); // And then show the conversation (Current.Windows[0] as MainWindow).ShowConversation(conversationId); break; // Open the image case MyToastActions.ViewImage: // The URL retrieved from the toast args string imageUrl = args["imageUrl"]; // Make sure we have a window open and in foreground OpenWindowIfNeeded(); // And then show the image (Current.Windows[0] as MainWindow).ShowImage(imageUrl); break; // Background: Quick reply to the conversation case MyToastActions.Reply: // Get the response the user typed string msg = e.UserInput["tbReply"] as string; // And send this message ShowToast("Message sent: " + msg + "\nconversationId: " + conversationId); // If there's no windows open, exit the app if (Current.Windows.Count == 0) { Current.Shutdown(); } break; // Background: Send a like case MyToastActions.Like: ShowToast($"Like sent to conversation {conversationId}!"); // If there's no windows open, exit the app if (Current.Windows.Count == 0) { Current.Shutdown(); } break; default: OpenWindowIfNeeded(); break; } } }); }
private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e) { // throw new NotImplementedException(); }
private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e) { var args = ToastArguments.Parse(e.Argument); var path = args.ToString()[18..];