diff --git a/Files/BaseLayout.cs b/Files/BaseLayout.cs index cf90bec90b8c..eac51f1893f7 100644 --- a/Files/BaseLayout.cs +++ b/Files/BaseLayout.cs @@ -500,76 +500,6 @@ protected virtual void Page_CharacterReceived(CoreWindow sender, CharacterReceiv } } - protected async void List_DragEnter(object sender, DragEventArgs e) - { - var deferral = e.GetDeferral(); - - ClearSelection(); - if (e.DataView.Contains(StandardDataFormats.StorageItems)) - { - e.Handled = true; - e.DragUIOverride.IsCaptionVisible = true; - IEnumerable draggedItems = new List(); - try - { - draggedItems = await e.DataView.GetStorageItemsAsync(); - } - catch (Exception dropEx) when ((uint)dropEx.HResult == 0x80040064) - { - if (Connection != null) - { - await Connection.SendMessageAsync(new ValueSet() { - { "Arguments", "FileOperation" }, - { "fileop", "DragDrop" }, - { "droptext", "DragDropWindowText".GetLocalized() }, - { "droppath", ParentShellPageInstance.FilesystemViewModel.WorkingDirectory } }); - } - } - catch (Exception ex) - { - NLog.LogManager.GetCurrentClassLogger().Warn(ex, ex.Message); - } - if (!draggedItems.Any()) - { - e.AcceptedOperation = DataPackageOperation.None; - deferral.Complete(); - return; - } - - var folderName = Path.GetFileName(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory); - // As long as one file doesn't already belong to this folder - if (InstanceViewModel.IsPageTypeSearchResults || draggedItems.AreItemsAlreadyInFolder(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory)) - { - e.AcceptedOperation = DataPackageOperation.None; - } - else if (draggedItems.AreItemsInSameDrive(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory)) - { - e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalized(), folderName); - e.AcceptedOperation = DataPackageOperation.Move; - } - else - { - e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalized(), folderName); - e.AcceptedOperation = DataPackageOperation.Copy; - } - } - - deferral.Complete(); - } - - protected async void List_Drop(object sender, DragEventArgs e) - { - var deferral = e.GetDeferral(); - - if (e.DataView.Contains(StandardDataFormats.StorageItems)) - { - await ParentShellPageInstance.FilesystemHelpers.PerformOperationTypeAsync(e.AcceptedOperation, e.DataView, ParentShellPageInstance.FilesystemViewModel.WorkingDirectory, true); - e.Handled = true; - } - - deferral.Complete(); - } - protected async void Item_DragStarting(object sender, DragStartingEventArgs e) { List selectedStorageItems = new List(); @@ -737,57 +667,6 @@ protected void UninitializeDrag(UIElement element) public readonly VirtualKey MinusKey = (VirtualKey)189; - public void GridViewSizeIncrease(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args) - { - FolderSettings.GridViewSize = FolderSettings.GridViewSize + Constants.Browser.GridViewBrowser.GridViewIncrement; // Make Larger - if (args != null) - { - args.Handled = true; - } - } - - public void GridViewSizeDecrease(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args) - { - FolderSettings.GridViewSize = FolderSettings.GridViewSize - Constants.Browser.GridViewBrowser.GridViewIncrement; // Make Smaller - if (args != null) - { - args.Handled = true; - } - } - - public void BaseLayout_PointerWheelChanged(object sender, PointerRoutedEventArgs e) - { - if (e.KeyModifiers == VirtualKeyModifiers.Control) - { - if (e.GetCurrentPoint(null).Properties.MouseWheelDelta < 0) // Mouse wheel down - { - GridViewSizeDecrease(null, null); - } - else // Mouse wheel up - { - GridViewSizeIncrease(null, null); - } - - e.Handled = true; - } - } - - public async void PinItemToStart_Click(object sender, RoutedEventArgs e) - { - foreach (ListedItem listedItem in SelectedItems) - { - await App.SecondaryTileHelper.TryPinFolderAsync(listedItem.ItemPath, listedItem.ItemName); - } - } - - public async void UnpinItemFromStart_Click(object sender, RoutedEventArgs e) - { - foreach (ListedItem listedItem in SelectedItems) - { - await App.SecondaryTileHelper.UnpinFromStartAsync(listedItem.ItemPath); - } - } - public abstract void Dispose(); public void RefreshItems() diff --git a/Files/Helpers/ContextFlyoutItemHelper.cs b/Files/Helpers/ContextFlyoutItemHelper.cs index 75a5719382d9..d0730d74651e 100644 --- a/Files/Helpers/ContextFlyoutItemHelper.cs +++ b/Files/Helpers/ContextFlyoutItemHelper.cs @@ -484,18 +484,18 @@ public static List GetBaseItemMenuItems(BaseLayo }, new ContextMenuFlyoutItemViewModel() { - Text = "PinItemToStart2".GetLocalized(), + Text = "PinItemToStart/Text".GetLocalized(), Glyph = "\uE840", - // TODO: Add command + Command = commandsViewModel.PinItemToStartCommand, ShowOnShift = true, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsItemPinnedToStart), SingleItemOnly = true, }, new ContextMenuFlyoutItemViewModel() { - Text = "UnpinItemFromStart2".GetLocalized(), + Text = "UnpinItemFromStart/Text".GetLocalized(), Glyph = "\uE77A", - // TODO: Add command + Command = commandsViewModel.UnpinItemFromStartCommand, ShowOnShift = true, ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && x.IsItemPinnedToStart), SingleItemOnly = true, @@ -569,4 +569,3 @@ public static List GetNewItemItems(BaseLayoutCom } } } - diff --git a/Files/Interacts/BaseLayoutCommandImplementationModel.cs b/Files/Interacts/BaseLayoutCommandImplementationModel.cs index b35426cd94d0..5e11c0a27308 100644 --- a/Files/Interacts/BaseLayoutCommandImplementationModel.cs +++ b/Files/Interacts/BaseLayoutCommandImplementationModel.cs @@ -404,6 +404,129 @@ public virtual void ItemPointerPressed(PointerRoutedEventArgs e) } } + public virtual async void UnpinItemFromStart(RoutedEventArgs e) + { + foreach (ListedItem listedItem in associatedInstance.SlimContentPage.SelectedItems) + { + await App.SecondaryTileHelper.UnpinFromStartAsync(listedItem.ItemPath); + } + } + + public async void PinItemToStart(RoutedEventArgs e) + { + foreach (ListedItem listedItem in associatedInstance.SlimContentPage.SelectedItems) + { + await App.SecondaryTileHelper.TryPinFolderAsync(listedItem.ItemPath, listedItem.ItemName); + } + } + + public virtual void PointerWheelChanged(PointerRoutedEventArgs e) + { + if (e.KeyModifiers == VirtualKeyModifiers.Control) + { + if (e.GetCurrentPoint(null).Properties.MouseWheelDelta < 0) // Mouse wheel down + { + GridViewSizeDecrease(null); + } + else // Mouse wheel up + { + GridViewSizeIncrease(null); + } + + e.Handled = true; + } + } + + public virtual void GridViewSizeDecrease(KeyboardAcceleratorInvokedEventArgs e) + { + associatedInstance.InstanceViewModel.FolderSettings.GridViewSize = associatedInstance.InstanceViewModel.FolderSettings.GridViewSize - Constants.Browser.GridViewBrowser.GridViewIncrement; // Make Smaller + + if (e != null) + { + e.Handled = true; + } + } + + public virtual void GridViewSizeIncrease(KeyboardAcceleratorInvokedEventArgs e) + { + associatedInstance.InstanceViewModel.FolderSettings.GridViewSize = associatedInstance.InstanceViewModel.FolderSettings.GridViewSize + Constants.Browser.GridViewBrowser.GridViewIncrement; // Make Larger + + if (e != null) + { + e.Handled = true; + } + } + + public virtual async void DragEnter(DragEventArgs e) + { + var deferral = e.GetDeferral(); + + SlimContentPage.ClearSelection(); + if (e.DataView.Contains(StandardDataFormats.StorageItems)) + { + e.Handled = true; + e.DragUIOverride.IsCaptionVisible = true; + IEnumerable draggedItems = new List(); + try + { + draggedItems = await e.DataView.GetStorageItemsAsync(); + } + catch (Exception dropEx) when ((uint)dropEx.HResult == 0x80040064) + { + if (associatedInstance.ServiceConnection != null) + { + await associatedInstance.ServiceConnection.SendMessageAsync(new ValueSet() { + { "Arguments", "FileOperation" }, + { "fileop", "DragDrop" }, + { "droptext", "DragDropWindowText".GetLocalized() }, + { "droppath", associatedInstance.FilesystemViewModel.WorkingDirectory } }); + } + } + catch (Exception ex) + { + NLog.LogManager.GetCurrentClassLogger().Warn(ex, ex.Message); + } + if (!draggedItems.Any()) + { + e.AcceptedOperation = DataPackageOperation.None; + deferral.Complete(); + return; + } + + var folderName = System.IO.Path.GetFileName(associatedInstance.FilesystemViewModel.WorkingDirectory); + // As long as one file doesn't already belong to this folder + if (associatedInstance.InstanceViewModel.IsPageTypeSearchResults || draggedItems.AreItemsAlreadyInFolder(associatedInstance.FilesystemViewModel.WorkingDirectory)) + { + e.AcceptedOperation = DataPackageOperation.None; + } + else if (draggedItems.AreItemsInSameDrive(associatedInstance.FilesystemViewModel.WorkingDirectory)) + { + e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalized(), folderName); + e.AcceptedOperation = DataPackageOperation.Move; + } + else + { + e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalized(), folderName); + e.AcceptedOperation = DataPackageOperation.Copy; + } + } + + deferral.Complete(); + } + + public virtual async void Drop(DragEventArgs e) + { + var deferral = e.GetDeferral(); + + if (e.DataView.Contains(StandardDataFormats.StorageItems)) + { + await associatedInstance.FilesystemHelpers.PerformOperationTypeAsync(e.AcceptedOperation, e.DataView, associatedInstance.FilesystemViewModel.WorkingDirectory, true); + e.Handled = true; + } + + deferral.Complete(); + } + public virtual void RefreshItems(RoutedEventArgs e) { SlimContentPage.RefreshItems(); diff --git a/Files/Interacts/BaseLayoutCommandsViewModel.cs b/Files/Interacts/BaseLayoutCommandsViewModel.cs index f41d31544219..09d8275dac9a 100644 --- a/Files/Interacts/BaseLayoutCommandsViewModel.cs +++ b/Files/Interacts/BaseLayoutCommandsViewModel.cs @@ -61,6 +61,13 @@ private void InitializeCommands() ShareItemCommand = new RelayCommand(commandsModel.ShareItem); PinDirectoryToSidebarCommand = new RelayCommand(commandsModel.PinDirectoryToSidebar); ItemPointerPressedCommand = new RelayCommand(commandsModel.ItemPointerPressed); + UnpinItemFromStartCommand = new RelayCommand(commandsModel.UnpinItemFromStart); + PinItemToStartCommand = new RelayCommand(commandsModel.PinItemToStart); + PointerWheelChangedCommand = new RelayCommand(commandsModel.PointerWheelChanged); + GridViewSizeDecreaseCommand = new RelayCommand(commandsModel.GridViewSizeDecrease); + GridViewSizeIncreaseCommand = new RelayCommand(commandsModel.GridViewSizeIncrease); + DragEnterCommand = new RelayCommand(commandsModel.DragEnter); + DropCommand = new RelayCommand(commandsModel.Drop); RefreshCommand = new RelayCommand(commandsModel.RefreshItems); } @@ -129,6 +136,21 @@ private void InitializeCommands() public ICommand PinDirectoryToSidebarCommand { get; private set; } public ICommand ItemPointerPressedCommand { get; private set; } + + public ICommand UnpinItemFromStartCommand { get; private set; } + + public ICommand PinItemToStartCommand { get; private set; } + + public ICommand PointerWheelChangedCommand { get; private set; } + + public ICommand GridViewSizeDecreaseCommand { get; private set; } + + public ICommand GridViewSizeIncreaseCommand { get; private set; } + + public ICommand DragEnterCommand { get; private set; } + + public ICommand DropCommand { get; private set; } + public ICommand RefreshCommand { get; private set; } #endregion Commands diff --git a/Files/Interacts/IBaseLayoutCommandImplementationModel.cs b/Files/Interacts/IBaseLayoutCommandImplementationModel.cs index ac58552d19e0..f8bc8d984563 100644 --- a/Files/Interacts/IBaseLayoutCommandImplementationModel.cs +++ b/Files/Interacts/IBaseLayoutCommandImplementationModel.cs @@ -68,6 +68,21 @@ public interface IBaseLayoutCommandImplementationModel : IDisposable void PinDirectoryToSidebar(RoutedEventArgs e); void ItemPointerPressed(PointerRoutedEventArgs e); + + void UnpinItemFromStart(RoutedEventArgs e); + + void PinItemToStart(RoutedEventArgs e); + + void PointerWheelChanged(PointerRoutedEventArgs e); + + void GridViewSizeDecrease(KeyboardAcceleratorInvokedEventArgs e); + + void GridViewSizeIncrease(KeyboardAcceleratorInvokedEventArgs e); + + void DragEnter(DragEventArgs e); + + void Drop(DragEventArgs e); + void RefreshItems(RoutedEventArgs e); } } \ No newline at end of file diff --git a/Files/Views/LayoutModes/GenericFileBrowser.xaml b/Files/Views/LayoutModes/GenericFileBrowser.xaml index b0650d0930d5..fa7441429a1b 100644 --- a/Files/Views/LayoutModes/GenericFileBrowser.xaml +++ b/Files/Views/LayoutModes/GenericFileBrowser.xaml @@ -2,8 +2,6 @@ x:Class="Files.Views.LayoutModes.GenericFileBrowser" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:Core="using:Microsoft.Xaml.Interactions.Core" - xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:controlsprimitives="using:Microsoft.Toolkit.Uwp.UI.Controls.Primitives" xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters" @@ -17,10 +15,13 @@ xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:icore="using:Microsoft.Xaml.Interactions.Core" xmlns:xh="using:Files.Helpers.XamlHelpers" - xmlns:usercontrols="using:Files.UserControls" NavigationCacheMode="Enabled" - PointerWheelChanged="BaseLayout_PointerWheelChanged" mc:Ignorable="d"> + + + + + @@ -46,12 +47,22 @@ + Modifiers="Control"> + + + + + + + Modifiers="Control"> + + + + + + + + + @@ -329,20 +329,40 @@ + Modifiers="Control"> + + + + + + + Modifiers="Control"> + + + + + + + Modifiers="Control"> + + + + + + + Modifiers="Control"> + + + + + +