示例#1
0
        /// <summary>
        /// Invoked when the window is about to be closed.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            if (UpgradeManager.InProgress)
            {
                if (MessageBox.Show(U.T("MessageUpgradeInProgress", "Message"),
                                    U.T("MessageUpgradeInProgress", "Title"),
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Warning,
                                    MessageBoxResult.No) == MessageBoxResult.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (SettingsManager.FastStart && !forceShutdown)
            {
                if (UpgradeManager.Pending)
                {
                    CloseProgress cp = new CloseProgress(true);
                    try
                    {
                        cp.Owner = this;
                    }
                    catch { }
                    cp.ShowDialog();
                }

                ShowInTaskbar = false;
                Hide();
                e.Cancel = true;
                MediaManager.Pause();
                trayIcon.Visibility = Visibility.Collapsed;
                SettingsManager.Save();
            }
            else
            {
                forceShutdown = false;
                kListener.Dispose();
                CloseProgress cp = new CloseProgress();
                try
                {
                    cp.Owner = this;
                }
                catch { }
                cp.ShowDialog();
                if (doRestart)
                    Process.Start(Path.GetFullPath((new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath));

                U.L(LogLevel.Debug, "MAIN", "Forcing shutdown");
                Application.Current.Shutdown();
            }
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            if (UpgradeManager.InProgress)
            {
                if (MessageBox.Show(U.T("MessageUpgradeInProgress", "Message"),
                                    U.T("MessageUpgradeInProgress", "Title"),
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Warning,
                                    MessageBoxResult.No) == MessageBoxResult.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            MediaManager.Pause();

            kListener.Dispose();

            if (UpgradeManager.Pending)
            {
                CloseProgress cp = new CloseProgress();
                try
                {
                    cp.Owner = this;
                }
                catch { }
                cp.ShowDialog();
            }
            if (doRestart)
                System.Diagnostics.Process.Start(U.FullPath, "--restart");

            U.L(LogLevel.Debug, "MAIN", "Shutting down");
            Application.Current.Shutdown();
        }