From 6d7b92c7da11872bc392bec7fdf1a9edffe7ba14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Garc=C3=ADa=20Ruiz?= Date: Sat, 25 Feb 2023 17:33:22 +0100 Subject: [PATCH 1/7] [WIP] --- .../UserControls/Widgets/DrivesWidget.xaml.cs | 4 +- .../UserControls/Widgets/FileTagsWidget.xaml | 2 +- .../Widgets/FileTagsWidget.xaml.cs | 87 ++++++++++++------- .../UserControls/Widgets/HomePageWidget.cs | 2 +- .../Widgets/QuickAccessWidget.xaml.cs | 2 +- .../Widgets/RecentFilesWidget.xaml.cs | 2 +- .../UserControls/Widgets/WidgetCardItem.cs | 2 +- .../Widgets/FileTagsContainerViewModel.cs | 54 ++++++++++++ .../Widgets/FileTagsItemViewModel.cs | 48 ++++++++++ .../Widgets/FileTagsWidgetViewModel.cs | 43 +++++++++ 10 files changed, 209 insertions(+), 37 deletions(-) create mode 100644 src/Files.App/ViewModels/Widgets/FileTagsContainerViewModel.cs create mode 100644 src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs create mode 100644 src/Files.App/ViewModels/Widgets/FileTagsWidgetViewModel.cs diff --git a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs index 6254f267b3dd..21b8773866ef 100644 --- a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs @@ -140,8 +140,8 @@ public DrivesWidget() MapNetworkDriveCommand = new AsyncRelayCommand(DoNetworkMapDrive); DisconnectNetworkDriveCommand = new RelayCommand(DisconnectNetworkDrive); } - - public override List GetItemMenuItems(WidgetCardItem item, bool isPinned) + + public override List GetItemMenuItems(WidgetCardItem item, bool isPinned, bool isFolder = false) { var drive = ItemsAdded.Where(x => string.Equals(PathNormalization.NormalizePath(x.Path), PathNormalization.NormalizePath(item.Path), StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); var options = drive?.Item.MenuOptions; diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml index 40a7381a2779..c80a733022cd 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml @@ -8,7 +8,7 @@ xmlns:local="using:Files.App.UserControls.Widgets" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vc="using:Files.App.ValueConverters" - xmlns:vm="using:Files.Backend.ViewModels.Widgets.FileTagsWidget" + xmlns:vm="using:Files.App.ViewModels.Widgets" d:DesignHeight="300" d:DesignWidth="400" mc:Ignorable="d"> diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs index 23acf1fc2e5e..bce5c8ca03d1 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs @@ -1,11 +1,11 @@ -using CommunityToolkit.WinUI.UI; +using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.WinUI.UI; using Files.App.Extensions; using Files.App.Filesystem; using Files.App.Helpers; using Files.App.Helpers.ContextFlyouts; using Files.App.ViewModels; using Files.App.ViewModels.Widgets; -using Files.Backend.ViewModels.Widgets.FileTagsWidget; using Files.Shared.Extensions; using Microsoft.UI.Input; using Microsoft.UI.Xaml; @@ -52,6 +52,8 @@ public FileTagsWidget() // Second function is layered on top to ensure that OpenPath function is late initialized and a null reference is not passed-in // See FileTagItemViewModel._openAction for more information ViewModel = new(x => OpenAction!(x)); + OpenInNewTabCommand = new RelayCommand(OpenInNewTab); + OpenInNewWindowCommand = new RelayCommand(OpenInNewWindow); } private async void FileTagItem_ItemClick(object sender, ItemClickEventArgs e) @@ -60,48 +62,73 @@ private async void FileTagItem_ItemClick(object sender, ItemClickEventArgs e) await itemViewModel.ClickCommand.ExecuteAsync(null); } - private void Item_RightTapped(object sender, RightTappedRoutedEventArgs e) + private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e) { + App.Logger.Warn("rightTapped"); var itemContextMenuFlyout = new CommandBarFlyout { Placement = FlyoutPlacementMode.Full }; itemContextMenuFlyout.Opening += (sender, e) => App.LastOpenedFlyout = sender as CommandBarFlyout; if (sender is not StackPanel tagsItemsStackPanel || tagsItemsStackPanel.DataContext is not FileTagsItemViewModel item) return; + + App.Logger.Warn("Item path: " + item.Path + " widgetcarditem.path = " + (item as WidgetCardItem)?.Path); + var menuItems = GetItemMenuItems(item, QuickAccessService.IsItemPinned(item.Path)); + var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(menuItems); + + if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) + secondaryElements.OfType() + .ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width if the overflow menu setting is disabled + + secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i)); itemContextMenuFlyout.ShowAt(tagsItemsStackPanel, new FlyoutShowOptions { Position = e.GetPosition(tagsItemsStackPanel) }); - LoadShellMenuItems(item.Path, itemContextMenuFlyout); + await ShellContextmenuHelper.LoadShellMenuItems(item.Path, itemContextMenuFlyout); e.Handled = true; } - public async void LoadShellMenuItems(string item, CommandBarFlyout itemContextMenuFlyout) + public override List GetItemMenuItems(WidgetCardItem item, bool isPinned, bool isFolder = false) { - var shiftPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); - var shellMenuItems = await ContextFlyoutItemHelper.GetItemContextShellCommandsAsync(workingDir: null, - new List() { new ListedItem(null!) { ItemPath = item } }, shiftPressed: shiftPressed, showOpenMenu: false, default); - try + return new() { - var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(shellMenuItems); - if (!secondaryElements.Any()) - return; - - var openedPopups = Microsoft.UI.Xaml.Media.VisualTreeHelper.GetOpenPopups(App.Window); - var secondaryMenu = openedPopups.FirstOrDefault(popup => popup.Name == "OverflowPopup"); - - var itemsControl = secondaryMenu?.Child.FindDescendant(); - if (itemsControl is not null) + new ContextMenuFlyoutItemViewModel() + { + Text = "SideBarOpenInNewTab/Text".GetLocalizedResource(), + Glyph = "\uF113", + GlyphFontFamilyName = "CustomGlyph", + Command = OpenInNewTabCommand, + CommandParameter = item, + ShowItem = isFolder + }, + new ContextMenuFlyoutItemViewModel() { - var maxWidth = itemsControl.ActualWidth - Constants.UI.ContextMenuLabelMargin; - secondaryElements.OfType() - .ForEach(x => x.MaxWidth = maxWidth); // Set items max width to current menu width (#5555) + Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(), + Glyph = "\uE737", + Command = OpenInNewWindowCommand, + CommandParameter = item, + ShowItem = isFolder + }, + new ContextMenuFlyoutItemViewModel() + { + Text = "RecentItemOpenFileLocation/Text".GetLocalizedResource(), + Glyph = "\uED25", + Command = OpenFileLocationCommand, + CommandParameter = item, + ShowItem = !isFolder + }, + new ContextMenuFlyoutItemViewModel() + { + ItemType = ItemType.Separator, + Tag = "OverflowSeparator", + }, + new ContextMenuFlyoutItemViewModel() + { + Text = "LoadingMoreOptions".GetLocalizedResource(), + Glyph = "\xE712", + Items = new List(), + ID = "ItemOverflow", + Tag = "ItemOverflow", + IsEnabled = false, } - - secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i)); - } - catch { } - } - - public override List GetItemMenuItems(WidgetCardItem item, bool isPinned) - { - return new(); + }; } public Task RefreshWidget() diff --git a/src/Files.App/UserControls/Widgets/HomePageWidget.cs b/src/Files.App/UserControls/Widgets/HomePageWidget.cs index a0d911fc9b05..a7124ada5910 100644 --- a/src/Files.App/UserControls/Widgets/HomePageWidget.cs +++ b/src/Files.App/UserControls/Widgets/HomePageWidget.cs @@ -33,7 +33,7 @@ public abstract class HomePageWidget : UserControl protected CommandBarFlyout ItemContextMenuFlyout; - public abstract List GetItemMenuItems(WidgetCardItem item, bool isPinned); + public abstract List GetItemMenuItems(WidgetCardItem item, bool isPinned, bool isFolder = false); public void Button_RightTapped(object sender, RightTappedRoutedEventArgs e) { diff --git a/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs b/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs index 9c17cc21cda8..5db0593f2a39 100644 --- a/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs @@ -152,7 +152,7 @@ public QuickAccessWidget() public string WidgetHeader => "QuickAccess".GetLocalizedResource(); - public override List GetItemMenuItems(WidgetCardItem item, bool isPinned) + public override List GetItemMenuItems(WidgetCardItem item, bool isPinned, bool isFolder = false) { return new List() { diff --git a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs index 5a28676d189e..f2a7bf0d31da 100644 --- a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs @@ -121,7 +121,7 @@ private void Grid_RightTapped(object sender, RightTappedRoutedEventArgs e) e.Handled = true; } - public override List GetItemMenuItems(WidgetCardItem item, bool isPinned) + public override List GetItemMenuItems(WidgetCardItem item, bool isPinned, bool isFolder = false) { return new List() { diff --git a/src/Files.App/UserControls/Widgets/WidgetCardItem.cs b/src/Files.App/UserControls/Widgets/WidgetCardItem.cs index c124e0b8ba44..c44860bf2a22 100644 --- a/src/Files.App/UserControls/Widgets/WidgetCardItem.cs +++ b/src/Files.App/UserControls/Widgets/WidgetCardItem.cs @@ -4,7 +4,7 @@ namespace Files.App.UserControls.Widgets { public abstract class WidgetCardItem : ObservableObject { - public string Path; + public virtual string Path { get; set; } public virtual object Item { get; set; } } diff --git a/src/Files.App/ViewModels/Widgets/FileTagsContainerViewModel.cs b/src/Files.App/ViewModels/Widgets/FileTagsContainerViewModel.cs new file mode 100644 index 000000000000..4ced3c407170 --- /dev/null +++ b/src/Files.App/ViewModels/Widgets/FileTagsContainerViewModel.cs @@ -0,0 +1,54 @@ +using System; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.Backend.Services; +using Files.Shared.Utils; +using System.Collections.ObjectModel; +using System.Threading; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.Input; +using Files.Sdk.Storage.LocatableStorage; + +namespace Files.App.ViewModels.Widgets +{ + public sealed partial class FileTagsContainerViewModel : ObservableObject, IAsyncInitialize + { + private readonly string _tagUid; + private readonly Func _openAction; + + private IFileTagsService FileTagsService { get; } = Ioc.Default.GetRequiredService(); + + private IImageService ImageService { get; } = Ioc.Default.GetRequiredService(); + + public ObservableCollection Tags { get; } + + [ObservableProperty] + private string _Color; + + [ObservableProperty] + private string _Name; + + public FileTagsContainerViewModel(string tagUid, Func openAction) + { + _tagUid = tagUid; + _openAction = openAction; + Tags = new(); + } + + /// + public async Task InitAsync(CancellationToken cancellationToken = default) + { + await foreach (var item in FileTagsService.GetItemsForTagAsync(_tagUid, cancellationToken)) + { + var icon = await ImageService.GetIconAsync(item.Storable, cancellationToken); + Tags.Add(new(item.Storable, _openAction, icon)); + } + } + + [RelayCommand] + private Task ViewMore(CancellationToken cancellationToken) + { + return _openAction($"tag:{Name}"); + } + } +} diff --git a/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs b/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs new file mode 100644 index 000000000000..e6b5774c28bc --- /dev/null +++ b/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs @@ -0,0 +1,48 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Files.Backend.Models; +using Files.Sdk.Storage.Extensions; +using Files.Sdk.Storage.LocatableStorage; +using System; +using System.Threading; +using System.Threading.Tasks; +using Files.Backend.Helpers; +using Files.App.UserControls.Widgets; + +namespace Files.App.ViewModels.Widgets +{ + public sealed partial class FileTagsItemViewModel : WidgetCardItem + { + private readonly ILocatableStorable _associatedStorable; + private readonly Func _openAction; // A workaround for lack of MVVM-compliant navigation support. + // This workaround must be kept until further refactor of navigation code is completed + + [ObservableProperty] + private IImageModel? _Icon; + + [ObservableProperty] + private string _Name; + + private string path; + public override string Path + { + get => path; + set => SetProperty(ref path, value); + } + + public FileTagsItemViewModel(ILocatableStorable associatedStorable, Func openAction, IImageModel? icon) + { + _associatedStorable = associatedStorable; + _openAction = openAction; + _Icon = icon; + _Name = PathHelpers.FormatName(associatedStorable.Path); + Path = associatedStorable.TryGetPath(); + } + + [RelayCommand] + private Task ClickAsync(CancellationToken cancellationToken) + { + return _openAction(_associatedStorable.Path); + } + } +} diff --git a/src/Files.App/ViewModels/Widgets/FileTagsWidgetViewModel.cs b/src/Files.App/ViewModels/Widgets/FileTagsWidgetViewModel.cs new file mode 100644 index 000000000000..216b30e5feb6 --- /dev/null +++ b/src/Files.App/ViewModels/Widgets/FileTagsWidgetViewModel.cs @@ -0,0 +1,43 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.DependencyInjection; +using Files.Backend.Services; +using Files.Backend.ViewModels.Widgets.FileTagsWidget; +using Files.Shared.Utils; +using System; +using System.Collections.ObjectModel; +using System.Threading; +using System.Threading.Tasks; + +namespace Files.App.ViewModels.Widgets +{ + public sealed partial class FileTagsWidgetViewModel : ObservableObject, IAsyncInitialize + { + private readonly Func _openAction; + + private IFileTagsService FileTagsService { get; } = Ioc.Default.GetRequiredService(); + + public ObservableCollection Containers { get; } + + public FileTagsWidgetViewModel(Func openAction) + { + _openAction = openAction; + Containers = new(); + } + + /// + public async Task InitAsync(CancellationToken cancellationToken = default) + { + await foreach (var item in FileTagsService.GetTagsAsync(cancellationToken)) + { + var container = new FileTagsContainerViewModel(item.Uid, _openAction) + { + Name = item.Name, + Color = item.Color + }; + Containers.Add(container); + + _ = container.InitAsync(cancellationToken); + } + } + } +} From f1ae183516f226cc4f6fecf6de773019fd74247a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Garc=C3=ADa=20Ruiz?= Date: Sat, 25 Feb 2023 18:58:04 +0100 Subject: [PATCH 2/7] Add context menu to file tags widget --- .../Widgets/FileTagsWidget.xaml.cs | 80 ++++++++++++++++++- .../Widgets/FileTagsItemViewModel.cs | 2 + src/Files.App/Views/WidgetsPage.xaml.cs | 16 ++-- 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs index bce5c8ca03d1..516de39e8304 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs @@ -1,4 +1,5 @@ -using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.DependencyInjection; +using CommunityToolkit.Mvvm.Input; using CommunityToolkit.WinUI.UI; using Files.App.Extensions; using Files.App.Filesystem; @@ -6,6 +7,8 @@ using Files.App.Helpers.ContextFlyouts; using Files.App.ViewModels; using Files.App.ViewModels.Widgets; +using Files.App.Views; +using Files.Backend.Services.Settings; using Files.Shared.Extensions; using Microsoft.UI.Input; using Microsoft.UI.Xaml; @@ -14,8 +17,11 @@ using Microsoft.UI.Xaml.Input; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; +using System.Windows.Input; +using Windows.Storage; using Windows.System; using Windows.UI.Core; @@ -31,8 +37,16 @@ public FileTagsWidgetViewModel ViewModel set => DataContext = value; } + private readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService(); + public Func? OpenAction { get; set; } + public delegate void FileTagsOpenLocationInvokedEventHandler(object sender, PathNavigationEventArgs e); + public delegate void FileTagsNewPaneInvokedEventHandler(object sender, QuickAccessCardInvokedEventArgs e); + + public event FileTagsOpenLocationInvokedEventHandler FileTagsOpenLocationInvoked; + public event FileTagsNewPaneInvokedEventHandler FileTagsNewPaneInvoked; + public string WidgetName => nameof(BundlesWidget); public string WidgetHeader => "FileTags".GetLocalizedResource(); @@ -45,6 +59,8 @@ public FileTagsWidgetViewModel ViewModel public MenuFlyoutItem? MenuFlyoutItem => null; + private ICommand OpenInNewPaneCommand; + public FileTagsWidget() { InitializeComponent(); @@ -54,6 +70,16 @@ public FileTagsWidget() ViewModel = new(x => OpenAction!(x)); OpenInNewTabCommand = new RelayCommand(OpenInNewTab); OpenInNewWindowCommand = new RelayCommand(OpenInNewWindow); + OpenFileLocationCommand = new RelayCommand(OpenFileLocation); + OpenInNewPaneCommand = new RelayCommand(OpenInNewPane); + } + + private void OpenInNewPane(WidgetCardItem? item) + { + FileTagsNewPaneInvoked?.Invoke(this, new QuickAccessCardInvokedEventArgs() + { + Path = item?.Path ?? string.Empty + }); } private async void FileTagItem_ItemClick(object sender, ItemClickEventArgs e) @@ -71,7 +97,7 @@ private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e) return; App.Logger.Warn("Item path: " + item.Path + " widgetcarditem.path = " + (item as WidgetCardItem)?.Path); - var menuItems = GetItemMenuItems(item, QuickAccessService.IsItemPinned(item.Path)); + var menuItems = GetItemMenuItems(item, QuickAccessService.IsItemPinned(item.Path), item.IsFolder); var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(menuItems); if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) @@ -87,7 +113,7 @@ private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e) public override List GetItemMenuItems(WidgetCardItem item, bool isPinned, bool isFolder = false) { - return new() + return new List() { new ContextMenuFlyoutItemViewModel() { @@ -115,6 +141,43 @@ public override List GetItemMenuItems(WidgetCard ShowItem = !isFolder }, new ContextMenuFlyoutItemViewModel() + { + Text = "OpenInNewPane".GetLocalizedResource(), + ColoredIcon = new ColoredIconModel() + { + BaseBackdropGlyph = "\uF056", + BaseLayerGlyph = "\uF03B", + OverlayLayerGlyph = "\uF03C", + }, + Command = OpenInNewPaneCommand, + CommandParameter = item, + ShowItem = userSettingsService.PreferencesSettingsService.ShowOpenInNewPane && isFolder + }, + new ContextMenuFlyoutItemViewModel() + { + Text = "BaseLayoutItemContextFlyoutPinToFavorites/Text".GetLocalizedResource(), + Glyph = "\uE840", + Command = PinToFavoritesCommand, + CommandParameter = item, + ShowItem = !isPinned && isFolder + }, + new ContextMenuFlyoutItemViewModel() + { + Text = "SideBarUnpinFromFavorites/Text".GetLocalizedResource(), + Glyph = "\uE77A", + Command = UnpinFromFavoritesCommand, + CommandParameter = item, + ShowItem = isPinned && isFolder + }, + new ContextMenuFlyoutItemViewModel() + { + Text = "BaseLayoutContextFlyoutPropertiesFolder/Text".GetLocalizedResource(), + Glyph = "\uE946", + Command = OpenPropertiesCommand, + CommandParameter = item, + ShowItem = isFolder + }, + new ContextMenuFlyoutItemViewModel() { ItemType = ItemType.Separator, Tag = "OverflowSeparator", @@ -128,7 +191,16 @@ public override List GetItemMenuItems(WidgetCard Tag = "ItemOverflow", IsEnabled = false, } - }; + }.Where(x => x.ShowItem).ToList(); + } + + public void OpenFileLocation(WidgetCardItem? item) + { + FileTagsOpenLocationInvoked?.Invoke(this, new PathNavigationEventArgs() + { + ItemPath = Directory.GetParent(item?.Path ?? string.Empty)?.FullName ?? string.Empty, + ItemName = Path.GetFileName(item?.Path ?? string.Empty), + }); } public Task RefreshWidget() diff --git a/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs b/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs index e6b5774c28bc..8849bab50b5e 100644 --- a/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs +++ b/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs @@ -30,6 +30,8 @@ public override string Path set => SetProperty(ref path, value); } + public bool IsFolder => _associatedStorable is ILocatableFolder; + public FileTagsItemViewModel(ILocatableStorable associatedStorable, Func openAction, IImageModel? icon) { _associatedStorable = associatedStorable; diff --git a/src/Files.App/Views/WidgetsPage.xaml.cs b/src/Files.App/Views/WidgetsPage.xaml.cs index cbe1959f3180..f851c3a3162e 100644 --- a/src/Files.App/Views/WidgetsPage.xaml.cs +++ b/src/Files.App/Views/WidgetsPage.xaml.cs @@ -72,10 +72,10 @@ public void ReloadWidgets() Widgets.ViewModel.InsertWidget(new(quickAccessWidget, (value) => UserSettingsService.PreferencesSettingsService.FoldersWidgetExpanded = value, () => UserSettingsService.PreferencesSettingsService.FoldersWidgetExpanded), 0); quickAccessWidget.CardInvoked -= QuickAccessWidget_CardInvoked; - quickAccessWidget.CardNewPaneInvoked -= QuickAccessWidget_CardNewPaneInvoked; + quickAccessWidget.CardNewPaneInvoked -= WidgetCardNewPaneInvoked; quickAccessWidget.CardPropertiesInvoked -= QuickAccessWidget_CardPropertiesInvoked; quickAccessWidget.CardInvoked += QuickAccessWidget_CardInvoked; - quickAccessWidget.CardNewPaneInvoked += QuickAccessWidget_CardNewPaneInvoked; + quickAccessWidget.CardNewPaneInvoked += WidgetCardNewPaneInvoked; quickAccessWidget.CardPropertiesInvoked += QuickAccessWidget_CardPropertiesInvoked; } if (shouldReloadDrivesWidget && drivesWidget is not null) @@ -92,6 +92,10 @@ public void ReloadWidgets() { Widgets.ViewModel.InsertWidget(new(fileTagsWidget, (value) => UserSettingsService.PreferencesSettingsService.FileTagsWidgetExpanded = value, () => UserSettingsService.PreferencesSettingsService.FileTagsWidgetExpanded), 2); fileTagsWidget.OpenAction = x => NavigationHelpers.OpenPath(x, AppInstance); + fileTagsWidget.FileTagsOpenLocationInvoked -= WidgetOpenLocationInvoked; + fileTagsWidget.FileTagsNewPaneInvoked -= WidgetCardNewPaneInvoked; + fileTagsWidget.FileTagsOpenLocationInvoked += WidgetOpenLocationInvoked; + fileTagsWidget.FileTagsNewPaneInvoked += WidgetCardNewPaneInvoked; _ = fileTagsWidget.ViewModel.InitAsync(); } if (shouldReloadBundles && bundlesWidget is not null) @@ -103,9 +107,9 @@ public void ReloadWidgets() { Widgets.ViewModel.InsertWidget(new(recentFilesWidget, (value) => UserSettingsService.PreferencesSettingsService.RecentFilesWidgetExpanded = value, () => UserSettingsService.PreferencesSettingsService.RecentFilesWidgetExpanded), 4); - recentFilesWidget.RecentFilesOpenLocationInvoked -= RecentFilesWidget_RecentFilesOpenLocationInvoked; + recentFilesWidget.RecentFilesOpenLocationInvoked -= WidgetOpenLocationInvoked; recentFilesWidget.RecentFileInvoked -= RecentFilesWidget_RecentFileInvoked; - recentFilesWidget.RecentFilesOpenLocationInvoked += RecentFilesWidget_RecentFilesOpenLocationInvoked; + recentFilesWidget.RecentFilesOpenLocationInvoked += WidgetOpenLocationInvoked; recentFilesWidget.RecentFileInvoked += RecentFilesWidget_RecentFileInvoked; } } @@ -157,7 +161,7 @@ await DialogDisplayHelper.ShowDialogAsync( } } - private void RecentFilesWidget_RecentFilesOpenLocationInvoked(object sender, UserControls.PathNavigationEventArgs e) + private void WidgetOpenLocationInvoked(object sender, UserControls.PathNavigationEventArgs e) { AppInstance.NavigateWithArguments(FolderSettings.GetLayoutType(e.ItemPath), new NavigationArguments() { @@ -176,7 +180,7 @@ private void QuickAccessWidget_CardInvoked(object sender, QuickAccessCardInvoked AppInstance.InstanceViewModel.IsPageTypeNotHome = true; // show controls that were hidden on the home page } - private void QuickAccessWidget_CardNewPaneInvoked(object sender, QuickAccessCardInvokedEventArgs e) + private void WidgetCardNewPaneInvoked(object sender, QuickAccessCardInvokedEventArgs e) { AppInstance.PaneHolder?.OpenPathInNewPane(e.Path); } From 7271a225edac34a6510f93e028a0265af6e7b950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Garc=C3=ADa=20Ruiz?= Date: Sun, 26 Feb 2023 16:29:19 +0100 Subject: [PATCH 3/7] Add missing commands --- .../Widgets/FileTagsWidget.xaml.cs | 25 ++++++++++++++++++- .../Widgets/FileTagsItemViewModel.cs | 1 + src/Files.App/Views/WidgetsPage.xaml.cs | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs index 516de39e8304..a7ff2bbd7d96 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs @@ -39,6 +39,7 @@ public FileTagsWidgetViewModel ViewModel private readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService(); + public IShellPage AppInstance; public Func? OpenAction { get; set; } public delegate void FileTagsOpenLocationInvokedEventHandler(object sender, PathNavigationEventArgs e); @@ -72,6 +73,27 @@ public FileTagsWidget() OpenInNewWindowCommand = new RelayCommand(OpenInNewWindow); OpenFileLocationCommand = new RelayCommand(OpenFileLocation); OpenInNewPaneCommand = new RelayCommand(OpenInNewPane); + PinToFavoritesCommand = new RelayCommand(PinToFavorites); + UnpinFromFavoritesCommand = new RelayCommand(UnpinFromFavorites); + OpenPropertiesCommand = new RelayCommand(OpenProperties); + } + + private void OpenProperties(WidgetCardItem? item) + { + EventHandler flyoutClosed = null!; + flyoutClosed = async (s, e) => + { + ItemContextMenuFlyout.Closed -= flyoutClosed; + ListedItem listedItem = new(null!) + { + ItemPath = (item.Item as FileTagsItemViewModel).Path, + ItemNameRaw = (item.Item as FileTagsItemViewModel).Name, + PrimaryItemAttribute = StorageItemTypes.Folder, + ItemType = "Folder".GetLocalizedResource(), + }; + await FilePropertiesHelpers.OpenPropertiesWindowAsync(listedItem, AppInstance); + }; + ItemContextMenuFlyout.Closed += flyoutClosed; } private void OpenInNewPane(WidgetCardItem? item) @@ -105,6 +127,7 @@ private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e) .ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width if the overflow menu setting is disabled secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i)); + ItemContextMenuFlyout = itemContextMenuFlyout; itemContextMenuFlyout.ShowAt(tagsItemsStackPanel, new FlyoutShowOptions { Position = e.GetPosition(tagsItemsStackPanel) }); await ShellContextmenuHelper.LoadShellMenuItems(item.Path, itemContextMenuFlyout); @@ -184,7 +207,7 @@ public override List GetItemMenuItems(WidgetCard }, new ContextMenuFlyoutItemViewModel() { - Text = "LoadingMoreOptions".GetLocalizedResource(), + Text = "Loading".GetLocalizedResource(), Glyph = "\xE712", Items = new List(), ID = "ItemOverflow", diff --git a/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs b/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs index 8849bab50b5e..b88f3bf96105 100644 --- a/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs +++ b/src/Files.App/ViewModels/Widgets/FileTagsItemViewModel.cs @@ -39,6 +39,7 @@ public FileTagsItemViewModel(ILocatableStorable associatedStorable, Func UserSettingsService.PreferencesSettingsService.FileTagsWidgetExpanded = value, () => UserSettingsService.PreferencesSettingsService.FileTagsWidgetExpanded), 2); + + fileTagsWidget.AppInstance = AppInstance; fileTagsWidget.OpenAction = x => NavigationHelpers.OpenPath(x, AppInstance); fileTagsWidget.FileTagsOpenLocationInvoked -= WidgetOpenLocationInvoked; fileTagsWidget.FileTagsNewPaneInvoked -= WidgetCardNewPaneInvoked; From 8d9858f183db4ab396a30acfac70e7009a901afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Garc=C3=ADa=20Ruiz?= Date: Sun, 26 Feb 2023 19:24:24 +0100 Subject: [PATCH 4/7] Add open with and send to to items --- .../UserControls/InnerNavigationToolbar.xaml | 52 +++++++++---------- .../Widgets/FileTagsWidget.xaml.cs | 19 ++++++- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/Files.App/UserControls/InnerNavigationToolbar.xaml b/src/Files.App/UserControls/InnerNavigationToolbar.xaml index 249acf06e21d..57156f9fdc38 100644 --- a/src/Files.App/UserControls/InnerNavigationToolbar.xaml +++ b/src/Files.App/UserControls/InnerNavigationToolbar.xaml @@ -79,7 +79,7 @@ Command="{x:Bind ViewModel.CreateNewFileCommand, Mode=OneWay}" CommandParameter="{x:Null}" IsEnabled="{x:Bind ViewModel.InstanceViewModel.CanCreateFileInPage, Mode=OneWay}" - Text="{helpers:ResourceString Name=File}"> + Text="{helpers:ResourceString Name=BaseLayoutContextFlyoutNewFile/Text}"> @@ -135,9 +135,9 @@ AutomationProperties.AutomationId="InnerNavigationToolbarPasteButton" Command="{x:Bind ViewModel.PasteItemsFromClipboardCommand, Mode=OneWay}" IsEnabled="{x:Bind converters:MultiBooleanConverter.AndConvert(ViewModel.InstanceViewModel.CanPasteInPage, local1:App.AppModel.IsPasteEnabled), Mode=OneWay, FallbackValue=False}" - Label="{helpers:ResourceString Name=Paste}" + Label="{helpers:ResourceString Name=NavigationToolbarPaste/Label}" LabelPosition="Collapsed" - ToolTipService.ToolTip="{helpers:ResourceString Name=Paste}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=BaseLayoutContextFlyoutPaste/Text}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=BaseLayoutItemContextFlyoutRename/Text}"> @@ -192,12 +192,12 @@ Width="Auto" MinWidth="40" AccessKey="O" - AutomationProperties.Name="{helpers:ResourceString Name=Properties}" + AutomationProperties.Name="{helpers:ResourceString Name=PropertiesTitle}" Command="{x:Bind ViewModel.PropertiesCommand, Mode=OneWay}" IsEnabled="{x:Bind converters:MultiBooleanConverter.AndConvert(ViewModel.CanViewProperties, ViewModel.InstanceViewModel.IsPageTypeNotHome), Mode=OneWay, FallbackValue=False}" - Label="{helpers:ResourceString Name=Properties}" + Label="{helpers:ResourceString Name=PropertiesTitle}" LabelPosition="Collapsed" - ToolTipService.ToolTip="{helpers:ResourceString Name=Properties}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=PropertiesTitle}"> @@ -230,8 +230,8 @@ AccessKey="R" Command="{x:Bind ViewModel.RestoreSelectionRecycleBinCommand, Mode=OneWay}" IsEnabled="{x:Bind ViewModel.CanRestoreSelectionRecycleBin, Mode=OneWay}" - Label="{helpers:ResourceString Name=Restore}" - ToolTipService.ToolTip="{helpers:ResourceString Name=Restore}" + Label="{helpers:ResourceString Name=RestoreSelection}" + ToolTipService.ToolTip="{helpers:ResourceString Name=RestoreSelection}" Visibility="{x:Bind ViewModel.CanRestoreSelectionRecycleBin, Mode=OneWay}"> @@ -417,11 +417,11 @@ MinWidth="40" x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}" AccessKey="S" - AutomationProperties.Name="{helpers:ResourceString Name=SelectionOptions}" + AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarSelectionOptions/AutomationProperties/Name}" Label="{helpers:ResourceString Name=NavToolbarSelectionOptions/Label}" LabelPosition="Collapsed" Style="{StaticResource ToolBarAppBarButtonFlyoutStyle}" - ToolTipService.ToolTip="{helpers:ResourceString Name=SelectionOptions}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=NavToolbarSelectionOptions/ToolTipService/ToolTip}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=NavToolbarSortOptionsButton/ToolTipService/ToolTip}"> - + - + - + - + + ToolTipService.ToolTip="{helpers:ResourceString Name=NavToolbarLayoutOptionsButton/ToolTipService/ToolTip}"> - + @@ -633,7 +633,7 @@ Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" - AutomationProperties.Name="{helpers:ResourceString Name=SmallIcons}" + AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarSmallIcons/AutomationProperties/Name}" Command="{x:Bind ViewModel.InstanceViewModel.FolderSettings.ToggleLayoutModeGridViewSmallCommand, Mode=OneWay}" CommandParameter="{xh:SystemTypeToXaml Bool=True}" CornerRadius="{StaticResource ControlCornerRadius}" @@ -660,7 +660,7 @@ Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" - AutomationProperties.Name="{helpers:ResourceString Name=MediumIcons}" + AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarMediumIcons/AutomationProperties/Name}" Command="{x:Bind ViewModel.InstanceViewModel.FolderSettings.ToggleLayoutModeGridViewMediumCommand, Mode=OneWay}" CommandParameter="{xh:SystemTypeToXaml Bool=True}" CornerRadius="{StaticResource ControlCornerRadius}" @@ -696,7 +696,7 @@ Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" - AutomationProperties.Name="{helpers:ResourceString Name=LargeIcons}" + AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarLargeIcons/AutomationProperties/Name}" Command="{x:Bind ViewModel.InstanceViewModel.FolderSettings.ToggleLayoutModeGridViewLargeCommand, Mode=OneWay}" CommandParameter="{xh:SystemTypeToXaml Bool=True}" CornerRadius="{StaticResource ControlCornerRadius}" diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs index a7ff2bbd7d96..c457322d1fa6 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs @@ -130,7 +130,7 @@ private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e) ItemContextMenuFlyout = itemContextMenuFlyout; itemContextMenuFlyout.ShowAt(tagsItemsStackPanel, new FlyoutShowOptions { Position = e.GetPosition(tagsItemsStackPanel) }); - await ShellContextmenuHelper.LoadShellMenuItems(item.Path, itemContextMenuFlyout); + await ShellContextmenuHelper.LoadShellMenuItems(item.Path, itemContextMenuFlyout, showOpenWithMenu: true, showSendToMenu: true); e.Handled = true; } @@ -138,6 +138,21 @@ public override List GetItemMenuItems(WidgetCard { return new List() { + new ContextMenuFlyoutItemViewModel() + { + Text = "OpenItemsWithCaptionText".GetLocalizedResource(), + Glyph = "\uE17D", + Tag = "OpenWithPlaceholder", + IsEnabled = false, + ShowItem = !isFolder + }, + new ContextMenuFlyoutItemViewModel() + { + Text = "SendTo".GetLocalizedResource(), + Tag = "SendToPlaceholder", + IsEnabled = false, + ShowItem = !isFolder + }, new ContextMenuFlyoutItemViewModel() { Text = "SideBarOpenInNewTab/Text".GetLocalizedResource(), @@ -157,7 +172,7 @@ public override List GetItemMenuItems(WidgetCard }, new ContextMenuFlyoutItemViewModel() { - Text = "RecentItemOpenFileLocation/Text".GetLocalizedResource(), + Text = "OpenFileLocation".GetLocalizedResource(), Glyph = "\uED25", Command = OpenFileLocationCommand, CommandParameter = item, From 5679876eae497c772e4e7515d836da4434a40683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Garc=C3=ADa=20Ruiz?= Date: Sun, 26 Feb 2023 19:31:56 +0100 Subject: [PATCH 5/7] Fix error --- .../UserControls/InnerNavigationToolbar.xaml | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Files.App/UserControls/InnerNavigationToolbar.xaml b/src/Files.App/UserControls/InnerNavigationToolbar.xaml index 57156f9fdc38..249acf06e21d 100644 --- a/src/Files.App/UserControls/InnerNavigationToolbar.xaml +++ b/src/Files.App/UserControls/InnerNavigationToolbar.xaml @@ -79,7 +79,7 @@ Command="{x:Bind ViewModel.CreateNewFileCommand, Mode=OneWay}" CommandParameter="{x:Null}" IsEnabled="{x:Bind ViewModel.InstanceViewModel.CanCreateFileInPage, Mode=OneWay}" - Text="{helpers:ResourceString Name=BaseLayoutContextFlyoutNewFile/Text}"> + Text="{helpers:ResourceString Name=File}"> @@ -135,9 +135,9 @@ AutomationProperties.AutomationId="InnerNavigationToolbarPasteButton" Command="{x:Bind ViewModel.PasteItemsFromClipboardCommand, Mode=OneWay}" IsEnabled="{x:Bind converters:MultiBooleanConverter.AndConvert(ViewModel.InstanceViewModel.CanPasteInPage, local1:App.AppModel.IsPasteEnabled), Mode=OneWay, FallbackValue=False}" - Label="{helpers:ResourceString Name=NavigationToolbarPaste/Label}" + Label="{helpers:ResourceString Name=Paste}" LabelPosition="Collapsed" - ToolTipService.ToolTip="{helpers:ResourceString Name=BaseLayoutContextFlyoutPaste/Text}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=Paste}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=Rename}"> @@ -192,12 +192,12 @@ Width="Auto" MinWidth="40" AccessKey="O" - AutomationProperties.Name="{helpers:ResourceString Name=PropertiesTitle}" + AutomationProperties.Name="{helpers:ResourceString Name=Properties}" Command="{x:Bind ViewModel.PropertiesCommand, Mode=OneWay}" IsEnabled="{x:Bind converters:MultiBooleanConverter.AndConvert(ViewModel.CanViewProperties, ViewModel.InstanceViewModel.IsPageTypeNotHome), Mode=OneWay, FallbackValue=False}" - Label="{helpers:ResourceString Name=PropertiesTitle}" + Label="{helpers:ResourceString Name=Properties}" LabelPosition="Collapsed" - ToolTipService.ToolTip="{helpers:ResourceString Name=PropertiesTitle}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=Properties}"> @@ -230,8 +230,8 @@ AccessKey="R" Command="{x:Bind ViewModel.RestoreSelectionRecycleBinCommand, Mode=OneWay}" IsEnabled="{x:Bind ViewModel.CanRestoreSelectionRecycleBin, Mode=OneWay}" - Label="{helpers:ResourceString Name=RestoreSelection}" - ToolTipService.ToolTip="{helpers:ResourceString Name=RestoreSelection}" + Label="{helpers:ResourceString Name=Restore}" + ToolTipService.ToolTip="{helpers:ResourceString Name=Restore}" Visibility="{x:Bind ViewModel.CanRestoreSelectionRecycleBin, Mode=OneWay}"> @@ -417,11 +417,11 @@ MinWidth="40" x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}" AccessKey="S" - AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarSelectionOptions/AutomationProperties/Name}" + AutomationProperties.Name="{helpers:ResourceString Name=SelectionOptions}" Label="{helpers:ResourceString Name=NavToolbarSelectionOptions/Label}" LabelPosition="Collapsed" Style="{StaticResource ToolBarAppBarButtonFlyoutStyle}" - ToolTipService.ToolTip="{helpers:ResourceString Name=NavToolbarSelectionOptions/ToolTipService/ToolTip}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=SelectionOptions}"> + ToolTipService.ToolTip="{helpers:ResourceString Name=Sort}"> - + - + - + - + + ToolTipService.ToolTip="{helpers:ResourceString Name=Layout}"> - + @@ -633,7 +633,7 @@ Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" - AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarSmallIcons/AutomationProperties/Name}" + AutomationProperties.Name="{helpers:ResourceString Name=SmallIcons}" Command="{x:Bind ViewModel.InstanceViewModel.FolderSettings.ToggleLayoutModeGridViewSmallCommand, Mode=OneWay}" CommandParameter="{xh:SystemTypeToXaml Bool=True}" CornerRadius="{StaticResource ControlCornerRadius}" @@ -660,7 +660,7 @@ Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" - AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarMediumIcons/AutomationProperties/Name}" + AutomationProperties.Name="{helpers:ResourceString Name=MediumIcons}" Command="{x:Bind ViewModel.InstanceViewModel.FolderSettings.ToggleLayoutModeGridViewMediumCommand, Mode=OneWay}" CommandParameter="{xh:SystemTypeToXaml Bool=True}" CornerRadius="{StaticResource ControlCornerRadius}" @@ -696,7 +696,7 @@ Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" - AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarLargeIcons/AutomationProperties/Name}" + AutomationProperties.Name="{helpers:ResourceString Name=LargeIcons}" Command="{x:Bind ViewModel.InstanceViewModel.FolderSettings.ToggleLayoutModeGridViewLargeCommand, Mode=OneWay}" CommandParameter="{xh:SystemTypeToXaml Bool=True}" CornerRadius="{StaticResource ControlCornerRadius}" From 21cffbb14c2427fed589ffee69b17e27bea1c075 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 26 Feb 2023 16:22:43 -0500 Subject: [PATCH 6/7] New icons --- .../Helpers/ContextFlyoutItemHelper.cs | 5 ++--- .../Helpers/ShellContextMenuHelper.cs | 5 ++--- .../UserControls/SidebarControl.xaml.cs | 22 ++++++++++++------- .../Widgets/FileTagsWidget.xaml.cs | 22 ++++++++++++------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/Files.App/Helpers/ContextFlyoutItemHelper.cs b/src/Files.App/Helpers/ContextFlyoutItemHelper.cs index 6730216e3909..de017f7b2204 100644 --- a/src/Files.App/Helpers/ContextFlyoutItemHelper.cs +++ b/src/Files.App/Helpers/ContextFlyoutItemHelper.cs @@ -218,10 +218,9 @@ public static List GetBaseItemMenuItems( new ContextMenuFlyoutItemViewModel() { Text = "SortBy".GetLocalizedResource(), - ColoredIcon = new ColoredIconModel() + OpacityIcon = new OpacityIconModel() { - BaseLayerGlyph = "\uF029", - OverlayLayerGlyph = "\uF02A", + OpacityIconStyle = "ColorIconSort", }, ShowInRecycleBin = true, ShowInSearchPage = true, diff --git a/src/Files.App/Helpers/ShellContextMenuHelper.cs b/src/Files.App/Helpers/ShellContextMenuHelper.cs index 24e6977dc661..024d5d550aa9 100644 --- a/src/Files.App/Helpers/ShellContextMenuHelper.cs +++ b/src/Files.App/Helpers/ShellContextMenuHelper.cs @@ -272,10 +272,9 @@ public static async Task LoadShellMenuItems( var openWithItem = shellMenuItems.Where(x => (x.Tag as Win32ContextMenuItem)?.CommandString == "openas").ToList().FirstOrDefault(); if (openWithItem is not null) { - openWithItem.ColoredIcon = new ColoredIconModel() + openWithItem.OpacityIcon = new OpacityIconModel() { - BaseLayerGlyph = "\uF049", - OverlayLayerGlyph = "\uF04A", + OpacityIconStyle = "ColorIconOpenWith", }; var (_, openWithItems) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(new List() { openWithItem }); var placeholder = itemContextMenuFlyout.SecondaryCommands.Where(x => Equals((x as AppBarButton)?.Tag, "OpenWithPlaceholder")).FirstOrDefault() as AppBarButton; diff --git a/src/Files.App/UserControls/SidebarControl.xaml.cs b/src/Files.App/UserControls/SidebarControl.xaml.cs index a76c02674cda..0d6e3c2a84ce 100644 --- a/src/Files.App/UserControls/SidebarControl.xaml.cs +++ b/src/Files.App/UserControls/SidebarControl.xaml.cs @@ -213,26 +213,29 @@ private List GetLocationItemMenuItems(INavigatio new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewTab".GetLocalizedResource(), - Glyph = "\uF113", - GlyphFontFamilyName = "CustomGlyph", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewTab", + }, Command = OpenInNewTabCommand, ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab }, new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewWindow".GetLocalizedResource(), - Glyph = "\uE737", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewWindow", + }, Command = OpenInNewWindowCommand, ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab }, new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewPane".GetLocalizedResource(), - ColoredIcon = new ColoredIconModel() + OpacityIcon = new OpacityIconModel() { - BaseBackdropGlyph = "\uF056", - BaseLayerGlyph = "\uF03B", - OverlayLayerGlyph = "\uF03C", + OpacityIconStyle = "ColorIconRightPane", }, Command = OpenInNewPaneCommand, ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewPane @@ -276,7 +279,10 @@ private List GetLocationItemMenuItems(INavigatio new ContextMenuFlyoutItemViewModel() { Text = "Properties".GetLocalizedResource(), - Glyph = "\uE946", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconProperties", + }, Command = OpenPropertiesCommand, CommandParameter = menu, ShowItem = options.ShowProperties diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs index c457322d1fa6..b7f3f4f8f7f3 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs @@ -141,7 +141,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenItemsWithCaptionText".GetLocalizedResource(), - Glyph = "\uE17D", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenWith", + }, Tag = "OpenWithPlaceholder", IsEnabled = false, ShowItem = !isFolder @@ -156,8 +159,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "SideBarOpenInNewTab/Text".GetLocalizedResource(), - Glyph = "\uF113", - GlyphFontFamilyName = "CustomGlyph", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewTab", + }, Command = OpenInNewTabCommand, CommandParameter = item, ShowItem = isFolder @@ -165,7 +170,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(), - Glyph = "\uE737", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewWindow", + }, Command = OpenInNewWindowCommand, CommandParameter = item, ShowItem = isFolder @@ -181,11 +189,9 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewPane".GetLocalizedResource(), - ColoredIcon = new ColoredIconModel() + OpacityIcon = new OpacityIconModel() { - BaseBackdropGlyph = "\uF056", - BaseLayerGlyph = "\uF03B", - OverlayLayerGlyph = "\uF03C", + OpacityIconStyle = "ColorIconRightPane", }, Command = OpenInNewPaneCommand, CommandParameter = item, From 7896b021489873dc879d220169aafb9aa40b2897 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 26 Feb 2023 16:33:36 -0500 Subject: [PATCH 7/7] More icons --- .../UserControls/Widgets/DrivesWidget.xaml.cs | 21 ++++++++++++------ .../Widgets/QuickAccessWidget.xaml.cs | 22 ++++++++++++------- .../Widgets/RecentFilesWidget.xaml.cs | 5 ++++- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs index e2a51742ea26..3504076f0462 100644 --- a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs @@ -151,7 +151,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewTab".GetLocalizedResource(), - Glyph = "\uF113", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewTab", + }, GlyphFontFamilyName = "CustomGlyph", Command = OpenInNewTabCommand, CommandParameter = item, @@ -160,7 +163,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewWindow".GetLocalizedResource(), - Glyph = "\uE737", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewWindow", + }, Command = OpenInNewWindowCommand, CommandParameter = item, ShowItem = userSettingsService.PreferencesSettingsService.ShowOpenInNewWindow @@ -168,11 +174,9 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewPane".GetLocalizedResource(), - ColoredIcon = new ColoredIconModel() + OpacityIcon = new OpacityIconModel() { - BaseBackdropGlyph = "\uF056", - BaseLayerGlyph = "\uF03B", - OverlayLayerGlyph = "\uF03C", + OpacityIconStyle = "ColorIconRightPane", }, Command = OpenInNewPaneCommand, CommandParameter = item, @@ -213,7 +217,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "Properties".GetLocalizedResource(), - Glyph = "\uE946", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconProperties", + }, Command = OpenPropertiesCommand, CommandParameter = item }, diff --git a/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs b/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs index d825a49a4dda..bb34acab94e8 100644 --- a/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs @@ -155,8 +155,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewTab".GetLocalizedResource(), - Glyph = "\uF113", - GlyphFontFamilyName = "CustomGlyph", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewTab", + }, Command = OpenInNewTabCommand, CommandParameter = item, ShowItem = userSettingsService.PreferencesSettingsService.ShowOpenInNewTab @@ -164,7 +166,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewWindow".GetLocalizedResource(), - Glyph = "\uE737", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenInNewWindow", + }, Command = OpenInNewWindowCommand, CommandParameter = item, ShowItem = userSettingsService.PreferencesSettingsService.ShowOpenInNewWindow @@ -172,11 +177,9 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenInNewPane".GetLocalizedResource(), - ColoredIcon = new ColoredIconModel() + OpacityIcon = new OpacityIconModel() { - BaseBackdropGlyph = "\uF056", - BaseLayerGlyph = "\uF03B", - OverlayLayerGlyph = "\uF03C", + OpacityIconStyle = "ColorIconRightPane", }, Command = OpenInNewPaneCommand, CommandParameter = item, @@ -201,7 +204,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "Properties".GetLocalizedResource(), - Glyph = "\uE946", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconProperties", + }, Command = OpenPropertiesCommand, CommandParameter = item }, diff --git a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs index 8078d1d278f9..b38d208b992b 100644 --- a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs @@ -128,7 +128,10 @@ public override List GetItemMenuItems(WidgetCard new ContextMenuFlyoutItemViewModel() { Text = "OpenItemsWithCaptionText".GetLocalizedResource(), - Glyph = "\uE17D", + OpacityIcon = new OpacityIconModel() + { + OpacityIconStyle = "ColorIconOpenWith", + }, Tag = "OpenWithPlaceholder", IsEnabled = false },