Пример #1
0
        /// <summary>
        /// Prompts user to exit and exits cleanly if they choose yes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnClose(object sender, CancelEventArgs e)
        {
            if (
                MessageBox.Show(this, "Are you sure?", Utils.ProductName, MessageBoxButton.YesNo,
                                MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                TabControl.ForceExit = true;

                var canExit = TabControl.CanUnload(TabControl.SelectedContent as ContentControl);

                if (!canExit)
                {
                    // NOTE: Invoked function is responsible for displaying message on why it can't exit
                    e.Cancel             = true;
                    TabControl.ForceExit = false;
                }
            }
            else
            {
                e.Cancel = true;
            }

            if (!e.Cancel)
            {
                Watcher.Stop();
                GarbageCollectAndFinalize();
            }
        }