コード例 #1
0
        private void OnMainWindowClosing(object sender, CancelEventArgs e)
        {
            if (DataContext == null)
            {
                e.Cancel = true;
                Application.Current.MainWindow.Hide();
                var projectBrowser = new GameProject.ProjectBrowserDialog();
                if (projectBrowser.ShowDialog() == false || projectBrowser.DataContext == null)
                {
                    Application.Current.Shutdown();
                }
                else
                {
                    GameProject.Project.Current?.Unload();
                    DataContext = projectBrowser.DataContext;

                    if (DataContext != null)
                    {
                        Application.Current.MainWindow.Show();
                    }
                }
            }
            else
            {
                Closing -= OnMainWindowClosing;
                GameProject.Project.Current?.Unload();
                DataContext = null;
            }
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: Kimpai/Dual-DirectX
        private void OpenProjectBrowserDialog()
        {
            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            var projectBrowser = new GameProject.ProjectBrowserDialog();

            if (projectBrowser.ShowDialog() == false || projectBrowser.DataContext == null)
            {
                Current.Shutdown();
            }
            else
            {
                var mainWindow = new MainWindow();
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                Current.MainWindow   = mainWindow;
                GameProject.Project.Current?.Unload();
                Current.MainWindow.DataContext = projectBrowser.DataContext;
                mainWindow.Show();
            }
        }