Artemis.Services.MetroDialogService.ShowQuestionMessageBox C# (CSharp) Метод

ShowQuestionMessageBox() публичный Метод

public ShowQuestionMessageBox ( string title, string message ) : Task
title string
message string
Результат Task
        public override async Task<bool?> ShowQuestionMessageBox(string title, string message)
        {
            if (GetActiveWindow() == null)
                return null;

            var metroDialogSettings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
            var result =
                await
                    GetActiveWindow()
                        .ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings);
            switch (result)
            {
                case MessageDialogResult.Negative:
                    return false;
                case MessageDialogResult.Affirmative:
                    return true;
                default:
                    return null;
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        ///     Checks to see if the program has updated and shows a dialog if so.
        /// </summary>
        /// <param name="dialogService">The dialog service to use for progress and result dialogs</param>
        /// <returns></returns>
        public static async Task CheckChangelog(MetroDialogService dialogService)
        {
            var settings = SettingsProvider.Load<GeneralSettings>();
            var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
            if ((settings.LastRanVersion != null) && (currentVersion > settings.LastRanVersion))
            {
                Logger.Info("Updated from {0} to {1}, showing changelog.", settings.LastRanVersion, currentVersion);

                // Ask the user whether he/she wants to see what's new
                var showChanges = await dialogService.
                    ShowQuestionMessageBox("New version installed",
                        $"Artemis has recently updated from version {settings.LastRanVersion} to {currentVersion}. \n" +
                        "Would you like to see what's new?");

                // If user wants to see changelog, show it to them
                if ((showChanges != null) && showChanges.Value)
                    await ShowChanges(dialogService, currentVersion);
            }

            settings.LastRanVersion = currentVersion;
            settings.Save();
        }