Beispiel #1
0
        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 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)
            {
                //新規作成の場合

                TargetQuestionConstruct = controlConstructScheme.SelectedConstruct as QuestionConstructVM;
                branches = new ObservableCollection<BranchVM>();
                //IF~THENを追加
                BranchVM ifBranch = new BranchVM(BranchVM.TYPE_IF_CODE)
                {
                    Parent = this,
                    No = 1,
                };
                ifBranch.Init();
                branches.Add(ifBranch);
            }
            else
            {
                // 編集の場合

                TargetQuestionConstruct = EDOUtils.Find(controlConstructScheme.QuestionConstructs, ifThenElse.IfCondition.QuestionId);
                branches = SequenceUtils.CreateBranches(ifThenElse, this);
            }
        }
Beispiel #3
0
        private static BranchVM CreateIfBranch(IfThenElse ifThenElse, CreateBranchWindowVM window)
        {
            BranchVM branch = new BranchVM(BranchVM.TYPE_IF_CODE)
            {
                Parent = window
            };

            branch.Init();
            branch.CondGroups.Clear();
            IfCondition ifCondition = ifThenElse.IfCondition;

            CreateCondGroups(ifCondition.Code, branch, window.QuestionConstructs);
            branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, ifThenElse.ThenConstructId);
            return(branch);
        }
Beispiel #4
0
        public BranchVM DeepCopy()
        {
            BranchVM newBranch = new BranchVM(TypeCode);

            newBranch.Parent = Parent;
            newBranch.Init();
            newBranch.IsNew         = IsNew;
            newBranch.ThenConstruct = ThenConstruct;
            newBranch.CondGroups.Clear();
            foreach (CondGroupVM condGroup in condGroups)
            {
                CondGroupVM newGroup = condGroup.DeepCopy(newBranch);
                newBranch.CondGroups.Add(newGroup);
            }
            return(newBranch);
        }
Beispiel #5
0
        private static BranchVM CreateElseBranch(IfThenElse ifThenElse, CreateBranchWindowVM window)
        {
            if (ifThenElse.ElseConstructId == null)
            {
                return(null);
            }
            BranchVM branch = new BranchVM(BranchVM.TYPE_ELSE_CODE)
            {
                Parent = window
            };

            branch.Init();
            branch.CondGroups.Clear();
            branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, ifThenElse.ElseConstructId);
            return(branch);
        }
Beispiel #6
0
        public void AddBranch(BranchVM branch)
        {
            int index = Branches.IndexOf(branch);

            //Add ELSE IF ~ THEN ~
            BranchVM elseIfBranch = new BranchVM(BranchVM.TYPE_ELSE_IF_CODE)
            {
                Parent = this,
                IsNew  = true
            };

            elseIfBranch.Init();
            branches.Insert(index + 1, elseIfBranch);
            OnBranchOrderChanged();

            Editor.Dispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new Action(() => { elseIfBranch.EditBranch(); }));
        }
Beispiel #7
0
        private static List <BranchVM> CreateElseIfBranches(IfThenElse ifThenElse, CreateBranchWindowVM window)
        {
            List <BranchVM> branches = new List <BranchVM>();
            List <ElseIf>   elseIfs  = ifThenElse.ElseIfs;

            foreach (ElseIf elseIf in elseIfs)
            {
                BranchVM branch = new BranchVM(BranchVM.TYPE_ELSE_IF_CODE)
                {
                    Parent = window
                };
                branch.Init();
                branch.CondGroups.Clear();
                CreateCondGroups(elseIf.IfCondition.Code, branch, window.QuestionConstructs);
                branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, elseIf.ThenConstructId);
                branches.Add(branch);
            }
            return(branches);
        }
Beispiel #8
0
 public BranchVM DeepCopy()
 {
     BranchVM newBranch = new BranchVM(TypeCode);
     newBranch.Parent = Parent;
     newBranch.Init();
     newBranch.IsNew = IsNew;
     newBranch.ThenConstruct = ThenConstruct;
     newBranch.CondGroups.Clear();
     foreach (CondGroupVM condGroup in condGroups)
     {
         CondGroupVM newGroup = condGroup.DeepCopy(newBranch);
         newBranch.CondGroups.Add(newGroup);
     }
     return newBranch;
 }
 private static BranchVM CreateElseBranch(IfThenElse ifThenElse, CreateBranchWindowVM window)
 {
     if (ifThenElse.ElseConstructId == null)
     {
         return null;
     }
     BranchVM branch = new BranchVM(BranchVM.TYPE_ELSE_CODE)
     {
         Parent = window
     };
     branch.Init();
     branch.CondGroups.Clear();
     branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, ifThenElse.ElseConstructId);
     return branch;
 }
Beispiel #10
0
 private static BranchVM CreateIfBranch(IfThenElse ifThenElse, CreateBranchWindowVM window)
 {
     BranchVM branch = new BranchVM(BranchVM.TYPE_IF_CODE)
     {
         Parent = window
     };
     branch.Init();
     branch.CondGroups.Clear();
     IfCondition ifCondition = ifThenElse.IfCondition;
     CreateCondGroups(ifCondition.Code, branch, window.QuestionConstructs);
     branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, ifThenElse.ThenConstructId);
     return branch;
 }
Beispiel #11
0
 private static List<BranchVM> CreateElseIfBranches(IfThenElse ifThenElse, CreateBranchWindowVM window)
 {
     List<BranchVM> branches = new List<BranchVM>();
     List<ElseIf> elseIfs = ifThenElse.ElseIfs;
     foreach (ElseIf elseIf in elseIfs)
     {
         BranchVM branch = new BranchVM(BranchVM.TYPE_ELSE_IF_CODE)
         {
             Parent = window
         };
         branch.Init();
         branch.CondGroups.Clear();
         CreateCondGroups(elseIf.IfCondition.Code, branch, window.QuestionConstructs);
         branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, elseIf.ThenConstructId);
         branches.Add(branch);
     }
     return branches;
 }
        public void AddBranch(BranchVM branch)
        {
            int index = Branches.IndexOf(branch);

            //ELSE IF~THEN~を追加
            BranchVM elseIfBranch = new BranchVM(BranchVM.TYPE_ELSE_IF_CODE)
            {
                Parent = this,
                IsNew = true
            };
            elseIfBranch.Init();
            branches.Insert(index + 1, elseIfBranch);
            OnBranchOrderChanged();

            Editor.Dispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new Action(() => { elseIfBranch.EditBranch(); }));
        }