public void DownConstruct() { ConstructVM construct = SelectedConstruct; int fromIndex = SelectedConstructIndex; int toIndex = fromIndex + 1; MoveConstruct(fromIndex, toIndex); }
private void InsertConstruct(ConstructVM construct, bool manualOperation) { InitConstruct(construct); if (manualOperation) { //add below the selected row if added by screen int index = SelectedConstructIndex + 1; constructs.Insert(index, construct); } else { //Added to the end when new question is added automatically constructs.Add(construct); } //memory to be able to Undo if added by screen UpdateModel(manualOperation); }
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(); } } } } }
public void InsertQuestionGroupConstruct(QuestionGroupVM questionGroup, bool manualOperation) { ConstructVM construct = ConstructVM.FindByQuestionGroupId(constructs, questionGroup.Id); if (construct != null) { if (manualOperation) { MessageBox.Show(Resources.AlreadySelectedQuestionGroup); //This question group is already selected } return; } QuestionGroupConstruct questionGroupConstructModel = new QuestionGroupConstruct(); questionGroupConstructModel.QuestionGroupId = questionGroup.Id; questionGroupConstructModel.No = ControlConstructScheme.QUESTION_GROUP_NO_PREFIX + (ConstructUtils.QuestionGroupConstructCount(constructs) + 1); QuestionGroupConstructVM questionGroupConstruct = new QuestionGroupConstructVM(questionGroupConstructModel, questionGroup); InsertConstruct(questionGroupConstruct, manualOperation); }
public void InsertQuestionConstruct(QuestionVM question, bool manualOperation) { ConstructVM construct = ConstructVM.FindByQuestionId(constructs, question.Id); if (construct != null) { if (manualOperation) { //show error message if added by screen MessageBox.Show(Resources.AlreadySelectedQuestion); //This question is already selected } return; } QuestionConstruct questionConstructModel = new QuestionConstruct(); questionConstructModel.QuestionId = question.Id; questionConstructModel.No = ControlConstructScheme.QUESTION_NO_PREFIX + (ConstructUtils.QuestionConstructCount(constructs) + 1); QuestionConstructVM questionConstruct = new QuestionConstructVM(questionConstructModel, question); InsertConstruct(questionConstruct, manualOperation); }
public void RemoveQuestion(QuestionVM question) { bool removed = false; for (int i = constructs.Count - 1; i >= 0; i--) { ConstructVM construct = constructs[i]; if (construct is QuestionConstructVM) { QuestionConstructVM questionConstruct = (QuestionConstructVM)construct; if (questionConstruct.Question == question) { constructs.RemoveAt(i); removed = true; } } } if (removed) { UpdateModel(false); } }
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 int GetCondCount() { int count = 0; ConstructVM construct = FindConstruct(ifThenElse.ThenConstructId); if (construct != null) { count++; } foreach (ElseIf elseIf in ifThenElse.ElseIfs) { construct = FindConstruct(elseIf.ThenConstructId); if (construct != null) { count++; } } construct = FindConstruct(ifThenElse.ElseConstructId); if (construct != null) { count++; } return(count); }
private void InitConstruct(ConstructVM construct) { construct.Parent = this; }
//Statement and Question can be moved in Then clause, so they're stored in ConstructVM private bool IsValidThenConstructNo(string no) { return(ConstructVM.FindByNo(ThenConstructs, no) != null); }
private void InsertConstruct(ConstructVM construct, bool manualOperation) { InitConstruct(construct); if (manualOperation) { //画面から追加した場合選択された行の下に追加 int index = SelectedConstructIndex + 1; constructs.Insert(index, construct); } else { //質問追加時に自動生成する場合末尾に追加 constructs.Add(construct); } //画面から追加した場合記憶してUndoできるようにする UpdateModel(manualOperation); }