Exemplo n.º 1
0
 public AccountsPopupController(IEventAggregator eventAggregator)
 {
     eventAggregator.GetEvent<CreateAccountRequestEvent>().Subscribe(
         OnCreateAccountRequest, ThreadOption.UIThread, true);
     eventAggregator.GetEvent<EditAccountRequestEvent>().Subscribe(
         OnEditAccountRequest, ThreadOption.UIThread, true);
 }
        public CompareSentenceEditorView(
            SentenceEditorViewModel sentenceEditorViewModel,
            IEventAggregator eventAggregator,
            IAppConfig appConfig)
            : this(eventAggregator, appConfig)
        {
            if (sentenceEditorViewModel == null)
            {
                throw new ArgumentNullException("sentenceEditorViewModel");
            }

            Loaded += SentenceEditorView_Loaded;
            viewModel = sentenceEditorViewModel;
            viewModel.ViewId = viewUniqueId;
            DataContext = viewModel;

            GgArea.ShowAllEdgesArrows();
            GgArea.ShowAllEdgesLabels();
            GgZoomCtrl.MouseLeftButtonUp += GgZoomCtrlMouseLeftButtonUp;
            GgArea.GenerateGraphFinished += GgAreaGenerateGraphFinished;
            GgArea.EdgeLabelFactory = new DefaultEdgelabelFactory();

            eventAggregator.GetEvent<GenerateGraphEvent>().Subscribe(OnGenerateGraph);
            eventAggregator.GetEvent<ZoomOnWordVertexEvent>().Subscribe(OnZoomOnWordVertex);
            eventAggregator.GetEvent<ZoomToFillEvent>().Subscribe(ZoomToFill);
        }
Exemplo n.º 3
0
        //fileGuid == null && IsActive == true for Global SaveCommand, just save current actived tab
        //fileGuid != null && fileGuid == _fileGuid for Global SaveAllCommand, save all tabs
        private void Save(string fileGuid)
        {
            var isNullOrEmpty = string.IsNullOrEmpty(fileGuid);

            if (isNullOrEmpty && IsActive || !isNullOrEmpty && fileGuid == _fileGuid)
            {
                Reset();

                if (!_textEditor.CheckAccess())
                {
                    _textEditor.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        _eventAggregator?.GetEvent <SaveTextEvent>().Publish(new TabInfo {
                            Guid = _fileGuid, FileContent = _textEditor.Text
                        });
                    }));
                }
                else
                {
                    _eventAggregator?.GetEvent <SaveTextEvent>().Publish(new TabInfo {
                        Guid = _fileGuid, FileContent = _textEditor.Text
                    });
                }
            }
        }
		public PersonDirectoryViewModel(IPersonService personService, IDispatcher dispatcher, IEventAggregator aggregator, IDialogService dialogService) 
			: base(personService, dispatcher, aggregator, dialogService)
		{
			personDirectory = new RangeEnabledObservableCollection<Person>();
			aggregator.GetEvent<PersonDirectoryUpdatedEvent>().Subscribe(OnPersonDirectoryUpdated, ThreadOption.BackgroundThread);
			aggregator.GetEvent<PersonDeletedEvent>().Subscribe(OnPersonDeleted, ThreadOption.UIThread);
		}
Exemplo n.º 5
0
        public CellViewModel(Cell cell, IEventAggregator events)
        {
            _cell = cell;

            GotFocus = new DelegateCommand<string>( CellFocused);

            _selectionEvent = events.GetEvent<CellSelectedEvent>();
            _selectionEvent.Subscribe( c =>
                                  {
                                      Selected = _cell == c;
                                  }); // Note: Could be memory leak due to event link

            events.GetEvent<HintProvidedEvent>().Subscribe( hint =>
                {
                    if( hint.Cells.Contains( _cell ) )
                    {
                        if (CellHinted != null) CellHinted(this, EventArgs.Empty);
                    }
                });

            var numberRequestEvent = events.GetEvent<NumberRequestEvent>();
            numberRequestEvent.Subscribe(ToggleNumber);

            var modeRequestEvent = events.GetEvent<ModeRequestEvent>();
            modeRequestEvent.Subscribe(ChangeMode);
        }
Exemplo n.º 6
0
		public LinkButtonSwitch(IEventAggregator eventAggregator) {
			this.eventAggregator = eventAggregator;
			var RefreshSubscription = eventAggregator.GetEvent<RefreshSelection>().Subscribe(RefreshSelection, false);
			disposables.Add(Disposable.Create(() => {
				eventAggregator.GetEvent<RefreshSelection>().Unsubscribe(RefreshSubscription);
			}));
		}
        public BadgerControlStatusView()
        {
            InitializeComponent();
            joystickQueryThread = null;
            CompositionTarget.Rendering += OnRender;

            _eventAggregator = ApplicationService.Instance.EventAggregator;
            _eventAggregator.GetEvent<DeliverJoystickEvent>().Subscribe((joystick) =>
            {
                // send a confirmation back when we receive a joystick
                joystickQueryThread = joystick;
                _eventAggregator.GetEvent<ConfirmJoystickEvent>().Publish(JOYSTICK_ID);
            });
            _eventAggregator.GetEvent<ConnectionDetailsEvent>().Subscribe((connection) =>
            {
                UpdateConnection(connection);
            });

            // create a ConnectionDetails to keep around. its fields will be used to help organize which
            // components have which connection statuses
            ConnectionDetails connectionDetails = new ConnectionDetails();
            connectionDetails.ai = ConnectionOption.DISCONNECTED;
            connectionDetails.remote = ConnectionOption.DISCONNECTED;
            connectionDetails.direct = ConnectionOption.DISCONNECTED;
            UpdateConnection(connectionDetails);
        }
        public PackageDatabaseTreeViewModel(CompositionContainer container, IEventAggregator eventAggregator, IPackageRepository repository)
        {
            this._eventAggregator = eventAggregator;
            this._rootNodes = new ObservableCollection<PackageTreeNodeViewModel>();
            this._container = container;
            this._contextMenuStyleSelector = new ContextMenuItemStyleSelector();
            this._repository = repository;

            this._eventAggregator.GetEvent<CompositePresentationEvent<PackageDatabaseOpenedEvent>>()
                .Subscribe(PackageDatabaseOpened, ThreadOption.UIThread, true);

            eventAggregator.GetEvent<CompositePresentationEvent<PackageCreatedEvent>>().Subscribe(
             x =>
             {
                 _rootNodes.First().AddChild(new PackageNodeViewModel(x.NewPackage, this, container, _repository));
             }, ThreadOption.UIThread, true);

            eventAggregator.GetEvent<CompositePresentationEvent<AssetCreatedEvent>>().Subscribe(
             x =>
             {
                 var packageNode = _rootNodes.First().Children.Where(node => ((Package)node.Model).Id == x.NewAsset.PackageId).Single();
                 packageNode.AddChild(new AssetNodeViewModel(x.NewAsset, this, container));
             }, ThreadOption.UIThread, true);

            eventAggregator.GetEvent<CompositePresentationEvent<PackageDeletedEvent>>().Subscribe(
             x =>
             {
                 var packageNode = _rootNodes.First().Children.Where(node => ((Package)node.Model).Id == x.PackageId).Single();
                 _rootNodes.First().RemoveChild(packageNode);
             }, ThreadOption.UIThread, true);
        }
        /// <summary>
        /// Creates an instance of CharacterAttributeViewModel.
        /// </summary>
        /// <param name="eventAggregator">The event aggregator. May be null when under test.</param>
        public CharacterAttributeViewModel(IEventAggregator eventAggregator)
        {
            eventAggregator?.GetEvent <SaveEvent>().Subscribe(args =>
            {
                var saveData = new XElement
                               (
                    CharacterAttributesRootNodeName,
                    new[]
                {
                    new KeyValuePair <string, int>(StrengthAttributeName, StrengthValue),
                    new KeyValuePair <string, int>(DexterityAttributeName, DexterityValue),
                    new KeyValuePair <string, int>(ConstitutionAttributeName, ConstitutionValue),
                    new KeyValuePair <string, int>(IntelligenceAttributeName, IntelligenceValue),
                    new KeyValuePair <string, int>(WisdomAttributeName, WisdomValue)
                }.Select(attribute => new XAttribute(attribute.Key, attribute.Value)).ToArray()
                               );

                args.Callback(saveData);
            });

            eventAggregator?.GetEvent <LoadEvent>().Subscribe(args =>
            {
                // TODO: what if the node is missing?
                // TODO: what if false is returned?
                Load(this, args.RootNode.Element(CharacterAttributesRootNodeName));
            });
        }
Exemplo n.º 10
0
 public HistoryViewModel(PetRepository repository, IEventAggregator events)
 {
     _repository = repository;
     _history = repository.History;
     events.GetEvent<NewPetEvent>().Subscribe(pet => PetsChanged());
     events.GetEvent<SoldPetEvent>().Subscribe(pet => PetsChanged());
 }
Exemplo n.º 11
0
        public ShellViewModel(IUserService userService, INavigationService navigationService, IEventAggregator eventAggregator)
        {
            _userService = userService;
            _navigationService = navigationService;
            _eventAggregator = eventAggregator;

            eventAggregator.GetEvent<LoginEvent>().Subscribe(
                (u) =>
                    {
                        CurrentUser = _userService.GetAuthenticatedUser();
                        NavigationPaneVisibility = Visibility.Visible;
                    },true);

            eventAggregator.GetEvent<LogoutEvent>().Subscribe(
                (u) =>
                {
                    CurrentUser = _userService.GetAuthenticatedUser();
                    NavigationPaneVisibility = Visibility.Collapsed;
                },true);

            SingleInstance.SingleInstanceActivated += new EventHandler<SingleInstanceEventArgs>(SingleInstance_SingleInstanceActivated);

            try
            {
                Version = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
            }
            catch (Exception ex)
            {
                Version = "Debug build";
            }
        }
        public BadgerControlDrive()
        {
            isEnabled = false;
            hasControl = false;
            isReady = false;
            triedJoystick = false;
            joystickMessageGiven = false;
            componentOneActive = componentTwoActive = componentThreeActive = false;
            joystickConfirmedFromVisualView = false;
            joystickConfirmedFromStatusView = false;

            _eventAggregator = ApplicationService.Instance.EventAggregator;

            // create an empty ConnectionDetails struct and keep it around
            connectionDetails = new ConnectionDetails();
            connectionDetails.ai = ConnectionOption.DISCONNECTED;
            connectionDetails.remote = ConnectionOption.DISCONNECTED;
            connectionDetails.direct = ConnectionOption.DISCONNECTED;

            // record which classes have confirmed the joystick. write to the console only when both have confirmed
            _eventAggregator.GetEvent<ConfirmJoystickEvent>().Subscribe((confirmationID) =>
            {
                if (confirmationID == BadgerControlStatusView.JOYSTICK_ID)
                    joystickConfirmedFromStatusView = true;
                else if (confirmationID == BadgerControlVisualView.JOYSTICK_ID)
                    joystickConfirmedFromVisualView = true;

                if (JoyStickConfirmed && !joystickMessageGiven)
                {
                    _eventAggregator.GetEvent<LoggerEvent>().Publish("Joystick connected.");
                    joystickMessageGiven = true; // jank hack to fix the duplicate event publishing due to multithreading
                }
            });
        }
Exemplo n.º 13
0
        public MainViewModel(IEventAggregator eventAggregator, IWindowDialogService dialogService, IConfirmDialogService confirmService, IRegionManager regionManager)
        {
            NavigationDetails = new Dictionary<string, NavigationDetails>
                                    {
                                        {
                                            "Event Query", new NavigationDetails
                                                                  {
                                                                      SubNavigationPath = "/EventQuerySubView",
                                                                      MainPath = "/EventQueryMainView"
                                                                  }
                                            },
                                            {
                                            "Data Maintenance", new NavigationDetails
                                                                  {
                                                                      SubNavigationPath = "/DataMaintenanceSubView",
                                                                      MainPath = "/DataMaintenanceMainView"
                                                                  }
                                            }
                                    };

            ShowView = new DelegateCommand<string>(OnShowExecuted);
            ExitCommand = new DelegateCommand(OnExit);

            _regionManager = regionManager;
            _eventAggregator = eventAggregator;
            _dialogService = dialogService;
            _confirmService = confirmService;

            // Subscribe to user notification messages that we need to display
            _eventAggregator.GetEvent<UserNotificationEvent>().Subscribe(DisplayUserMessage);
            _eventAggregator.GetEvent<UserConfirmationEvent>().Subscribe(DisplayUserConfirmation);
            _eventAggregator.GetEvent<BusyStartedEvent>().Subscribe(BusyStarted);
            _eventAggregator.GetEvent<BusyFinishedEvent>().Subscribe(BusyFinished);
        }
Exemplo n.º 14
0
 public BasketViewModel(
     ILookAfterPets petRepository, 
     ILookAfterAccessories accessoryRepository,
     IHandleMessages messenger,
     IEventAggregator events)
 {
     _petRepository = petRepository;
     _accessoryRepository = accessoryRepository;
     _messenger = messenger;
     _petBasket = new List<Pet>();
     _accessoryBasket = new List<Accessory>();
     events.GetEvent<NewPetEvent>().Subscribe(pet => NotifyPropertyChanged("AllAvailablePets"));
     events.GetEvent<SoldPetEvent>().Subscribe(pet => NotifyPropertyChanged("AllAvailablePets"));
     _accessoryRepository.OnAccessorySelected((o, e) =>
                                                     {
                                                         foreach (var accessory in e.Accessories)
                                                         {
                                                             if (!_accessoryBasket.Contains(accessory))
                                                             {
                                                                 _accessoryBasket.Add(accessory);
                                                             }
                                                         }
                                                         NotifyPropertyChanged("Basket", "HasItemsInBasket", "Total", "PurchaseAllowed");
                                                     });
     _accessoryRepository.OnAccessoryUnselected((o, e) =>
                                                       {
                                                           _accessoryBasket.RemoveAll(
                                                               a => e.Accessories.Contains(a));
                                                           NotifyPropertyChanged("Basket", "HasItemsInBasket", "Total", "PurchaseAllowed");
                                                       });                                  
 }
Exemplo n.º 15
0
        public AdminAreaViewModel(IEventAggregator eventAggregator, QuestionGridViewModel questionGridViewModel, 
            RoundService roundService, StandingsService standingsService, InputService inputService)
        {
            _eventAggregator = eventAggregator;
            _roundService = roundService;
            _standingsService = standingsService;
            _inputService = inputService;
            QuestionGridViewModel = questionGridViewModel;
            _round = 1;
            ChangeRoundCommand = new DelegateCommand<object>(ChangedRound);
            ShowScoresCommand = new DelegateCommand(() => _standingsService.ToggleShowScores());
            IsSelecting = _standingsService.Players[new Random().Next(0, 4)];
            _eventAggregator.GetEvent<CategoryClickedEvent>().Subscribe(DisplayQuestion);
            _eventAggregator.GetEvent<ActivePlayerChangedEvent>().Subscribe(ActivePlayerChangedEventHandler);

            _eventAggregator.GetEvent<NewSelectorEvent>().Subscribe((i) =>
                {
                    IsSelecting = _standingsService.Players[i - 1];
                });

            _inputService.PropertyChanged +=
                (s, e) =>
                    {
                        if(e.PropertyName.Equals("ActiveController"))
                            RaisePropertyChanged(() => CurrentActive);
                    };

            _standingsService.PropertyChanged +=
                (s, e) =>
                    {
                        if (e.PropertyName.Equals("TimeLeft"))
                            RaisePropertyChanged(() => TimeLeft);
                    };
        }
Exemplo n.º 16
0
        public PuzzleViewModel(ICreateNinerViewModels ninerViewModelFactory, IEventAggregator events)
        {
            _numberRequestCommand = new NumberRequestCommand(events.GetEvent<NumberRequestEvent>());
            _newGameRequestCommand = new DelegateCommand<Mode>(p =>
                                                                   {
                                                                       events.GetEvent<ModeRequestEvent>().Publish(Mode.NewGame);
                                                                       GameCreated = false;
                                                                       NotifyPropertyChanged(() => GameCreated);

                                                                   });
            _playGameRequestCommand = new DelegateCommand<Mode>(p =>
                                                                    {
                                                                        events.GetEvent<ModeRequestEvent>().Publish(Mode.PlayGame);
                                                                        GameCreated = true;
                                                                        NotifyPropertyChanged(() => GameCreated);
                                                                    });

            _askForHelpCommand = new DelegateCommand<object>(b => events.GetEvent<HintRequestEvent>().Publish(null));

            events.GetEvent<HintProvidedEvent>().Subscribe(hint => HintText = hint.Text);

            var ninerModels = new List<NinerViewModel>();

            foreach (var id in Enumerable.Range(0, 9))
            {
                ninerModels.Add(ninerViewModelFactory.Create(id));
            }
            _niners = ninerModels;
        }
Exemplo n.º 17
0
 public Shell(IEventAggregator aggregator)
 {
     InitializeComponent();
     aggregator.GetEvent<SaveLayoutEvent>().Subscribe(this.SaveLayout, ThreadOption.PublisherThread);
     aggregator.GetEvent<LoadLayoutEvent>().Subscribe(this.LoadLayout, ThreadOption.PublisherThread);
     Application.Current.Exit += (s, e) => this.SaveLayout(null);
 }
        public ParticlePropertiesViewModel(IEventAggregator eventAggregator,
            IParticlesManager particlesManager, IBlockManager blockManager)
        {
            _particleGuid = Guid.Empty;
            _eventAggregator = eventAggregator;
            _particlesManager = particlesManager;
            _blockManager = blockManager;
            ParticleInplaces = new ObservableCollection<ParticleInplaceBlock>();

            _eventAggregator.GetEvent<BookmarkSelected>().Subscribe(BookmarkSelected);

            DeleteParticleInplaceCommand = new DelegateCommand<ParticleInplaceBlock>(pi =>
            {
                _particlesManager.DeleteParticleInplace(pi.ParticleInplace);
                ParticleInplaces.Remove(pi);
            });

            DeleteParticleCommand = new DelegateCommand(() =>
            {
                if (_particleGuid != Guid.Empty)
                {
                    var result = _particlesManager.DeleteParticle(_particleGuid);
                    if (result)
                    {
                        _eventAggregator.GetEvent<MaterialUpdatedEvent>().Publish(_materialId);
                        _eventAggregator.GetEvent<BookmarkSelected>().Publish(Guid.Empty);
                    }
                }
            });
        }
Exemplo n.º 19
0
 public FileServicesModule(IRegionManager regionManager, IEventAggregator aggregator)
 {
     this.regionManager = regionManager;
     this.aggregator = aggregator;
     aggregator.GetEvent<CreateDocumentEvent>().Subscribe(this.OnCreateDocument, ThreadOption.PublisherThread);
     aggregator.GetEvent<ActivateViewEvent>().Subscribe(this.OnActivateView, ThreadOption.PublisherThread);
 }
Exemplo n.º 20
0
 public Solver(IEventAggregator events, ILookAfterCells cells, IEnumerable<IMightBeAbleToHelp> rules)
 {
     _cells = cells;
     _rules = rules;
     _hintProviderEvent = events.GetEvent<HintProvidedEvent>();
     events.GetEvent<HintRequestEvent>().Subscribe(o => ProvideHint(), true);
 }
        public NodeDetailsViewModel( IEventAggregator eventAggregator, IProjectService<Project> projectService )
        {
            myProjectService = projectService;

            eventAggregator.GetEvent<NodeSelectedEvent>().Subscribe( node => SetNode( node ) );
            eventAggregator.GetEvent<NodeActivatedEvent>().Subscribe( node => ActivateNode( node ) );
        }
        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));

        }
        public ProductsPresenterService(IDatabaseAccessService databaseAccessService, IEventAggregator eventAggregator, IRegionManager regionManager)
        {
            this.regionManager = regionManager;

            foreach (var databaseHandlerService in databaseAccessService.DatabaseHandlers)
            {
                var wrapper = new ProductsPresenterWrapper();

                var loadingViewModel = new LoadingViewModel();
                var loadingGrid = new LoadingGrid(loadingViewModel);

                var productsViewModel = new ProductsViewModel(databaseHandlerService, eventAggregator, loadingViewModel);
                var productsGrid = new ProductsGrid(productsViewModel);

                var productEditorViewModel = new ProductEditorViewModel(databaseHandlerService, eventAggregator, productsViewModel);
                var productEditorGrid = new ProductEditorGrid(productEditorViewModel);

                wrapper.LoadingGrid = loadingGrid;
                wrapper.ProductsGrid = productsGrid;
                wrapper.ProductEditorGrid = productEditorGrid;

                wrappers.Add(databaseHandlerService.ConnectionString, wrapper);
            }

            var connectionStringChangedEvent = eventAggregator.GetEvent<ConnectionStringChangedEvent>();
            connectionStringChangedEvent.Subscribe(SetCurrentConnectionString);

            var visualizeModuleEvent = eventAggregator.GetEvent<VisualizeModuleEvent>();
            visualizeModuleEvent.Subscribe(VisualizeModule);
        }
        public MainPageViewModel(IDataRepository citiesRepository, INavigationService navigation, IEventAggregator eventAggregator)
        {
            _citiesRepository = citiesRepository;
            _navigation = navigation;
            _eventAggregator = eventAggregator;
            var clocks = _citiesRepository.GetUsersCities();
            Clocks = new ObservableCollection<CityInfo>(clocks);
            _eventAggregator.GetEvent<AddCityMessage>().Subscribe(HandleAddCity, true);
            _eventAggregator.GetEvent<DeleteCityMessage>().Subscribe(HandleDeleteCity, true);

            Add = new RelayCommand(() =>
            {
                _navigation.Navigate(Experiences.CitySelector.ToString(), null);
            });
            Donate = new RelayCommand(() => Launcher.LaunchUriAsync(new Uri("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UFS2JX3EJGU3N")));
            GoToDetails = new DelegateCommand<CityInfo>(HandleGotoDetails);
            SetShowMenu = new RelayCommand(() =>
            {
                MenuActive = !MenuActive;
            });
            GoToSettings = new RelayCommand(() =>
            {
                _navigation.Navigate(Experiences.Settings.ToString(), null);
            });
        }
Exemplo n.º 25
0
        public ResultsModule(IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            _regionManager = regionManager;
            _eventAggregator = eventAggregator;

            eventAggregator.GetEvent<ViewResultsEvent>().Subscribe(OnViewResults, ThreadOption.UIThread);
            eventAggregator.GetEvent<FileClickedEvent>().Subscribe(OnFileClicked, ThreadOption.PublisherThread, true, FilterClicks);
        }
 public GoalCollectionService(IEventAggregator eventAggregator, IGoalCollectionFactory goalCollectionFactory)
 {
     eventAggregator.GetEvent<NewGoalCollectionEvent>()
         .Subscribe(obj => eventAggregator.GetEvent<GoalCollectionCreatedEvent>()
                               .Publish(goalCollectionFactory.Create()),
             ThreadOption.PublisherThread,
             keepSubscriberReferenceAlive: true);
 }
 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 AngelCourseService(IEventAggregator eventAggregator, ILoginService loginService)
        {
            this.eventAggregator = eventAggregator;
            this.loginService = loginService;

            eventAggregator.GetEvent<LoginStatusChangedEvent>().Subscribe(GetCoursesForUser, ThreadOption.UIThread);
            eventAggregator.GetEvent<ActiveCourseChangedEvent>().Subscribe(LoadCourse, ThreadOption.UIThread);
        }
Exemplo n.º 29
0
 public ProjectExplorerViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
 {
     _eventAggregator = eventAggregator;
     _regionManager = regionManager;
     _project = new ObservableCollection<ProjectViewModel>();
     eventAggregator.GetEvent<LoadProjectDataEvent>().Subscribe(OnLoadProject);
     eventAggregator.GetEvent<ResultAddedEvent>().Subscribe(OnResultAdded, ThreadOption.UIThread);
 }
Exemplo n.º 30
0
 public MainPage()
 {
     InitializeComponent();
     _messageBus = ((ServiceLocator)App.Current.Resources["ServiceLocator"]).MessageBus;
     ContentFrame.Navigating += (obj, e) => _messageBus.GetEvent<Messages.NavigatingMessage>().Publish(e.Uri);
     ContentFrame.Navigated += (obj, e) => _messageBus.GetEvent<Messages.NavigatedMessage>().Publish(e.Uri);
     VisualStateManager.GoToState(this, "loggedOut", true);
 }
Exemplo n.º 31
0
 public CurrentUser(AuthenticationContext authContext, IEventAggregator eventMgr)
 {
     _authContext = authContext;
     EventManager = eventMgr;
     Instance = this;
     EventManager.GetEvent<LogonEvent>().Subscribe(HandleLogonEvent);
     EventManager.GetEvent<LogoffEvent>().Subscribe(HandleLogoffEvent);
 }
Exemplo n.º 32
0
 public OutputViewModel(IEventAggregator eventAggregator)
 {
     _outputText = string.Empty;
     OutputText = new ObservableCollection<IOutput>();
     eventAggregator.GetEvent<OutputEvent>().Subscribe(AddOutput, ThreadOption.UIThread);
     eventAggregator.GetEvent<ClickableOutputEvent>().Subscribe(AddClickableOutput, ThreadOption.UIThread);
     eventAggregator.GetEvent<ClearOutputEvent>().Subscribe(ClearOutput, ThreadOption.UIThread);
     Clear = new DelegateCommand<string>(ClearOutput);
 }
Exemplo n.º 33
0
        public MainWindow(IMainWindowViewModel viewModel, IEventAggregator eventAggregator)
        {
            eventAggregator?.GetEvent <ExceptionEvent>().Subscribe(ShowException);

            InitializeComponent();
            ViewModel = viewModel;
        }
Exemplo n.º 34
0
 public RootPage(IEventAggregator ea)
 {
     InitializeComponent();
     ea?.GetEvent <ShowMenuEvent>().Subscribe((newState) => {
         IsPresented = newState;
     });
 }
Exemplo n.º 35
0
 private void SyncDataSource()
 {
     if (_appData.Config.IsSyncDataSource)
     {
         _eventAggregator?.GetEvent <SyncDataSourceEvent>().Publish(_appData.Config.DataSourceJsonString?.Trim());
     }
 }
        /*
         * Simulate card swiping and connecting to the user api to check on the guid of the customer
         */
        private async void ExecuteSendValidateCommandAsync()
        {
            Customer.ClientCard = new CardInfo()
            {
                CardNumber = SelectedUser
            };
            try
            {
                CustomerIdentification customer = await httpActions.ValidateCustomerAsync(Customer.ClientCard);

                Customer.CustomerID = customer.CustomerId;
                _ea?.GetEvent <ChangeViewEvent>().Publish(ViewType.select);
                _ea?.GetEvent <SendPatientEvent>().Publish(Customer);
            }
            catch (HttpRequestException e)
            {
                views.ShowErrorDialog(e.Message);
            }
        }
Exemplo n.º 37
0
        public NotificationCenter()
        {
            InitializeComponent();

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseCommandExecuted));

            try
            {
                Focusable = true;

                _eventAggregator = null; //DiContainer.GetInstance().Resolve<IEventAggregator>();
                _eventAggregator?.GetEvent <NotificationMessageEvent>().Subscribe(OnNotificationMessage, ThreadOption.UIThread);

                EventManager.RegisterClassHandler(typeof(MainWindow), Mouse.PreviewMouseDownEvent, new MouseButtonEventHandler(OnPreviewMouseDown));
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebViewControl"/> class.
        /// </summary>
        public WebViewControl()
        {
            try {
                using (Log.CriticalOperation($"ctor", Serilog.Events.LogEventLevel.Debug)) {
                    this.IsVisibleChanged += WebViewControl_IsVisibleChanged;

                    InitializeComponent();

                    _componentModel = Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;
                    Assumes.Present(_componentModel);

                    _eventAggregator = _componentModel.GetService <IEventAggregator>();
                    _sessionService  = _componentModel.GetService <ISessionService>();
                    _browserService  = _componentModel.GetService <IBrowserService>();
                    _ = _browserService.InitializeAsync().ContinueWith(_ => {
                        ThreadHelper.JoinableTaskFactory.Run(async delegate {
                            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                            // requires UI thread
                            _browserService.AttachControl(Grid);
                            _browserService.LoadSplashView();
                            _languageServerDisconnectedEvent = _eventAggregator?.GetEvent <LanguageServerDisconnectedEvent>()
                                                               .Subscribe(e => {
                                Log.Debug($"{nameof(LanguageServerDisconnectedEvent)} IsReloading={e?.IsReloading}");

                                // if we're in the process of reloading the agent, don't show the splash screen
                                if (e.IsReloading)
                                {
                                    return;
                                }

                                _browserService.LoadSplashView();
                            });

                            SetupInitialization();
                        });
                    }, TaskScheduler.Default);
                }
            }
            catch (Exception ex) {
                Log.Fatal(ex.UnwrapCompositionException(), nameof(WebViewControl));
            }
        }
Exemplo n.º 39
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebViewControl"/> class.
        /// </summary>
        public WebViewControl()
        {
            try {
                using (Log.CriticalOperation($"ctor", Serilog.Events.LogEventLevel.Debug)) {
                    this.IsVisibleChanged += WebViewControl_IsVisibleChanged;

                    InitializeComponent();

                    _componentModel = Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;
                    Assumes.Present(_componentModel);

                    _eventAggregator = _componentModel.GetService <IEventAggregator>();
                    _sessionService  = _componentModel.GetService <ISessionService>();
                    _browserService  = _componentModel.GetService <IBrowserService>();

                    _browserService.Initialize();
                    _browserService.AttachControl(Grid);
                    _browserService.LoadSplashView();

                    _languageServerDisconnectedEvent = _eventAggregator?.GetEvent <LanguageServerDisconnectedEvent>()
                                                       .Subscribe(_ => {
                        Log.Debug($"{nameof(LanguageServerDisconnectedEvent)} IsReloading={_?.IsReloading}");

                        // if we're in the process of reloading the agent, don't show the splash screen
                        if (_.IsReloading)
                        {
                            return;
                        }

                        _browserService.LoadSplashView();
                    });

                    SetupInitialization();
                }
            }
            catch (Exception ex) {
                Log.Fatal(ex.UnwrapCompositionException(), nameof(WebViewControl));
            }
        }
Exemplo n.º 40
0
        public static void Invoke(this IEventAggregator events, Action action, ThreadOption threadOption = ThreadOption.UIThread)
        {
            if (action == null)
            {
                return;
            }

            var e = events?.GetEvent <InvokeMessage>() ?? throw new ArgumentNullException(nameof(events));
            ExceptionDispatchInfo exception = null;

            using (var waitHandle = new ManualResetEventSlim())
            {
                Action <InvokeMessage> handleMessage = msg =>
                {
                    try
                    {
                        msg.Action();
                    }
                    catch (Exception ex)
                    {
                        exception = ExceptionDispatchInfo.Capture(ex);
                    }
                    finally
                    {
                        waitHandle.Set();
                    }
                };

                using (e.Subscribe(handleMessage, threadOption))
                {
                    e.Publish(new InvokeMessage {
                        Action = action
                    });
                    waitHandle.Wait();
                    exception?.Throw();
                }
            }
        }
Exemplo n.º 41
0
 public void Login()
 {
     mEventAggregator.GetEvent <LoginEvent>().Publish(true);
 }
 public MainView(IEventAggregator eventAggregator)
 {
     eventAggregator?.GetEvent <JoinedConvoEvent>()?.Subscribe(OnJoinedConvo);
     InitializeComponent();
 }
Exemplo n.º 43
0
 public BViewModel(IEventAggregator eventAggregator)
 {
     eventAggregator.GetEvent <UpdateEvent>().Subscribe(Updated);
 }
Exemplo n.º 44
0
 private void RaiseViewChanged()
 {
     _eventAggregator.GetEvent <NavigationEvents.NavigateViewEvent>().Publish(_currentView);
 }
Exemplo n.º 45
0
        public void GetMessages(IEventAggregator _eventAggregator)
        {
            ResponseHandler._eventAggregator = _eventAggregator;
            String response = "";

            // Bytes Array to receive Server Response.
            Byte[] data = new Byte[512];

            Task.Run(async() =>
            {
                // Read the Tcp Server Response Bytes.
                try
                {
                    Int32 bytes;
                    while ((bytes = await networkStream.ReadAsync(data, 0, data.Length)) != 0)
                    {
                        //Int32 bytes = await networkStream.ReadAsync(data, 0, data.Length);
                        response = System.Text.Encoding.UTF8.GetString(data, 0, bytes);
                        _eventAggregator?.GetEvent <UpdateUserConsole>().Publish(response);

                        if (response.Contains("BYE"))
                        {
                            ResponseHandler.Bye();
                            Disconnect();
                            break;
                        }

                        var responseTokens = response.Split(Environment.NewLine);
                        responseTokens     = responseTokens.Where(i => i != "").ToArray();


                        if (responseTokens.Last().Split(' ')[0] == outgoingTag)
                        {
                            //Here we can handle a server result (it means that the command execution is finished
                            //on server side and we can start handle its result on the server).
                            wholeServerResponse += response;
                            ResponseHandler.HandleResponse(outgoingCommand, response);
                            wholeServerResponse += "";
                        }
                        else if (response.Split(' ')[0] == "*" || response.Split(' ')[0] == "+")
                        {
                            //Over here we can add a condition for a currently occuring command
                            //for an instance, sending encryption keys if the server response is "+",
                            //or when we want to read the information a bit by a bit.
                            wholeServerResponse += response;
                        }
                        else
                        {
                            //Illegal server response. Should usually not be the case.
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("You are now disconnected from the server.");
                    Disconnect();
                    ResponseHandler.Bye();
                    //System.Windows.MessageBox.Show(ex.Message);
                    //break;
                }
            });
        }
        public EventPageViewModel(IEventAggregator eventAggregator)
        {
            Title = "Event Aggregator";

            eventAggregator?.GetEvent <GreetEvent>()?.Subscribe(OnMessageReceived);
        }
Exemplo n.º 47
0
        public static async Task StartRunTest(IReadOnlyList <HomeExercise> homeExercises,
                                              IReadOnlyList <InputOutputModel> inputOutputModels, int numberOfSecondsToWait, IEventAggregator eventAggregator = null)
        {
            for (var index = 0; index < homeExercises.Count; index++)
            {
                var homeExercise = homeExercises[index];
                homeExercise.CompatibleRunTestList = new List <string>();
                homeExercise.RunTestErrorsList     = new List <string>();
                foreach (var inputOutputModel in inputOutputModels)
                {
                    Process process = new Process();
                    process.StartInfo.FileName = @"java.exe";
                    // arguments actually will not work if program does not need arguments and instead wants input in running time
                    if (homeExercise.HomeExerciseName.EndsWith(".jar"))
                    {
                        process.StartInfo.Arguments = $"-jar \"{homeExercise.HomeExerciseName}\" < \"{inputOutputModel.InputTextFullPath}\"";
                    }
                    else
                    {
                        process.StartInfo.Arguments =
                            $"\"{homeExercise.HomeExerciseName}\" < \"{inputOutputModel.InputTextFullPath}\"";
                    }

                    //process.StartInfo.CreateNoWindow = true;
                    process.StartInfo.WorkingDirectory       = homeExercise.HomeExercisePath;
                    process.StartInfo.UseShellExecute        = false;
                    process.StartInfo.CreateNoWindow         = true;
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.RedirectStandardError  = true;
                    process.StartInfo.RedirectStandardInput  = true;

                    try
                    {
                        process.Start();
                    }
                    catch
                    {
                        throw new Exception("Error: java.exe compiler not found in path variables");
                    }

                    // needed if java Program wants some enter input
                    using (StreamWriter sw = process.StandardInput)
                    {
                        sw.Write(inputOutputModel.InputText);
                    }

                    // needed to see output from program
                    using (StreamReader srOutput = process.StandardOutput)
                    {
                        string output         = null;
                        var    readOutputTask = Task.Run(() => { output = srOutput.ReadToEnd(); });
                        await Task.WhenAny(readOutputTask, Task.Delay(TimeSpan.FromSeconds(numberOfSecondsToWait)));

                        if (output == null)
                        {
                            homeExercise.RunTestErrorsList.Add("Exercise didn't stopped after {numberOfSecondsToWait} seconds");
                            process.Kill();
                            eventAggregator?.GetEvent <UpdateProgressBarEvent>().Publish(((double)(index + 1) / homeExercises.Count) * 100);
                            continue;
                        }
                        homeExercise.RunTestOutput = output;
                    }

                    // needed to see errors from program
                    using (StreamReader srError = process.StandardError)
                    {
                        homeExercise.RunTestErrorsList.Add(srError.ReadToEnd());
                    }
                    CompareOutputs(inputOutputModel, homeExercise);
                }
                ErrorsChecker(homeExercise);
                CompatibleChecker(homeExercise);
                eventAggregator?.GetEvent <UpdateProgressBarEvent>().Publish(((double)(index + 1) / homeExercises.Count) * 100);
            }
        }
Exemplo n.º 48
0
 public void Initialize()
 {
     eventAggregator.GetEvent <CharacterSelectedLoginEvent>().Publish("testing character");
 }
 /// <summary>
 /// Method to Kill Events & Event Subscribers
 /// </summary>
 public void Dispose()
 {
     eventAggregator.GetEvent <PortfolioReferenceSetEvent>().Unsubscribe(HandleFundReferenceSet);
     eventAggregator.GetEvent <EffectiveDateReferenceSetEvent>().Unsubscribe(HandleEffectiveDateSet);
 }
 public void HandleCommandLineArguments(IEnumerable <string> args)
 {
     _eventAggregator.GetEvent <ApplicationArgumentsEvent>().Publish(args);
 }
Exemplo n.º 51
0
 public void UpdateBannerTitle(string title)
 {
     _eventAggregator?.GetEvent <OnNavigatedToEvent>().Publish(title);
 }
Exemplo n.º 52
0
 public void OnLoaded()
 {
     DataContext = ViewModel;
     EventAggregator?.GetEvent <SelectSettingEvent>().Subscribe(OnSelectSetting);
 }
 public void TheContactDetailsMethod(int?value)
 {
     _ea.GetEvent <TheContactDetailsSentEvent>().Publish(value);
 }
Exemplo n.º 54
0
 public BrowsePageViewModel(IPageDialogService dialogService, IEventAggregator eventAggregator)
 {
     _dialogService = dialogService;
     beginFetchingData();
     eventAggregator.GetEvent <DownloadEvent>().Subscribe(downloadEventCallback);
 }
        public SettingsBrowserControlViewModel()
        {
            _eventAggregator = _container.Resolve <IEventAggregator>();

            ClearConsoleCommand = new DelegateCommand(() => _eventAggregator.GetEvent <SettingsEvent>().Publish(SettingsOperation.ClearConsole));
        }
Exemplo n.º 56
0
 public void OnNavigatedTo(NavigationContext navigationContext)
 {
     IsCheckIOBusy = true;
     _eventAggregator.GetEvent <PubSubEvent <string> >().Publish("navReferenceCentre");
     IsCheckIOBusy = false;
 }
Exemplo n.º 57
0
 public void Dispose()
 {
     _EventAggregator.GetEvent <ShutDownEvent>().Publish(true);
 }
 /// <summary>
 ///
 /// </summary>
 private void SendMessageMethod()
 {
     _ea.GetEvent <MessageSentEvent>().Publish(MessageProperty);
 }
Exemplo n.º 59
0
 private void ObjApp_PresentationCloseFinal(POWERPOINT.Presentation Pres)
 {
     _eventAggregator?.GetEvent <PPTClosedEvent>().Publish(isManualClose);
 }
Exemplo n.º 60
0
 public Task <int> OnLoaded()
 {
     DataContext = ViewModel;
     EventAggregator?.GetEvent <SelectSettingEvent>().Subscribe(OnSelectSetting);
     return(Task.FromResult(0));
 }