Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        public void ReplaceIfThenElse(IfThenElseVM ifThenElse, IfThenElseVM newIfThenElse)
        {
            InitConstruct(newIfThenElse);
            newIfThenElse.ThenConstructs = ThenConstructs;
            int index = constructs.IndexOf(ifThenElse);

            constructs.RemoveAt(index);
            constructs.Insert(index, newIfThenElse);
        }
Ejemplo n.º 3
0
        public void InsertIfThenElseConstruct(IfThenElse ifThenElseModel)
        {
            if (ifThenElseModel == null)
            {
                return;
            }
            ifThenElseModel.No = ControlConstructScheme.IFTHENELSE_NO;
            IfThenElseVM ifThenElse = new IfThenElseVM(ifThenElseModel);

            ifThenElse.ThenConstructs = ThenConstructs;
            InsertConstruct(ifThenElse, true);
        }
Ejemplo n.º 4
0
        private static void ReplaceIfThenElses(ControlConstructSchemeVM controlConstructScheme, Dictionary <IfThenElseVM, CreateBranchWindowVM> updatingIfThenElseDict)
        {
            Dictionary <IfThenElseVM, IfThenElseVM> ifThenElses = new Dictionary <IfThenElseVM, IfThenElseVM>();

            foreach (KeyValuePair <IfThenElseVM, CreateBranchWindowVM> pair in updatingIfThenElseDict)
            {
                IfThenElseVM         ifThenElse = pair.Key;
                CreateBranchWindowVM vm         = pair.Value;
                vm.Save();
                IfThenElseVM newIfThenElse = new IfThenElseVM(vm.IfThenElse);
                controlConstructScheme.ReplaceIfThenElse(ifThenElse, newIfThenElse);
            }
        }
Ejemplo n.º 5
0
        public bool EditBranchExternal(IfThenElseVM ifThenElse, Window ownerWindow)
        {
            CreateBranchWindowVM vm     = new CreateBranchWindowVM(this, (IfThenElse)ifThenElse.Model);
            CreateBranchWindow   window = new CreateBranchWindow(vm);

            window.Owner = Application.Current.MainWindow;
            if (window.ShowDialog() == true && vm.IfThenElse != null)
            {
                IfThenElseVM newIfThenElse = new IfThenElseVM(vm.IfThenElse);
                ReplaceIfThenElse(ifThenElse, newIfThenElse);
                UpdateModel(true);
                SelectedConstructItem = newIfThenElse;
                return(true);
            }

            return(false);
        }
 public void InsertIfThenElseConstruct(IfThenElse ifThenElseModel)
 {
     if (ifThenElseModel == null)
     {
         return;
     }
     ifThenElseModel.No = ControlConstructScheme.IFTHENELSE_NO;
     IfThenElseVM ifThenElse = new IfThenElseVM(ifThenElseModel);
     ifThenElse.ThenConstructs = ThenConstructs;
     InsertConstruct(ifThenElse, 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 bool EditBranchExternal(IfThenElseVM ifThenElse, Window ownerWindow)
        {
            CreateBranchWindowVM vm = new CreateBranchWindowVM(this, (IfThenElse)ifThenElse.Model);
            CreateBranchWindow window = new CreateBranchWindow(vm);
            window.Owner = Application.Current.MainWindow;
            if (window.ShowDialog() == true && vm.IfThenElse != null)
            {
                IfThenElseVM newIfThenElse = new IfThenElseVM(vm.IfThenElse);
                InitConstruct(newIfThenElse);
                newIfThenElse.ThenConstructs = ThenConstructs;
                int index = constructs.IndexOf(ifThenElse);
                constructs.RemoveAt(index);
                constructs.Insert(index, newIfThenElse);
                UpdateModel(true);
                SelectedConstructItem = newIfThenElse;
                return true;
            }

            return false;
        }