Ejemplo n.º 1
0
		public static bool SelectObjects(ObjectType objectType, ref List<ObjectReference> currentReferences)
		{
			if (objectType == ObjectType.Device)
			{
				var selectGKDevicesEventArg = new SelectGKDevicesEventArg { Devices = currentReferences == null ? null : currentReferences.Select(x => (GKDevice)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKDevicesEvent>().Publish(selectGKDevicesEventArg);
				currentReferences = selectGKDevicesEventArg.Cancel ?
					null :
					selectGKDevicesEventArg.Devices.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.Zone)
			{
				var selectGKZonesEventArg = new SelectGKZonesEventArg { Zones = currentReferences == null ? null : currentReferences.Select(x => (GKZone)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKZonesEvent>().Publish(selectGKZonesEventArg);
				currentReferences = selectGKZonesEventArg.Cancel ?
					null :
					selectGKZonesEventArg.Zones.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.GuardZone)
			{
				var selectGKGuardZonesEventArg = new SelectGKGuardZonesEventArg { GuardZones = currentReferences == null ? null : currentReferences.Select(x => (GKGuardZone)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKGuardZonesEvent>().Publish(selectGKGuardZonesEventArg);
				currentReferences = selectGKGuardZonesEventArg.Cancel ?
					null :
					selectGKGuardZonesEventArg.GuardZones.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.GKDoor)
			{
				var selectGKDoorsEventArg = new SelectGKDoorsEventArg { Doors = currentReferences == null ? null : currentReferences.Select(x => (GKDoor)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKDoorsEvent>().Publish(selectGKDoorsEventArg);
				currentReferences = selectGKDoorsEventArg.Cancel ?
					null :
					selectGKDoorsEventArg.Doors.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.Direction)
			{
				var selectGKDirectionsEventArg = new SelectGKDirectionsEventArg { Directions = currentReferences == null ? null : currentReferences.Select(x => (GKDirection)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKDirectionsEvent>().Publish(selectGKDirectionsEventArg);
				currentReferences = selectGKDirectionsEventArg.Cancel ?
					null :
					selectGKDirectionsEventArg.Directions.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.PumpStation)
			{
				var selectGKPumpStationsEventArg = new SelectGKPumpStationsEventArg { PumpStations = currentReferences == null ? null : currentReferences.Select(x => (GKPumpStation)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKPumpStationsEvent>().Publish(selectGKPumpStationsEventArg);
				currentReferences = selectGKPumpStationsEventArg.Cancel ?
					null :
					selectGKPumpStationsEventArg.PumpStations.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.MPT)
			{
				var selectGKMPTsEventArg = new SelectGKMPTsEventArg { MPTs = currentReferences == null ? null : currentReferences.Select(x => (GKMPT)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKMPTsEvent>().Publish(selectGKMPTsEventArg);
				currentReferences = selectGKMPTsEventArg.Cancel ?
					null :
					selectGKMPTsEventArg.MPTs.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.VideoDevice)
			{
				var selectCamerasEventArg = new SelectCamerasEventArg { Cameras = currentReferences == null ? null : currentReferences.Select(x => (Camera)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectCamerasEvent>().Publish(selectCamerasEventArg);
				currentReferences = selectCamerasEventArg.Cancel ?
					null :
					selectCamerasEventArg.Cameras.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.Delay)
			{
				var selectGKDelaysEventArg = new SelectGKDelaysEventArg { Delays = currentReferences == null ? null : currentReferences.Select(x => (GKDelay)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectGKDelaysEvent>().Publish(selectGKDelaysEventArg);
				currentReferences = selectGKDelaysEventArg.Cancel ?
					null :
					selectGKDelaysEventArg.Delays.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}

			if (objectType == ObjectType.Organisation)
			{
				var selectOrganisationsEventArg = new SelectOrganisationsEventArg { Organisations = currentReferences == null ? null : currentReferences.Select(x => (Organisation)ExplicitValue.GetObjectValue(x)).ToList() };
				ServiceFactory.Events.GetEvent<SelectOrganisationsEvent>().Publish(selectOrganisationsEventArg);
				currentReferences = selectOrganisationsEventArg.Cancel ?
					null :
					selectOrganisationsEventArg.Organisations.Select(x => new ObjectReference { UID = x.UID, ObjectType = objectType }).ToList();
				return true;
			}
			return false;
		}
Ejemplo n.º 2
0
		void OnSelectCameras(SelectCamerasEventArg selectCamerasEventArg)
		{
			var camerasSelectionViewModel = new CamerasSelectionViewModel(selectCamerasEventArg.Cameras);
			selectCamerasEventArg.Cancel = !ServiceFactory.DialogService.ShowModalWindow(camerasSelectionViewModel);
			selectCamerasEventArg.Cameras = camerasSelectionViewModel.TargetCameras.ToList();
		}