Пример #1
0
        private void Ok(Window window)
        {
            CoerceValues();

            if (ChangesRequireRestart)
            {
                //Warn if restart required and prompt for Confirmation before restarting
                ConfirmationRequest.Raise(
                    new Confirmation
                {
                    Title   = Resources.VERIFY_RESTART,
                    Content = Resources.RESTART_MESSAGE
                }, confirmation =>
                {
                    if (confirmation.Confirmed)
                    {
                        Log.Info("Applying management changes and attempting to restart OptiKey");
                        ApplyChanges();
                        Settings.Default.Save();
                        try
                        {
                            OptiKeyApp.RestartApp();
                        }
                        catch { }     //Swallow any exceptions (e.g. DispatcherExceptions) - we're shutting down so it doesn't matter.
                        Application.Current.Shutdown();
                    }
                });
            }
            else
            {
                Log.Info("Applying management changes");
                ApplyChanges();
                window.Close();
            }
        }
Пример #2
0
 private void Restart()
 {
     if (MessageBox.Show(Properties.Resources.REFRESH_MESSAGE, Properties.Resources.RESTART, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         OptiKeyApp.RestartApp();
         Application.Current.Shutdown();
     }
 }
Пример #3
0
        public CrashWindow()
        {
            InitializeComponent();

            this.Loaded += (sender, args) =>
            {
                var dt = new DispatcherTimer {
                    Interval = new TimeSpan(0, 0, Settings.Default.AutoCloseCrashMessageSeconds)
                };
                dt.Tick += (o, eventArgs) =>
                {
                    this.Close();

                    // The first crash might attempt a restart, but subsequent crashes shouldn't
                    if (Settings.Default.AttemptRestartUponCrash && Settings.Default.CleanShutdown)
                    {
                        Settings.Default.CleanShutdown = false;
                        Settings.Default.Save();
                        OptiKeyApp.RestartApp();
                    }
                };
                dt.Start();
            };
        }