public void OnNavigatedTo(NavigationContext navigationContext) { _trackMenuBarToken = _eventAggregator.GetEvent<TrackCommandBarEvent>().Subscribe(OnTrackMenuBarEvent, true); _tracksMenuBarToken = _eventAggregator.GetEvent<TracksCommandBarEvent>().Subscribe(OnTracksMenuBarEvent, true); Album = navigationContext.Tag as IAlbum; }
public ItemListFilter() { InitializeComponent(); Init(); ItemListFilterViewModel = new ItemListFilterViewModel(iEventAggregator, controls.Length); this.DataContext = ItemListFilterViewModel; propertyChangedMap = new Dictionary<string, Action>() { { "SelectedControlIndex", () => { SetControlSelected(controls[selectedControlIndex], false); selectedControlIndex = ItemListFilterViewModel.SelectedControlIndex; SetControlSelected(controls[selectedControlIndex], true); }}, }; ItemListFilterViewModel.PropertyChanged += PropertyChangedHandler; eventMap = new Dictionary<string, Action>() { {"FILTER_SELECT_CONTROL", SelectControl } }; filterActionToken = this.iEventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Subscribe( (viewEventArgs) => { EventHandler(viewEventArgs); } ); }
public SoundQuestionWindowViewModel(IEventAggregator eventAggregator, StandingsService standingsService, InputService inputService) : base(eventAggregator, standingsService, inputService) { _soundToken = ShowEvent.Subscribe(PauseStart); _closeEvent = eventAggregator.GetEvent<CloseEvent>(); _stopToken = _closeEvent.Subscribe((o) => Dispose()); }
public ModuleBWorkspace(IStringCopyService stringCopyService)/*IEventAggregator eventAggregator*/ { // código exclusivo para la recepción de un string a traves de un agregador de eventos. var eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); // eventAggregator.GetEvent<MyCopyDataAddedEvent>().Subscribe(OnCopyDataReceived, ThreadOption.UIThread); var evento = eventAggregator.GetEvent<MyCopyDataAddedEvent>(); if (subscriptionToken != null) { evento.Unsubscribe(subscriptionToken); } subscriptionToken = evento.Subscribe(OnCopyDataReceived, ThreadOption.UIThread, true); InitializeComponent(); //código exclusivo para recepción de un string a traves de un servicio compartido stringCopyService.CopyStringEvent += TheStringCopyService_CopyStringEvent; //código exclusivo para la recepción de datos atraves del regioncontext. // get the region context from the current view // (which is plugged into the region) Microsoft.Practices.Prism.ObservableObject<object> regionContexto = RegionContext.GetObservableContext(this); // set an event handler to run when PropertyChanged event is fired regionContexto.PropertyChanged += regionContext_PropertyChanged; }
public SearchGameDataViewModel(string _gameQuery) { iEventAggregator = Event.EventInstance.EventAggregator; SelectedCol = 0; SelectedRow = 0; TitleBarText = "Searching for " + _gameQuery + "..."; GameData = GameRetriever.GetGameDataSetLists(_gameQuery); GameQuery = _gameQuery; eventMap = new Dictionary<string, Action>() { { "SEARCHGAMEDATA_MOVE_LEFT", () => { SelectedCol = SelectedCol - 1; } }, { "SEARCHGAMEDATA_MOVE_RIGHT", () => { SelectedCol = SelectedCol + 1; } }, { "SEARCHGAMEDATA_MOVE_UP", () => { SelectedRow = SelectedRow - 1; } }, { "SEARCHGAMEDATA_MOVE_DOWN", () => { SelectedRow = SelectedRow + 1; } }, { "SEARCHGAMEDATA_SELECT", SelectItem } }; searchGameDataActionToken = iEventAggregator.GetEvent<PubSubEvent<SearchGameDataEventArgs>>().Subscribe( (viewEventArgs) => { EventHandler(this, viewEventArgs); } ); }
public void OnImportsSatisfied() { if (_obj == null) { _obj = _eventAggregator.GetEvent<CompositePresentationEvent<ObservableCollection<IDataItem>>>().Subscribe(dataItemsReceived => DataService.DataItems = dataItemsReceived, true); } }
public Task<bool> Stop() { bool returnValue = false; try { // *** // *** Unsubscribe from the event // *** if (_exceptionEventToken != null) { this.EventAggregator.GetEvent<Events.TemperatureChangedEvent>().Unsubscribe(_exceptionEventToken); _exceptionEventToken.Dispose(); _exceptionEventToken = null; } // *** // *** Release the collection items // *** this.Items.Clear(); returnValue = true; } catch (Exception ex) { this.EventAggregator.GetEvent<Events.DebugEvent>().Publish(new DebugEventArgs(ex)); returnValue = false; } return Task<bool>.FromResult(returnValue); }
public void WhenDisposeIsCalledMoreThanOnce_ThenExceptionIsNotThrown() { SubscriptionToken token = new SubscriptionToken(t => { }); token.Dispose(); token.Dispose(); }
public HeadPageViewModel( IEventAggregator events, MouthViewModel mouth, RightEyeViewModel rightEye, LeftEyeViewModel leftEye, NoseViewModel nose, INavigationService navService, MotionActivatedSimpleAnimation animation) { _events = events; _actionFacialCodingEventToken = _events.GetEvent<Events.ActionFacialCodingEvent>().Subscribe((args) => { this.OnActionFacialCodingCommand(args); }, ThreadOption.UIThread); _sensorChangedEventToken = _events.GetEvent<Events.RangeSensorEvent>().Subscribe((args) => { this.OnRangeSensorChanged(args); }, ThreadOption.UIThread); _navService = navService; GoBackCommand = new DelegateCommand(_navService.GoBack); NavigateControlCommand = new DelegateCommand(() => navService.Navigate("Control", null)); HideCommand = new DelegateCommand(this.Hide); _mouth = mouth; _rightEye = rightEye; _leftEye = leftEye; _nose = nose; _animationService = animation; Image = new BitmapImage(new Uri(@"ms-appx:///Assets/pumpkinbackground.png", UriKind.RelativeOrAbsolute)); }
App() { iEventAggregator = Event.EventInstance.EventAggregator; viewActionToken = this.iEventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Subscribe( (viewEventArgs) => { EventHandler(viewEventArgs); } ); }
/// <summary> /// Returns <see langword="true"/> if there is a subscriber matching <see cref="SubscriptionToken"/>. /// </summary> /// <param name="token">The <see cref="SubscriptionToken"/> returned by <see cref="EventBase"/> while subscribing to the event.</param> /// <returns><see langword="true"/> if there is a <see cref="SubscriptionToken"/> that matches; otherwise <see langword="false"/>.</returns> public virtual bool Contains(SubscriptionToken token) { lock (Subscriptions) { IEventSubscription subscription = Subscriptions.FirstOrDefault(evt => evt.SubscriptionToken == token); return subscription != null; } }
public ItemListFilterViewModel(IEventAggregator iEventAggregator, int _numControls) { this.iEventAggregator = iEventAggregator; buttonActions = new string[] { "FILTER_RESET", "FILTER_TYPE", "FILTER_FILES" }; Filter = ""; FilterType = "Contains"; numControls = _numControls; MoveRightCommand = new DelegateCommand(MoveRight, CanMoveRight); MoveLeftCommand = new DelegateCommand(MoveLeft, CanMoveLeft); RemoveLastCharFromFilterCommand = new DelegateCommand(RemoveLastCharFromFilter, CanRemoveLastCharFromFilter); ResetFiltersCommand = new DelegateCommand(ResetFilters, CanResetFilters); EventMap = new Dictionary<string, Action>() { {"FILTER_MOVE_LEFT", () => { if (MoveLeftCommand.CanExecute()) { MoveLeftCommand.Execute(); } } }, {"FILTER_MOVE_RIGHT", () => { if (MoveRightCommand.CanExecute()) { MoveRightCommand.Execute(); } } }, {"CHAR_BACK", () => { if (RemoveLastCharFromFilterCommand.CanExecute()) { RemoveLastCharFromFilterCommand.Execute(); } } } }; EventMapParam = new Dictionary<string, Action<string>>() { {"CHAR_SELECT", AppendToFilter}, {"VOS_OPTION", (_filterType) => { FilterType = _filterType; } } }; filterViewToken = this.iEventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Subscribe( (viewEventArgs) => { EventHandler(viewEventArgs); } ); }
public ItemsViewViewModel(IItemsView view, IEventAggregator eventAgg, IUnityContainer cont) : base(view) { _container = cont; _eventMgr = eventAgg; _subToken = _eventMgr.GetEvent<DocumentLoadingEvent>().Subscribe(OnLoadingDocument); _subTokenClosing = _eventMgr.GetEvent<CloseDocumentEvent>().Subscribe(OnClosingDocument); }
public MotionActivatedSimpleAnimation(IEventAggregator events, SoundService sound,TimerService timer):base(events,sound, timer) { _motionEventToken = _events.GetEvent<Events.PressenceEvent>().Subscribe((args) => { this.OnPresenceEvent(args); }, ThreadOption.UIThread); }
public void Equals_Should_Return_False_When_Comparing_Different_Instances() { SubscriptionToken token = new SubscriptionToken(); object tokenObject = new SubscriptionToken(); Assert.False(token.Equals(tokenObject)); }
public void EqualsShouldReturnFalseWhenComparingDifferentInstances() { var aToken = new SubscriptionToken(); object anotherToken = new SubscriptionToken(); Assert.That(aToken.Equals(anotherToken), Is.False); }
public AllPurchaseFamiliesViewModel(IDbConversation dbConversation, IEventAggregator eventAggregator) : base(dbConversation, eventAggregator) { base.DisplayName = Strings.ViewModel_AllPurchaseFamiliesViewModel_DisplayName; CreateAllPurchaseFamilies(); _purchaseFamilyInsertedToken = EventAggregator.GetEvent<PurchaseFamilyChangedEvent>().Subscribe(OnPurchaseFamilyChanged); }
public void HashCodeIsTheSameForSameToken() { SubscriptionToken token = new SubscriptionToken(); int hashCode = token.GetHashCode(); Assert.AreNotEqual(0, hashCode); Assert.AreEqual(hashCode, token.GetHashCode()); }
public AllUnitTypesViewModel(IDbConversation dbConversation, IEventAggregator eventAggregator) : base(dbConversation, eventAggregator) { base.DisplayName = Strings.ViewModel_AllUnitTypesViewModel_DisplayName; CreateAllUnitTypes(); _unitTypeInsertedToken = EventAggregator.GetEvent<UnitTypeChangededEvent>().Subscribe(OnUnitTypeChanged); }
public void EqualsShouldReturnTrueWhenComparingSameObjectInstances() { SubscriptionToken token = new SubscriptionToken(); object tokenObject = token; Assert.IsTrue(token.Equals(tokenObject)); }
public SensorReadingPageViewModel(IEventAggregator events) { _events = events; _sensorEventToken = _events.GetEvent<Events.RangeSensorEvent>().Subscribe((args) => { this.OnSensorChanged(args); }, ThreadOption.UIThread); }
public AllStocksViewModel(IDbConversation dbConversation, IEventAggregator eventAggregator) : base(dbConversation, eventAggregator) { base.DisplayName = Strings.ViewModel_AllStocksViewModel_DisplayName; CreateAllStocks(); _stockInsertedToken = EventAggregator.GetEvent<StockChangedEvent>().Subscribe(OnStockChanged); }
public void EqualsShouldReturnFalseWhenComparingDifferentObjectInstances() { SubscriptionToken token = new SubscriptionToken(); object tokenObject = new SubscriptionToken(); Assert.IsFalse(token.Equals(tokenObject)); }
public AllProductionItemsViewModel(IDbConversation dbConversation, IEventAggregator eventAggregator) : base(dbConversation, eventAggregator) { base.DisplayName = Strings.ViewModel_AllProductionItemsViewModel_DisplayName; CreateAllProductionItems(); _productionItemInsertedToken = EventAggregator.GetEvent<ProductionItemChangedEvent>().Subscribe(OnProductionItemChanged); }
public Task<bool> Start() { bool returnValue = false; try { GpioController gpio = GpioController.GetDefault(); if (gpio != null) { this.GreenPin = gpio.OpenPin(this.GpioPinConfiguration.GreenLedPinNumber); this.GreenPin.SetDriveMode(GpioPinDriveMode.Output); this.RedPin = gpio.OpenPin(this.GpioPinConfiguration.RedLedPinNumber); this.RedPin.SetDriveMode(GpioPinDriveMode.Output); this.BluePin = gpio.OpenPin(this.GpioPinConfiguration.BluePinNumber); this.BluePin.SetDriveMode(GpioPinDriveMode.Output); this.YellowPin = gpio.OpenPin(this.GpioPinConfiguration.YellowPinNumber); this.YellowPin.SetDriveMode(GpioPinDriveMode.Output); // *** // *** Initialize all to off // *** this.GreenPin.Write(GpioPinValue.High); this.RedPin.Write(GpioPinValue.High); this.BluePin.Write(GpioPinValue.High); this.YellowPin.Write(GpioPinValue.High); this._temperatureAlertChangedEventToken = this.EventAggregator.GetEvent<Events.TemperatureChangedEvent>().Subscribe((args) => { this.UpdateLeds(args.SensorReading); }, ThreadOption.BackgroundThread); this.EventAggregator.GetEvent<Events.DeviceCommandEvent>().Subscribe(async (args) => { // *** // *** This service will handle the LED test command // *** if (!_runningLedTest && args.DeviceCommand == DeviceCommand.RunLedTest) { await this.RunLedTest(); } }); returnValue = true; } } catch (Exception ex) { this.EventAggregator.GetEvent<Events.DebugEvent>().Publish(new DebugEventArgs(ex)); returnValue = false; } return Task<bool>.FromResult(returnValue); }
public MainPageTeamViewModel() { //if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) // Value = "Design time value"; _token1 = EventAggregator.Istance<SearchEvent>().Subscribe((query) => Search(query)); _token2 = EventAggregator.Istance<CloseTeamItemEvent>().Subscribe((item) => PresentationItemCollection.Remove(item)); PresentationItemCollection.Add(new ToolBarViewModel()); }
/// <summary> /// Removes the subscriber matching the <seealso cref="SubscriptionToken"/>. /// </summary> /// <param name="token">The <see cref="SubscriptionToken"/> returned by <see cref="EventBase"/> while subscribing to the event.</param> public virtual void Unsubscribe(SubscriptionToken token) { lock (Subscriptions) { IEventSubscription subscription = Subscriptions.FirstOrDefault(evt => evt.SubscriptionToken == token); if (subscription != null) { Subscriptions.Remove(subscription); } } }
public FaceComponentViewModel(IEventAggregator aggregator) { _events = aggregator; _actionFacialCodingEventToken = _events.GetEvent<Events.ActionFacialCodingEvent>().Subscribe((args) => { this.OnActionFacialCodingCommand(args); }, ThreadOption.UIThread); }
/// <summary> /// 移除符合<seealso cref="T:UniCloud.Domain.Events.SubscriptionToken" />的订阅。 /// </summary> /// <param name="token"> /// 订阅事件时,由<see cref="T:UniCloud.Domain.Events.EventBase" />返回的 /// <see cref="T:UniCloud.Domain.Events.SubscriptionToken" />。 /// </param> public virtual void Unsubscribe(SubscriptionToken token) { lock (Subscriptions) { var local0 = Subscriptions.FirstOrDefault(evt => evt.SubscriptionToken == token); if (local0 == null) return; Subscriptions.Remove(local0); } }
public void WhenSubscriptionTokenIsDisposed_ThenEventUnSubscribes() { bool unsubscribed = false; SubscriptionToken token = new SubscriptionToken(t => { unsubscribed = true; }); token.Dispose(); Assert.IsTrue(unsubscribed); }
public TextEditorModuleEventAggregation(IEventAggregator eventAggregator, IDockController dockController) { _eventAggregator = eventAggregator; _dockController = dockController; var createNewFile = _eventAggregator.GetEvent <MenuSelectEvent>(); if (_subscriptionToken != null) { createNewFile.Unsubscribe(_subscriptionToken); } _subscriptionToken = createNewFile.Subscribe(MenuSelecteEventHandler, ThreadOption.UIThread, false); }
/// <summary> /// Initializes a new instance of the <see cref="EntityChangeMonitor{T}"/> class. /// </summary> /// <param name="eventAggregator">The event aggregator.</param> public EntityChangeMonitor(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; _subscriptionToken = eventAggregator.GetEvent <EntityUpdated>().Subscribe(entity => { if (entity is T) { OnChanged(entity); } }); _uniqueId = Guid.NewGuid().ToString(); InitializationComplete(); }
/// <summary> /// setup event listeners for a given featurelayer (with featurelayer name) /// </summary> /// <param name="activeMapView"></param> /// <param name="featureLayerName"></param> private void SetUpRowEventListener(MapView activeMapView, string featureLayerName) { // Find our polygon feature layer _workedOnPolygonLayer = activeMapView.Map.GetLayersAsFlattenedList().FirstOrDefault((fl) => fl.Name == featureLayerName) as FeatureLayer; UpdateStatusText((_workedOnPolygonLayer == null) ? $@"{featureLayerName} NOT found" : $@"Listening to {featureLayerName} changes"); // setup event listening ... QueuedTask.Run(() => { _onRowChangedEvent = RowChangedEvent.Subscribe(OnRowChangedEvent, _workedOnPolygonLayer.GetTable()); _onRowCreatedEvent = RowCreatedEvent.Subscribe(OnRowCreatedEvent, _workedOnPolygonLayer.GetTable()); }); }
public void Initialize(PokerClientDataManagerInfo dataManagerInfo) { Check.ArgumentNotNull(() => dataManagerInfo); logger = dataManagerInfo.Logger; site = dataManagerInfo.Site; pokerClientTableClosedSubsciption = eventAggregator.GetEvent <PokerClientTableClosedEvent>().Subscribe(RemoveOpenedTable, ThreadOption.BackgroundThread); var settingsService = ServiceLocator.Current.GetInstance <ISettingsService>(); var settings = settingsService.GetSettings(); isLoggingEnabled = settings.GeneralSettings.IsAdvancedLoggingEnabled; }
protected override void Subscribe() { // Prevents subscribing twice this.Unsubscribe(); // Commands ApplicationCommands.SemanticJumpCommand.RegisterCommand(this.SemanticJumpCommand); ApplicationCommands.AddTracksToPlaylistCommand.RegisterCommand(this.AddTracksToPlaylistCommand); ApplicationCommands.AddAlbumsToPlaylistCommand.RegisterCommand(this.AddAlbumsToPlaylistCommand); ApplicationCommands.AddArtistsToPlaylistCommand.RegisterCommand(this.AddArtistsToPlaylistCommand); // Events this.shellMouseUpToken = this.eventAggregator.GetEvent <ShellMouseUp>().Subscribe((_) => this.IsArtistsZoomVisible = false); }
public IDisposable ManageConsumer(RabbitConsumer consumer) { var tokenId = Guid.NewGuid(); if (!_receivers.TryAdd(tokenId, consumer)) { throw new Exception("Could not add subscriber"); } var token = new SubscriptionToken(this, consumer.RabbitToken, tokenId, consumer.Queue.QueueName, consumer.Queue.RemoteTopic); _tokens.Add(token); return(token); }
private void ActivateModification() { DeActivateModification(); UpdateStatusText($@"Activate Modification - MapView active: {(MapView.Active != null)}"); var activeMapView = MapView.Active; if (activeMapView == null) { // the map view is not active yet _activeMapViewChangedEvent = ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChangedEvent); return; } SetUpRowEventListener(activeMapView, PolygonLayerName, PointLayerName); }
public void SignalSubscrerThrowExceptionDefaultSubscriptionErrorHandlerRethrow() { try { using (SubscriptionToken sub = this.signals.Subscribe <TestEvent>(transaction1 => throw new System.Exception("TestingException"))) { this.signals.Publish(new TestEvent()); } } catch (System.Exception ex) { Assert.True(ex.Message == "TestingException"); } }
public WpfInteractionController(IEventAggregator eventAgg, ExcelInteraction excelOperation, ILogger logger) { this.eventAgg = eventAgg; this.excelOperation = excelOperation; this.logger = logger; tokenMeetingData = eventAgg.GetEvent <PubSubEvent <ExcelMeetingDataRequest> >() .Subscribe(WriteMeetingData); tokenSheetName = eventAgg.GetEvent <PubSubEvent <ExcelWorksheetNamesRequest> >() .Subscribe(GetWorksheetsName); }
/// <summary> /// Initialize the block observer with the wallet manager and the cross chain monitor. /// </summary> /// <param name="walletSyncManager">The wallet sync manager to pass new incoming blocks to.</param> /// <param name="depositExtractor">The component used to extract the deposits from the blocks appearing on chain.</param> /// <param name="withdrawalExtractor">The component used to extract withdrawals from blocks.</param> /// <param name="withdrawalReceiver">The component that receives the withdrawals extracted from blocks.</param> /// <param name="federationGatewayClient">Client for federation gateway api.</param> public BlockObserver(IFederationWalletSyncManager walletSyncManager, IInputConsolidator inputConsolidator, ISignals signals) { Guard.NotNull(walletSyncManager, nameof(walletSyncManager)); this.walletSyncManager = walletSyncManager; this.inputConsolidator = inputConsolidator; this.signals = signals; this.blockConnectedSubscription = this.signals.Subscribe <BlockConnected>(ev => this.OnBlockReceived(ev.ConnectedBlock)); // TODO: Dispose ?? }
public NexusViewModel(IEventAggregator iEventAggregator) { this.iEventAggregator = iEventAggregator; SubscriptionToken subscriptionToken = this .iEventAggregator .GetEvent <PubSubEvent <Character> >() .Subscribe((details) => { this.SelectedCharacter = details; }); iEventAggregator.GetEvent <PubSubEvent <ArrWeapon> >().Subscribe((details) => { this.ArrWeapon = details; }); }
public void Initialize() { this.pollsRepository.Initialize(); this.polls = this.pollsRepository.GetAllPolls(); this.blockConnectedSubscription = this.signals.Subscribe <BlockConnected>(this.OnBlockConnected); this.blockDisconnectedSubscription = this.signals.Subscribe <BlockDisconnected>(this.OnBlockDisconnected); this.nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name, 1200); this.isInitialized = true; this.logger.LogDebug("VotingManager initialized."); }
public void CanInitEventSubscription() { var actionDelegateReference = new MockDelegateReference((Action <object>) delegate { }); var filterDelegateReference = new MockDelegateReference((Predicate <object>) delegate { return(true); }); var eventSubscription = new EventSubscription <object>(actionDelegateReference, filterDelegateReference); var subscriptionToken = new SubscriptionToken(t => { }); eventSubscription.SubscriptionToken = subscriptionToken; Assert.Same(actionDelegateReference.Target, eventSubscription.Action); Assert.Same(filterDelegateReference.Target, eventSubscription.Filter); Assert.Same(subscriptionToken, eventSubscription.SubscriptionToken); }
private void SubscribeToEvents() { m_ArrowGraphDataUpdatedSubscriptionToken = m_EventService.GetEvent <PubSubEvent <ArrowGraphDataUpdatedPayload> >() .Subscribe(payload => { ArrowGraphAreaCtrl.ClearLayout(); ArrowGraphData arrowGraphData = ViewModel.ArrowGraphData; if (arrowGraphData != null) { ArrowGraphAreaCtrl.GenerateGraph(arrowGraphData); ResetGraph(); } }, ThreadOption.UIThread); }
public MainPage() { this.InitializeComponent(); var application = new UsingEventAggregator.App(new UwpConfiguration()); SubscriptionToken token = application .PlatformConfiguration .Container .Resolve <IEventAggregator>() .GetEvent <NativeEvent>() .Subscribe(OnNativeEvent); LoadApplication(application); }
public MasterDetailViewModelBase( INavigationService navigationService, IPageNavigator pageNavigator, IUserDialogs userDialogs, IEventAggregator eventAggregator) : base(pageNavigator, null, userDialogs, null, eventAggregator) { _navigationService = navigationService; _hamburgerTappedEventSubscriptionToken = EventAggregator.GetEvent <HamburgerTappedEvent>().Subscribe(() => OnPresentToggle(true), ThreadOption.UIThread); _hamburgerNavigateEventSubscriptionToken = EventAggregator.GetEvent <HamburgerNavigateEvent>().Subscribe(async(model) => await OnHamburgerNavigate(model), ThreadOption.UIThread); _hamburgerNavigateModalEventSubscriptionToken = EventAggregator.GetEvent <HamburgerNavigateModalEvent>().Subscribe(async(model) => await OnHamburgerNavigateModal(model), ThreadOption.UIThread); _hamburgerNavigateBackToRootEventSubscriptionToken = EventAggregator.GetEvent <HamburgerNavigateBackToRootEvent>().Subscribe(async(defaultPage) => await OnHamburgerNavigateBackToRoot(defaultPage), ThreadOption.UIThread); _hamburgerSetSwipeGestureEventSubscriptionToken = EventAggregator.GetEvent <HamburgerSetSwipeGestureEvent>().Subscribe((val) => IsGestureEnabled = val, ThreadOption.UIThread); }
// Called when the visibility of the DockPane changes. protected override void OnShow(bool isVisible) { if (isVisible && _eventToken == null) //Subscribe to event when dockpane is visible { _eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent); _toceventToken = TOCSelectionChangedEvent.Subscribe(OnTOCSelectionChangeEvent); } if (!isVisible && _eventToken != null) //Unsubscribe as the dockpane closes. { MapSelectionChangedEvent.Unsubscribe(_eventToken); TOCSelectionChangedEvent.Unsubscribe(_toceventToken); _eventToken = null; } }
public void Awake() { if (FoodPrefab == null) { throw new ArgumentException("FoodPrefab"); } if (FoodColors == null) { throw new ArgumentException("FoodColors"); } _eventAggregator = DependencyResolver.Current.GetService <IEventAggregator>(); _foodEventSubscriptionToken = _eventAggregator.Subscribe(new Action <FoodEvent>(OnFoodEvent)); }
/// <summary> /// ドッキングウインドウの表示/非表示でイベントを登録/解除 /// </summary> protected override void OnShow(bool isVisible) { if (isVisible && _mapSelectionChangedEvent == null) { // イベントの登録 _mapSelectionChangedEvent = MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged); } if (!isVisible && _mapSelectionChangedEvent != null) { // イベントの解除 MapSelectionChangedEvent.Unsubscribe(_mapSelectionChangedEvent); _mapSelectionChangedEvent = null; } }
private void SubscribeEvents() { SubscriptionToken projectSavedEventToken = _eventAggregator.GetEvent <ProjectSavedEvent>().Subscribe((args) => { if (_browserPane.Url.Scheme.Equals(ProjectStartPageScheme.SCHEMENAME, StringComparison.CurrentCultureIgnoreCase)) { _browserPane.Navigate(ProjectStartPageScheme.PROJECT_STARTPAGE_URI); } }); this.FormClosed += (sender, e) => { _eventAggregator.GetEvent <ProjectSavedEvent>().Unsubscribe(projectSavedEventToken); }; }
public void SignalBlockDisconnectedToBlockSignaler() { Block block = KnownNetworks.StratisMain.CreateBlock(); ChainedHeader header = ChainedHeadersHelper.CreateGenesisChainedHeader(); var chainedHeaderBlock = new ChainedHeaderBlock(block, header); bool signaled = false; using (SubscriptionToken sub = this.signals.Subscribe <BlockDisconnected>(headerBlock => signaled = true)) { this.signals.Publish(new BlockDisconnected(chainedHeaderBlock)); } Assert.True(signaled); }
public override Task OpenAsync() { QueuedTask.Run(() => { _okRelay = new RelayCommand(() => ConstructPoints(IsNumberOfPoints, Value), CanCreatePoints); NotifyPropertyChanged("OKCommand"); if (_mscToken == null) { _mscToken = MapSelectionChangedEvent.Subscribe(OnSelectionChangedAsync); } SetState(MapView.Active.Map.GetSelection()); }); return(Task.FromResult(true)); }
/// <summary> /// Initializes a new instance of the <see cref="Subscription"/> class. /// </summary> /// <param name="messageKey">The message key.</param> /// <param name="action">The delegate action to create a WeakAction from.</param> /// <param name="actionType">The parameter type of the action.</param> public Subscription(string messageKey, Delegate action, Type actionType) { if (action == null) { throw new ArgumentNullException("action"); } if (actionType == null) { throw new ArgumentNullException("actionType"); } _token = new SubscriptionToken(); _messageKey = messageKey; _weakAction = new WeakAction(action.Target, action.Method, actionType); }
/// <summary> /// Initializes a new instance of the <see cref="Subscription"/> class. /// </summary> /// <param name="action">The delegate action to create a WeakAction from.</param> /// <param name="actionType">The parameter type of the action.</param> public Subscription(Delegate action, Type actionType) { if (action == null) { throw new ArgumentNullException("action"); } if (actionType == null) { throw new ArgumentNullException("actionType"); } _token = new SubscriptionToken(); _messageKey = actionType.AssemblyQualifiedName; _weakAction = new WeakAction(action.Target, action.Method, actionType); }
/// <summary> /// Subscribe to the editing events. /// </summary> /// <param name="currentMap">The map object from which to subscribe or to unsubscribe from the edit events.</param> internal static void AttachEditEvents(Map currentMap) { // if there is an existing subscription token for the edit events if (_editEventsToken != null) { // then unsubscribe EditEvent.Unsubscribe(_editEventsToken); _editEventsToken = null; } if (GenerateComment) { // get the list of feature layers and subscribe to generate an edit comment _editEventsToken = EditEvent.Subscribe(currentMap.Layers.OfType <FeatureLayer>(), TrackEditEvents); } }
} // SimpleSubscriberFormFormClosing() #endregion // UI HANDLING //// --------------------------------------------------------------------- #region PRIVATE METHODS /// <summary> /// Does the subscription. /// </summary> /// <param name="subscribe">if set to <c>true</c> subscribes.</param> private void DoSubscribe(bool subscribe) { var evt = ServiceLocator.EventAggregator.GetEvent <SimpleMessageEvent>(); if (subscribe) { this.tokenSubscriber = evt.Subscribe(this.OnMessageForSubscriber, ThreadOption.UIThread); } else { if (this.tokenSubscriber != null) { evt.Unsubscribe(this.tokenSubscriber); } // if } // if } // DoSubscribe()
public ShellBackgroundService(IEventAggregator eventAggregator, ILoggerFactory loggeFactory) { this.eventAggregator = eventAggregator; this.logger = loggeFactory.CreateLogger <ShellBackgroundService>(); this.logger.LogInformation("created instance ShellBackgroundService"); this.connectedToken = this.eventAggregator.GetEvent <ConnectToSignalRClientEvent>() .Subscribe(this.ConnectToSignalRServer, ThreadOption.UIThread); this.disconnectedToken = this.eventAggregator.GetEvent <DisconnectSignalRServerRequestEvent>().Subscribe(this.Disconnect, ThreadOption.UIThread); this.sendMessageToken = this.eventAggregator.GetEvent <SendMessageSignalRServerRequestEvent>() .Subscribe(this.SendNotification, ThreadOption.UIThread); }
public SettingsViewModel() { eventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>(); DeleteAllNotesCommand = ReactiveCommand.Create(() => DeleteNotes(null)); DeleteNotesCommand = ReactiveCommand.Create(() => DeleteNotes(OlderThanDate)); RestoreDefaultsCommand = ReactiveCommand.Create(() => RestoreDefaults()); olderThanDate = DateTime.Today; profiles = new ReactiveList <AutoNoteProfile>(); RefreshSettings(); refreshSettingsSubscriptionToken = eventAggregator.GetEvent <RefreshSettingsEvent>().Subscribe(x => RefreshSettings()); }
void SubscriptionWatchedIfNotWatch(Interfaces.IVideoContent video) { UnsubscriptionWatched(); if (video != null) { var watched = Database.VideoPlayedHistoryDb.IsVideoPlayed(video.Id); IsWatched = watched; if (!watched) { var eventAggregator = App.Current.Container.Resolve <IEventAggregator>(); var palyedEvent = eventAggregator.GetEvent <UseCase.Playlist.Events.VideoPlayedEvent>(); _watchedDisposable = palyedEvent.Subscribe(Watched, ThreadOption.UIThread); } } }
public void Initialize(IFederationHistory federationHistory, IIdleFederationMembersKicker idleFederationMembersKicker = null) { this.federationHistory = federationHistory; this.idleFederationMembersKicker = idleFederationMembersKicker; this.PollsRepository.Initialize(); this.PollsRepository.WithTransaction(transaction => this.polls = new PollsCollection(this.PollsRepository.GetAllPolls(transaction))); this.blockConnectedSubscription = this.signals.Subscribe <BlockConnected>(this.OnBlockConnected); this.blockDisconnectedSubscription = this.signals.Subscribe <BlockDisconnected>(this.OnBlockDisconnected); this.nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name, 1200); this.isInitialized = true; this.logger.LogDebug("VotingManager initialized."); }