Example #1
0
        private void InsertStatementConstruct(Statement statementModel)
        {
            statementModel.No = ControlConstructScheme.STATEMENT_NO_PREFIX + (ConstructUtils.StatementCount(constructs) + 1);
            StatementVM statement = new StatementVM(statementModel);

            InsertConstruct(statement, true);
        }
Example #2
0
        public void Init()
        {
            List <string> ids = controlConstructScheme.Sequence.ControlConstructIds;

            foreach (string id in ids)
            {
                QuestionConstruct questionConstructModel = controlConstructScheme.FindQuestionConstruct(id);
                if (questionConstructModel != null)
                {
                    QuestionVM question = StudyUnit.FindQuestion(questionConstructModel.QuestionId);
                    Debug.Assert(question != null, "Question not found id=" + questionConstructModel.QuestionId);
                    QuestionConstructVM questionConstruct = new QuestionConstructVM(questionConstructModel, question);
                    InitConstruct(questionConstruct);
                    constructModels.Add(questionConstructModel);
                    constructs.Add(questionConstruct);
                    continue;
                }
                QuestionGroupConstruct questionGroupConstructModel = controlConstructScheme.FindQuestionGroupConstruct(id);
                if (questionGroupConstructModel != null)
                {
                    QuestionGroupVM          questionGroup          = StudyUnit.FindQuestionGroup(questionGroupConstructModel.QuestionGroupId);
                    QuestionGroupConstructVM questionGroupConstruct = new QuestionGroupConstructVM(questionGroupConstructModel, questionGroup);
                    InitConstruct(questionGroupConstruct);
                    constructModels.Add(questionGroupConstructModel);
                    constructs.Add(questionGroupConstruct);
                    continue;
                }
                Statement statementModel = controlConstructScheme.FindStatement(id);
                if (statementModel != null)
                {
                    StatementVM statement = new StatementVM(statementModel);
                    InitConstruct(statement);
                    constructModels.Add(statementModel);
                    constructs.Add(statement);
                    continue;
                }
                IfThenElse ifThenElseModel = controlConstructScheme.FindIfThenElse(id);
                if (ifThenElseModel != null)
                {
                    IfThenElseVM ifThenElse = new IfThenElseVM(ifThenElseModel);
                    InitConstruct(ifThenElse);
                    constructModels.Add(ifThenElseModel);
                    constructs.Add(ifThenElse);
                }
            }

            List <QuestionConstructVM> questionConstructs = QuestionConstructs;

            foreach (ConstructVM construct in constructs)
            {
                if (construct is IfThenElseVM)
                {
                    IfThenElseVM ifThenElse = (IfThenElseVM)construct;
                    ifThenElse.ThenConstructs = ThenConstructs;
                }
            }
            modelSyncher = new ModelSyncher <ConstructVM, IConstruct>(this, constructs, constructModels);
            InitTitle();
        }
Example #3
0
        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 InsertStatementConstruct(Statement statementModel)
 {
     statementModel.No = ControlConstructScheme.STATEMENT_NO_PREFIX + (ConstructUtils.StatementCount(constructs) + 1);
     StatementVM statement = new StatementVM(statementModel);
     InsertConstruct(statement, true);
 }
        public void Init()
        {
            List<string> ids = controlConstructScheme.Sequence.ControlConstructIds;
            foreach (string id in ids)
            {
                QuestionConstruct questionConstructModel = controlConstructScheme.FindQuestionConstruct(id);
                if (questionConstructModel != null)
                {
                    QuestionVM question = StudyUnit.FindQuestion(questionConstructModel.QuestionId);
                      Debug.Assert(question != null, "Question not found id=" + questionConstructModel.QuestionId);
                    QuestionConstructVM questionConstruct = new QuestionConstructVM(questionConstructModel, question);
                    InitConstruct(questionConstruct);
                    constructModels.Add(questionConstructModel);
                    constructs.Add(questionConstruct);
                    continue;
                }
                QuestionGroupConstruct questionGroupConstructModel = controlConstructScheme.FindQuestionGroupConstruct(id);
                if (questionGroupConstructModel != null)
                {
                    QuestionGroupVM questionGroup = StudyUnit.FindQuestionGroup(questionGroupConstructModel.QuestionGroupId);
                    QuestionGroupConstructVM questionGroupConstruct = new QuestionGroupConstructVM(questionGroupConstructModel, questionGroup);
                    InitConstruct(questionGroupConstruct);
                    constructModels.Add(questionGroupConstructModel);
                    constructs.Add(questionGroupConstruct);
                    continue;
                }
                Statement statementModel = controlConstructScheme.FindStatement(id);
                if (statementModel != null)
                {
                    StatementVM statement = new StatementVM(statementModel);
                    InitConstruct(statement);
                    constructModels.Add(statementModel);
                    constructs.Add(statement);
                    continue;
                }
                IfThenElse ifThenElseModel = controlConstructScheme.FindIfThenElse(id);
                if (ifThenElseModel != null)
                {
                    IfThenElseVM ifThenElse = new IfThenElseVM(ifThenElseModel);
                    InitConstruct(ifThenElse);
                    constructModels.Add(ifThenElseModel);
                    constructs.Add(ifThenElse);
                }
            }

            List<QuestionConstructVM> questionConstructs = QuestionConstructs;
            foreach (ConstructVM construct in constructs)
            {
                if (construct is IfThenElseVM)
                {
                    IfThenElseVM ifThenElse = (IfThenElseVM)construct;
                    ifThenElse.ThenConstructs = ThenConstructs;
                }
            }
            modelSyncher = new ModelSyncher<ConstructVM, IConstruct>(this, constructs, constructModels);
            InitTitle();
        }
 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);
     }
 }