public StateLogicViewModel(DeviceLogicViewModel deviceDetailsViewModel, StateLogic stateLogic) { AddCommand = new RelayCommand(OnAdd); RemoveCommand = new RelayCommand<ClauseViewModel>(OnRemove); ChangeJoinOperatorCommand = new RelayCommand(OnChangeJoinOperator); StateTypes = new List<XStateType>(); StateTypes.Add(XStateType.TurnOn); StateTypes.Add(XStateType.CancelDelay); StateTypes.Add(XStateType.TurnOff); StateTypes.Add(XStateType.Stop); StateTypes.Add(XStateType.ForbidStart); StateTypes.Add(XStateType.TurnOnNow); StateTypes.Add(XStateType.TurnOffNow); SelectedStateType = stateLogic.StateType; _deviceDetailsViewModel = deviceDetailsViewModel; Clauses = new ObservableCollection<ClauseViewModel>(); foreach (var clause in stateLogic.Clauses) { var clauseViewModel = new ClauseViewModel(this, clause); Clauses.Add(clauseViewModel); } }
void OnAdd() { var clause = new XClause(); var clauseViewModel = new ClauseViewModel(clause, Device); Clauses.Add(clauseViewModel); UpdateJoinOperatorVisibility(); }
public ClauseGroupViewModel(GKBase gkBase, GKClauseGroup clauseGroup) { AddCommand = new RelayCommand(OnAdd); AddGroupCommand = new RelayCommand(OnAddGroup); RemoveCommand = new RelayCommand<ClauseViewModel>(OnRemove); RemoveGroupCommand2 = new RelayCommand(OnRemoveGroup2, CanRemoveGroup2); RemoveGroupCommand = new RelayCommand<ClauseGroupViewModel>(OnRemoveGroup); ChangeJoinOperatorCommand = new RelayCommand(OnChangeJoinOperator); GKBase = gkBase; Clauses = new ObservableCollection<ClauseViewModel>(); foreach (var clause in clauseGroup.Clauses) { var clauseViewModel = new ClauseViewModel(gkBase, clause); Clauses.Add(clauseViewModel); } ClauseGroups = new ObservableCollection<ClauseGroupViewModel>(); foreach (var clause in clauseGroup.ClauseGroups) { var clauseGroupViewModel = new ClauseGroupViewModel(gkBase, clause); clauseGroupViewModel.Parent = this; ClauseGroups.Add(clauseGroupViewModel); } JoinOperator = clauseGroup.ClauseJounOperationType; }
public LogicViewModel(XDevice device, List<XClause> clauses) { Device = device; AddCommand = new RelayCommand(OnAdd); RemoveCommand = new RelayCommand<ClauseViewModel>(OnRemove); ChangeJoinOperatorCommand = new RelayCommand(OnChangeJoinOperator); Clauses = new ObservableCollection<ClauseViewModel>(); if (clauses != null) { foreach (var clause in clauses) { var clauseViewModel = new ClauseViewModel(clause, device); Clauses.Add(clauseViewModel); JoinOperator = clause.ClauseJounOperationType; } } UpdateJoinOperatorVisibility(); }
void OnRemove(ClauseViewModel clauseViewModel) { Clauses.Remove(clauseViewModel); UpdateJoinOperatorVisibility(); }
void OnRemove(ClauseViewModel clauseViewModel) { Clauses.Remove(clauseViewModel); }
void OnAdd() { var clauseViewModel = new ClauseViewModel(GKBase, new GKClause()); Clauses.Add(clauseViewModel); }