Beispiel #1
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 #2
0
        public SettingsViewModel(
            IAppSettings appSettings,
            INavigatorService navigatorService,
            IUpdateCheck updateCheck,
            IWindowManager windowManager,
            IHelpers helpers) : base()
        {
            _extensionValidater = new ExtensionValidater();
            _navigatorService   = navigatorService;
            _helpers            = helpers;
            _appSettings        = appSettings;
            _windowManager      = windowManager;
            _updateCheck        = updateCheck;

            SetPropeertiesFromAppSettings();

            SelectedLanguage   = Languages.Where(x => x.Code == _appSettings.Language).FirstOrDefault();
            SelectedColorTheme = ColorThemes.Where(x => x.Id == _appSettings.Theme).FirstOrDefault();

            CancelSettingsCommand               = new RelayCommand(CancelSettings);
            SaveSettingsCommand                 = new RelayCommand(SaveSettings);
            CheckForUpdatesNowCommand           = new RelayCommand(CheckForUpdatesNow);
            RestoreDefaultsCommand              = new RelayCommand(RestoreDefaults);
            RemoveImageExtensionCommand         = new RelayParameterizedCommand(item => ImageFileExtensions.Remove((string)item));
            OpenAddImageExtensionCommand        = new RelayCommand(() => IsAddingImageExtension = true);
            AddImageEtensionCommand             = new RelayCommand(AddImageExtension);
            CloseImageFileExtensopnPopupCommand = new RelayCommand(() => IsAddingImageExtension = false);
        }
Beispiel #3
0
        public UpdateCheck(IUpdateCheck updateCheckInterface)
        {
            this.updateCheckInterface = updateCheckInterface;

            thread = new Thread(new ThreadStart(CheckForUpdateThreadWorker));
            thread.Start();
        }
Beispiel #4
0
        public UpdateCheck(IUpdateCheck updateCheckInterface)
        {
            this.updateCheckInterface = updateCheckInterface;

            thread = new Thread(new ThreadStart(CheckForUpdateThreadWorker));
            thread.Start();
        }
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 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));
                });
            });
        }
 void WhenCheckForUpdateIsCalled()
 {
     _updateCheck = _updater.CheckForUpdate();
 }
 void WhenCheckForUpdateIsCalled()
 {
     _updateCheck = _updater.CheckForUpdate();
 }