/// <summary> /// Attempts to open a database of the user's choosing. /// </summary> /// <param name="sender">The "open database" button.</param> /// <param name="e">Args for the click.</param> private async void OpenFile_Click(object sender, RoutedEventArgs e) { Debug.WriteLine("User clicked the 'open database' button."); await PickFileForOpenAndContinueAsync( async file => { NavigateToOpenedFile(await DatabaseCandidateFactory.AssembleAsync(file)); } ); }
/// <summary> /// Handles letting the user select a different database from this View, without navigating. /// </summary> /// <param name="sender">The button that invokes this command.</param> /// <param name="e">EventArgs for the click.</param> private async void DifferentDatabaseButton_Click(object sender, RoutedEventArgs e) { DebugHelper.Trace("User clicked the 'open different database' button."); await PickFileForOpenAndContinueAsync( async file => { await ViewModel.UpdateCandidateFileAsync(await DatabaseCandidateFactory.AssembleAsync(file)); } ); }
/// <summary> /// Navigates to the proper view for opening a database file. /// </summary> /// <param name="file">The file being opened.</param> /// <param name="isSample">Whether we are unlocking a sample file.</param> public async void OpenFile(ITestableFile file, bool isSample = false) { DebugHelper.Trace("Navigating RootView to Database Unlocker..."); this.contentFrame.Navigate(typeof(DatabaseUnlockView), new NavigationParameter( new { file = await DatabaseCandidateFactory.AssembleAsync(file), isSampleFile = isSample } ) ); }
/// <summary> /// Attempts to open the sample database. /// </summary> /// <param name="sender">The "open sample" button.</param> /// <param name="e">Args for the click.</param> private async void OpenSample_Click(object sender, RoutedEventArgs e) { // Locate the sample file StorageFolder installFolder = Package.Current.InstalledLocation; StorageFolder subFolder = await installFolder.GetFolderAsync("Assets"); IDatabaseCandidate sample = await DatabaseCandidateFactory.AssembleAsync( new StorageFileWrapper(await subFolder.GetFileAsync("SampleDatabase.kdbx")) ); NavigateToOpenedFile(sample, true); }
public async void LockRequestedHandler(object sender, EventArgs e) { Frame.Navigated += FrameLockNavigation; Frame.Navigate( typeof(DatabaseUnlockView), new NavigationParameter( new { file = await DatabaseCandidateFactory.AssembleAsync(ViewModel.File), isSampleFile = ViewModel.FileIsSample } ) ); }
/// <summary> /// Attempts to load a recent database from a StoredFileDescriptor. /// </summary> /// <param name="descriptor">The descriptor to load.</param> private async Task AttemptToLoadRecentDatabase(StoredFileDescriptor descriptor) { if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } ITestableFile storedFile = await ViewModel.GetFileAsync(descriptor); if (storedFile == null) { Debug.WriteLine("Warning: Could not fetch StorageFile. Forgetting descriptor."); descriptor.ForgetCommand.Execute(null); } else { Debug.WriteLine("Retrieved StorageFile from descriptor."); NavigateToOpenedFile(await DatabaseCandidateFactory.AssembleAsync(storedFile)); } }