public ConditionGroupsEditorViewModel(Func <IHistoryManager> historyCreator, IConditionDataProvider conditionDataProvider, IWindowManager windowManager, IMessageBoxService messageBoxService, ITaskRunner taskRunner) { this.conditionDataProvider = conditionDataProvider; this.windowManager = windowManager; this.messageBoxService = messageBoxService; SourceItems = new ObservableCollection <ConditionGroupsEditorData>(); foreach (var item in conditionDataProvider.GetConditionGroups()) { SourceItems.Add(new ConditionGroupsEditorData(in item)); } Save = new DelegateCommand(() => { taskRunner.ScheduleTask("Saving condition groups", SaveGroupsToFile); }, () => IsModified); AddGroup = new AsyncCommand(AddGroupToSource); DeleteItem = new DelegateCommand <object>(DeleteItemFromSource); AddMember = new AsyncCommand <ConditionGroupsEditorData>(AddItemToGroup); EditItem = new AsyncCommand <ConditionGroupsEditorData>(EditSourceItem); // history setup historyHandler = new ConditionGroupsEditorHistoryHandler(SourceItems !); History = historyCreator(); undoCommand = new DelegateCommand(History.Undo, () => History.CanUndo); redoCommand = new DelegateCommand(History.Redo, () => History.CanRedo); History.PropertyChanged += (sender, args) => { undoCommand.RaiseCanExecuteChanged(); redoCommand.RaiseCanExecuteChanged(); IsModified = !History.IsSaved; }; History.AddHandler(historyHandler); }
private void MakeItems() { SourceItems = new ObservableCollection <ConditionGroupsEditorData>(); foreach (var item in conditionDataProvider.GetConditionGroups()) { SourceItems.Add(new ConditionGroupsEditorData(in item)); } }