public LocationInputViewModel(CompositionContainer container, ILoggerFacade loggerFacade, IEventAggregator eventAggregator)
 {
     this.Street = string.Empty;
     this.Number = string.Empty;
     this.City = string.Empty;
     this.PostCode = string.Empty;
     this.OkCommand = new DelegateCommand<object>(
     this.OnOKClicked, this.CanOKClicked);
     this.CancelCommand = new DelegateCommand<object>(
     this.OnCancelClicked, this.CanCancelClicked);
     this.MoveDownStopCommand = new DelegateCommand<object>(
     this.OnMoveDownCommand, this.CanMoveDownCommand);
     this.MoveUpStopCommand = new DelegateCommand<object>(
     this.OnMoveUpCommand, this.CanMoveUpCommand);
     this.DeleteStopCommand = new DelegateCommand<object>(
     this.OnDeleteStopCommand, this.CanDeleteStopCommand);
     this._container = container;
     this._loggerFacade = loggerFacade;
     this.eventAggregator = eventAggregator;
     mainTabEvent = eventAggregator.GetEvent<CompositePresentationEvent<MainTabInfo>>();
     _notificationErrorInteraction = new InteractionRequest<Notification>();
     this.LocationSelectedCommand = new DelegateCommand<object>(
     this.OnLocationSelected, this.CanLocationSelected);
     this.StopSelectedCommand = new DelegateCommand<object>(
     this.OnStopSelected, this.CanStopSelected);
     this.LocationsSelected = new ObservableCollection<GeoLocatorDetail>();
     this.LocationResults = new ObservableCollection<GeoLocatorDetail>();
     this.RouteDirections = new ObservableCollection<string>();
     this.SelectionVisibility = Visibility.Visible;
     this.StopsVisibility = Visibility.Collapsed;
     this.RouteDirectionsVisibility = Visibility.Collapsed;
 }
        void EventAgregatorCopy_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            TheEventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>();
            // get a reference to the event from
            // the event aggregator
            CompositePresentationEvent <MyCopyData> myCopyEvent =
                TheEventAggregator.GetEvent <MyCopyDataAddedEvent>();

            // get the data text from TheTextToCopyTextBox TextBox control
            MyCopyData copyData = new MyCopyData
            {
                CopyString = Parametro1.Text
            };

            //publish data via event aggregator
            myCopyEvent.Publish(copyData);
        }
示例#3
0
 public MapViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, ILoggerFacade loggerFacade, IConfiguration configuration)
 {
     _container = new ErrorsContainer<string>(OnErrorsChanged);
     this.regionManager = regionManager;
     mapDataEvent = eventAggregator.GetEvent<CompositePresentationEvent<MapData>>();
     mapLoadedEvent = eventAggregator.GetEvent<CompositePresentationEvent<MapLoaded>>();
     mapExtentEvent = eventAggregator.GetEvent<CompositePresentationEvent<MapExtent>>();
     this._loggerFacade = loggerFacade;
     this.configuration = configuration;
     _notificationErrorInteraction = new InteractionRequest<Notification>();
     this.NotificationErrorInteraction.Raised += (o, e) =>
     {
         // Do some logging
         _loggerFacade.Log(e.Context.Content as string, Category.Exception, Priority.High);
         var result = messageBoxCustom.Show(e.Context.Content as string, Silverlight.UI.Esri.JTMap.Resources.Map.ErrorMessage,
         MessageBoxCustomEnum.MessageBoxButtonCustom.Ok);
     };
     HandleRightClick = new DelegateCommand<object>(this.OnRightMouseClicked, this.CanRightMouseClicked);
     this.ContextMenuVisibility = Visibility.Collapsed;
     this.MenuItemCommand = new DelegateCommand<object>(
         this.OnMenuItemClicked, this.CanMenuItemClicked);
     string tradeNote = "J&T Software BVBA - Custom Silverlight map editor - Version 1.0";
     HelpContents.DisplayHelp(tradeNote, regionManager,false);
 }
示例#4
0
		void OnAutomationCallback(AutomationCallbackResult automationCallbackResult)
		{
			if (automationCallbackResult.AutomationCallbackType == AutomationCallbackType.GlobalVariable)
			{
				var data = automationCallbackResult.Data as GlobalVariableCallBackData;
				if (data != null)
				{
					var variable = ProcedureExecutionContext.GlobalVariables.FirstOrDefault(x => x.Uid == data.VariableUID);
					variable.Value = data.ExplicitValue.Value;
				}
				return;
			}

			if (automationCallbackResult.AutomationCallbackType == AutomationCallbackType.OpcDaTag)
			{
				var data = automationCallbackResult.Data as OpcDaTagCallBackData;
				if (data != null)
					OpcDaHelper.SetTagValue(data.TagUID, data.Value);
				return;
			}

			if (!AutomationHelper.CheckLayoutFilter(automationCallbackResult, GetLayoutUID()))
				return;

			switch (automationCallbackResult.AutomationCallbackType)
			{
				case AutomationCallbackType.ShowDialog:
					var showDialogData = automationCallbackResult.Data as ShowDialogCallbackData;
					if (showDialogData != null)
						LayoutDialogViewModel.Show(showDialogData);
					break;
				case AutomationCallbackType.CloseDialog:
					var closeDialogData = automationCallbackResult.Data as CloseDialogCallbackData;
					if (closeDialogData != null)
						LayoutDialogViewModel.Close(closeDialogData);
					break;
				case AutomationCallbackType.Sound:
					var soundData = (SoundCallbackData)automationCallbackResult.Data;
					var sound =
						ClientManager.SystemConfiguration.AutomationConfiguration.AutomationSounds.FirstOrDefault(
							x => x.Uid == soundData.SoundUID);
					if (sound != null)
						ApplicationService.Invoke(
							() =>
								AlarmPlayerHelper.Play(
									FileHelper.GetSoundFilePath(Path.Combine(ServiceFactoryBase.ContentService.ContentFolder, sound.Uid.ToString())), false));
					break;
				case AutomationCallbackType.Message:
					var messageData = (MessageCallbackData)automationCallbackResult.Data;
					ApplicationService.Invoke(() =>
					{
						if (messageData.WithConfirmation)
						{
							ApplicationService.BeginInvoke(() =>
								{
									var confirm = MessageBoxService.ShowConfirmation(messageData.Message, "Сообщение");
									ProcedureExecutionContext.CallbackResponse(RubezhServiceFactory.UID, automationCallbackResult.ContextType, automationCallbackResult.CallbackUID, confirm);
								});
						}
						else
							MessageBoxService.ShowExtended(messageData.Message, "Сообщение", messageData.IsModalWindow);
					});
					break;
				case AutomationCallbackType.Property:
					{
						var propertyData = (PropertyCallBackData)automationCallbackResult.Data;
						var ShowObjectDetailsEvent = new CompositePresentationEvent<Guid>();
						switch (propertyData.ObjectType)
						{
							case ObjectType.Device:
								var device = GKManager.Devices.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (device != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDeviceDetailsEvent>();
								break;

							case ObjectType.Zone:
								var zone = GKManager.Zones.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (zone != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKZoneDetailsEvent>();
								break;

							case ObjectType.Direction:
								var direction = GKManager.Directions.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (direction != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDirectionDetailsEvent>();
								break;

							case ObjectType.Delay:
								var delay = GKManager.Delays.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (delay != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDelayDetailsEvent>();
								break;

							case ObjectType.GuardZone:
								var guardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (guardZone != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKGuardZoneDetailsEvent>();
								break;

							case ObjectType.VideoDevice:
								var videoDevice = ClientManager.SystemConfiguration.Cameras.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (videoDevice != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowCameraDetailsEvent>();
								break;

							case ObjectType.GKDoor:
								var gkDoor = GKManager.Doors.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (gkDoor != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDoorDetailsEvent>();
								break;

							case ObjectType.PumpStation:
								var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (pumpStation != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>();
								break;

							case ObjectType.MPT:
								var mpt = GKManager.MPTs.FirstOrDefault(x => x.UID == propertyData.ObjectUid);
								if (mpt != null)
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKMPTDetailsEvent>();
								break;
						}
						if (ShowObjectDetailsEvent != null)
							ApplicationService.BeginInvoke(() => ShowObjectDetailsEvent.Publish(propertyData.ObjectUid));
					}
					break;
				case AutomationCallbackType.GetPlanProperty:
					var controlPlanEventArg = new ControlPlanEventArg
					{
						ControlElementType = ControlElementType.Get,
						PlanCallbackData = (PlanCallbackData)automationCallbackResult.Data
					};
					ServiceFactory.Events.GetEvent<ControlPlanEvent>().Publish(controlPlanEventArg);
					ProcedureExecutionContext.CallbackResponse(RubezhServiceFactory.UID, automationCallbackResult.ContextType, automationCallbackResult.CallbackUID, controlPlanEventArg.PlanCallbackData.Value);
					break;
				case AutomationCallbackType.SetPlanProperty:
					controlPlanEventArg = new ControlPlanEventArg
					{
						ControlElementType = ControlElementType.Set,
						PlanCallbackData = (PlanCallbackData)automationCallbackResult.Data
					};
					ServiceFactory.Events.GetEvent<ControlPlanEvent>().Publish(controlPlanEventArg);
					break;
			}

		}
示例#5
0
        public ToolbarViewModel(IRegionManager regionManager, CompositionContainer container,
		ILoggerFacade loggerFacade, IEventAggregator eventAggregator)
        {
            this.QueryCommand = new DelegateCommand<object>(
            this.OnQueryCommandClicked, this.CanQueryCommandClicked);
            this.ZoomInCommand = new DelegateCommand<object>(
            this.OnZoomInCommandClicked, this.CanZoomInCommandClicked);
            this.ZoomOutCommand = new DelegateCommand<object>(
            this.OnZoomOutCommandClicked, this.CanZoomOutCommandClicked);
            this.InfoCommand = new DelegateCommand<object>(
            this.OnInfoCommandClicked, this.CanInfoCommandClicked);
            this.AddressLocatorCommand = new DelegateCommand<object>(
            this.OnAddressLocatorCommandClicked, this.CanAddressLocatorCommandClicked);
            this.RouteStartCommand = new DelegateCommand<object>(
            this.OnRouteStartCommandClicked, this.CanRouteStartCommandClicked);
            this.RouteClearCommand = new DelegateCommand<object>(
            this.OnRouteClearCommandClicked, this.CanRouteClearCommandClicked);
            this.AddLayerCommand = new DelegateCommand<object>(
            this.OnAddLayerCommandClicked, this.CanAddLayerCommandClicked);
            this.RemoveLayerCommand = new DelegateCommand<object>(
            this.OnRemoveLayerCommandClicked, this.CanRemoveLayerCommandClicked);
            this.PanCommand = new DelegateCommand<object>(
            this.OnPanCommandClicked, this.CanPanCommandClicked);
            this.BookmarkCommand = new DelegateCommand<object>(
                this.OnBookmarkCommandClicked, this.CanBookmarkCommandClicked);
            //
            this.regionManager = regionManager;
            this.container = container;
            this.loggerFacade = loggerFacade;
            resultEvent = eventAggregator.GetEvent<CompositePresentationEvent<List<SearchResult>>>();
            mainTabEvent = eventAggregator.GetEvent<CompositePresentationEvent<MainTabInfo>>();
            if (eventAggregator != null)
                eventAggregator.GetEvent<CompositePresentationEvent<MapLoaded>>().Subscribe(OnMapLoadedChanged);
            if (eventAggregator != null)
                eventAggregator.GetEvent<CompositePresentationEvent<MapExtent>>().Subscribe(OnMapExtentChanged);
            ShowMessagebox = new InteractionRequest<Notification>();
            ShowErrorMessagebox = new InteractionRequest<Notification>();
        }
示例#6
0
		public JournalItemViewModel(JournalItem journalItem)
		{
			ShowObjectCommand = new RelayCommand(OnShowObject, CanShowObject);
			ShowPropertiesCommand = new RelayCommand(OnShowProperties, CanShowProperties);
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan);
			ShowObjectOrPlanCommand = new RelayCommand(OnShowObjectOrPlan);
			ShowVideoCommand = new RelayCommand(OnShowVideo, CanShowVideo);

			JournalItem = journalItem;

			if (journalItem.JournalEventNameType != JournalEventNameType.NULL)
			{
				Name = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventNameType);
			}

			if (journalItem.JournalEventDescriptionType != JournalEventDescriptionType.NULL)
			{
				Description = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventDescriptionType);
				if (!string.IsNullOrEmpty(journalItem.DescriptionText))
					Description += " " + journalItem.DescriptionText;
			}
			else
			{
				Description = journalItem.DescriptionText;
			}

			IsExistsInConfig = true;
			_isVideoExist = journalItem.VideoUID != Guid.Empty;
			ObjectImageSource = JournalItem.GetImageSource(journalItem.JournalObjectType);
			StateClass = EventDescriptionAttributeHelper.ToStateClass(journalItem.JournalEventNameType);

			switch (JournalItem.JournalObjectType)
			{
				case JournalObjectType.GKDevice:
					Device = GKManager.Devices.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (Device != null)
					{
						ObjectName = Device.GetGKDescriptorName(GKManager.DeviceConfiguration.GKNameGenerationType);
						ObjectImageSource = Device.Driver.ImageSource;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDeviceEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDeviceDetailsEvent>();
					}
					else
						ObjectImageSource = "/Controls;component/Images/Blank.png";
					break;

				case JournalObjectType.GKZone:
					Zone = GKManager.Zones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (Zone != null)
					{
						ObjectName = Zone.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKZoneEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKZoneDetailsEvent>();
					}
					break;

				case JournalObjectType.GKDirection:
					Direction = GKManager.Directions.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (Direction != null)
					{
						ObjectName = Direction.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDirectionEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDirectionDetailsEvent>();
					}
					break;

				case JournalObjectType.GKPumpStation:
					PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (PumpStation != null)
					{
						ObjectName = PumpStation.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>();
					}
					break;

				case JournalObjectType.GKMPT:
					MPT = GKManager.MPTs.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (MPT != null)
					{
						ObjectName = MPT.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKMPTEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKMPTDetailsEvent>();
					}
					break;

				case JournalObjectType.GKDelay:
					Delay = GKManager.Delays.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (Delay != null)
					{
						ObjectName = Delay.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDelayEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDelayDetailsEvent>();
					}
					else
					{
						Delay = GKManager.AutoGeneratedDelays.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
						if (Delay != null)
						{
							ObjectName = Delay.PresentationName;
							ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDelayEvent>();
							ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDelayDetailsEvent>();
							if (Delay.PumpStationUID != Guid.Empty)
							{
								PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == Delay.PumpStationUID);
								if (PumpStation != null)
								{
									ObjectName += " (" + PumpStation.PresentationName + ")";
									ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationEvent>();
									ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>();
									ObjectImageSource = "/Controls;component/Images/BPumpStation.png";
									break;
								}
							}
						}
					}
					break;

				case JournalObjectType.GKPim:
					Pim = GKManager.AutoGeneratedPims.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (Pim != null)
					{
						ObjectName = Pim.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPimEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPIMDetailsEvent>();
						if (Pim.PumpStationUID != Guid.Empty)
						{
							PumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == Pim.PumpStationUID);
							if (PumpStation != null)
							{
								ObjectName += " (" + PumpStation.PresentationName + ")";
								ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationEvent>();
								ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKPumpStationDetailsEvent>();
								ObjectImageSource = "/Controls;component/Images/BPumpStation.png";
								break;
							}
						}
						if (Pim.MPTUID != Guid.Empty)
						{
							MPT = GKManager.MPTs.FirstOrDefault(x => x.UID == Pim.MPTUID);
							if (MPT != null)
							{
								ObjectName += " (" + MPT.PresentationName + ")";
								ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKMPTEvent>();
								ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKMPTDetailsEvent>();
								ObjectImageSource = "/Controls;component/Images/BMPT.png";
								break;
							}
						}
					}
					break;

				case JournalObjectType.GKGuardZone:
					GuardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (GuardZone != null)
					{
						ObjectName = GuardZone.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKGuardZoneEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKGuardZoneDetailsEvent>();
					}
					break;

				case JournalObjectType.GKSKDZone:
					GKSKDZone = GKManager.SKDZones.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (GKSKDZone != null)
					{
						ObjectName = GKSKDZone.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKSKDZoneEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKSKDZoneDetailsEvent>();
					}
					break;

				case JournalObjectType.GKDoor:
					GKDoor = GKManager.Doors.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (GKDoor != null)
					{
						ObjectName = GKDoor.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowGKDoorEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowGKDoorDetailsEvent>();
					}
					break;

				case JournalObjectType.Camera:
					Camera = ClientManager.SystemConfiguration.Cameras.FirstOrDefault(x => x.UID == JournalItem.ObjectUID);
					if (Camera != null)
					{
						ObjectName = Camera.PresentationName;
						ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowCameraEvent>();
						ShowObjectDetailsEvent = ServiceFactory.Events.GetEvent<ShowCameraDetailsEvent>();
					}
					break;

				case JournalObjectType.None:
				case JournalObjectType.GKUser:
					ObjectName = JournalItem.ObjectName != null ? JournalItem.ObjectName : "";
					break;
			}

			if (ObjectName == null)
			{
				ObjectName = JournalItem.ObjectName;
				IsExistsInConfig = false;
			}

			if (ObjectName == null)
				ObjectName = "<Нет в конфигурации>";

			if (JournalItem.JournalSubsystemType == JournalSubsystemType.SKD)
			{
				IsExistsInConfig = true;
				if ((int)JournalItem.JournalObjectType >= 11 && (int)JournalItem.JournalObjectType <= 19)
					ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowJournalHREvent>();

				if ((int)JournalItem.JournalObjectType >= 20 && (int)JournalItem.JournalObjectType <= 26)
					ShowObjectEvent = ServiceFactory.Events.GetEvent<ShowJournalTimeTrackingEvent>();
			}

		}