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; }