public SettingsViewModel(IUserSettings userSettings, AppUpdateManager appUpdateManager)
        {
            ChangeShortcutCommand = new RelayCommand(() =>
            {
                ShortCutPreview = ShortCut;
                ShowingKeyboardCaptureOverlay = true;
            });
            ConfirmShortcutCommand = new RelayCommand(() =>
            {
                ShortCut = ShortCutPreview;
                ShowingKeyboardCaptureOverlay = false;
            });

            CancelShortcutCommand = new RelayCommand(() =>
            {
                ShowingKeyboardCaptureOverlay = false;
            });

            CheckForUpdatesCommand = new RelayCommand(async() =>
            {
                CheckingForUpdateInProgress = true;
                if (await appUpdateManager.IsNewUpdateAvailable())
                {
                    await appUpdateManager.Update();
                }

                CheckingForUpdateInProgress = false;
            });

            _userSettings = userSettings;
            _userSettings.ActivationShortcut.PropertyChanged += (s, e) => { OnPropertyChanged(nameof(ShortCut)); };
        }
Example #2
0
 private static void CheckForUpdates(AppUpdateManager appUpdateManager, IUserSettings userSettings)
 {
     if (userSettings.AutomaticUpdates.Value)
     {
         Task.Run(async() =>
         {
             // do not start it immediately after the app start
             await Task.Delay(TimeSpan.FromSeconds(5));
             if (await appUpdateManager.IsNewUpdateAvailable())
             {
                 await appUpdateManager.Update();
             }
         });
     }
 }