Inheritance: Command, ISaveCommand
Exemple #1
0
        /// <inheritdoc/>
        public override void Run()
        {
            var window = ServiceProvider.GetService <MainWindow>();
            var editor = ServiceProvider.GetService <ProjectEditor>();

            if (editor.IsProjectDirty)
            {
                var result = MessageBox.Show(
                    "Save changes to the project?",
                    "Unsaved Changes",
                    MessageBoxButton.YesNoCancel,
                    MessageBoxImage.Question,
                    MessageBoxResult.Yes);

                switch (result)
                {
                case MessageBoxResult.Yes:
                {
                    var save = new SaveCommand();
                    if (save.CanRun())
                    {
                        save.Run();
                    }
                    window.Close();
                }
                break;

                case MessageBoxResult.No:
                {
                    window.Close();
                }
                break;

                case MessageBoxResult.Cancel:
                    break;
                }
            }
            else
            {
                window.Close();
            }
        }
Exemple #2
0
        /// <inheritdoc/>
        public override void Run()
        {
            var window = ServiceProvider.GetService<MainWindow>();
            var editor = ServiceProvider.GetService<ProjectEditor>();
            if (editor.IsProjectDirty)
            {
                var result = MessageBox.Show(
                    "Save changes to the project?",
                    "Unsaved Changes",
                    MessageBoxButton.YesNoCancel,
                    MessageBoxImage.Question,
                    MessageBoxResult.Yes);

                switch (result)
                {
                    case MessageBoxResult.Yes:
                        {
                            var save = new SaveCommand();
                            if (save.CanRun())
                            {
                                save.Run();
                            }
                            window.Close();
                        }
                        break;
                    case MessageBoxResult.No:
                        {
                            window.Close();
                        }
                        break;
                    case MessageBoxResult.Cancel:
                        break;
                }
            }
            else
            {
                window.Close();
            }
        }