void OnChange(ExplicitValueViewModel explicitValueViewModel) { if (IsList) ProcedureHelper.SelectObject(Argument.ObjectType, explicitValueViewModel); else ProcedureHelper.SelectObject(Argument.ObjectType, ExplicitValue); OnPropertyChanged(() => ExplicitValue); }
public ArgumentViewModel(Variable argument) { Argument = argument; ExplicitValue = new ExplicitValueViewModel((ExplicitValue)argument, true); ChangeCommand = new RelayCommand<ExplicitValueViewModel>(OnChange); Name = argument.Name; IsList = argument.IsList; }
public VariableDetailsViewModel(Variable variable, List<Variable> availableVariables, string title = "", bool isGlobal = false) { automationChanged = ServiceFactory.SaveService.AutomationChanged; _availableVariables = availableVariables; Variable = new Variable { IsGlobal = isGlobal }; if (variable == null) { ExplicitTypes = new ObservableCollection<ExplicitTypeViewModel>(ProcedureHelper.BuildExplicitTypes(AutomationHelper.GetEnumList<ExplicitType>(), AutomationHelper.GetEnumList<EnumType>(), AutomationHelper.GetEnumList<ObjectType>())); _selectedExplicitType = ExplicitTypes.FirstOrDefault(); } else { Variable.Uid = variable.Uid; Variable.Value = variable.Value; Variable.IsReference = variable.IsReference; Variable.IsGlobal = variable.IsGlobal; Variable.IsList = variable.IsList; Variable.ObjectType = variable.ObjectType; Name = variable.Name; IsEditMode = true; _isNameEdited = true; ExplicitTypes = new ObservableCollection<ExplicitTypeViewModel>(ProcedureHelper.BuildExplicitTypes(new List<ExplicitType> { variable.ExplicitType }, new List<EnumType> { variable.EnumType }, new List<ObjectType> { variable.ObjectType })); var explicitTypeViewModel = ExplicitTypes.FirstOrDefault(); if (explicitTypeViewModel != null) { _selectedExplicitType = explicitTypeViewModel.GetAllChildren().LastOrDefault(); if (_selectedExplicitType != null) _selectedExplicitType.ExpandToThis(); } } SelectedContextType = Variable.ContextType; Title = title; IsGlobal = isGlobal; ContextTypes = AutomationHelper.GetEnumObs<ContextType>(); ExplicitValueViewModel = new ExplicitValueViewModel((ExplicitValue)Variable); }
public static bool SelectObject(ObjectType objectType, ExplicitValueViewModel currentExplicitValue) { if (objectType == ObjectType.Device) { var selectGKDeviceEventArg = new SelectGKDeviceEventArg { Device = currentExplicitValue.Device }; ServiceFactory.Events.GetEvent<SelectGKDeviceEvent>().Publish(selectGKDeviceEventArg); if (!selectGKDeviceEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKDeviceEventArg.Device; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.Zone) { var selectGKZoneEventArg = new SelectGKZoneEventArg { Zone = currentExplicitValue.Zone }; ServiceFactory.Events.GetEvent<SelectGKZoneEvent>().Publish(selectGKZoneEventArg); if (!selectGKZoneEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKZoneEventArg.Zone; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.GuardZone) { var selectGKGuardZoneEventArg = new SelectGKGuardZoneEventArg { GuardZone = currentExplicitValue.GuardZone }; ServiceFactory.Events.GetEvent<SelectGKGuardZoneEvent>().Publish(selectGKGuardZoneEventArg); if (!selectGKGuardZoneEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKGuardZoneEventArg.GuardZone; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.GKDoor) { var selectGKDoorEventArg = new SelectGKDoorEventArg { Door = currentExplicitValue.GKDoor }; ServiceFactory.Events.GetEvent<SelectGKDoorEvent>().Publish(selectGKDoorEventArg); if (!selectGKDoorEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKDoorEventArg.Door; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.Direction) { var selectGKDirectionEventArg = new SelectGKDirectionEventArg { Direction = currentExplicitValue.Direction }; ServiceFactory.Events.GetEvent<SelectGKDirectionEvent>().Publish(selectGKDirectionEventArg); if (!selectGKDirectionEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKDirectionEventArg.Direction; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.PumpStation) { var selectGKPumpStationEventArg = new SelectGKPumpStationEventArg { PumpStation = currentExplicitValue.PumpStation }; ServiceFactory.Events.GetEvent<SelectGKPumpStationEvent>().Publish(selectGKPumpStationEventArg); if (!selectGKPumpStationEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKPumpStationEventArg.PumpStation; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.MPT) { var selectGKMPTEventArg = new SelectGKMPTEventArg { MPT = currentExplicitValue.MPT }; ServiceFactory.Events.GetEvent<SelectGKMPTEvent>().Publish(selectGKMPTEventArg); if (!selectGKMPTEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKMPTEventArg.MPT == null; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.VideoDevice) { var selectCameraEventArg = new SelectCameraEventArg { Camera = currentExplicitValue.Camera }; ServiceFactory.Events.GetEvent<SelectCameraEvent>().Publish(selectCameraEventArg); if (!selectCameraEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectCameraEventArg.Camera; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.Delay) { var selectGKDelayEventArg = new SelectGKDelayEventArg { Delay = currentExplicitValue.Delay }; ServiceFactory.Events.GetEvent<SelectGKDelayEvent>().Publish(selectGKDelayEventArg); if (!selectGKDelayEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKDelayEventArg.Delay; currentExplicitValue.Initialize(); } return true; } if (objectType == ObjectType.Organisation) { var selectGKOrganisationEventArg = new SelectOrganisationEventArg { Organisation = currentExplicitValue.Organisation }; ServiceFactory.Events.GetEvent<SelectOrganisationEvent>().Publish(selectGKOrganisationEventArg); if (!selectGKOrganisationEventArg.Cancel) { currentExplicitValue.ExplicitValue.Value = selectGKOrganisationEventArg.Organisation; currentExplicitValue.Initialize(); } return true; } return false; }
public static bool SelectObject(ObjectType objectType, ExplicitValueViewModel currentExplicitValue) { if (objectType == ObjectType.Device) { var deviceSelectationViewModel = new DeviceSelectionViewModel(currentExplicitValue.Device != null ? currentExplicitValue.Device : null); if (DialogService.ShowModalWindow(deviceSelectationViewModel)) { currentExplicitValue.ExplicitValue.Value = deviceSelectationViewModel.SelectedDevice.Device; currentExplicitValue.Initialize(); return true; } } if (objectType == ObjectType.Zone) { var zoneSelectationViewModel = new ZoneSelectionViewModel(currentExplicitValue.Zone != null ? currentExplicitValue.Zone : null); if (DialogService.ShowModalWindow(zoneSelectationViewModel)) { currentExplicitValue.ExplicitValue.Value = zoneSelectationViewModel.SelectedZone.Zone; currentExplicitValue.Initialize(); return true; } } if (objectType == ObjectType.GuardZone) { var guardZoneSelectationViewModel = new GuardZoneSelectionViewModel(currentExplicitValue.GuardZone != null ? currentExplicitValue.GuardZone : null); if (DialogService.ShowModalWindow(guardZoneSelectationViewModel)) { currentExplicitValue.ExplicitValue.Value = guardZoneSelectationViewModel.SelectedZone.GuardZone; currentExplicitValue.Initialize(); return true; } } if (objectType == ObjectType.Direction) { var directionSelectationViewModel = new DirectionSelectionViewModel(currentExplicitValue.Direction != null ? currentExplicitValue.Direction : null); if (DialogService.ShowModalWindow(directionSelectationViewModel)) { currentExplicitValue.ExplicitValue.Value = directionSelectationViewModel.SelectedDirection.Direction; currentExplicitValue.Initialize(); return true; } } if (objectType == ObjectType.VideoDevice) { var cameraSelectionViewModel = new CameraSelectionViewModel(currentExplicitValue.Camera != null ? currentExplicitValue.Camera : null); if (DialogService.ShowModalWindow(cameraSelectionViewModel)) { currentExplicitValue.ExplicitValue.Value = cameraSelectionViewModel.SelectedCamera; currentExplicitValue.Initialize(); return true; } } if (objectType == ObjectType.Delay) { var delaySelectionViewModel = new DelaySelectionViewModel(currentExplicitValue.Delay); if (DialogService.ShowModalWindow(delaySelectionViewModel)) { currentExplicitValue.ExplicitValue.Value = delaySelectionViewModel.SelectedDelay; currentExplicitValue.Initialize(); return true; } } return false; }