public async void ToggleQuickLook() { try { string selectedItemPath = null; int selectedItemCount; Type sourcePageType = App.CurrentInstance.CurrentPageType; selectedItemCount = (CurrentInstance.ContentPage as BaseLayout).SelectedItems.Count; if (selectedItemCount == 1) { selectedItemPath = (CurrentInstance.ContentPage as BaseLayout).SelectedItems[0].FilePath; } if (selectedItemCount == 1) { var clickedOnItem = (CurrentInstance.ContentPage as BaseLayout).SelectedItems[0]; Debug.WriteLine("Toggle QuickLook"); ApplicationData.Current.LocalSettings.Values["path"] = clickedOnItem.FilePath; ApplicationData.Current.LocalSettings.Values["Arguments"] = "ToggleQuickLook"; await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); } } catch (FileNotFoundException) { MessageDialog dialog = new MessageDialog("The file you are attempting to preview may have been moved or deleted.", "File Not Found"); var task = dialog.ShowAsync(); task.AsTask().Wait(); NavigationActions.Refresh_Click(null, null); } }
public static async void DeleteItem_Click(object sender, RoutedEventArgs e) { //MessageDialog DeleteConfirmationDialog = new MessageDialog("Are you sure you want to send " + GenericFileBrowser.data.SelectedItems.Count + " item(s) to the Recycle Bin?", "Move to Recycle Bin?"); //DeleteConfirmationDialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(Interaction.DeleteConfirmed))); //DeleteConfirmationDialog.Commands.Add(new UICommand("Cancel")); //await DeleteConfirmationDialog.ShowAsync(); try { foreach (ListedItem storItem in GenericFileBrowser.data.SelectedItems) { if (storItem.FileExtension != "Folder") { var item = await StorageFile.GetFileFromPathAsync(storItem.FilePath); await item.DeleteAsync(StorageDeleteOption.Default); } else { var item = await StorageFolder.GetFolderFromPathAsync(storItem.FilePath); await item.DeleteAsync(StorageDeleteOption.Default); } } NavigationActions.Refresh_Click(null, null); } catch (InvalidOperationException) { } catch (System.UnauthorizedAccessException) { MessageDialog AccessDeniedDialog = new MessageDialog("Access Denied", "Unable to delete this item"); await AccessDeniedDialog.ShowAsync(); } }
public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e) { var DestinationPath = App.ViewModel.Universal.path; DataPackageView packageView = Clipboard.GetContent(); var oldCount = App.ViewModel.FilesAndFolders.Count; var ItemsToPaste = await packageView.GetStorageItemsAsync(); foreach (IStorageItem item in ItemsToPaste) { if (item.IsOfType(StorageItemTypes.Folder)) { CloneDirectoryAsync(item.Path, DestinationPath, item.Name); } else if (item.IsOfType(StorageItemTypes.File)) { StorageFile ClipboardFile = await StorageFile.GetFileFromPathAsync(item.Path); await ClipboardFile.CopyAsync(await StorageFolder.GetFolderFromPathAsync(DestinationPath), item.Name, NameCollisionOption.GenerateUniqueName); } } if (packageView.RequestedOperation == DataPackageOperation.Move) { foreach (string path in pathsToDeleteAfterPaste) { if (path.Contains(".")) { StorageFile file = await StorageFile.GetFileFromPathAsync(path); await file.DeleteAsync(); } if (!path.Contains(".")) { StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(path); await folder.DeleteAsync(); } } } if (page.Name == "GenericItemView") { NavigationActions.Refresh_Click(null, null); } else if (page.Name == "PhotoAlbumViewer") { PhotoAlbumNavActions.Refresh_Click(null, null); } }
public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e) { // TODO: Add progress box and collision options for this operation var DestinationPath = ItemViewModel.PUIP.Path; DataPackageView packageView = Clipboard.GetContent(); var ItemsToPaste = await packageView.GetStorageItemsAsync(); foreach (IStorageItem item in ItemsToPaste) { if (item.IsOfType(StorageItemTypes.Folder)) { CloneDirectoryAsync(item.Path, DestinationPath, item.Name); } else if (item.IsOfType(StorageItemTypes.File)) { StorageFile ClipboardFile = await StorageFile.GetFileFromPathAsync(item.Path); await ClipboardFile.CopyAsync(await StorageFolder.GetFolderFromPathAsync(DestinationPath), item.Name, NameCollisionOption.GenerateUniqueName); } } NavigationActions.Refresh_Click(null, null); if (packageView.RequestedOperation == DataPackageOperation.Move) { foreach (string path in pathsToDeleteAfterPaste) { if (path.Contains(".")) { StorageFile file = await StorageFile.GetFileFromPathAsync(path); await file.DeleteAsync(); } if (!path.Contains(".")) { StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(path); await folder.DeleteAsync(); } } } }
public async void ToggleQuickLook() { try { if (CurrentInstance.ContentPage.IsItemSelected && !App.CurrentInstance.ContentPage.isRenamingItem) { var clickedOnItem = CurrentInstance.ContentPage.SelectedItem; Debug.WriteLine("Toggle QuickLook"); ApplicationData.Current.LocalSettings.Values["path"] = clickedOnItem.ItemPath; ApplicationData.Current.LocalSettings.Values["Arguments"] = "ToggleQuickLook"; await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); } } catch (FileNotFoundException) { await DialogDisplayHelper.ShowDialog(ResourceController.GetTranslation("FileNotFoundDialog.Title"), ResourceController.GetTranslation("FileNotFoundPreviewDialog.Text")); NavigationActions.Refresh_Click(null, null); } }
public async void ToggleQuickLook() { try { if (CurrentInstance.ContentPage.IsItemSelected && !App.CurrentInstance.ContentPage.isRenamingItem) { var clickedOnItem = CurrentInstance.ContentPage.SelectedItem; Debug.WriteLine("Toggle QuickLook"); ApplicationData.Current.LocalSettings.Values["path"] = clickedOnItem.ItemPath; ApplicationData.Current.LocalSettings.Values["Arguments"] = "ToggleQuickLook"; await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); } } catch (FileNotFoundException) { MessageDialog dialog = new MessageDialog("The file you are attempting to preview may have been moved or deleted.", "File Not Found"); var task = dialog.ShowAsync(); task.AsTask().Wait(); NavigationActions.Refresh_Click(null, null); } }
private async void OpenSelectedItems(bool displayApplicationPicker) { try { int selectedItemCount; Type sourcePageType = App.CurrentInstance.CurrentPageType; selectedItemCount = CurrentInstance.ContentPage.SelectedItems.Count; // Access MRU List var mostRecentlyUsed = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; if (selectedItemCount == 1) { var clickedOnItem = CurrentInstance.ContentPage.SelectedItem; var clickedOnItemPath = clickedOnItem.ItemPath; if (clickedOnItem.PrimaryItemAttribute == StorageItemTypes.Folder) { // Add location to MRU List mostRecentlyUsed.Add(await StorageFolder.GetFolderFromPathAsync(clickedOnItemPath)); CurrentInstance.ViewModel.WorkingDirectory = clickedOnItemPath; CurrentInstance.NavigationToolbar.PathControlDisplayText = clickedOnItemPath; CurrentInstance.ContentPage.AssociatedViewModel.EmptyTextState.IsVisible = Visibility.Collapsed; CurrentInstance.ContentFrame.Navigate(sourcePageType, clickedOnItemPath, new SuppressNavigationTransitionInfo()); } else { // Add location to MRU List mostRecentlyUsed.Add(await StorageFile.GetFileFromPathAsync(clickedOnItem.ItemPath)); if (displayApplicationPicker) { StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.ItemPath); var options = new LauncherOptions { DisplayApplicationPicker = true }; await Launcher.LaunchFileAsync(file, options); } else { await InvokeWin32Component(clickedOnItem.ItemPath); } } } else if (selectedItemCount > 1) { foreach (ListedItem clickedOnItem in CurrentInstance.ContentPage.SelectedItems) { if (clickedOnItem.PrimaryItemAttribute == StorageItemTypes.Folder) { instanceTabsView.AddNewTab(typeof(ModernShellPage), clickedOnItem.ItemPath); } else { // Add location to MRU List mostRecentlyUsed.Add(await StorageFile.GetFileFromPathAsync(clickedOnItem.ItemPath)); if (displayApplicationPicker) { StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.ItemPath); var options = new LauncherOptions { DisplayApplicationPicker = true }; await Launcher.LaunchFileAsync(file, options); } else { await InvokeWin32Component(clickedOnItem.ItemPath); } } } } } catch (FileNotFoundException) { MessageDialog dialog = new MessageDialog("The file you are attempting to access may have been moved or deleted.", "File Not Found"); await dialog.ShowAsync(); NavigationActions.Refresh_Click(null, null); } }
private async void OpenSelectedItems(bool displayApplicationPicker) { try { string selectedItemPath = null; int selectedItemCount; Type sourcePageType = App.CurrentInstance.CurrentPageType; selectedItemCount = (CurrentInstance.ContentPage as BaseLayout).SelectedItems.Count; if (selectedItemCount == 1) { selectedItemPath = (CurrentInstance.ContentPage as BaseLayout).SelectedItems[0].FilePath; } // Access MRU List var mostRecentlyUsed = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; if (selectedItemCount == 1) { var clickedOnItem = (CurrentInstance.ContentPage as BaseLayout).SelectedItems[0]; if (clickedOnItem.FileType == "Folder") { // Add location to MRU List mostRecentlyUsed.Add(await StorageFolder.GetFolderFromPathAsync(selectedItemPath)); CurrentInstance.ViewModel.Universal.WorkingDirectory = selectedItemPath; CurrentInstance.NavigationToolbar.PathControlDisplayText = selectedItemPath; (CurrentInstance.ContentPage as BaseLayout).AssociatedViewModel.EmptyTextState.isVisible = Visibility.Collapsed; App.CurrentInstance.SidebarSelectedItem = App.sideBarItems.FirstOrDefault(x => x.Path != null && x.Path.Equals(selectedItemPath, StringComparison.OrdinalIgnoreCase)); if (App.CurrentInstance.SidebarSelectedItem == null) { App.CurrentInstance.SidebarSelectedItem = App.sideBarItems.FirstOrDefault(x => x.Path != null && x.Path.Equals(Path.GetPathRoot(selectedItemPath), StringComparison.OrdinalIgnoreCase)); } CurrentInstance.ContentFrame.Navigate(sourcePageType, selectedItemPath, new SuppressNavigationTransitionInfo()); } else { // Add location to MRU List mostRecentlyUsed.Add(await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath)); if (displayApplicationPicker) { StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath); var options = new LauncherOptions { DisplayApplicationPicker = true }; await Launcher.LaunchFileAsync(file, options); } else { await InvokeWin32Component(clickedOnItem.FilePath); } } } else if (selectedItemCount > 1) { foreach (ListedItem clickedOnItem in (CurrentInstance.ContentPage as BaseLayout).SelectedItems) { if (clickedOnItem.FileType == "Folder") { instanceTabsView.AddNewTab(typeof(ProHome), clickedOnItem.FilePath); } else { // Add location to MRU List mostRecentlyUsed.Add(await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath)); if (displayApplicationPicker) { StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath); var options = new LauncherOptions { DisplayApplicationPicker = true }; await Launcher.LaunchFileAsync(file, options); } else { await InvokeWin32Component(clickedOnItem.FilePath); } } } } } catch (FileNotFoundException) { MessageDialog dialog = new MessageDialog("The file you are attempting to access may have been moved or deleted.", "File Not Found"); await dialog.ShowAsync(); NavigationActions.Refresh_Click(null, null); } }
public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e) { // TODO: Add progress box and collision options for this operation var DestinationPath = ItemViewModel.PUIP.Path; DataPackageView packageView = Clipboard.GetContent(); var ItemsToPaste = await packageView.GetStorageItemsAsync(); foreach (IStorageItem item in ItemsToPaste) { try // tries to do this if collision doesn't happen { if (isReplaceEnabled) { if (item.IsOfType(StorageItemTypes.Folder)) { CloneDirectoryAsync(item.Path, DestinationPath, item.Name, true, item); } else if (item.IsOfType(StorageItemTypes.File)) { StorageFile ClipboardFile = await StorageFile.GetFileFromPathAsync(item.Path); await ClipboardFile.CopyAndReplaceAsync(await StorageFile.GetFileFromPathAsync(DestinationPath + @"\" + item.Name)); } } else if (isSkipEnabled) { // Skip doing anything with file entirely } else if (isReviewEnabled) { ItemSnapshot = item; DestinationPathSnapshot = DestinationPath; ItemViewModel.DisplayReviewUIWithArgs("Skip or Replace This Item?", "An item already exists with the name " + item.Name + "."); isLoopPaused = true; } else // First time of this collision, so prompt for user choice { ItemViewModel.DisplayCollisionUIWithArgs("Replace All Existing Items?", "You can choose whether to replace or skip all items if there are more than one. Optionally, you can review each one individually."); return; } } catch (Exception) { if (isReplaceEnabled) { if (item.IsOfType(StorageItemTypes.Folder)) { CloneDirectoryAsync(item.Path, DestinationPath, item.Name, true, item); } else if (item.IsOfType(StorageItemTypes.File)) { StorageFile ClipboardFile = await StorageFile.GetFileFromPathAsync(item.Path); await ClipboardFile.CopyAndReplaceAsync(await StorageFile.GetFileFromPathAsync(DestinationPath + @"\" + item.Name)); } } else if (isSkipEnabled) { // Skip doing anything with file entirely } else if (isReviewEnabled) { ItemSnapshot = item; DestinationPathSnapshot = DestinationPath; ItemViewModel.DisplayReviewUIWithArgs("Skip or Replace This Item?", "An item already exists with the name " + item.Name + "."); } else // First time of this collision, so prompt for user choice { ItemViewModel.DisplayCollisionUIWithArgs("Replace All Existing Items?", "You can choose whether to replace or skip all items if there are more than one. Optionally, you can review each one individually."); return; } } } NavigationActions.Refresh_Click(null, null); }
private async void OpenSelectedItems(bool displayApplicationPicker) { try { string selectedItemPath = null; int selectedItemCount; Type sourcePageType = App.CurrentInstance.CurrentPageType; selectedItemCount = (CurrentInstance.ContentPage as BaseLayout).SelectedItems.Count; if (selectedItemCount == 1) { selectedItemPath = (CurrentInstance.ContentPage as BaseLayout).SelectedItems[0].FilePath; } // Access MRU List var mostRecentlyUsed = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; if (selectedItemCount == 1) { var clickedOnItem = (CurrentInstance.ContentPage as BaseLayout).SelectedItems[0]; if (clickedOnItem.FileType == "Folder") { // Add location to MRU List mostRecentlyUsed.Add(await StorageFolder.GetFolderFromPathAsync(selectedItemPath)); CurrentInstance.ViewModel.Universal.path = selectedItemPath; CurrentInstance.PathControlDisplayText = selectedItemPath; (CurrentInstance.ContentPage as BaseLayout).AssociatedViewModel.EmptyTextState.isVisible = Visibility.Collapsed; if (selectedItemPath == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)) { CurrentInstance.PathControlDisplayText = "Desktop"; (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = App.sideBarItems.First(x => (x as INavigationControlItem).Path.Equals(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase)); CurrentInstance.ContentFrame.Navigate(sourcePageType, App.AppSettings.DesktopPath, new SuppressNavigationTransitionInfo()); } else if (selectedItemPath == Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) { CurrentInstance.PathControlDisplayText = "Documents"; (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = App.sideBarItems.First(x => (x as INavigationControlItem).Path.Equals(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase)); CurrentInstance.ContentFrame.Navigate(sourcePageType, App.AppSettings.DocumentsPath, new SuppressNavigationTransitionInfo()); } else if (selectedItemPath == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads")) { CurrentInstance.PathControlDisplayText = "Downloads"; (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = App.sideBarItems.First(x => (x as INavigationControlItem).Path.Equals(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase)); CurrentInstance.ContentFrame.Navigate(sourcePageType, App.AppSettings.DownloadsPath, new SuppressNavigationTransitionInfo()); } else if (selectedItemPath == Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)) { CurrentInstance.PathControlDisplayText = "Pictures"; (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = App.sideBarItems.First(x => (x as INavigationControlItem).Path.Equals(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase)); CurrentInstance.ContentFrame.Navigate(sourcePageType, App.AppSettings.PicturesPath, new SuppressNavigationTransitionInfo()); } else if (selectedItemPath == Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)) { CurrentInstance.PathControlDisplayText = "Music"; (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = App.sideBarItems.First(x => (x as INavigationControlItem).Path.Equals(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase)); CurrentInstance.ContentFrame.Navigate(sourcePageType, App.AppSettings.MusicPath, new SuppressNavigationTransitionInfo()); } else if (selectedItemPath == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\OneDrive")) { CurrentInstance.PathControlDisplayText = "OneDrive"; (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = SettingsViewModel.foundDrives.First(x => (x as DriveItem).tag.ToString().Equals("OneDrive", StringComparison.OrdinalIgnoreCase)); CurrentInstance.ContentFrame.Navigate(sourcePageType, App.AppSettings.OneDrivePath, new SuppressNavigationTransitionInfo()); } else if (selectedItemPath == Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)) { CurrentInstance.PathControlDisplayText = "Videos"; (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = App.sideBarItems.First(x => (x as INavigationControlItem).Path.Equals(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase)); CurrentInstance.ContentFrame.Navigate(sourcePageType, App.AppSettings.VideosPath, new SuppressNavigationTransitionInfo()); } else { if (selectedItemPath.Split(@"\")[0].Contains("C:")) { (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = SettingsViewModel.foundDrives.Where(x => (x as DriveItem).tag == "C:\\").First(); } else { (App.CurrentInstance as ProHome).SidebarControl.SidebarNavView.SelectedItem = SettingsViewModel.foundDrives.Where(x => (x as DriveItem).tag.Contains(selectedItemPath.Split(@"\")[0])).First(); } CurrentInstance.ContentFrame.Navigate(sourcePageType, selectedItemPath, new SuppressNavigationTransitionInfo()); } } else { if (clickedOnItem.FileType == "Folder") { instanceTabsView.AddNewTab(typeof(ProHome), clickedOnItem.FilePath); } else { // Add location to MRU List mostRecentlyUsed.Add(await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath)); if (displayApplicationPicker) { StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath); var options = new LauncherOptions { DisplayApplicationPicker = true }; await Launcher.LaunchFileAsync(file, options); } else { await InvokeWin32Component(clickedOnItem.FilePath); } } } } else if (selectedItemCount > 1) { foreach (ListedItem clickedOnItem in (CurrentInstance.ContentPage as BaseLayout).SelectedItems) { if (clickedOnItem.FileType == "Folder") { instanceTabsView.AddNewTab(typeof(ProHome), clickedOnItem.FilePath); } else { // Add location to MRU List mostRecentlyUsed.Add(await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath)); if (displayApplicationPicker) { StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath); var options = new LauncherOptions { DisplayApplicationPicker = true }; await Launcher.LaunchFileAsync(file, options); } else { await InvokeWin32Component(clickedOnItem.FilePath); } } } } } catch (FileNotFoundException) { MessageDialog dialog = new MessageDialog("The file you are attempting to access may have been moved or deleted.", "File Not Found"); await dialog.ShowAsync(); NavigationActions.Refresh_Click(null, null); } }