private async Task HandleSessionChangedInternalAsync(SessionNotification notification) { switch (notification.NotificationType) { case SessionNotificationType.WatchedFolderAdded: await SetWatchedFoldersAsync(); break; case SessionNotificationType.WatchedFolderRemoved: await SetWatchedFoldersAsync(); break; case SessionNotificationType.SignIn: case SessionNotificationType.SignOut: LoggedOn = Resolve.KnownIdentities.IsLoggedOn; break; case SessionNotificationType.WatchedFolderChange: FilesArePending = AreFilesPending(); break; case SessionNotificationType.KnownKeyChange: if (notification.Identity == LogOnIdentity.Empty) { throw new InvalidOperationException("Attempt to add the empty identity as a known key."); } if (!_fileSystemState.KnownPassphrases.Any(p => p.Thumbprint == notification.Identity.Passphrase.Thumbprint)) { _fileSystemState.KnownPassphrases.Add(notification.Identity.Passphrase); await _fileSystemState.Save(); } break; case SessionNotificationType.SessionStart: case SessionNotificationType.ActiveFileChange: FilesArePending = AreFilesPending(); SetRecentFiles(); break; case SessionNotificationType.LicensePolicyChanged: LicenseUpdate.Execute(null); break; case SessionNotificationType.WorkFolderChange: case SessionNotificationType.ProcessExit: case SessionNotificationType.SessionChange: default: break; } }
private void BindPropertyChangedEvents() { BindPropertyChangedInternal(nameof(DragAndDropFiles), (IEnumerable <string> files) => { DragAndDropFilesTypes = DetermineFileTypes(files.Select(f => New <IDataItem>(f))); }); BindPropertyChangedInternal(nameof(DragAndDropFiles), (IEnumerable <string> files) => { DroppableAsRecent = DetermineDroppableAsRecent(files.Select(f => New <IDataItem>(f))); }); BindPropertyChangedInternal(nameof(DragAndDropFiles), (IEnumerable <string> files) => { DroppableAsWatchedFolder = DetermineDroppableAsWatchedFolder(files.Select(f => New <IDataItem>(f))); }); BindPropertyChangedInternal(nameof(RecentFilesComparer), (ActiveFileComparer comparer) => { SetRecentFilesComparer(); }); BindPropertyChangedInternal(nameof(LoggedOn), (bool loggedOn) => LicenseUpdate.Execute(null)); BindPropertyChangedInternal(nameof(LoggedOn), async(bool loggedOn) => { if (loggedOn) { await AxCryptUpdateCheck.ExecuteAsync(_userSettings.LastUpdateCheckUtc); } }); BindPropertyChanged(nameof(DebugMode), (bool enabled) => { UpdateDebugMode(enabled); }); BindPropertyChanged(nameof(LoggedOn), (bool loggedOn) => EncryptFileEnabled = loggedOn || !License.Has(LicenseCapability.EncryptNewFiles)); BindPropertyChanged(nameof(License), async(LicenseCapabilities policy) => await SetWatchedFoldersAsync()); BindPropertyChanged(nameof(EncryptionUpgradeMode), (EncryptionUpgradeMode mode) => Resolve.UserSettings.EncryptionUpgradeMode = mode); BindPropertyChanged(nameof(FolderOperationMode), async(FolderOperationMode mode) => await SetFolderOperationMode(mode)); }