public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme, IfThenElse ifThenElse) { this.controlConstructScheme = controlConstructScheme; questionConstructs = new ObservableCollection <QuestionConstructVM>(); questionConstructs.AddRange(controlConstructScheme.QuestionConstructs); thenConstructs = new ObservableCollection <ConstructVM>(); thenConstructs.AddRange(controlConstructScheme.ThenConstructs); if (ifThenElse == null) { //In the case of TargetQuestionConstruct = controlConstructScheme.SelectedConstruct as QuestionConstructVM; branches = new ObservableCollection <BranchVM>(); //Add IF ~ THEN BranchVM ifBranch = new BranchVM(BranchVM.TYPE_IF_CODE) { Parent = this, No = 1, }; ifBranch.Init(); branches.Add(ifBranch); } else { // Inthe case of edit TargetQuestionConstruct = EDOUtils.Find(controlConstructScheme.QuestionConstructs, ifThenElse.IfCondition.QuestionId); branches = SequenceUtils.CreateBranches(ifThenElse, this); } }
public void ChangeQuestionNumbers() { ChangeMultipleQuestionNumberWindowVM vm = new ChangeMultipleQuestionNumberWindowVM(this); ChangeMultipleQuestionNumberWindow window = new ChangeMultipleQuestionNumberWindow(vm); window.Owner = Application.Current.MainWindow; if (window.ShowDialog() == true) { using (UndoTransaction tx = new UndoTransaction(UndoManager)) { if (SequenceUtils.RenumberQuestionNumbers(this, vm.QuestionNumbers)) { UpdateModel(false); tx.Commit(); } } } }
public void EditConstruct() { ConstructVM construct = SelectedConstruct; if (construct is StatementVM) { StatementVM statement = (StatementVM)construct; CreateSentenceWindowVM vm = new CreateSentenceWindowVM(this, (Statement)statement.Model); CreateSentenceWindow window = new CreateSentenceWindow(vm); window.Owner = Application.Current.MainWindow; if (window.ShowDialog() == true && vm.Statement != null) { StatementVM newStatement = new StatementVM(vm.Statement); InitConstruct(newStatement); int index = constructs.IndexOf(construct); constructs.RemoveAt(index); constructs.Insert(index, newStatement); UpdateModel(true); SelectedConstructItem = newStatement; } } else if (construct is IfThenElseVM) { EditBranchExternal((IfThenElseVM)construct, Application.Current.MainWindow); } else if (construct is QuestionConstructVM) { ChangeSingleQuestionNumberWindowVM vm = new ChangeSingleQuestionNumberWindowVM((QuestionConstructVM)construct); ChangeSingleQuestionNumberWindow window = new ChangeSingleQuestionNumberWindow(vm); window.Owner = Application.Current.MainWindow; if (window.ShowDialog() == true) { using (UndoTransaction tx = new UndoTransaction(UndoManager)) { if (SequenceUtils.RenumberQuestionNumber(this, vm.QuestionNumber)) { UpdateModel(false); tx.Commit(); } } } } }
private void MoveConstruct(int fromIndex, int toIndex) { using (UndoTransaction tx = new UndoTransaction(UndoManager)) { ConstructVM fromConstruct = Constructs[fromIndex]; ConstructVM toConstruct = Constructs[toIndex]; if (RenumberQuestionNo && fromConstruct is QuestionConstructVM && toConstruct is QuestionConstructVM) { QuestionNumberVM fromQuestionNumber = new QuestionNumberVM((QuestionConstructVM)fromConstruct); fromQuestionNumber.AfterValue = toConstruct.No; QuestionNumberVM toQuestionNumber = new QuestionNumberVM((QuestionConstructVM)toConstruct); toQuestionNumber.AfterValue = fromConstruct.No; List <QuestionNumberVM> questionNumbers = new List <QuestionNumberVM>(); questionNumbers.Add(fromQuestionNumber); questionNumbers.Add(toQuestionNumber); SequenceUtils.RenumberQuestionNumbers(this, questionNumbers); } Constructs.Move(fromIndex, toIndex); UpdateModel(false); tx.Commit(); } FocusCell(); }
public void Save() { IfThenElse = SequenceUtils.CreateIfThenElse(ValidBranches); }
public void Validate() { SequenceUtils.ValidateQuestionNumber(controlConstructScheme, questionNumber); }