Inheritance: Caliburn.Micro.Screen
Exemplo n.º 1
0
        /// <summary>
        ///     Method to check if there is a new application version available.
        /// </summary>
        private async void UpdateAsync()
        {
            try
            {
                var update = await ApplicationUpdater.CheckForRemoteUpdateAsync().ConfigureAwait(true);

                if (update.CanUpdate)
                {
                    var boxType = update.Update.Type == UpdateType.Standard ? BoxType.Default : BoxType.Warning;
                    var boxText = update.Update.Type == UpdateType.Standard
                                                ? LocalizationEx.GetUiString("dialog_message_update_standard_text",
                                                                             Thread.CurrentThread.CurrentCulture)
                                                : LocalizationEx.GetUiString("dialog_message_update_critical_text",
                                                                             Thread.CurrentThread.CurrentCulture);
                    var boxTitle = update.Update.Type == UpdateType.Standard
                                                ? LocalizationEx.GetUiString("dialog_message_update_standard_title",
                                                                             Thread.CurrentThread.CurrentCulture)
                                                : LocalizationEx.GetUiString("dialog_message_update_critical_title",
                                                                             Thread.CurrentThread.CurrentCulture);
                    var userResult =
                        _windowManager.ShowMetroMessageBox(
                            string.Format(boxText, update.Update.Version), boxTitle,
                            MessageBoxButton.YesNo, boxType);

                    if (userResult != MessageBoxResult.Yes)
                    {
                        return;
                    }
                    var updateViewModel = new UpdateViewModel(update.Update)
                    {
                        DisplayName =
                            LocalizationEx.GetUiString("window_update_title", Thread.CurrentThread.CurrentCulture)
                    };
                    dynamic settings = new ExpandoObject();
                    settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    settings.Owner = GetView();
                    var result = _windowManager.ShowDialog(updateViewModel, null, settings);
                    if (!result)
                    {
                        return;
                    }
                    if (!File.Exists(updateViewModel.InstallerPath))
                    {
                        return;
                    }
                    // start the installer
                    Process.Start(updateViewModel.InstallerPath);
                    // kill running application
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Method to check if there is a new application version available.
        /// </summary>
        private async void UpdateAsync()
        {
            try
            {
                var update = await ApplicationUpdater.CheckForRemoteUpdateAsync().ConfigureAwait(true);
                if (update.CanUpdate)
                {
                    var boxType = update.Update.Type == UpdateType.Standard ? BoxType.Default : BoxType.Warning;
                    var boxText = update.Update.Type == UpdateType.Standard
                        ? LocalizationEx.GetUiString("dialog_message_update_standard_text",
                            Thread.CurrentThread.CurrentCulture)
                        : LocalizationEx.GetUiString("dialog_message_update_critical_text",
                            Thread.CurrentThread.CurrentCulture);
                    var boxTitle = (update.Update.Type == UpdateType.Standard)
                        ? LocalizationEx.GetUiString("dialog_message_update_standard_title",
                            Thread.CurrentThread.CurrentCulture)
                        : LocalizationEx.GetUiString("dialog_message_update_critical_title",
                            Thread.CurrentThread.CurrentCulture);
                    var userResult =
                        _windowManager.ShowMetroMessageBox(
                            string.Format(boxText, update.Update.Version), boxTitle,
                            MessageBoxButton.YesNo, boxType);

                    if (userResult != MessageBoxResult.Yes) return;
                    var updateViewModel = new UpdateViewModel(update.Update)
                    {
                        DisplayName =
                            LocalizationEx.GetUiString("window_update_title", Thread.CurrentThread.CurrentCulture)
                    };
                    dynamic settings = new ExpandoObject();
                    settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    settings.Owner = GetView();
                    var result = _windowManager.ShowDialog(updateViewModel, null, settings);
                    if (!result) return;
                    if (!File.Exists(updateViewModel.InstallerPath)) return;
                    // start the installer
                    Process.Start(updateViewModel.InstallerPath);
                    // kill running application
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception)
            {
            }
        }