Example #1
0
        private void OnCommandAdd()
        {
            var newBuild = new YsBuildRunner.Data.Build();

            var dlg = new YsBuildRunner.Build.BuildWindow(newBuild)
            {
                Owner = window_
            };

            var result = dlg.ShowDialog();

            if (result.HasValue && result.Value)
            {
                Storage.Builds.Add(newBuild);
                Save();
            }
        }
Example #2
0
        public Model(BuildWindow window, YsBuildRunner.Data.Build build)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }
            window_ = window;

            Build = build;

            window_.listBoxSolutions.SelectionChanged += ListBoxSolutionsSelectionChanged;

            CommandAdd.OnExecute          += OnCommandAdd;
            CommandEdit.OnExecute         += OnCommandEdit;
            CommandDelete.OnExecute       += OnCommandDelete;
            CommandExecuteBuild.OnExecute += OnCommandExecuteBuild;
            CommandStopBuild.OnExecute    += OnCommandStopBuild;
            CommandDown.OnExecute         += OnCommandDown;
            CommandUp.OnExecute           += OnCommandUp;
            CommandShowLog.OnExecute      += OnCommandShowLog;
            CommandOk.OnExecute           += OnCommandOk;
            CommandCancel.OnExecute       += OnCommandCancel;
            CommandAll.OnExecute          += OnCommandAll;

            enablementManager_.AddCommand(CommandAdd, ExecutionState.NoRunning,
                                          new ListState[] { ListState.All }, null,
                                          new SelectionState[] { SelectionState.All }, null);
            enablementManager_.AddCommand(CommandEdit, ExecutionState.NoRunning,
                                          new ListState[] { ListState.NoEmpty }, new ListState[] { ListState.Empty },
                                          new SelectionState[] { SelectionState.OneItemSelected }, new SelectionState[] { SelectionState.NoOneItemSelected, SelectionState.ManyItemsSelected });
            enablementManager_.AddCommand(CommandDelete, ExecutionState.NoRunning,
                                          new ListState[] { ListState.NoEmpty }, new ListState[] { ListState.Empty },
                                          new SelectionState[] { SelectionState.OneItemSelected }, new SelectionState[] { SelectionState.NoOneItemSelected, SelectionState.ManyItemsSelected });
            enablementManager_.AddCommand(CommandExecuteBuild, ExecutionState.NoRunning,
                                          new ListState[] { ListState.NoEmpty }, null,
                                          new SelectionState[] { SelectionState.All }, null);
            enablementManager_.AddCommand(CommandStopBuild, ExecutionState.Running,
                                          new ListState[] { ListState.All }, null,
                                          new SelectionState[] { SelectionState.All }, null);
            enablementManager_.AddCommand(CommandDown, ExecutionState.NoRunning,
                                          new ListState[] { ListState.NoEmpty }, new ListState[] { ListState.Empty },
                                          new SelectionState[] { SelectionState.OneItemSelected }, new SelectionState[] { SelectionState.NoOneItemSelected, SelectionState.ManyItemsSelected },
                                          new FirstElementSelectionState[] { FirstElementSelectionState.All }, null,
                                          new LastElementSelectionState[] { LastElementSelectionState.All }, new LastElementSelectionState[] { LastElementSelectionState.Selected });
            enablementManager_.AddCommand(CommandUp, ExecutionState.NoRunning,
                                          new ListState[] { ListState.NoEmpty }, new ListState[] { ListState.Empty },
                                          new SelectionState[] { SelectionState.OneItemSelected }, new SelectionState[] { SelectionState.NoOneItemSelected, SelectionState.ManyItemsSelected },
                                          new FirstElementSelectionState[] { FirstElementSelectionState.All }, new FirstElementSelectionState[] { FirstElementSelectionState.Selected },
                                          new LastElementSelectionState[] { LastElementSelectionState.All }, null);
            enablementManager_.AddCommand(CommandShowLog, ExecutionState.NoRunning,
                                          new ListState[] { ListState.NoEmpty }, new ListState[] { ListState.Empty },
                                          new SelectionState[] { SelectionState.OneItemSelected }, new SelectionState[] { SelectionState.NoOneItemSelected, SelectionState.ManyItemsSelected });
            enablementManager_.AddCommand(CommandOk, ExecutionState.NoRunning,
                                          new ListState[] { ListState.All }, null,
                                          new SelectionState[] { SelectionState.All }, null);
            enablementManager_.AddCommand(CommandCancel, ExecutionState.NoRunning,
                                          new ListState[] { ListState.All }, null,
                                          new SelectionState[] { SelectionState.All }, null);
            enablementManager_.AddCommand(CommandAll, ExecutionState.NoRunning,
                                          new ListState[] { ListState.NoEmpty }, new ListState[] { ListState.Empty },
                                          new SelectionState[] { SelectionState.All }, null);

            enablementManager_.ListState      = Build.Solutions.Any() ? ListState.NoEmpty : ListState.Empty;
            enablementManager_.SelectionState = SelectionState.NoOneItemSelected;
            enablementManager_.ExecutionState = ExecutionState.NoRunning;
        }