private async Task PlaySongInternal(SongRequestItem item)
        {
            if (item != null)
            {
                if (item.Type == SongRequestServiceTypeEnum.Spotify)
                {
                    if (ChannelSession.Services.Spotify != null)
                    {
                        SpotifySong song = await ChannelSession.Services.Spotify.GetSong(item.ID);

                        if (song != null)
                        {
                            await ChannelSession.Services.Spotify.PlaySong(song);

                            this.currentSong = item;
                        }
                    }
                }
                else if (item.Type == SongRequestServiceTypeEnum.YouTube)
                {
                    IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(ChannelSession.Services.OverlayServers.DefaultOverlayName);
                    if (overlay != null)
                    {
                        await overlay.SendSongRequest(new OverlaySongRequest()
                        {
                            Type = SongRequestServiceTypeEnum.YouTube.ToString(), Action = "song", Source = item.ID, Volume = ChannelSession.Settings.SongRequestVolume
                        });

                        this.currentSong = item;
                    }
                }
            }
        }
Beispiel #2
0
        public StateViewModel(IRecordDirectoryObserver recordObserver,
                              IEventAggregator eventAggregator,
                              IAppConfiguration appConfiguration,
                              ICaptureService captureService,
                              IOverlayService overlayService,
                              IUpdateCheck updateCheck,
                              IAppVersionProvider appVersionProvider,
                              IWebVersionProvider webVersionProvider,
                              LoginManager loginManager,
                              IRTSSService rTSSService,
                              ILogger <StateViewModel> logger)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            _recordObserver     = recordObserver;
            _eventAggregator    = eventAggregator;
            _appConfiguration   = appConfiguration;
            _captureService     = captureService;
            _overlayService     = overlayService;
            _updateCheck        = updateCheck;
            _appVersionProvider = appVersionProvider;
            _logger             = logger;

            IsCaptureModeActive = false;
            IsOverlayActive     = _appConfiguration.IsOverlayActive && rTSSService.IsRTSSInstalled();

            _captureService.IsCaptureModeActiveStream
            .Subscribe(state => IsCaptureModeActive = state);

            _captureService.IsLoggingActiveStream
            .Subscribe(state => IsLoggingActive = state);

            _overlayService.IsOverlayActiveStream
            .Subscribe(state => IsOverlayActive = state);

            IsLoggedIn = loginManager.State.Token != null;

            _eventAggregator.GetEvent <PubSubEvent <AppMessages.LoginState> >().Subscribe(state =>
            {
                IsLoggedIn = state.IsLoggedIn;
                RaisePropertyChanged(nameof(IsLoggedIn));
            });


            Task.Run(async() =>
            {
                var(updateAvailable, updateVersion) = await _updateCheck.IsUpdateAvailable();
                Dispatcher.CurrentDispatcher.Invoke(() =>
                {
                    IsUpdateAvailable   = updateAvailable;
                    UpdateHyperlinkText = $"New version available on GitHub: v{updateVersion}";
                    RaisePropertyChanged(nameof(IsUpdateAvailable));
                });
            });

            stopwatch.Stop();
            _logger.LogInformation(this.GetType().Name + " {initializationTime}s initialization time", Math.Round(stopwatch.ElapsedMilliseconds * 1E-03, 1));
        }
Beispiel #3
0
 public SelectProfileBubble(IOverlayService overlayService)
 {
     BackgroundColor = "DarkGrey";
     Name            = "Select profile";
     Icon            = "mdi-arrow-left-right";
     _overlayService = overlayService;
 }
 public ErrorMessageViewModel(IEventAggregator eventAggregator, IOverlayService overlayService)
 {
     _eventAggregator = eventAggregator;
     _overlayService  = overlayService;
     _eventAggregator.GetEvent <UpdateErrorView>().Subscribe(OnUpdateErrorView);
     CloseCommand = new DelegateCommand(() => _overlayService.RemoveOverlay());
 }
Beispiel #5
0
        public StateViewModel(IRecordDirectoryObserver recordObserver,
                              IEventAggregator eventAggregator,
                              IAppConfiguration appConfiguration,
                              ICaptureService captureService,
                              IOverlayService overlayService,
                              IUpdateCheck updateCheck,
                              IAppVersionProvider appVersionProvider,
                              IWebVersionProvider webVersionProvider)
        {
            _recordObserver      = recordObserver;
            _eventAggregator     = eventAggregator;
            _appConfiguration    = appConfiguration;
            _captureService      = captureService;
            _overlayService      = overlayService;
            _updateCheck         = updateCheck;
            _appVersionProvider  = appVersionProvider;
            IsDirectoryObserving = true;
            IsCaptureModeActive  = false;
            IsOverlayActive      = _appConfiguration.IsOverlayActive && !string.IsNullOrEmpty(RTSSUtils.GetRTSSFullPath());

            UpdateHyperlinkText = $"New version available on GitHub: v{webVersionProvider.GetWebVersion()}";

            _recordObserver.HasValidSourceStream
            .Subscribe(state => IsDirectoryObserving = state);

            _captureService.IsCaptureModeActiveStream
            .Subscribe(state => IsCaptureModeActive = state);

            _overlayService.IsOverlayActiveStream
            .Subscribe(state => IsOverlayActive = state);
        }
 public SelectEntitiesBubble(IOverlayService overlayService)
 {
     BackgroundColor = "DarkGrey";
     Name            = "Select entities";
     Icon            = "mdi-plus";
     _overlayService = overlayService;
 }
Beispiel #7
0
        /// <summary>
        /// Creates an instance of the chat room view model and resolves its dependencies
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="networkConnectionController"></param>
        /// <param name="currentUser"></param>
        /// <param name="chatManager"></param>
        /// <param name="regionManager"></param>
        /// <param name="overlayService"></param>
        public ChatRoomViewModel(IEventAggregator eventAggregator, INetworkConnectionController networkConnectionController, ICurrentUser currentUser, IChatManager chatManager, IRegionManager regionManager, IOverlayService overlayService)
        {
            //assigns local variables
            _eventAggregator             = eventAggregator;
            _networkConnectionController = networkConnectionController;
            _currentUser    = currentUser;
            _chatManager    = chatManager;
            _regionManager  = regionManager;
            _overlayService = overlayService;

            _eventAggregator.GetEvent <UserLoginEvent>().Subscribe(UserLogin);
            _eventAggregator.GetEvent <OfflineUsersLoadedEvent>().Subscribe(() => IsConnectAllowed = true);
            _eventAggregator.GetEvent <UserEditedEvent>().Subscribe((user) => User = user);

            //Sets up the basic server settings
            ServerModel              = new ServerModel();
            ServerModel.IpAddress    = "192.168.1.97";
            ServerModel.Port         = 2500;
            ServerModel.ServerStatus = ServerStatus.Disconnected;

            //Sets up command executions
            ServerConnectCommand      = new DelegateCommand(Connect);
            ToggleBaseCommand         = new DelegateCommand <object>(ToggleBaseColor);
            CurrentUserClickedCommand = new DelegateCommand(CurrentUserClicked);
            LogoutCommand             = new DelegateCommand(Logout);
        }
        public async Task HideItem()
        {
            IOverlayService overlay = this.GetOverlay();

            if (overlay != null)
            {
                await overlay.HideItem(this.Item);
            }
        }
        public async Task UpdateItem(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers)
        {
            IOverlayService overlay = this.GetOverlay();

            if (overlay != null)
            {
                await overlay.UpdateItem(this.Item, user, arguments, extraSpecialIdentifiers);
            }
        }
        public MainViewModel(IDiagnosticsViewModel diagnosticsViewModel,
                             ITabularDataService tabularDataService,
                             IColumnsService columnsService,
                             IOverlayService overlayService,
                             IDateTimeService dateTimeService,
                             ISchedulerService schedulerService)
        {
            _tabularDataService = tabularDataService;
            _schedulerService   = schedulerService;
            _columnsService     = columnsService;
            _overlayService     = overlayService;
            _dateTimeService    = dateTimeService;
            Diagnostics         = diagnosticsViewModel;

            _dataIds        = new Dictionary <object, DynamicDataViewModel>(1000);
            _data           = new CustomTypeRangeObservableCollection <DynamicDataViewModel>();
            _collectionView = new ListCollectionView(_data)
            {
                Filter = FilterData
            };

            _updateStats = new Dictionary <long, int>();

            RefreshCommand = ReactiveCommand.Create()
                             .DisposeWith(this);

            ClearCommand = ReactiveCommand.Create()
                           .DisposeWith(this);

            ColumnPickerCommand = ReactiveCommand.Create(HasDataChanged)
                                  .DisposeWith(this);

            _dataStream = InitialiseAndProcessDataAsync()
                          .DisposeWith(this);

            RefreshCommand.Subscribe(x => Refresh())
            .DisposeWith(this);

            ClearCommand.Subscribe(x => Clear())
            .DisposeWith(this);

            ColumnPickerCommand.Subscribe(x => ShowColumnPicker())
            .DisposeWith(this);

            _suspendNotifications = new SerialDisposable()
                                    .DisposeWith(this);

            FilterChanged.Subscribe(x => _collectionView.Refresh())
            .DisposeWith(this);

            ColumnsChanged.ObserveOn(schedulerService.Dispatcher)
            .Subscribe(x => OnPropertyChanged(nameof(VisibleColumns)))
            .DisposeWith(this);

            Disposable.Create(() => Clear())
            .DisposeWith(this);
        }
        private async Task HideWidget(OverlayWidget widget)
        {
            IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(widget.OverlayName);

            if (overlay != null)
            {
                await overlay.RemoveItem(widget.Item);
            }
        }
Beispiel #12
0
        /// <summary>
        ///  Called when it is time for the tab order UI to go away.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (region != null)
                {
                    region.Dispose();
                    region = null;
                }

                if (host != null)
                {
                    IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService));
                    if (os != null)
                    {
                        os.RemoveOverlay(this);
                    }

                    IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));
                    if (ehs != null)
                    {
                        ehs.PopHandler(this);
                    }

                    IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));
                    if (mcs != null)
                    {
                        foreach (MenuCommand mc in newCommands)
                        {
                            mcs.RemoveCommand(mc);
                        }
                    }

                    // We sync add, remove and change events so we remain in sync with any nastiness that the
                    // form may pull on us.
                    //
                    IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
                    if (cs != null)
                    {
                        cs.ComponentAdded   -= new ComponentEventHandler(OnComponentAddRemove);
                        cs.ComponentRemoved -= new ComponentEventHandler(OnComponentAddRemove);
                        cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged);
                    }

                    IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService));
                    if (hs != null)
                    {
                        hs.RemoveContextAttribute("Keyword", "TabOrderView");
                    }

                    host = null;
                }
            }

            base.Dispose(disposing);
        }
Beispiel #13
0
        public async Task RemoveOverlay(string name)
        {
            IOverlayService overlay = this.GetOverlay(name);
            if (overlay != null)
            {
                overlay.OnWebSocketConnectedOccurred -= Overlay_OnWebSocketConnectedOccurred;
                overlay.OnWebSocketDisconnectedOccurred -= Overlay_OnWebSocketDisconnectedOccurred;

                await overlay.Disconnect();
                this.overlays.Remove(name);
            }
        }
Beispiel #14
0
 public LoginViewModel(IRegionManager regionManager, IPasswordProtectionService passwordProtectionService, IEventAggregator eventAggregator, INetworkConnectionController networkConnectionController, ICurrentUser currentUser, IOverlayService overlayService)
 {
     _regionManager               = regionManager;
     _passwordProtectionService   = passwordProtectionService;
     _eventAggregator             = eventAggregator;
     _networkConnectionController = networkConnectionController;
     _currentUser           = currentUser;
     _overlayService        = overlayService;
     PasswordChangedCommand = new DelegateCommand <object>(PasswordChanged);
     LoginCommand           = new DelegateCommand(Login);
     RegisterCommand        = new DelegateCommand(Register);
 }
        private async Task PlayPauseOverlaySong(SongRequestServiceTypeEnum type)
        {
            IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(ChannelSession.Services.OverlayServers.DefaultOverlayName);

            if (overlay != null)
            {
                await overlay.SendSongRequest(new OverlaySongRequest()
                {
                    Type = type.ToString(), Action = "playpause", Volume = ChannelSession.Settings.SongRequestVolume
                });
            }
        }
        private async Task SkipToNextSongInternal()
        {
            if (this.allRequests.Count > 0 && this.allRequests.First().Equals(this.currentSong))
            {
                this.allRequests.RemoveAt(0);
            }
            else if (this.playlistItems.Count > 0 && this.playlistItems.First().Equals(this.currentSong))
            {
                this.playlistItems.RemoveAt(0);
            }

            if (this.currentSong != null)
            {
                if (this.currentSong.Type == SongRequestServiceTypeEnum.Spotify)
                {
                    await ChannelSession.Services.Spotify.PauseCurrentlyPlaying();

                    this.spotifyStatus = null;
                }
                else if (this.currentSong.Type == SongRequestServiceTypeEnum.YouTube)
                {
                    IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(ChannelSession.Services.OverlayServers.DefaultOverlayName);
                    if (overlay != null)
                    {
                        await overlay.SendSongRequest(new OverlaySongRequest()
                        {
                            Type = SongRequestServiceTypeEnum.YouTube.ToString(), Action = "stop", Volume = ChannelSession.Settings.SongRequestVolume
                        });

                        this.youTubeStatus = null;
                    }
                }
                this.currentSong.State = SongRequestStateEnum.Ended;
                this.currentSong       = null;
            }

            SongRequestItem newSong = null;

            if (this.allRequests.Count > 0)
            {
                newSong = this.allRequests.First();
            }
            else if (this.playlistItems.Count > 0)
            {
                newSong = this.playlistItems.First();
            }

            if (newSong != null)
            {
                await this.PlaySongInternal(newSong);
            }
        }
Beispiel #17
0
 public RegisterViewModel(IFileProcessorService fileProcessorService, IRegionManager regionManager, IPasswordProtectionService passwordProtectionService, IOverlayService overlayService)
 {
     _fileProcessorService      = fileProcessorService;
     _regionManager             = regionManager;
     _passwordProtectionService = passwordProtectionService;
     _overlayService            = overlayService;
     SelectImageCommand         = new DelegateCommand(SelectImage);
     PasswordChangedCommand     = new DelegateCommand <object>(PasswordChanged);
     RePasswordChangedCommand   = new DelegateCommand <object>(RePasswordChanged);
     LoginCommand    = new DelegateCommand(() => _regionManager.RequestNavigate(RegionNames.MainRegion, nameof(LoginView)));
     RegisterCommand = new DelegateCommand(Register);
     User            = new SocketUser();
 }
        private async Task WidgetsBackgroundUpdate()
        {
            await BackgroundTaskWrapper.RunBackgroundTask(this.backgroundThreadCancellationTokenSource, async (tokenSource) =>
            {
                tokenSource.Token.ThrowIfCancellationRequested();

                UserViewModel user = await ChannelSession.GetCurrentUser();

                foreach (var widgetGroup in ChannelSession.Settings.OverlayWidgets.GroupBy(ow => ow.OverlayName))
                {
                    IOverlayService overlay = this.GetOverlay(widgetGroup.Key);
                    if (overlay != null)
                    {
                        overlay.StartBatching();
                        foreach (OverlayWidget widget in widgetGroup)
                        {
                            try
                            {
                                if (widget.IsEnabled)
                                {
                                    bool isInitialized = widget.Item.IsInitialized;

                                    if (!isInitialized)
                                    {
                                        await widget.Item.Initialize();
                                    }

                                    if (!isInitialized || !widget.DontRefresh)
                                    {
                                        OverlayItemBase item = await widget.Item.GetProcessedItem(user, new List <string>(), new Dictionary <string, string>());
                                        if (item != null)
                                        {
                                            await overlay.SendItem(item, widget.Position, new OverlayItemEffects());
                                        }
                                    }
                                }
                                else
                                {
                                    await widget.Item.Disable();
                                }
                            }
                            catch (Exception ex) { Logger.Log(ex); }
                        }
                        await overlay.EndBatching();
                    }
                }

                await Task.Delay(ChannelSession.Settings.OverlayWidgetRefreshTime * 1000);
            });
        }
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(ChannelSession.Services.OverlayServers.DefaultOverlayName);

            if (overlay != null)
            {
                string message = await this.ReplaceStringWithSpecialModifiers(this.SpeechText, user, arguments);

                await overlay.SendTextToSpeech(new OverlayTextToSpeech()
                {
                    Text = message, Voice = this.Voice, Volume = this.Volume, Pitch = this.Pitch, Rate = this.Rate
                });
            }
        }
Beispiel #20
0
        public ChromeViewModel(IStartWindowViewModel main, IOverlayService overlayService)
        {
            Main = main;

            overlayService.Show
            .Subscribe(UpdateOverlay)
            .DisposeWith(this);

            CloseOverlayCommand = ReactiveCommand <object> .Create()
                                  .DisposeWith(this);

            CloseOverlayCommand.Subscribe(x => ClearOverlay())
            .DisposeWith(this);
        }
        public StateViewModel(IRecordDirectoryObserver recordObserver,
                              IEventAggregator eventAggregator,
                              IAppConfiguration appConfiguration,
                              ICaptureService captureService,
                              IOverlayService overlayService,
                              IUpdateCheck updateCheck,
                              IAppVersionProvider appVersionProvider,
                              IWebVersionProvider webVersionProvider,
                              LoginManager loginManager,
                              IRTSSService rTSSService)
        {
            _recordObserver     = recordObserver;
            _eventAggregator    = eventAggregator;
            _appConfiguration   = appConfiguration;
            _captureService     = captureService;
            _overlayService     = overlayService;
            _updateCheck        = updateCheck;
            _appVersionProvider = appVersionProvider;
            IsCaptureModeActive = false;
            IsOverlayActive     = _appConfiguration.IsOverlayActive && rTSSService.IsRTSSInstalled();

            _captureService.IsCaptureModeActiveStream
            .Subscribe(state => IsCaptureModeActive = state);

            _captureService.IsLoggingActiveStream
            .Subscribe(state => IsLoggingActive = state);

            _overlayService.IsOverlayActiveStream
            .Subscribe(state => IsOverlayActive = state);

            IsLoggedIn = loginManager.State.Token != null;

            _eventAggregator.GetEvent <PubSubEvent <AppMessages.LoginState> >().Subscribe(state => {
                IsLoggedIn = state.IsLoggedIn;
                RaisePropertyChanged(nameof(IsLoggedIn));
            });


            Task.Run(async() =>
            {
                var(updateAvailable, updateVersion) = await _updateCheck.IsUpdateAvailable();
                Dispatcher.CurrentDispatcher.Invoke(() =>
                {
                    IsUpdateAvailable   = updateAvailable;
                    UpdateHyperlinkText = $"New version available on GitHub: v{updateVersion}";
                    RaisePropertyChanged(nameof(IsUpdateAvailable));
                });
            });
        }
Beispiel #22
0
        private async Task WidgetsBackgroundUpdate()
        {
            long updateSeconds = 0;
            await BackgroundTaskWrapper.RunBackgroundTask(this.backgroundThreadCancellationTokenSource, async (tokenSource) =>
            {
                tokenSource.Token.ThrowIfCancellationRequested();

                UserViewModel user = await ChannelSession.GetCurrentUser();

                foreach (var widgetGroup in ChannelSession.Settings.OverlayWidgets.GroupBy(ow => ow.OverlayName))
                {
                    IOverlayService overlay = this.GetOverlay(widgetGroup.Key);
                    if (overlay != null)
                    {
                        overlay.StartBatching();
                        foreach (OverlayWidgetModel widget in widgetGroup)
                        {
                            try
                            {
                                if (widget.IsEnabled)
                                {
                                    if (!widget.Item.IsInitialized)
                                    {
                                        await widget.Initialize();
                                    }
                                    else if (widget.SupportsRefreshUpdating && widget.RefreshTime > 0 && (updateSeconds % widget.RefreshTime) == 0)
                                    {
                                        await widget.UpdateItem();
                                    }
                                }
                                else
                                {
                                    if (widget.Item.IsInitialized)
                                    {
                                        await widget.Disable();
                                    }
                                }
                            }
                            catch (Exception ex) { Logger.Log(ex); }
                        }
                        await overlay.EndBatching();
                    }
                }

                await Task.Delay(1000);
                updateSeconds++;
            });
        }
        public SettingsService(IOverlayService overlayService, IJSRuntime jsRuntime)
        {
            var settingsBubble = new SettingsBubble(this);

            _settingsOffDefaultBubbles = new Bubble[] { settingsBubble };
            _settingsOnDefaultBubbles  = new Bubble[]
            {
                new SelectEntitiesBubble(overlayService),
                new ReloadBubble(jsRuntime),
                new SelectProfileBubble(overlayService),
                settingsBubble
            };

            _defaultBubbles    = new BehaviorSubject <IReadOnlyCollection <Bubble> >(_settingsOffDefaultBubbles);
            _areSettingEnabled = new BehaviorSubject <bool>(false);
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.region != null)
         {
             this.region.Dispose();
             this.region = null;
         }
         if (this.host != null)
         {
             IOverlayService service = (IOverlayService)this.host.GetService(typeof(IOverlayService));
             if (service != null)
             {
                 service.RemoveOverlay(this);
             }
             IEventHandlerService service2 = (IEventHandlerService)this.host.GetService(typeof(IEventHandlerService));
             if (service2 != null)
             {
                 service2.PopHandler(this);
             }
             IMenuCommandService service3 = (IMenuCommandService)this.host.GetService(typeof(IMenuCommandService));
             if (service3 != null)
             {
                 foreach (MenuCommand command in this.newCommands)
                 {
                     service3.RemoveCommand(command);
                 }
             }
             IComponentChangeService service4 = (IComponentChangeService)this.host.GetService(typeof(IComponentChangeService));
             if (service4 != null)
             {
                 service4.ComponentAdded   -= new ComponentEventHandler(this.OnComponentAddRemove);
                 service4.ComponentRemoved -= new ComponentEventHandler(this.OnComponentAddRemove);
                 service4.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
             }
             IHelpService service5 = (IHelpService)this.host.GetService(typeof(IHelpService));
             if (service5 != null)
             {
                 service5.RemoveContextAttribute("Keyword", "TabOrderView");
             }
             this.host = null;
         }
     }
     base.Dispose(disposing);
 }
Beispiel #25
0
 public CaptureManager(ICaptureService presentMonCaptureService,
                       ISensorService sensorService,
                       IOverlayService overlayService,
                       SoundManager soundManager,
                       IRecordManager recordManager,
                       ILogger <CaptureManager> logger,
                       IAppConfiguration appConfiguration)
 {
     _presentMonCaptureService = presentMonCaptureService;
     _sensorService            = sensorService;
     _overlayService           = overlayService;
     _soundManager             = soundManager;
     _recordManager            = recordManager;
     _logger           = logger;
     _appConfiguration = appConfiguration;
     _presentMonCaptureService.IsCaptureModeActiveStream.OnNext(false);
 }
        private async Task RefreshVolumeInternal()
        {
            if (ChannelSession.Services.Spotify != null)
            {
                await ChannelSession.Services.Spotify.SetVolume(ChannelSession.Settings.SongRequestVolume);
            }

            IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(ChannelSession.Services.OverlayServers.DefaultOverlayName);

            if (overlay != null)
            {
                await overlay.SendSongRequest(new OverlaySongRequest()
                {
                    Type = SongRequestServiceTypeEnum.YouTube.ToString(), Action = "volume", Volume = ChannelSession.Settings.SongRequestVolume
                });
            }
        }
Beispiel #27
0
        public ChromeViewModel(IMainViewModel main, IOverlayService overlayService)
        {
            Main = main;

            overlayService.Show
            .Subscribe(x => UpdateOverlay(x))
            .DisposeWith(this);

            CloseOverlayCommand = ReactiveCommand <object> .Create()
                                  .DisposeWith(this);

            CloseOverlayCommand.Subscribe(x => ClearOverlay())
            .DisposeWith(this);

            Disposable.Create(() => CloseOverlayCommand = null)
            .DisposeWith(this);
        }
Beispiel #28
0
        private const string ToolboxFormat = ".NET Toolbox Item"; // used to detect if a drag is coming from the toolbox.

        internal BehaviorService(IServiceProvider serviceProvider, Control windowFrame)
        {
            _serviceProvider = serviceProvider;
            _adornerWindow   = new AdornerWindow(this, windowFrame);

            // Use the adornerWindow as an overlay
            IOverlayService os = (IOverlayService)serviceProvider.GetService(typeof(IOverlayService));

            if (os != null)
            {
                AdornerWindowIndex = os.PushOverlay(_adornerWindow);
            }

            _dragEnterReplies = new Hashtable();

            // Start with an empty adorner collection & no behavior on the stack
            Adorners       = new BehaviorServiceAdornerCollection(this);
            _behaviorStack = new ArrayList();

            _hitTestedGlyph     = null;
            _validDragArgs      = null;
            DesignerActionUI    = null;
            _trackMouseEvent    = default;
            _trackingMouseEvent = false;

            // Create out object that will handle all menucommands
            if (serviceProvider.GetService(typeof(IMenuCommandService)) is IMenuCommandService menuCommandService &&
                serviceProvider.GetService(typeof(IDesignerHost)) is IDesignerHost host)
            {
                _menuCommandHandler = new MenuCommandHandler(this, menuCommandService);
                host.RemoveService(typeof(IMenuCommandService));
                host.AddService(typeof(IMenuCommandService), _menuCommandHandler);
            }

            // Default layoutmode is SnapToGrid.
            _useSnapLines     = false;
            _queriedSnapLines = false;

            // Test hooks
            WM_GETALLSNAPLINES    = User32.RegisterWindowMessageW("WM_GETALLSNAPLINES");
            WM_GETRECENTSNAPLINES = User32.RegisterWindowMessageW("WM_GETRECENTSNAPLINES");

            // Listen to the SystemEvents so that we can resync selection based on display settings etc.
            SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(OnUserPreferenceChanged);
        }
 internal ToolStripAdornerWindowService(IServiceProvider serviceProvider, Control windowFrame)
 {
     this.serviceProvider = serviceProvider;
     this.toolStripAdornerWindow = new ToolStripAdornerWindow(windowFrame);
     this.bs = (BehaviorService) serviceProvider.GetService(typeof(BehaviorService));
     int adornerWindowIndex = this.bs.AdornerWindowIndex;
     this.os = (IOverlayService) serviceProvider.GetService(typeof(IOverlayService));
     if (this.os != null)
     {
         this.os.InsertOverlay(this.toolStripAdornerWindow, adornerWindowIndex);
     }
     this.dropDownAdorner = new Adorner();
     int count = this.bs.Adorners.Count;
     if (count > 1)
     {
         this.bs.Adorners.Insert(count - 1, this.dropDownAdorner);
     }
 }
        private async Task <SongRequestItem> GetYouTubeStatus()
        {
            IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(ChannelSession.Services.OverlayServers.DefaultOverlayName);

            if (overlay != null)
            {
                this.youTubeStatus = null;
                await overlay.SendSongRequest(new OverlaySongRequest()
                {
                    Type = SongRequestServiceTypeEnum.YouTube.ToString(), Action = "status"
                });

                for (int i = 0; i < 10 && this.youTubeStatus == null; i++)
                {
                    await Task.Delay(500);
                }
            }
            return(this.youTubeStatus);
        }
Beispiel #31
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            if (this.WidgetID != Guid.Empty)
            {
                OverlayWidget widget = ChannelSession.Settings.OverlayWidgets.FirstOrDefault(w => w.Item.ID.Equals(this.WidgetID));
                if (widget != null)
                {
                    widget.IsEnabled = this.ShowWidget;
                    if (!widget.IsEnabled)
                    {
                        IOverlayService overlay = ChannelSession.Services.OverlayServers.GetOverlay(widget.OverlayName);
                        if (overlay != null)
                        {
                            await overlay.RemoveItem(widget.Item);
                        }
                    }
                }
            }
            else
            {
#pragma warning disable CS0612 // Type or member is obsolete
                if (this.Position == null && this.Effect != null)
                {
                    this.Position = new OverlayItemPosition(OverlayEffectPositionType.Percentage, this.Effect.Horizontal, this.Effect.Vertical);
                }
                if (this.Effects == null && this.Effect != null)
                {
                    this.Effects = new OverlayItemEffects((OverlayEffectEntranceAnimationTypeEnum)this.Effect.EntranceAnimation,
                                                          (OverlayEffectVisibleAnimationTypeEnum)this.Effect.VisibleAnimation, (OverlayEffectExitAnimationTypeEnum)this.Effect.ExitAnimation, this.Effect.Duration);
                }
                this.Effect = null;
#pragma warning restore CS0612 // Type or member is obsolete

                string          overlayName = (string.IsNullOrEmpty(this.OverlayName)) ? ChannelSession.Services.OverlayServers.DefaultOverlayName : this.OverlayName;
                IOverlayService overlay     = ChannelSession.Services.OverlayServers.GetOverlay(overlayName);
                if (overlay != null)
                {
                    OverlayItemBase processedItem = await this.Item.GetProcessedItem(user, arguments, this.extraSpecialIdentifiers);

                    await overlay.SendItem(processedItem, this.Position, this.Effects);
                }
            }
        }
 private void onFaulted()
 {
     m_serviceProxy = null;
     m_pipeFactory = null;
     try
     {
         if (m_performingAction)
         {
             m_performingAction = false;
             m_callback.onError("Error: Action could not be performed. Lost connection to server.");
         }
     }
     catch
     {
         // do nothing
     }
     changeState(CommunicationState.Created);
     activityOccured();
 }
 private void onOpening()
 {
     m_pipeFactory.Open(new TimeSpan(0,0,0,5));
     m_serviceProxy = m_pipeFactory.CreateChannel();
     m_serviceProxy.subscribeMessageListUpdate();
     m_callback.initializeMessages(m_serviceProxy.getDisplayMessages().ToArray());
     changeState(CommunicationState.Opened);
 }
 private void onClosing()
 {
     if (m_serviceProxy != null)
     {
         m_serviceProxy.unsubscribeMessageListUpdate();
         m_serviceProxy = null;
     }
     if (m_pipeFactory != null)
     {
         m_pipeFactory.Close();
         m_pipeFactory = null;
     }
     changeState(CommunicationState.Closed);
     activityOccured();
 }