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

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

public ShowMessageBox ( string title, string message ) : void
title string
message string
Результат void
        public override void ShowMessageBox(string title, string message)
        {
            if (GetActiveWindow() == null)
                return;

            Execute.OnUIThread(() => GetActiveWindow().ShowMessageAsync(title, message));
        }

Usage Example

Пример #1
0
        /// <summary>
        ///     Fetches all releases from GitHub, looks up the current release and shows the changelog
        /// </summary>
        /// <param name="dialogService">The dialog service to use for progress and result dialogs</param>
        /// <param name="version">The version to fetch the changelog for</param>
        /// <returns></returns>
        private static async Task ShowChanges(MetroDialogService dialogService, Version version)
        {
            var progressDialog = await dialogService.ShowProgressDialog("Changelog", "Fetching release data from GitHub..");
            progressDialog.SetIndeterminate();

            var jsonClient = new WebClient();

            // GitHub trips if we don't add a user agent
            jsonClient.Headers.Add("user-agent",
                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

            // Random number to get around cache issues
            var rand = new Random(DateTime.Now.Millisecond);
            var json = await jsonClient.DownloadStringTaskAsync(
                "https://api.github.com/repos/SpoinkyNL/Artemis/releases?random=" + rand.Next());

            // Get a list of releases
            var releases = JsonConvert.DeserializeObject<JArray>(json);
            var release = releases.FirstOrDefault(r => r["tag_name"].Value<string>() == version.ToString());
            try
            {
                await progressDialog.CloseAsync();
            }
            catch (InvalidOperationException)
            {
                // Occurs when main window is closed before finished
            }

            if (release != null)
                dialogService.ShowMessageBox(release["name"].Value<string>(), release["body"].Value<string>());
            else
                dialogService.ShowMessageBox("Couldn't fetch release",
                    "Sorry, Artemis was unable to fetch the release data off of GitHub.\n" +
                    "If you'd like, you can always find out the latest changes on the GitHub page accessible from the options menu");
        }