public static async Task <ContentDialogResult?> OpenDialogAsync(NotepadsDialog dialog, bool awaitPreviousDialog) { try { return(await OpenDialog(dialog, awaitPreviousDialog)); } catch (Exception ex) { var activeDialogTitle = string.Empty; var pendingDialogTitle = string.Empty; if (ActiveDialog?.Title is string activeTitle) { activeDialogTitle = activeTitle; } if (dialog?.Title is string pendingTitle) { pendingDialogTitle = pendingTitle; } Analytics.TrackEvent("FailedToOpenDialog", new Dictionary <string, string>() { { "Message", ex.Message }, { "Exception", ex.ToString() }, { "ActiveDialogTitle", activeDialogTitle }, { "PendingDialogTitle", pendingDialogTitle } }); } return(null); }
private static async Task <ContentDialogResult> OpenDialog(NotepadsDialog dialog, bool awaitPreviousDialog) { TaskCompletionSource <bool> currentAwaiter = _dialogAwaiter; TaskCompletionSource <bool> nextAwaiter = new TaskCompletionSource <bool>(); _dialogAwaiter = nextAwaiter; if (ActiveDialog != null) { if (awaitPreviousDialog) { await currentAwaiter.Task; } else { ActiveDialog.IsAborted = true; ActiveDialog.Hide(); } } ActiveDialog = dialog; try { return(await ActiveDialog.ShowAsync()); } finally { nextAwaiter.SetResult(true); } }
public static NotepadsDialog GetFileOpenErrorDialog(string filePath, string errorMsg) { NotepadsDialog fileOpenErrorDialog = new NotepadsDialog { Title = ResourceLoader.GetString("FileOpenErrorDialog_Title"), Content = string.IsNullOrEmpty(filePath) ? errorMsg : string.Format(ResourceLoader.GetString("FileOpenErrorDialog_Content"), filePath, errorMsg), PrimaryButtonText = ResourceLoader.GetString("FileOpenErrorDialog_PrimaryButtonText"), RequestedTheme = ThemeSettingsService.ThemeMode }; return(fileOpenErrorDialog); }
public static NotepadsDialog GetRevertAllChangesConfirmationDialog(string fileNameOrPath, Action confirmedAction) { NotepadsDialog revertAllChangesConfirmationDialog = new NotepadsDialog { Title = ResourceLoader.GetString("RevertAllChangesConfirmationDialog_Title"), Content = string.Format(ResourceLoader.GetString("RevertAllChangesConfirmationDialog_Content"), fileNameOrPath), PrimaryButtonText = ResourceLoader.GetString("RevertAllChangesConfirmationDialog_PrimaryButtonText"), CloseButtonText = ResourceLoader.GetString("RevertAllChangesConfirmationDialog_CloseButtonText"), RequestedTheme = ThemeSettingsService.ThemeMode, }; revertAllChangesConfirmationDialog.PrimaryButtonClick += (dialog, args) => { confirmedAction(); }; return(revertAllChangesConfirmationDialog); }
public static NotepadsDialog GetSetCloseSaveReminderDialog(string fileNameOrPath, Action saveAction, Action skipSavingAction) { NotepadsDialog setCloseSaveReminder = new NotepadsDialog { Title = ResourceLoader.GetString("SetCloseSaveReminderDialog_Title"), Content = string.Format(ResourceLoader.GetString("SetCloseSaveReminderDialog_Content"), fileNameOrPath), PrimaryButtonText = ResourceLoader.GetString("SetCloseSaveReminderDialog_PrimaryButtonText"), SecondaryButtonText = ResourceLoader.GetString("SetCloseSaveReminderDialog_SecondaryButtonText"), CloseButtonText = ResourceLoader.GetString("SetCloseSaveReminderDialog_CloseButtonText"), RequestedTheme = ThemeSettingsService.ThemeMode, }; setCloseSaveReminder.PrimaryButtonClick += (dialog, args) => { saveAction(); }; setCloseSaveReminder.SecondaryButtonClick += (dialog, args) => { skipSavingAction(); }; return(setCloseSaveReminder); }
public static NotepadsDialog GetAppCloseSaveReminderDialog(Action saveAndExitAction, Action discardAndExitAction, Action cancelAction) { NotepadsDialog saveReminderDialog = new NotepadsDialog { Title = ResourceLoader.GetString("AppCloseSaveReminderDialog_Title"), HorizontalAlignment = HorizontalAlignment.Center, Content = ResourceLoader.GetString("AppCloseSaveReminderDialog_Content"), PrimaryButtonText = ResourceLoader.GetString("AppCloseSaveReminderDialog_PrimaryButtonText"), SecondaryButtonText = ResourceLoader.GetString("AppCloseSaveReminderDialog_SecondaryButtonText"), CloseButtonText = ResourceLoader.GetString("AppCloseSaveReminderDialog_CloseButtonText"), RequestedTheme = ThemeSettingsService.ThemeMode, PrimaryButtonStyle = GetButtonStyle(Color.FromArgb(255, 38, 114, 201)), }; saveReminderDialog.PrimaryButtonClick += (dialog, eventArgs) => saveAndExitAction(); saveReminderDialog.SecondaryButtonClick += (dialog, eventArgs) => discardAndExitAction(); saveReminderDialog.CloseButtonClick += (dialog, eventArgs) => cancelAction(); return(saveReminderDialog); }
public static async Task <ContentDialogResult> OpenDialogAsync(NotepadsDialog dialog, bool awaitPreviousDialog) { return(await OpenDialog(dialog, awaitPreviousDialog)); }