public MainWindowViewModel(IStopwatchService service) { this.service = service; Ellapsed = this.service.ObserveProperty(x => x.Ellapsed) .ToReadOnlyReactiveProperty() .AddTo(CompositeDisposable); LapTimes = this.service.LapTimes ?.ToReadOnlyReactiveCollection(t => new LapTimeViewModel(this.service.LapTimes.Count, t)); StartCommand = this.service.ObserveProperty(x => x.IsRunning) .Inverse() .ToReactiveCommand() .AddTo(CompositeDisposable); StartCommand.Subscribe(() => this.service.Start()).AddTo(CompositeDisposable); StopCommand = this.service.ObserveProperty(x => x.IsRunning) .ToReactiveCommand() .AddTo(CompositeDisposable); StopCommand.Subscribe(() => this.service.Stop()).AddTo(CompositeDisposable); ResetCommand = new ReactiveCommand().AddTo(CompositeDisposable); ResetCommand.Subscribe(() => this.service.Reset()).AddTo(CompositeDisposable); LapCommand = this.service.ObserveProperty(x => x.IsRunning) .ToReactiveCommand() .AddTo(CompositeDisposable); LapCommand.Subscribe(() => this.service.Lap()).AddTo(CompositeDisposable); }
public StopwatchHub(IStopwatchService service, IObservable <Unit> elapsedInterval) { _service = service; // A timer for periodically broadcasting elapsed stopwatch times is abstracted // in order to ease testing. _elapsedInterval = elapsedInterval; }
public TimeService(ILogger <TimeService> logger, NtpConfiguration ntpConfiguration, WindowConfiguration windowConfiguration, DateAndTimeFormat dateAndTimeFormat, ApplicationConfiguration applicationConfiguration, IStopwatchService stopwatchService, INicService nicService) { _logger = logger; _ntpConfiguration = ntpConfiguration; _windowConfiguration = windowConfiguration; _dateAndTimeFormat = dateAndTimeFormat; _applicationConfiguration = applicationConfiguration; _stopwatchService = stopwatchService; _nicService = nicService; }
public MatchViewModel(IStopwatchService stopwatchService, INavigationService navigationService, IDialogService dialogService) { m_navigationService = navigationService; m_dialogService = dialogService; StopwatchService = stopwatchService; m_playingPlayers = new ObservableCollection <PlayerViewModel>(); m_nonPlayingPlayers = new ObservableCollection <PlayerViewModel>(); StartMatchCommand = new Command(StartMatch); StopMatchCommand = new Command(TryStopMatch); PauseMatchCommand = new Command(PauseMatch); stopwatchService.RegisterInterval(1000, OnEachMatchSecond); }
public ApplicationService(ILogger <ApplicationService> logger, ITimeService timeService, IWindowService windowService, DateAndTimeFormat dateAndTimeFormat, WindowConfiguration windowConfiguration, ApplicationConfiguration applicationConfiguration, IStopwatchService stopwatchService, IHostApplicationLifetime hostApplicationLifetime, IStorageService storageService, INicService nicService, IInternetService internetService) { _logger = logger; _timeService = timeService; _windowService = windowService; _dateAndTimeFormat = dateAndTimeFormat; _windowConfiguration = windowConfiguration; _applicationConfiguration = applicationConfiguration; _stopwatchService = stopwatchService; _hostApplicationLifetime = hostApplicationLifetime; _storageService = storageService; _nicService = nicService; _internetService = internetService; _internetService.InternetConnectionAvailable += _internetService_InternetConnectionAvailable; _hostApplicationLifetime.ApplicationStopping.Register(() => { if (_applicationConfiguration.CountSystemRunningTime) { _stopwatchService.StopTimer(); } if (_applicationConfiguration.CountNetworkActivity) { _nicService.StopNicsMonitoring(); } _storageService.EditData(); _logger.LogDebug("Shutting down application"); _logger.LogDebug(new string('-', 100)); }); }
public StopwatchController(IStopwatchService service) { _service = service; }