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; }
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); } }
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); }
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); } }
public void Submit() { IgnoreValidation(false); bool valid = Editor.ValidateEditingBranch(); IgnoreValidation(true); if (!valid) { return; } CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent; parent.SubmitEditingBranch(); }
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; }
private void ResetType() { if (IsTypeElse) { CondGroups.Clear(); } else { CondGroupVM condGroup = CreateDefaultCondGroup(); condGroups.Add(condGroup); CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent; ThenConstruct = parent.NextConstruct; } }
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); }
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); }
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); }
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); }
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); }
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); }
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; }
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; }
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); }
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); } }
public void AddBranch() { CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent; parent.AddBranch(this); }
public void RemoveBranch() { CreateBranchWindowVM parent = (CreateBranchWindowVM)Parent; parent.RemoveBranch(this); }
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; }
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; }