Exemplo n.º 1
0
        public ImageProvider(
            [NotNull] IMicrophoneControllerEx microphoneController,
            [NotNull] IConfigProvider <MicSwitchOverlayConfig> configProvider,
            [NotNull][Dependency(WellKnownSchedulers.UI)] IScheduler uiScheduler)
        {
            Observable.Merge(
                microphoneController.WhenAnyValue(x => x.Mute).ToUnit(),
                this.WhenAnyValue(x => x.StreamingMicrophoneImage).ToUnit(),
                this.WhenAnyValue(x => x.MutedMicrophoneImage).ToUnit())
            .ObserveOn(uiScheduler)
            .Select(x => microphoneController.Mute ?? false ? mutedMicrophoneImage : streamingMicrophoneImage)
            .SubscribeSafe(x => MicrophoneImage = x, Log.HandleUiException)
            .AddTo(Anchors);

            this.WhenAnyValue(x => x.MicrophoneImage)
            .Select(x => x as BitmapSource)
            .SelectSafeOrDefault(x => x == null ? default : Icon.FromHandle(x.ToBitmap().GetHicon()))
            .DisposePrevious()
            .SubscribeSafe(x => MicrophoneImageAsIcon = x, Log.HandleUiException)
            .AddTo(Anchors);

            configProvider.ListenTo(x => x.MicrophoneIcon)
            .ObserveOn(uiScheduler)
            .SelectSafeOrDefault(x => x.ToBitmapImage())
            .SubscribeSafe(x => StreamingMicrophoneImage = x ?? defaultMicrophoneImage, Log.HandleUiException)
            .AddTo(Anchors);

            configProvider.ListenTo(x => x.MutedMicrophoneIcon)
            .ObserveOn(uiScheduler)
            .SelectSafeOrDefault(x => x.ToBitmapImage())
            .SubscribeSafe(x => MutedMicrophoneImage = x ?? defaultMutedMicrophoneImage, Log.HandleUiException)
            .AddTo(Anchors);
        }
Exemplo n.º 2
0
        public ImageProvider(
            [NotNull] IMicrophoneControllerEx microphoneController,
            [NotNull] IConfigProvider <MicSwitchConfig> configProvider,
            [NotNull][Dependency(WellKnownSchedulers.UI)] IScheduler uiScheduler)
        {
            this.microphoneController = microphoneController;

            configProvider.ListenTo(x => x.MicrophoneLineId)
            .ObserveOn(uiScheduler)
            .Subscribe(lineId => microphoneController.LineId = lineId)
            .AddTo(Anchors);

            Observable.Merge(
                microphoneController.WhenAnyValue(x => x.Mute).ToUnit(),
                this.WhenAnyValue(x => x.MicrophoneImage).ToUnit(),
                this.WhenAnyValue(x => x.MutedMicrophoneImage).ToUnit()
                )
            .ObserveOn(uiScheduler)
            .Subscribe(() => RaisePropertyChanged(nameof(ActiveMicrophoneImage)))
            .AddTo(Anchors);

            configProvider.ListenTo(x => x.MicrophoneIcon)
            .ObserveOn(uiScheduler)
            .SelectSafeOrDefault(x => x.ToBitmapImage())
            .Subscribe(x => MicrophoneImage = x ?? defaultMicrophoneImage)
            .AddTo(Anchors);

            configProvider.ListenTo(x => x.MutedMicrophoneIcon)
            .ObserveOn(uiScheduler)
            .SelectSafeOrDefault(x => x.ToBitmapImage())
            .Subscribe(x => MutedMicrophoneImage = x ?? defaultMutedMicrophoneImage)
            .AddTo(Anchors);
        }