private async void OnBeginRoundsModeButtonClick(object sender, RoutedEventArgs e) { var tb = sender as ToggleButton; if (tb.IsChecked == false) { ConfirmationDialog confDiag = new ConfirmationDialog( "Ending Rounds Mode will log you out of this machine. Are you sure you want to continue?", "Confirm End of Rounds Mode", "Continue", "Cancel" ); confDiag.PrimaryButtonClick += (s, args) => { VM.ChangeOperationMode(OperationMode.Preparation); (tb.Content as TextBlock).Text = "BEGIN ROUNDS MODE"; Messenger.Default.Send(new LoggingOutMessage(isLocallyRequested: true)); }; confDiag.SecondaryButtonClick += (s, args) => { tb.IsChecked = true; }; await confDiag.ShowAsync(); } else { VM.ChangeOperationMode(OperationMode.Rounds); (tb.Content as TextBlock).Text = "END ROUNDS MODE"; } }
public static async Task <bool> ShowYesNoDialogAsync(string title, string content, string icon = null) { try { var dialog = new ConfirmationDialog() { Title = title, Content = content }; if (icon != null) { dialog.Icon = icon; } return(await dialog.ShowAsync() == ContentDialogResult.Primary ? true : false); } catch { return(false); } }
public static void OnClickBundleLogsItem(object sender, RoutedEventArgs e) { var mainWindowCfg = PahkatApp.Current.WindowService.Get <MainWindow>(); var mainWindow = (MainWindow)mainWindowCfg.Instance; mainWindow.HideContent(); PahkatApp.Current.Dispatcher.InvokeAsync(async() => { var confirmDialog = new ConfirmationDialog( "Create debugging zip file", "This function creates a zip file containing logging information useful " + "for assisting debugging issues with Divvun Manager and its packages.\n\n" + "This tool should only be used when requested by your IT administrator or Divvun personnel.", null, "Save Debug Zip"); if (await confirmDialog.ShowAsync() != ContentDialogResult.Primary) { mainWindow.ShowContent(); return; } var dialog = new SaveFileDialog(); dialog.AddExtension = true; dialog.DefaultExt = ".zip"; dialog.Filter = "Zip file|*.zip"; dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); dialog.FileName = "divvun-installer-debug.zip"; if (dialog.ShowDialog() == true) { await LogCollator.Run(dialog.FileName); await ShowCollationFinish(dialog.FileName); } mainWindow.ShowContent(); }); }
private static async Task ShowCollationFinish(string zipPath) { var fileName = Path.GetFileName(zipPath) !; var dirName = Path.GetDirectoryName(zipPath) !; Clipboard.SetText("*****@*****.**"); var dialog = new ConfirmationDialog( "Debug Data Zipped!", $"A zip file named {fileName} has been created.\n\n" + "Please attach this to an email to [email protected].", "(The email address has been automatically copied to your clipboard " + "for your convenience. You can paste this into your email program or web-based " + "email tool)", "Go to file", null); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { OpenFolderAndSelectItem(dirName, fileName); } }
private async Task <bool> Transaction(JArray args) { var actions = new List <PackageAction>(); foreach (var arg in args) { if (arg.Type != JTokenType.Object) { continue; } JObject obj = (JObject)arg; var rawKey = obj.Value <string>("key"); var rawAction = obj.Value <string>("action"); // var target = obj.Value<string>("target"); try { var key = PackageKey.From(rawKey); var action = InstallAction.Uninstall; if (rawAction == "install") { action = InstallAction.Install; } actions.Add(new PackageAction(key, action)); } catch { } } var primaryButton = string.Format(Strings.InstallUninstallNPackages, actions.Count); // Resolve the names for the package keys var strings = actions.Map(x => { var package = Repo.Packages.Packages[x.PackageKey.Id]; var release = Repo.Release(x.PackageKey); if (release == null || package == null) { return(null); } return($"{x.Action.NativeName()}: {package.NativeName()} {release.Version}"); }); return(await await PahkatApp.Current.Dispatcher.InvokeAsync(async() => { var dialog = new ConfirmationDialog( "Confirm Selection", "Do you wish to do the following actions:", string.Join("\n", strings), primaryButton); try { WebView.Visibility = Visibility.Hidden; var result = await dialog.ShowAsync(); WebView.Visibility = Visibility.Visible; if (result == ContentDialogResult.Primary) { var app = (PahkatApp)Application.Current; await app.StartTransaction(actions.ToArray()); return true; } } catch (Exception e) { Log.Debug(e, "wat"); } return false; })); }