예제 #1
0
 public CreateBranchWindow(CreateBranchWindowVM viewModel)
 {
     InitializeComponent();
     viewModel.Editor = this;
     this.viewModel   = viewModel;
     DataContext      = viewModel;
 }
 public CreateBranchWindow(CreateBranchWindowVM viewModel)
 {
     InitializeComponent();
     viewModel.Editor = this;
     this.viewModel = viewModel;
     DataContext = viewModel;
 }
예제 #3
0
        public void AddBranch()
        {
            CreateBranchWindowVM vm     = new CreateBranchWindowVM(this);
            CreateBranchWindow   window = new CreateBranchWindow(vm);

            window.Owner = Application.Current.MainWindow;
            if (window.ShowDialog() == true)
            {
                InsertIfThenElseConstruct(vm.IfThenElse);
            }
        }
예제 #4
0
        public static CondVM CreateDefault(CondGroupVM parent)
        {
            CondVM cond = new CondVM()
            {
                Parent = parent
            };
            CreateBranchWindowVM window = parent.Window;

            cond.SelectedQuestionConstruct = window.TargetQuestionConstruct;
            cond.SelectedOperatorCode      = Options.OPERATOR_EQUALS_CODE;
            return(cond);
        }
예제 #5
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);
            }
        }
예제 #6
0
파일: BranchVM.cs 프로젝트: ssjda-ddi/EDO
        public void Submit()
        {
            IgnoreValidation(false);
            bool valid = Editor.ValidateEditingBranch();

            IgnoreValidation(true);
            if (!valid)
            {
                return;
            }
            CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent;

            parent.SubmitEditingBranch();
        }
예제 #7
0
 public static ObservableCollection<BranchVM> CreateBranches(IfThenElse ifThenElse, CreateBranchWindowVM window)
 {
     ObservableCollection<BranchVM> branches = new ObservableCollection<BranchVM>();
     BranchVM ifBranch = CreateIfBranch(ifThenElse, window);
     branches.Add(ifBranch);
     List<BranchVM> elseIfBranches = CreateElseIfBranches(ifThenElse, window);
     branches.AddRange(elseIfBranches);
     BranchVM elseBranch = CreateElseBranch(ifThenElse, window);
     if (elseBranch != null)
     {
         branches.Add(elseBranch);
     }
     return branches;
 }
예제 #8
0
파일: BranchVM.cs 프로젝트: ssjda-ddi/EDO
        private void ResetType()
        {
            if (IsTypeElse)
            {
                CondGroups.Clear();
            }
            else
            {
                CondGroupVM condGroup = CreateDefaultCondGroup();
                condGroups.Add(condGroup);

                CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent;
                ThenConstruct = parent.NextConstruct;
            }
        }
예제 #9
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);
        }
예제 #10
0
        private static Dictionary <IfThenElseVM, CreateBranchWindowVM> UpdateQuestionNumberOfBranches(ControlConstructSchemeVM controlConstructScheme, ICollection <QuestionNumberVM> updatingQuestionNumbers)
        {
            Dictionary <IfThenElseVM, CreateBranchWindowVM> updatingIfThenElseDict = new Dictionary <IfThenElseVM, CreateBranchWindowVM>();

            List <IfThenElseVM> ifThenElses = controlConstructScheme.IfThenElses;

            foreach (IfThenElseVM ifThenElse in ifThenElses)
            {
                CreateBranchWindowVM vm = new CreateBranchWindowVM(controlConstructScheme, ifThenElse.IfThenElse);
                if (UpdateQuestionNumbers(vm.Branches, updatingQuestionNumbers))
                {
                    updatingIfThenElseDict[ifThenElse] = vm;
                }
            }
            return(updatingIfThenElseDict);
        }
예제 #11
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);
        }
예제 #12
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);
        }
예제 #13
0
파일: BranchVM.cs 프로젝트: ssjda-ddi/EDO
        private CondGroupVM CreateDefaultCondGroup()
        {
            CondGroupVM condGroup = new CondGroupVM()
            {
                Parent = this
            };
            CondVM cond = new CondVM()
            {
                Parent = condGroup
            };
            CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent;

            cond.SelectedQuestionConstruct = parent.TargetQuestionConstruct;
            cond.SelectedOperatorCode      = Options.OPERATOR_EQUALS_CODE;
            condGroup.Conds.Add(cond);
            return(condGroup);
        }
예제 #14
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);
        }
예제 #15
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;
 }
예제 #16
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;
 }
예제 #17
0
        public static ObservableCollection <BranchVM> CreateBranches(IfThenElse ifThenElse, CreateBranchWindowVM window)
        {
            ObservableCollection <BranchVM> branches = new ObservableCollection <BranchVM>();
            BranchVM ifBranch = CreateIfBranch(ifThenElse, window);

            branches.Add(ifBranch);
            List <BranchVM> elseIfBranches = CreateElseIfBranches(ifThenElse, window);

            branches.AddRange(elseIfBranches);
            BranchVM elseBranch = CreateElseBranch(ifThenElse, window);

            if (elseBranch != null)
            {
                branches.Add(elseBranch);
            }
            return(branches);
        }
예제 #18
0
파일: BranchVM.cs 프로젝트: ssjda-ddi/EDO
        public void Cancel()
        {
            CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent;

            parent.CancelEditingBranch();
        }
 public void AddBranch()
 {
     CreateBranchWindowVM vm = new CreateBranchWindowVM(this);
     CreateBranchWindow window = new CreateBranchWindow(vm);
     window.Owner = Application.Current.MainWindow;
     if (window.ShowDialog() == true)
     {
         InsertIfThenElseConstruct(vm.IfThenElse);
     }
 }
예제 #20
0
파일: BranchVM.cs 프로젝트: ssjda-ddi/EDO
        public void AddBranch()
        {
            CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent;

            parent.AddBranch(this);
        }
예제 #21
0
파일: BranchVM.cs 프로젝트: ssjda-ddi/EDO
        public void RemoveBranch()
        {
            CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent;

            parent.RemoveBranch(this);
        }
예제 #22
0
파일: BranchVM.cs 프로젝트: ssjda-ddi/EDO
        public void EditBranch()
        {
            CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent;

            parent.EditBranch(this);
        }
        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;
        }
예제 #24
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;
 }