Exemplo n.º 1
0
        public async Task Seek(TimeSpan time)
        {
            logger.Info(time.ToString());
            var token = activeTaskCts.Token;

            try
            {
                var resumeNeeded = player.GetState() == ESPlayer.ESPlayerState.Paused;
                if (resumeNeeded)
                {
                    await stateChangedSubject
                    .AsObservable()
                    .FirstAsync(state => state == PlayerState.Playing)
                    .ToTask(token);

                    token.ThrowIfCancellationRequested();
                }

                using (await asyncOpSerializer.LockAsync(token))
                {
                    // Set suspend clock. Clock is not available during seek, but required during Suspend/Resume
                    _suspendClock = time;

                    token.ThrowIfCancellationRequested();

                    await SeekStreamInitialize(token);

                    var seekToTime = await Client.Seek(time, token);

                    _dataClock.SetClock(time, token);
                    EnableInput();
                    _dataClock.Start();

                    await StreamSeek(seekToTime, resumeNeeded, token);

                    // Invalidate _suspendClock
                    _suspendClock = PlayerClockProviderConfig.InvalidClock;
                }
            }
            catch (SeekException e)
            {
                logger.Error(e);
                playbackErrorSubject.OnNext($"Seek Failed, reason \"{e.Message}\"");
                throw;
            }
            catch (OperationCanceledException)
            {
                logger.Info("Operation Cancelled");
            }
            catch (Exception e)
            {
                logger.Error(e);
                playbackErrorSubject.OnNext("Seek Failed");
            }
        }
Exemplo n.º 2
0
        public RelayListenerService()
        {
            var relayStateSubject = new BehaviorSubject <RelayListenerConnectionState>(RelayListenerConnectionState.Offline);

            _relayStateObservable = relayStateSubject.AsObservable();
            _relayStateObserver   = relayStateSubject.AsObserver();
        }
Exemplo n.º 3
0
        public RatingViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            IRatingService ratingService,
            IFeedbackService feedbackService,
            IAnalyticsService analyticsService,
            IOnboardingStorage onboardingStorage,
            IMvxNavigationService navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(ratingService, nameof(ratingService));
            Ensure.Argument.IsNotNull(feedbackService, nameof(feedbackService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));

            this.dataSource        = dataSource;
            this.timeService       = timeService;
            this.ratingService     = ratingService;
            this.feedbackService   = feedbackService;
            this.analyticsService  = analyticsService;
            this.onboardingStorage = onboardingStorage;
            this.navigationService = navigationService;

            Impression     = impressionSubject.AsObservable();
            CtaTitle       = Impression.Select(ctaTitle);
            CtaDescription = Impression.Select(ctaDescription);
            CtaButtonTitle = Impression.Select(ctaButtonTitle);
        }
Exemplo n.º 4
0
        private (ISubject <T>, IObservable <T>) prepareSubjectAndObservable <T>(T initialValue)
        {
            var subject    = new BehaviorSubject <T>(initialValue);
            var observable = subject.AsObservable().DistinctUntilChanged();

            return(subject, observable);
        }
Exemplo n.º 5
0
        public ReportsCalendarViewModel(
            ITimeService timeService,
            IDialogService dialogService,
            ITogglDataSource dataSource,
            IIntentDonationService intentDonationService,
            IRxActionFactory rxActionFactory)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(intentDonationService, nameof(intentDonationService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.timeService           = timeService;
            this.dialogService         = dialogService;
            this.dataSource            = dataSource;
            this.intentDonationService = intentDonationService;

            SelectDay      = rxActionFactory.FromAsync <ReportsCalendarDayViewModel>(calendarDayTapped);
            SelectShortcut = rxActionFactory.FromAction <ReportsCalendarBaseQuickSelectShortcut>(quickSelect);

            CurrentPageObservable = currentPageSubject.AsObservable();

            SelectedDateRangeObservable = selectedDateRangeSubject
                                          .ShareReplay(1);

            HighlightedDateRangeObservable = highlightedDateRangeSubject
                                             .ShareReplay(1);
        }
Exemplo n.º 6
0
        public LogsViewService(ILogFilterResultsService logFilterResultsService, IDialogService dialogService)
        {
            _logEvents = new BehaviorSubject <IList <LogEvent> >(Array.Empty <LogEvent>());
            _selectedLogEventProperty = new BehaviorSubject <LogEvent>(null);

            LogEvents = _logEvents.AsObservable();

            // Subscribe to log filter result
            logFilterResultsService
            .Result
            .AsItemsBehaviorObservable()
            .ObserveOn(Dispatcher)
            .Subscribe(_logEvents);

            LogEvents.Subscribe(CoerceSelectedLogEvent);

            SelectedLogEventProperty = _selectedLogEventProperty
                                       .DistinctUntilChanged()
                                       .AsObservable();

            OpenLogEventCommand = Command.Create(
                SelectedLogEventProperty.Select <LogEvent, Func <object, bool> >(logEvent => param => logEvent != null),
                async(param) =>
            {
                await dialogService.ShowDialog(new LogEventDialog());
            }
                );

            SelectNextCommand         = Command.Create((object o) => Move(1));
            SelectPreviousCommand     = Command.Create((object o) => Move(-1));
            SelectNextPageCommand     = Command.Create((object o) => NextPage());
            SelectPreviousPageCommand = Command.Create((object o) => PreviousPage());
            SelectFirstCommand        = Command.Create((object o) => SelectFirst());
            SelectLastCommand         = Command.Create((object o) => SelectLast());
        }
Exemplo n.º 7
0
        public InfiniteScrollViewModel(IInventoryDataService inventoryDataService)
        {
            _inventoryDataService = inventoryDataService;
            _pagingSubject        = new BehaviorSubject <IPageRequest>(new PageRequest(0, pageSize));

            Func <InventoryItemViewModel, bool> Search(string searchTerm) =>
            viewModel =>
            {
                if (string.IsNullOrEmpty(searchTerm))
                {
                    return(true);
                }

                var lower = searchTerm.ToLower();
                return(viewModel.Brand.ToLower().Contains(lower) || (viewModel.Coffee?.ToLower().Contains(lower) ?? false));
            };

            var searchChanged =
                this.WhenAnyValue(x => x.SearchText)
                .Throttle(TimeSpan.FromMilliseconds(800), RxApp.TaskpoolScheduler)
                .DistinctUntilChanged()
                .Select(Search);

            _inventoryDataService
            .ChangeSet
            .Transform(x =>
                       new InventoryItemViewModel
            {
                Id        = x.Id,
                Brand     = x.BrandName,
                Coffee    = x.CoffeeName,
                Roast     = x.Roast,
                Packaging = x.Packaging
            })
            .AutoRefresh(x => x.Id)
            .DeferUntilLoaded()
            .Filter(searchChanged)
            .Sort(SortExpressionComparer <InventoryItemViewModel> .Descending(x => x.Roast))
            .Page(_pagingSubject.AsObservable())
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _items)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(Garbage);

            this.WhenAnyObservable(x => x.Refresh.IsExecuting)
            .StartWith(false)
            .DistinctUntilChanged()
            .ToProperty(this, nameof(IsRefreshing), out _isRefreshing, deferSubscription: true)
            .DisposeWith(Garbage);

            this.WhenAnyObservable(x => x.Load.IsExecuting)
            .ToProperty(this, nameof(IsLoading), out _isLoading, deferSubscription: true)
            .DisposeWith(Garbage);

            Refresh = ReactiveCommand.CreateFromObservable <EventArgs, Unit>(ExecuteRefresh);
            Load    = ReactiveCommand.CreateFromObservable <int, Unit>(ExecuteLoad);

            _pagingSubject.DisposeWith(Garbage);
        }
Exemplo n.º 8
0
        private Device()
        {
            var deviceActivitySubject = new BehaviorSubject <DeviceActivity>(DeviceActivity.Initialized);

            _observerDeviceActivity  = deviceActivitySubject.AsObserver();
            DeviceActivityObservable = deviceActivitySubject.AsObservable();
        }
        internal HttpParserDelegate()
        {
            var handshakeParserStateSubject = new BehaviorSubject <ParserState>(ParserState.Start);

            _observerHandshakeParserState       = handshakeParserStateSubject.AsObserver();
            HandshakeParserCompletionObservable = handshakeParserStateSubject.AsObservable();
        }
        public ReportsCalendarViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            IRxActionFactory rxActionFactory,
            INavigationService navigationService,
            ISchedulerProvider schedulerProvider)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            this.dataSource        = dataSource;
            this.timeService       = timeService;
            this.schedulerProvider = schedulerProvider;

            SelectDay      = rxActionFactory.FromAsync <ReportsCalendarDayViewModel>(calendarDayTapped);
            SelectShortcut = rxActionFactory.FromAction <ReportsCalendarBaseQuickSelectShortcut>(quickSelect);

            CurrentPageObservable = currentPageSubject
                                    .AsObservable()
                                    .DistinctUntilChanged();

            SelectedDateRangeObservable = selectedDateRangeSubject
                                          .ShareReplay(1);

            HighlightedDateRangeObservable = highlightedDateRangeSubject
                                             .ShareReplay(1);
        }
Exemplo n.º 11
0
        private void setupSwipeRightOnboardingStep()
        {
            var shouldBeVisible = editTimeEntryOnboardingStep
                                  .ShouldBeVisible
                                  .Select(visible => !visible);

            var showSwipeRightOnboardingStep = Observable.CombineLatest(
                shouldBeVisible,
                mainRecyclerViewChangesObservable,
                ViewModel.SyncProgressState,
                (shouldShowStep, unit, syncState) => shouldShowStep && syncState == SyncProgress.Synced);


            swipeRightPopup = PopupWindowFactory.PopupWindowWithText(
                Context,
                Resource.Layout.TooltipWithLeftTopArrow,
                Resource.Id.TooltipText,
                Resource.String.OnboardingSwipeRight);

            swipeRightOnboardingStep = new SwipeRightOnboardingStep(shouldBeVisible, timeEntriesCountSubject.AsObservable())
                                       .ToDismissable(nameof(SwipeRightOnboardingStep), ViewModel.OnboardingStorage);
            swipeRightOnboardingStep.DismissByTapping(swipeRightPopup, () =>
            {
                if (swipeRightOnboardingAnimationStepDisposable != null)
                {
                    swipeRightOnboardingAnimationStepDisposable.Dispose();
                    swipeRightOnboardingAnimationStepDisposable = null;
                }
            });

            swipeToContinueWasUsedDisposable = mainRecyclerAdapter.ContinueTimeEntry
                                               .Subscribe(_ =>
            {
                swipeRightOnboardingStep.Dismiss();
                swipeToContinueWasUsedDisposable.Dispose();
                swipeToContinueWasUsedDisposable = null;
            });

            showSwipeRightOnboardingStep
            .Where(shouldShowStep => shouldShowStep)
            .Select(_ => findEarliestTimeEntryView())
            .DistinctUntilChanged()
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(updateSwipeRightOnboardingStep)
            .DisposedBy(DisposeBag);
        }
Exemplo n.º 12
0
 private ClusterHealthStore()
 {
     currentStateSubject    = new BehaviorSubject <string>(null);
     CurrentStateObservable = currentStateSubject
                              .AsObservable();
     //.DistinctUntilChanged()
     //.Throttle(TimeSpan.FromMilliseconds(500));
 }
Exemplo n.º 13
0
        private (ISubject <bool>, IObservable <bool>) prepareSubjectAndObservable(string key)
        {
            var initialValue = keyValueStorage.GetBool(key);
            var subject      = new BehaviorSubject <bool>(initialValue);
            var observable   = subject.AsObservable().DistinctUntilChanged();

            return(subject, observable);
        }
Exemplo n.º 14
0
        public ServiceControl(IBlobCache cache, string url = null)
        {
            this.cache = cache;
            subject = new BehaviorSubject<Unit>(Unit.Default);
            isValid = new BehaviorSubject<bool>(false);
            IsValid = isValid.AsObservable();

            UpdateUrl(url ?? "http://localhost:33333/api").Wait();
        }
        internal HttpParserDelegate(HttpRequestResponse requestResponse)
        {
            RequestResponse = requestResponse;

            var parserStateSubject = new BehaviorSubject <ParserState>(ParserState.Start);

            _observerParserState       = parserStateSubject.AsObserver();
            ParserCompletionObservable = parserStateSubject.AsObservable();
        }
Exemplo n.º 16
0
        public RxAction(Func <TInput, IObservable <TElement> > workFactory, IObservable <bool> enabledIf)
        {
            this.workFactory = workFactory;

            DisposeBag = new CompositeDisposable();
            Inputs     = new Subject <TInput>();

            var enabledSubject = new BehaviorSubject <bool>(false);

            Enabled = enabledSubject.AsObservable();

            var errorsSubject = new Subject <Exception>();

            Errors = errorsSubject.AsObservable();

            executionObservables = Inputs
                                   .WithLatestFrom(Enabled, (i, e) => (input: i, enabled: e))
                                   .SelectMany(tuple =>
            {
                var enabled = tuple.enabled;
                var input   = tuple.input;

                if (enabled)
                {
                    var ob = workFactory(input)
                             .Do(CommonFunctions.DoNothing, error => errorsSubject.OnNext(error))
                             .Replay(1).RefCount();

                    return(Observable.Return(ob));
                }
                else
                {
                    errorsSubject.OnNext(new RxActionNotEnabledException());
                    return(Observable.Empty <IObservable <TElement> >());
                }
            })
                                   .Share();

            Elements = executionObservables
                       .SelectMany(observable => observable.OnErrorResumeNext(Observable.Empty <TElement>()));

            Executing = executionObservables
                        .SelectMany(exec =>
            {
                var execution = exec
                                .SelectMany(_ => Observable.Empty <bool>())
                                .OnErrorResumeNext(Observable.Empty <bool>());

                return(Observable.Concat(Observable.Return(true), execution, Observable.Return(false)));
            })
                        .StartWith(false)
                        .Replay(1).RefCount();

            Observable.CombineLatest(Executing, enabledIf, (executing, enabled) => !executing && enabled)
            .Subscribe(enabledSubject)
            .DisposedBy(DisposeBag);
        }
Exemplo n.º 17
0
        public FootballPlayer(string name)
        {
            var includeChanged = new BehaviorSubject <bool>(false);

            Name            = name;
            IncludeCommand  = new Command(() => includeChanged.OnNext(true));
            ExcludeCommand  = new Command(() => includeChanged.OnNext(false));
            IncludedChanged = includeChanged.AsObservable();
        }
Exemplo n.º 18
0
        public MainWindowViewModel()
        {
            var viewmodel = new BehaviorSubject <ViewModelBase>(new LoginViewModel());

            this.Current = viewmodel.AsObservable();
            //viewmodel.ToProperty(this, x => x.Current);

            var preparing = new Subject <bool>();

            viewmodel.AsObservable()
            .OfType <LoginViewModel>()
            .Select(vm => vm.WhenAnyObservable(x => x.SelectedProfile.Login))
            .Switch()
            .Subscribe(session =>
            {
                foreach (var node in Nodes)
                {
                    if (!session.Tox.Bootstrap(node, out _))
                    {
                        throw new Exception();
                    }
                }

                session.Tox.Start();
                preparing.OnNext(true);
                session.Tox.Events()
                .ConnectionStatus
                .Where(x => x.Status != ToxConnectionStatus.None)
                .Take(1)
                .Do(_ => preparing.OnNext(false))
                .Select(_ => (ViewModelBase) new ActiveProfileViewModel(session))
                .Subscribe(viewmodel);
            });

            viewmodel.AsObservable()
            .OfType <ActiveProfileViewModel>()
            .Select(x => x.Logout)
            .Switch()
            .Select(_ => (ViewModelBase) new LoginViewModel())
            .Subscribe(viewmodel);
        }
Exemplo n.º 19
0
        private CentralManager()
        {
            @delegate = new CentralManagerDelegate();
            central   = new CBCentralManager(@delegate, new DispatchQueue("Dandy.Devices.BLE.Mac.CentralManager"));
            var isScanningSubject = new BehaviorSubject <bool>(central.IsScanning);

            isScanningObserver = central.AddObserver("isScanning", NSKeyValueObservingOptions.New, change => {
                var value = ((NSNumber)change.NewValue).BoolValue;
                isScanningSubject.OnNext(value);
            });
            isScanningObservable = isScanningSubject.AsObservable();
        }
Exemplo n.º 20
0
        public DialogService(IConcurrencyService concurrencyService)
        {
            mConcurrencyService = concurrencyService;

            var dialogViewModelSubject = new BehaviorSubject <object>(null);

            mPushDialogViewModel = dialogViewModelSubject.OnNext;

            mDialogActivationDisposable = new SerialDisposable();
            WhenDialogViewModelChanges  = dialogViewModelSubject.AsObservable()
                                          .Do(vm => mDialogActivationDisposable.Disposable = (vm as IActivatableViewModel)?.Activator.Activate());
        }
Exemplo n.º 21
0
        public StateMachineOrchestrator(IStateMachine stateMachine, StateMachineEntryPoints entryPoints)
        {
            Ensure.Argument.IsNotNull(stateMachine, nameof(stateMachine));
            Ensure.Argument.IsNotNull(entryPoints, nameof(entryPoints));

            this.stateMachine      = stateMachine;
            this.entryPoints       = entryPoints;
            StateObservable        = stateEntered.AsObservable();
            SyncCompleteObservable = syncComplete.AsObservable();

            stateMachine.StateTransitions.Subscribe(onStateEvent);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StoreSearchViewModel"/> class.
        /// </summary>
        /// <param name="popupViewStackService">The popup view stack service.</param>
        /// <param name="storeService">The store service.</param>
        /// <param name="notificationManager">The notification manager.</param>
        public StoreSearchViewModel(
            IPopupViewStackService popupViewStackService,
            IStoreService storeService,
            INotificationManager notificationManager)
            : base(popupViewStackService)
        {
            _popupViewStackService = popupViewStackService;
            _storeService          = storeService;
            _notificationManager   = notificationManager;

            _filterFunction.DisposeWith(Subscriptions);

            _storeService
            .Stores
            .Connect()
            .RefCount()
            .Filter(_filterFunction.AsObservable())
            .Transform(x => new StoreCardViewModel(x))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _stores)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(Subscriptions);

            _storeService
            .Metadata
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _storeNames)
            .DisposeMany()
            .Subscribe()
            .DisposeWith(Subscriptions);

            var isLoading =
                this.WhenAnyObservable(
                    x => x.Search.IsExecuting,
                    x => x.InitializeData.IsExecuting,
                    x => x.Details.IsExecuting,
                    x => x.Category.IsExecuting,
                    (search, initialize, details, category) =>
                    search || initialize || details || category);

            isLoading
            .ToProperty(this, nameof(IsLoading), out _isLoading, deferSubscription: true)
            .DisposeWith(Subscriptions);

            var canExecute = isLoading.Select(x => !x).StartWith(true);

            Search         = ReactiveCommand.CreateFromObservable(ExecuteSearch, canExecute);
            Details        = ReactiveCommand.CreateFromObservable <StoreCardViewModel, Unit>(ExecuteDetails);
            InitializeData = ReactiveCommand.CreateFromObservable(ExecuteInitializeData);
            Category       = ReactiveCommand.CreateFromObservable <string, Unit>(ExecuteCategory, canExecute);
        }
Exemplo n.º 23
0
        public TimeEntriesDataSource(IIdProvider idProvider, IRepository <IDatabaseTimeEntry> repository)
        {
            Ensure.Argument.IsNotNull(repository, nameof(repository));

            this.repository = repository;
            this.idProvider = idProvider;

            CurrentlyRunningTimeEntry = currentTimeEntrySubject.AsObservable().DistinctUntilChanged();

            repository
            .GetAll(te => te.Stop == null)
            .Subscribe(onRunningTimeEntry);
        }
Exemplo n.º 24
0
            public async Task UpdatesWhenTheTimeEntriesSourcesCurrentlyRunningTimeEntryEmitsANewTimeEntry()
            {
                var timeEntry = new TimeEntry();
                var subject   = new BehaviorSubject <ITimeEntry>(null);

                DataSource.TimeEntries.CurrentlyRunningTimeEntry.Returns(subject.AsObservable());

                await ViewModel.Initialize();

                subject.OnNext(timeEntry);

                ViewModel.CurrentlyRunningTimeEntry.Should().Be(timeEntry);
            }
Exemplo n.º 25
0
            public async Task UpdatesWhenTheTimeEntriesSourcesCurrentlyRunningTimeEntryEmitsANewTimeEntry()
            {
                var timeEntry = TimeEntry.Builder.Create(13).SetStart(DateTimeOffset.Now).SetDescription("").Build();
                var subject   = new BehaviorSubject <IDatabaseTimeEntry>(null);

                DataSource.TimeEntries.CurrentlyRunningTimeEntry.Returns(subject.AsObservable());

                await ViewModel.Initialize();

                subject.OnNext(timeEntry);

                ViewModel.CurrentlyRunningTimeEntry.Should().Be(timeEntry);
            }
Exemplo n.º 26
0
        public ReactiveAsyncAgent(
            TState initialState,
            Func <TState, TMessage, CancellationToken, Task <TState> > messageHandler,
            Func <Exception, CancellationToken, Task <bool> > errorHandler)
        {
            if (initialState == null)
            {
                throw new ArgumentNullException(nameof(initialState));
            }

            if (messageHandler == null)
            {
                throw new ArgumentNullException(nameof(messageHandler));
            }

            if (errorHandler == null)
            {
                throw new ArgumentNullException(nameof(errorHandler));
            }

            _stateSubject = new BehaviorSubject <TState>(initialState);
            _asyncAgent   = new AsyncAgent <TState, TMessage>(
                initialState: initialState,
                messageHandler: async(state, msg, ct) =>
            {
                TState newState = state;

                newState = await messageHandler(state, msg, ct);

                if (!ct.IsCancellationRequested)
                {
                    _stateSubject.OnNext(newState);
                }

                return(newState);
            },
                errorHandler: async(ex, ct) =>
            {
                bool shouldContinue = false;
                shouldContinue      = await errorHandler(ex, ct);

                if (!shouldContinue && !ct.IsCancellationRequested)
                {
                    _stateSubject.OnError(ex);
                }

                return(shouldContinue);
            });

            State = _stateSubject.AsObservable();
        }
Exemplo n.º 27
0
        public LogFilterService()
        {
            _filter  = new BehaviorSubject <Func <LogEvent, bool> >(LogFilter.PassAll);
            _filters = new ObservableCowList <IObservable <Func <LogEvent, bool> > >();

            _filters
            .AsItemsBehaviorObservable()
            .Select(items => items.CombineLatest(CombineFilters))
            .Switch()
            .DistinctUntilChanged()
            .Subscribe(_filter);

            Filter = _filter.AsObservable();
        }
Exemplo n.º 28
0
        public OverlayService(IStatisticProvider statisticProvider,
                              ISensorService sensorService,
                              IOverlayEntryProvider overlayEntryProvider,
                              IAppConfiguration appConfiguration,
                              ILogger <OverlayService> logger,
                              IRecordManager recordManager,
                              IRTSSService rTSSService)
        {
            _statisticProvider    = statisticProvider;
            _overlayEntryProvider = overlayEntryProvider;
            _appConfiguration     = appConfiguration;
            _logger                 = logger;
            _recordManager          = recordManager;
            _rTSSService            = rTSSService;
            _numberOfRuns           = _appConfiguration.SelectedHistoryRuns;
            SecondMetric            = _appConfiguration.SecondMetricOverlay;
            ThirdMetric             = _appConfiguration.ThirdMetricOverlay;
            IsOverlayActiveStream   = new BehaviorSubject <bool>(_appConfiguration.IsOverlayActive);
            _runHistoryOutlierFlags = Enumerable.Repeat(false, _numberOfRuns).ToArray();

            _logger.LogDebug("{componentName} Ready", this.GetType().Name);

            IsOverlayActiveStream.AsObservable()
            .Select(isActive =>
            {
                if (isActive)
                {
                    _rTSSService.ResetOSD();
                    return(sensorService.OnDictionaryUpdated
                           .SelectMany(_ => _overlayEntryProvider.GetOverlayEntries()));
                }
                else
                {
                    _rTSSService.ReleaseOSD();
                    return(Observable.Empty <IOverlayEntry[]>());
                }
            }).Switch()
            .Subscribe(entries =>
            {
                _rTSSService.SetOverlayEntries(entries);
                _rTSSService.CheckRTSSRunningAndRefresh();
            });

            _runHistory = Enumerable.Repeat("N/A", _numberOfRuns).ToList();
            _rTSSService.SetRunHistory(_runHistory.ToArray());
            _rTSSService.SetRunHistoryAggregation(string.Empty);
            _rTSSService.SetRunHistoryOutlierFlags(_runHistoryOutlierFlags);
            _rTSSService.SetIsCaptureTimerActive(false);
        }
Exemplo n.º 29
0
            public void UnsubscribesFromTheTheRunningTimeEntryObservable()
            {
                var now = new DateTimeOffset(2018, 02, 20, 0, 0, 0, TimeSpan.Zero);
                var runningTEParameter = DurationParameter.WithStartAndDuration(parameter.Start, null);
                var subject            = new BehaviorSubject <DateTimeOffset>(now);
                var observable         = subject.AsObservable().Publish();

                ViewModel.Prepare(new EditDurationParameters(runningTEParameter));
                TimeService.CurrentDateTime.Returns(now);
                TimeService.CurrentDateTimeObservable.Returns(observable);

                ViewModel.EditStopTimeCommand.Execute();
                subject.OnNext(now.AddSeconds(1));

                ViewModel.StopTime.Should().Be(now);
            }
Exemplo n.º 30
0
            private async Task prepare()
            {
                var timeEntry = Substitute.For <IDatabaseTimeEntry>();

                timeEntry.Id.Returns(TimeEntryId);
                timeEntry.Description.Returns(Description);
                timeEntry.Project.Name.Returns(Project);
                timeEntry.Project.Color.Returns(ProjectColor);
                timeEntry.Task.Name.Returns(Task);
                timeEntry.Project.Client.Name.Returns(Client);

                DataSource.TimeEntries.CurrentlyRunningTimeEntry.Returns(currentTimeEntrySubject.AsObservable());

                await ViewModel.Initialize();

                currentTimeEntrySubject.OnNext(timeEntry);
            }
Exemplo n.º 31
0
            private async ThreadingTask prepare()
            {
                var timeEntry = Substitute.For <IDatabaseTimeEntry>();

                timeEntry.Id.Returns(TimeEntryId);
                timeEntry.Description.Returns(Description);
                timeEntry.Project.Name.Returns(Project);
                timeEntry.Project.Color.Returns(ProjectColor);
                timeEntry.Task.Name.Returns(Task);
                timeEntry.Project.Client.Name.Returns(Client);

                DataSource.TimeEntries.CurrentlyRunningTimeEntry.Returns(currentTimeEntrySubject.AsObservable());

                await ViewModel.Initialize();

                currentTimeEntrySubject.OnNext(timeEntry);
                Scheduler.AdvanceBy(TimeSpan.FromMilliseconds(50).Ticks);
            }