public TimerProvider() { _schedulerProvider = Locator.CurrentMutable.GetService<ISchedulerProvider>(); _settings = Locator.CurrentMutable.GetService<Settings>(); }
public StartBootstrapper() { _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); _settings = (Settings)_config.Sections["settings"]; Locator.CurrentMutable.RegisterConstant(_settings, typeof(Settings)); _customObservable2 = new CustomObservable2(); var schedulerProvider = new SchedulerProvider(); if (_settings.IsFakeService) { _client = new FakeServiceClientHelper(); } else { _client = new MainServiceClientHelper(_settings.ServiceUrl); } _trayIconManager = new TrayIconManager(); _trayIconManager.Init(); Locator.CurrentMutable.RegisterConstant(_customObservable2, typeof(ICustomObservable2)); Locator.CurrentMutable.RegisterConstant(schedulerProvider, typeof(ISchedulerProvider)); Locator.CurrentMutable.RegisterConstant(_config, typeof(Configuration)); Locator.CurrentMutable.RegisterConstant(_client, typeof(IMainServiceClientHelper)); Locator.CurrentMutable.RegisterConstant(_trayIconManager, typeof(TrayIconManager)); _timerProvider = new TimerProvider(); Locator.CurrentMutable.RegisterConstant(_timerProvider, typeof (ITimerProvider)); Locator.CurrentMutable.RegisterConstant(new CheckingVersionView(), typeof(IViewFor<CheckingVersionViewModel>)); Locator.CurrentMutable.RegisterConstant(new CheckingVersionErrorRetryingView(), typeof(IViewFor<CheckingVersionErrorRetryingViewModel>)); Locator.CurrentMutable.RegisterConstant(new CheckingUserKeyView(), typeof(IViewFor<CheckingUserKeyViewModel>)); Locator.CurrentMutable.RegisterConstant(new NewUserKeyView(), typeof(IViewFor<NewUserKeyViewModel>)); Locator.CurrentMutable.RegisterConstant(new CheckingUserKeyErrorRetryingView(), typeof(IViewFor<CheckingUserKeyErrorRetryingViewModel>)); Locator.CurrentMutable.RegisterConstant(new SuspendedView(), typeof(IViewFor<SuspendedViewModel>)); Locator.CurrentMutable.RegisterConstant(new UnknownErrorView(), typeof(IViewFor<UnknownErrorViewModel>)); Locator.CurrentMutable.RegisterConstant(new UnsupportedVersionView(), typeof(IViewFor<UnsupportedVersionViewModel>)); NewUserKeyViewModel.Submit.Subscribe(_ => { NewUserKeyViewModel.CanSubmit = false; ViewModel = CheckingUserKeyViewModel; HandleTryCheckUserKey(NewUserKeyViewModel.UserKey); }); ViewModel = CheckingVersionViewModel; TryCheckVersion().Subscribe(a => { if (a == CheckingVersionErrorRetryingViewModel) { _trayIconManager.SetIconType(NotifyIconType.Warning); } else if (a == UnknownErrorViewModel || a == UnsupportedVersionViewModel) { _trayIconManager.SetIconType(NotifyIconType.Error); } else { _trayIconManager.SetIconType(NotifyIconType.Idle); } ViewModel = a; if (a == CheckingUserKeyViewModel) { HandleTryCheckUserKey(_settings.UserKey); } }); }
public MainBootstrapper() { _settings = Locator.CurrentMutable.GetService<Settings>(); _trayIconManager = Locator.CurrentMutable.GetService<TrayIconManager>(); Locator.CurrentMutable.Register(() => new MainView(), typeof(IViewFor<MainViewModel>)); Locator.CurrentMutable.Register(() => new MatchOrderItemView(), typeof(IViewFor<MatchOrderItemViewModel>)); Locator.CurrentMutable.Register(() => new SubmittingMatchOrderStatusView(), typeof(IViewFor<SubmittingMatchOrderStatusViewModel>)); Locator.CurrentMutable.Register(() => new LookingForMatchStatusView(), typeof(IViewFor<SuccessStatusViewModel>)); Locator.CurrentMutable.Register(() => new SubmitErrorRetryingStatusView(), typeof(IViewFor<ErrorRetryOrderMatchStatusViewModel>)); Locator.CurrentMutable.Register(() => new CheckingMatchOrderErrorRetryingStatusView(), typeof(IViewFor<ErrorRetryGetHasActiveMatchOrderStatusViewModel>)); Locator.CurrentMutable.Register(() => new UnknownErrorStatusView(), typeof(IViewFor<UnknownErrorStatusViewModel>)); Locator.CurrentMutable.Register(() => new UserKeyErrorStatusView(), typeof(IViewFor<UserKeyErrorStatusViewModel>)); Locator.CurrentMutable.Register(() => new SuspendedStatusView(), typeof(IViewFor<SuspendedStatusViewModel>)); Locator.CurrentMutable.Register(() => new MatchFoundView(), typeof(IViewFor<MatchFoundViewModel>)); Locator.CurrentMutable.Register(() => new BrowseGameFileView(), typeof(IViewFor<BrowseGameFileViewModel>)); Locator.CurrentMutable.Register(() => new MatchOrdersSummaryView(), typeof(IViewFor<MatchOrdersSummaryViewModel>)); Locator.CurrentMutable.Register(() => new ScriptMatchOrdersSummaryView(), typeof(IViewFor<ScriptMatchOrdersSummaryViewModel>)); Locator.CurrentMutable.Register(() => new ServerFilterMatchOrdersSummaryView(), typeof(IViewFor<ServerFilterMatchOrdersSummaryViewModel>)); Locator.CurrentMutable.Register(() => new MatchOrdersSummaryParametersView(), typeof(IViewFor<MatchOrdersSummaryParametersViewModel>)); _mainViewModel = new MainViewModel(); var matchFoundViewModel = new MatchFoundViewModel(); var browseGameFileViewModel = new BrowseGameFileViewModel(); ReactiveObject viewModelBeforeBrowseGameFile = null; ViewModel = _mainViewModel; var schedulerProvider = Locator.CurrentMutable.GetService<ISchedulerProvider>(); MessageBus.Current.Listen<GameServerSuggestion>() .ObserveOn(schedulerProvider.Dispatcher) .Subscribe(suggestion => { _trayIconManager.SetIconType(NotifyIconType.Success); UpdateMatchFoundViewModel(matchFoundViewModel, suggestion); ViewModel = matchFoundViewModel; _mainViewModel.CancelMatchOrder.Execute(null); ViewModels.Notification.NotificationViewModel.MatchFound.GameServerLink = matchFoundViewModel.GameServerLink; ViewModels.Notification.NotificationViewModel.MatchFound.IsJoinButtonVisible = !string.IsNullOrEmpty(_settings.GameFilePath); if (_mainViewModel.IsJoinMatchesAutomatically) { OpenGameServerInGame(matchFoundViewModel.GameServerLink); } else { ShowNotification.Execute(ViewModels.Notification.NotificationViewModel.MatchFound); } }); _mainViewModel.ShowNotification.Subscribe(a => ShowNotification.Execute(a)); MessageBus.Current.Listen<BrowseGameFileEvent>().Subscribe(a => { if (ViewModel != browseGameFileViewModel) { viewModelBeforeBrowseGameFile = ViewModel; ViewModel = browseGameFileViewModel; } }); MessageBus.Current.Listen<JoinMatchEvent>().Subscribe(a => OpenGameServerInGame(a.GameServerLink)); matchFoundViewModel.Cancel.Subscribe(_ => { _trayIconManager.SetIconType(NotifyIconType.Idle); ViewModel = _mainViewModel; }); browseGameFileViewModel.Close.Subscribe(_ => { ViewModel = viewModelBeforeBrowseGameFile; }); _mainViewModel.CancelMatchOrder.Subscribe(_ => { if (ViewModel == _mainViewModel) { _trayIconManager.SetIconType(NotifyIconType.Idle); } }); _mainViewModel.WhenAny(x => x.SearchingMatchStatus, x => x.Value).Subscribe(status => { if (status == SearchingMatchStatuses.SubmittingMatchOrder || status == SearchingMatchStatuses.Success) { _trayIconManager.SetIconType(NotifyIconType.Searching); } if (status == SearchingMatchStatuses.ErrorRepeatOrderMatch || status == SearchingMatchStatuses.ErrorRepeatGetHasActiveMatchOrder) { _trayIconManager.SetIconType(NotifyIconType.Warning); } if (status == SearchingMatchStatuses.UserKeyError || status == SearchingMatchStatuses.Suspended || status == SearchingMatchStatuses.UnknownError) { _trayIconManager.SetIconType(NotifyIconType.Error); } }); }
public MainServiceClientHelper(string serviceUrl) { _serviceUrl = serviceUrl; _settings = Locator.CurrentMutable.GetService<Settings>(); }