public bool Show() { var messageBox = new MessageBoxModel { Text = "Baza danych już istnieje. Czy chcesz ją usunąć?", Caption = "Info", Icon = MessageBoxImage.Question, Buttons = new[] { MessageBoxButtons.Yes("Tak"), MessageBoxButtons.No("Nie") }, IsSoundEnabled = false }; var buttons = messageBox.Buttons.ToArray(); buttons[0].IsDefault = false; buttons[1].IsDefault = true; MessageBox.Show(messageBox); switch (messageBox.Result) { case MessageBoxResult.No: return(false); case MessageBoxResult.Yes: return(true); default: throw new ArgumentOutOfRangeException(); } }
public bool Show() { var messageBox = new MessageBoxModel { Text = "Czy na pewno chcesz usunąć książkę?", Caption = "Info", Icon = MessageBoxImage.Warning, Buttons = new[] { MessageBoxButtons.Yes("Tak"), MessageBoxButtons.No("Nie") }, IsSoundEnabled = false }; MessageBox.Show(messageBox); switch (messageBox.Result) { case MessageBoxResult.No: return(false); case MessageBoxResult.Yes: return(true); default: throw new ArgumentOutOfRangeException(); } }
private async void OnStartup(object sender, StartupEventArgs e) { RxApp.MainThreadScheduler.Schedule(async() => { var settings = Locator.Current.GetService <SettingsViewModel>(); settings.Restore(); }); #if !DO_NOT_INCLUDE_UPDATER InstallerRunner.CleanUpInstaller(); var generalSettings = Locator.Current.GetService <IEnumerable <SettingsGroupViewModelBase> >() .OfType <GeneralSettingsGroupViewModel>() .Single(); if (!generalSettings.CheckForUpdatesOnStartup) { return; } var ghubClient = new GitHubClient(new ProductHeaderValue("Image-Sort")); var updateFetcher = new GitHubUpdateFetcher(ghubClient); (var success, var release) = await updateFetcher.TryGetLatestReleaseAsync(generalSettings.InstallPrereleaseBuilds).ConfigureAwait(true); if (success) { var messageBox = new MessageBoxModel { Caption = Text.UpdateAvailablePromptTitle, Text = Text.UpdateAvailablePromptText.Replace("{TagName}", release.TagName ?? "NO TAG INFORMATION AVAILABLE", StringComparison.OrdinalIgnoreCase), Buttons = new[] { MessageBoxButtons.Yes(Text.Update), MessageBoxButtons.No(Text.DoNotUpdate) }, Icon = AdonisUI.Controls.MessageBoxImage.Question }; if (AdonisUI.Controls.MessageBox.Show(messageBox) == AdonisUI.Controls.MessageBoxResult.Yes && updateFetcher.TryGetInstallerFromRelease(release, out var installerAsset)) { var installer = await updateFetcher.GetStreamFromAssetAsync(installerAsset).ConfigureAwait(false); InstallerRunner.RunAsync(installer).ConfigureAwait(false); } } #endif }