private async void RecentsView_ItemClick(object sender, ItemClickEventArgs e) { var path = (e.ClickedItem as RecentItem).path; try { var file = (await StorageFile.GetFileFromPathAsync(path)); if (file.FileType == "Application") { await Interaction.LaunchExe(path); } else { var options = new LauncherOptions { DisplayApplicationPicker = false }; await Launcher.LaunchFileAsync(file, options); } } catch (System.ArgumentException) { MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), path); } }
private async void VisiblePath_TextChanged(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) { var PathBox = (sender as TextBox); var CurrentInput = PathBox.Text; if (CurrentInput != App.ViewModel.Universal.path) { App.ViewModel.CancelLoadAndClearFiles(); if (CurrentInput == "Home" || CurrentInput == "home") { MainPage.accessibleContentFrame.Navigate(typeof(YourHome)); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Recents"; } else if (CurrentInput == "Desktop" || CurrentInput == "desktop") { App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), MainPage.DesktopPath); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Desktop"; App.PathText.Text = "Desktop"; } else if (CurrentInput == "Documents" || CurrentInput == "documents") { App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), MainPage.DocumentsPath); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Documents"; App.PathText.Text = "Documents"; } else if (CurrentInput == "Downloads" || CurrentInput == "downloads") { App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), MainPage.DownloadsPath); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Downloads"; App.PathText.Text = "Downloads"; } else if (CurrentInput == "Pictures" || CurrentInput == "pictures") { App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(PhotoAlbum), MainPage.PicturesPath); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Pictures"; App.PathText.Text = "Pictures"; } else if (CurrentInput == "Music" || CurrentInput == "music") { App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), MainPage.MusicPath); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Music"; App.PathText.Text = "Music"; } else if (CurrentInput == "Videos" || CurrentInput == "videos") { App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), MainPage.VideosPath); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Videos"; App.PathText.Text = "Videos"; } else if (CurrentInput == "OneDrive" || CurrentInput == "Onedrive" || CurrentInput == "onedrive") { App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), MainPage.OneDrivePath); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search OneDrive"; App.PathText.Text = "OneDrive"; } else { if (CurrentInput.Contains(".")) { if (CurrentInput.Contains(".exe") || CurrentInput.Contains(".EXE")) { if (StorageFile.GetFileFromPathAsync(CurrentInput) != null) { await Interaction.LaunchExe(CurrentInput); PathBox.Text = App.ViewModel.Universal.path; } else { MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path"); await dialog.ShowAsync(); } } else if (StorageFolder.GetFolderFromPathAsync(CurrentInput) != null) { await StorageFolder.GetFolderFromPathAsync(CurrentInput); App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), CurrentInput); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search"; } else { try { await StorageFile.GetFileFromPathAsync(CurrentInput); StorageFile file = await StorageFile.GetFileFromPathAsync(CurrentInput); var options = new LauncherOptions { DisplayApplicationPicker = false }; await Launcher.LaunchFileAsync(file, options); PathBox.Text = App.ViewModel.Universal.path; } catch (ArgumentException) { MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path"); await dialog.ShowAsync(); } catch (FileNotFoundException) { MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path"); await dialog.ShowAsync(); } } } else { try { await StorageFolder.GetFolderFromPathAsync(CurrentInput); App.ViewModel.TextState.isVisible = Visibility.Collapsed; MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), CurrentInput); MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search"; } catch (ArgumentException) { MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path"); await dialog.ShowAsync(); } catch (FileNotFoundException) { MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path"); await dialog.ShowAsync(); } } } } } }