diff --git a/src/Files.App/Actions/Display/LayoutAction.cs b/src/Files.App/Actions/Display/LayoutAction.cs index ccb92a3fc822..7e99a6d016fe 100644 --- a/src/Files.App/Actions/Display/LayoutAction.cs +++ b/src/Files.App/Actions/Display/LayoutAction.cs @@ -9,10 +9,10 @@ protected override LayoutTypes LayoutType => LayoutTypes.Details; public override string Label - => "Details".GetLocalizedResource(); + => Strings.Details.GetLocalizedResource(); public override string Description - => "LayoutDetailsDescription".GetLocalizedResource(); + => Strings.LayoutDetailsDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.IconLayout.Details"); @@ -27,10 +27,10 @@ protected override LayoutTypes LayoutType => LayoutTypes.List; public override string Label - => "List".GetLocalizedResource(); + => Strings.List.GetLocalizedResource(); public override string Description - => "LayoutListDescription".GetLocalizedResource(); + => Strings.LayoutListDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.IconLayout.List"); @@ -39,16 +39,16 @@ public override HotKey HotKey => new(Keys.Number2, KeyModifiers.CtrlShift); } - internal sealed class LayoutTilesAction : ToggleLayoutAction + internal sealed class LayoutCardsAction : ToggleLayoutAction { protected override LayoutTypes LayoutType - => LayoutTypes.Tiles; + => LayoutTypes.Cards; public override string Label - => "Tiles".GetLocalizedResource(); + => Strings.Cards.GetLocalizedResource(); public override string Description - => "LayoutTilesDescription".GetLocalizedResource(); + => Strings.LayoutCardsDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.IconLayout.Tiles"); @@ -63,10 +63,10 @@ protected override LayoutTypes LayoutType => LayoutTypes.Grid; public override string Label - => "Grid".GetLocalizedResource(); + => Strings.Grid.GetLocalizedResource(); public override string Description - => "LayoutGridDescription".GetLocalizedResource(); + => Strings.LayoutGridDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.IconSize.Small"); @@ -81,10 +81,10 @@ protected override LayoutTypes LayoutType => LayoutTypes.Columns; public override string Label - => "Columns".GetLocalizedResource(); + => Strings.Columns.GetLocalizedResource(); public override string Description - => "LayoutColumnsDescription".GetLocalizedResource(); + => Strings.LayoutColumnsDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.IconLayout.Columns"); @@ -99,10 +99,10 @@ protected override LayoutTypes LayoutType => LayoutTypes.Adaptive; public override string Label - => "Adaptive".GetLocalizedResource(); + => Strings.Adaptive.GetLocalizedResource(); public override string Description - => "LayoutAdaptiveDescription".GetLocalizedResource(); + => Strings.LayoutAdaptiveDescription.GetLocalizedResource(); public override bool IsExecutable => Context.IsLayoutAdaptiveEnabled; @@ -174,10 +174,10 @@ internal sealed class LayoutDecreaseSizeAction : ObservableObject, IAction private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService(); public string Label - => "DecreaseSize".GetLocalizedResource(); + => Strings.DecreaseSize.GetLocalizedResource(); public string Description - => "LayoutDecreaseSizeDescription".GetLocalizedResource(); + => Strings.LayoutDecreaseSizeDescription.GetLocalizedResource(); public HotKey HotKey => new(Keys.Subtract, KeyModifiers.Ctrl); @@ -190,6 +190,7 @@ ContentPageContext.PageType is not ContentPageTypes.Home && ContentPageContext.ShellPage?.InstanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes layoutMode && ((layoutMode is FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize > DetailsViewSizeKind.Compact) || (layoutMode is FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize > ListViewSizeKind.Compact) || + (layoutMode is FolderLayoutModes.CardsView && UserSettingsService.LayoutSettingsService.CardsViewSize > CardsViewSizeKind.Small) || (layoutMode is FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Small) || (layoutMode is FolderLayoutModes.ColumnView && UserSettingsService.LayoutSettingsService.ColumnsViewSize > ColumnsViewSizeKind.Compact)); @@ -217,6 +218,7 @@ private void UserSettingsService_PropertyChanged(object? sender, PropertyChanged case nameof(ILayoutSettingsService.ListViewSize): case nameof(ILayoutSettingsService.GridViewSize): case nameof(ILayoutSettingsService.ColumnsViewSize): + case nameof(ILayoutSettingsService.CardsViewSize): OnPropertyChanged(nameof(IsExecutable)); break; } @@ -234,7 +236,9 @@ public Task ExecuteAsync(object? parameter = null) if (UserSettingsService.LayoutSettingsService.ListViewSize > ListViewSizeKind.Compact) UserSettingsService.LayoutSettingsService.ListViewSize -= 1; break; - case FolderLayoutModes.TilesView: + case FolderLayoutModes.CardsView: + if (UserSettingsService.LayoutSettingsService.CardsViewSize > CardsViewSizeKind.Small) + UserSettingsService.LayoutSettingsService.CardsViewSize -= 1; break; case FolderLayoutModes.GridView: if (UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Small) @@ -258,10 +262,10 @@ internal sealed class LayoutIncreaseSizeAction : ObservableObject, IAction private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService(); public string Label - => "IncreaseSize".GetLocalizedResource(); + => Strings.IncreaseSize.GetLocalizedResource(); public string Description - => "LayoutIncreaseSizeDescription".GetLocalizedResource(); + => Strings.LayoutIncreaseSizeDescription.GetLocalizedResource(); public HotKey HotKey => new(Keys.Add, KeyModifiers.Ctrl); @@ -274,6 +278,7 @@ ContentPageContext.PageType is not ContentPageTypes.Home && ContentPageContext.ShellPage?.InstanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes layoutMode && ((layoutMode is FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize < DetailsViewSizeKind.ExtraLarge) || (layoutMode is FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize < ListViewSizeKind.ExtraLarge) || + (layoutMode is FolderLayoutModes.CardsView && UserSettingsService.LayoutSettingsService.CardsViewSize < CardsViewSizeKind.ExtraLarge) || (layoutMode is FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.ExtraLarge) || (layoutMode is FolderLayoutModes.ColumnView && UserSettingsService.LayoutSettingsService.ColumnsViewSize < ColumnsViewSizeKind.ExtraLarge)); @@ -318,7 +323,9 @@ public Task ExecuteAsync(object? parameter = null) if (UserSettingsService.LayoutSettingsService.ListViewSize < ListViewSizeKind.ExtraLarge) UserSettingsService.LayoutSettingsService.ListViewSize += 1; break; - case FolderLayoutModes.TilesView: + case FolderLayoutModes.CardsView: + if (UserSettingsService.LayoutSettingsService.CardsViewSize < CardsViewSizeKind.ExtraLarge) + UserSettingsService.LayoutSettingsService.CardsViewSize += 1; break; case FolderLayoutModes.GridView: if (UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.ExtraLarge) diff --git a/src/Files.App/App.xaml b/src/Files.App/App.xaml index 9991fe863f56..d24250ef0de5 100644 --- a/src/Files.App/App.xaml +++ b/src/Files.App/App.xaml @@ -77,6 +77,7 @@ #0070CB + @@ -94,6 +95,7 @@ #50C0FF + @@ -111,6 +113,7 @@ #50C0FF + diff --git a/src/Files.App/Converters/EnumToHumanizedConverter.cs b/src/Files.App/Converters/EnumToHumanizedConverter.cs index c464f7df5877..3cbcd6d26c40 100644 --- a/src/Files.App/Converters/EnumToHumanizedConverter.cs +++ b/src/Files.App/Converters/EnumToHumanizedConverter.cs @@ -19,8 +19,8 @@ public object Convert(object value, Type targetType, object parameter, string la => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), "ListViewSizeKind" => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), - "TilesViewSizeKind" - => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), + "CardsViewSizeKind" + => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), "GridViewSizeKind" => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), "ColumnsViewSizeKind" diff --git a/src/Files.App/Data/Commands/Manager/CommandCodes.cs b/src/Files.App/Data/Commands/Manager/CommandCodes.cs index 0ea8a3416d76..19c2158a0a29 100644 --- a/src/Files.App/Data/Commands/Manager/CommandCodes.cs +++ b/src/Files.App/Data/Commands/Manager/CommandCodes.cs @@ -133,7 +133,7 @@ public enum CommandCodes LayoutIncreaseSize, LayoutDetails, LayoutList, - LayoutTiles, + LayoutCards, LayoutGrid, LayoutColumns, LayoutAdaptive, diff --git a/src/Files.App/Data/Commands/Manager/CommandManager.cs b/src/Files.App/Data/Commands/Manager/CommandManager.cs index d1e63fca40f5..ba0b307b0b76 100644 --- a/src/Files.App/Data/Commands/Manager/CommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/CommandManager.cs @@ -132,7 +132,7 @@ public IRichCommand this[HotKey hotKey] public IRichCommand LayoutIncreaseSize => commands[CommandCodes.LayoutIncreaseSize]; public IRichCommand LayoutDetails => commands[CommandCodes.LayoutDetails]; public IRichCommand LayoutList => commands[CommandCodes.LayoutList]; - public IRichCommand LayoutTiles => commands[CommandCodes.LayoutTiles]; + public IRichCommand LayoutCards=> commands[CommandCodes.LayoutCards]; public IRichCommand LayoutGrid => commands[CommandCodes.LayoutGrid]; public IRichCommand LayoutColumns => commands[CommandCodes.LayoutColumns]; public IRichCommand LayoutAdaptive => commands[CommandCodes.LayoutAdaptive]; @@ -336,7 +336,7 @@ public IEnumerator GetEnumerator() => [CommandCodes.LayoutIncreaseSize] = new LayoutIncreaseSizeAction(), [CommandCodes.LayoutDetails] = new LayoutDetailsAction(), [CommandCodes.LayoutList] = new LayoutListAction(), - [CommandCodes.LayoutTiles] = new LayoutTilesAction(), + [CommandCodes.LayoutCards] = new LayoutCardsAction(), [CommandCodes.LayoutGrid] = new LayoutGridAction(), [CommandCodes.LayoutColumns] = new LayoutColumnsAction(), [CommandCodes.LayoutAdaptive] = new LayoutAdaptiveAction(), diff --git a/src/Files.App/Data/Commands/Manager/ICommandManager.cs b/src/Files.App/Data/Commands/Manager/ICommandManager.cs index 385fb56ec31f..61e554270e1b 100644 --- a/src/Files.App/Data/Commands/Manager/ICommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/ICommandManager.cs @@ -121,7 +121,7 @@ public interface ICommandManager : IEnumerable IRichCommand LayoutIncreaseSize { get; } IRichCommand LayoutDetails { get; } IRichCommand LayoutList { get; } - IRichCommand LayoutTiles { get; } + IRichCommand LayoutCards{ get; } IRichCommand LayoutGrid { get; } IRichCommand LayoutColumns { get; } IRichCommand LayoutAdaptive { get; } diff --git a/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs b/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs index 7004f0f0742e..1cb483a2c7ea 100644 --- a/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs +++ b/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs @@ -29,8 +29,8 @@ public LayoutTypes LayoutType case LayoutTypes.List: viewModel.ToggleLayoutModeList(true); break; - case LayoutTypes.Tiles: - viewModel.ToggleLayoutModeTiles(true); + case LayoutTypes.Cards: + viewModel.ToggleLayoutModeCards(true); break; case LayoutTypes.Grid: viewModel.ToggleLayoutModeGridView(true); @@ -230,11 +230,11 @@ private LayoutTypes GetLayoutType() { FolderLayoutModes.DetailsView => LayoutTypes.Details, FolderLayoutModes.ListView => LayoutTypes.List, - FolderLayoutModes.TilesView => LayoutTypes.Tiles, + FolderLayoutModes.CardsView => LayoutTypes.Cards, FolderLayoutModes.GridView => LayoutTypes.Grid, FolderLayoutModes.ColumnView => LayoutTypes.Columns, _ => throw new InvalidEnumArgumentException(), }; } } -} +} \ No newline at end of file diff --git a/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs b/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs index a91860b117f2..4d6309a34712 100644 --- a/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs +++ b/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs @@ -8,7 +8,7 @@ public enum LayoutTypes : ushort None, Details, List, - Tiles, + Cards, Grid, Columns, Adaptive, diff --git a/src/Files.App/Data/Contracts/ILayoutSettingsService.cs b/src/Files.App/Data/Contracts/ILayoutSettingsService.cs index 549544ff50ac..05b4363f7385 100644 --- a/src/Files.App/Data/Contracts/ILayoutSettingsService.cs +++ b/src/Files.App/Data/Contracts/ILayoutSettingsService.cs @@ -206,9 +206,9 @@ public interface ILayoutSettingsService : IBaseSettingsService, INotifyPropertyC ListViewSizeKind ListViewSize { get; set; } /// - /// Item size in the Tiles View + /// Item size in the Cards View /// - TilesViewSizeKind TilesViewSize { get; set; } + CardsViewSizeKind CardsViewSize { get; set; } /// /// Item size in the Grid View diff --git a/src/Files.App/Data/Enums/CardsViewSizeKind.cs b/src/Files.App/Data/Enums/CardsViewSizeKind.cs new file mode 100644 index 000000000000..2f266326395e --- /dev/null +++ b/src/Files.App/Data/Enums/CardsViewSizeKind.cs @@ -0,0 +1,31 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +namespace Files.App.Data.Enums +{ + /// + /// Defines constants that specify the size in the Cards View layout. + /// + public enum CardsViewSizeKind + { + /// + /// The size is small. + /// + Small = 1, + + /// + /// The size is medium. + /// + Medium = 2, + + /// + /// The size is large. + /// + Large = 3, + + /// + /// The size is extra large. + /// + ExtraLarge = 4, + } +} diff --git a/src/Files.App/Data/Enums/FolderLayoutModes.cs b/src/Files.App/Data/Enums/FolderLayoutModes.cs index 055965af078f..46d61ab87a75 100644 --- a/src/Files.App/Data/Enums/FolderLayoutModes.cs +++ b/src/Files.App/Data/Enums/FolderLayoutModes.cs @@ -16,9 +16,9 @@ public enum FolderLayoutModes ListView = 1, /// - /// Tiles view + /// Cards view /// - TilesView = 2, + CardsView = 2, /// /// Column view diff --git a/src/Files.App/Data/Enums/TilesViewSizeKind.cs b/src/Files.App/Data/Enums/TilesViewSizeKind.cs deleted file mode 100644 index cb5bc73ea868..000000000000 --- a/src/Files.App/Data/Enums/TilesViewSizeKind.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.App.Data.Enums -{ - /// - /// Defines constants that specify the size in the Tiles View layout. - /// - public enum TilesViewSizeKind - { - /// - /// The size is small. - /// - Small = 1, - } -} diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index f97414f2f89d..005220ee83d4 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -109,7 +109,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "Layout".GetLocalizedResource(), + Text = Strings.Layout.GetLocalizedResource(), Glyph = "\uE8A9", ShowItem = !itemsSelected, ShowInRecycleBin = true, @@ -122,7 +122,7 @@ public static List GetBaseItemMenuItems( { IsToggle = true }.Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutTiles) + new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutCards) { IsToggle = true }.Build(), @@ -146,7 +146,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "SortBy".GetLocalizedResource(), + Text = Strings.SortBy.GetLocalizedResource(), ThemedIconModel = new ThemedIconModel() { ThemedIconStyle = "App.ThemedIcons.Sorting", @@ -218,7 +218,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "GroupBy".GetLocalizedResource(), + Text = Strings.GroupBy.GetLocalizedResource(), Glyph = "\uF168", ShowItem = !itemsSelected, ShowInRecycleBin = true, @@ -237,7 +237,7 @@ public static List GetBaseItemMenuItems( }.Build(), new ContextMenuFlyoutItemViewModel() { - Text = "DateModifiedLowerCase".GetLocalizedResource(), + Text = Strings.DateModifiedLowerCase.GetLocalizedResource(), ShowInRecycleBin = true, ShowInSearchPage = true, ShowInFtpPage = true, @@ -260,7 +260,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "DateCreated".GetLocalizedResource(), + Text = Strings.DateCreated.GetLocalizedResource(), ShowInRecycleBin = true, ShowInSearchPage = true, ShowInFtpPage = true, @@ -303,7 +303,7 @@ public static List GetBaseItemMenuItems( }.Build(), new ContextMenuFlyoutItemViewModel() { - Text = "DateDeleted".GetLocalizedResource(), + Text = Strings.DateDeleted.GetLocalizedResource(), ShowInRecycleBin = true, IsHidden = !currentInstanceViewModel.IsPageTypeRecycleBin, Items = @@ -421,7 +421,7 @@ public static List GetBaseItemMenuItems( }.Build(), new ContextMenuFlyoutItemViewModel() { - Text = "BaseLayoutItemContextFlyoutSetAs/Text".GetLocalizedResource(), + Text = Strings.BaseLayoutItemContextFlyoutSetAs_Text.GetLocalizedResource(), ShowItem = itemsSelected && (selectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false), ShowInSearchPage = true, Items = @@ -530,7 +530,7 @@ public static List GetBaseItemMenuItems( }.Build(), new ContextMenuFlyoutItemViewModel { - Text = "Compress".GetLocalizedResource(), + Text = Strings.Compress.GetLocalizedResource(), ShowInSearchPage = true, ThemedIconModel = new ThemedIconModel() { @@ -546,7 +546,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel { - Text = "Extract".GetLocalizedResource(), + Text = Strings.Extract.GetLocalizedResource(), ShowInSearchPage = true, ThemedIconModel = new ThemedIconModel() { @@ -564,7 +564,7 @@ public static List GetBaseItemMenuItems( new ContextMenuFlyoutItemViewModelBuilder(Commands.FlattenFolder).Build(), new ContextMenuFlyoutItemViewModel() { - Text = "SendTo".GetLocalizedResource(), + Text = Strings.SendTo.GetLocalizedResource(), Tag = "SendTo", CollapseLabel = true, ShowInSearchPage = true, @@ -572,7 +572,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "SendTo".GetLocalizedResource(), + Text = Strings.SendTo.GetLocalizedResource(), Tag = "SendToOverflow", IsHidden = true, CollapseLabel = true, @@ -588,7 +588,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "TurnOnBitLocker".GetLocalizedResource(), + Text = Strings.TurnOnBitLocker.GetLocalizedResource(), Tag = "TurnOnBitLockerPlaceholder", CollapseLabel = true, IsEnabled = false, @@ -596,7 +596,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "ManageBitLocker".GetLocalizedResource(), + Text = Strings.ManageBitLocker.GetLocalizedResource(), Tag = "ManageBitLockerPlaceholder", CollapseLabel = true, ShowItem = isDriveRoot, @@ -631,7 +631,7 @@ public static List GetBaseItemMenuItems( }, new ContextMenuFlyoutItemViewModel() { - Text = "Loading".GetLocalizedResource(), + Text = Strings.Loading.GetLocalizedResource(), Glyph = "\xE712", Items = [], ID = "ItemOverflow", @@ -652,7 +652,7 @@ public static List GetNewItemItems(BaseLayoutVie new ContextMenuFlyoutItemViewModelBuilder(Commands.CreateFolder).Build(), new ContextMenuFlyoutItemViewModel() { - Text = "File".GetLocalizedResource(), + Text = Strings.File.GetLocalizedResource(), Glyph = "\uE7C3", Command = commandsViewModel.CreateNewFileCommand, ShowInFtpPage = true, diff --git a/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs b/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs index e20483b9c7de..9ac93861e5ae 100644 --- a/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs +++ b/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs @@ -10,7 +10,7 @@ internal static class LocalizedEnumDescriptionFactory { private static Dictionary DetailsViewSizeKinds { get; } = []; private static Dictionary ListViewSizeKinds { get; } = []; - private static Dictionary TilesViewSizeKinds { get; } = []; + private static Dictionary CardsViewSizeKinds { get; } = []; private static Dictionary GridViewSizeKinds { get; } = []; private static Dictionary ColumnsViewSizeKinds { get; } = []; @@ -18,11 +18,11 @@ public static string Get(DetailsViewSizeKind value) { if (DetailsViewSizeKinds.Count == 0) { - DetailsViewSizeKinds.Add(DetailsViewSizeKind.Compact, "Compact".GetLocalizedResource()); - DetailsViewSizeKinds.Add(DetailsViewSizeKind.Small, "Small".GetLocalizedResource()); - DetailsViewSizeKinds.Add(DetailsViewSizeKind.Medium, "Medium".GetLocalizedResource()); - DetailsViewSizeKinds.Add(DetailsViewSizeKind.Large, "Large".GetLocalizedResource()); - DetailsViewSizeKinds.Add(DetailsViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource()); + DetailsViewSizeKinds.Add(DetailsViewSizeKind.Compact, Strings.Compact.GetLocalizedResource()); + DetailsViewSizeKinds.Add(DetailsViewSizeKind.Small, Strings.Small.GetLocalizedResource()); + DetailsViewSizeKinds.Add(DetailsViewSizeKind.Medium, Strings.Medium.GetLocalizedResource()); + DetailsViewSizeKinds.Add(DetailsViewSizeKind.Large, Strings.Large.GetLocalizedResource()); + DetailsViewSizeKinds.Add(DetailsViewSizeKind.ExtraLarge, Strings.ExtraLarge.GetLocalizedResource()); } var stringValue = DetailsViewSizeKinds.GetValueOrDefault(value)!; @@ -33,25 +33,28 @@ public static string Get(ListViewSizeKind value) { if (ListViewSizeKinds.Count == 0) { - ListViewSizeKinds.Add(ListViewSizeKind.Compact, "Compact".GetLocalizedResource()); - ListViewSizeKinds.Add(ListViewSizeKind.Small, "Small".GetLocalizedResource()); - ListViewSizeKinds.Add(ListViewSizeKind.Medium, "Medium".GetLocalizedResource()); - ListViewSizeKinds.Add(ListViewSizeKind.Large, "Large".GetLocalizedResource()); - ListViewSizeKinds.Add(ListViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource()); + ListViewSizeKinds.Add(ListViewSizeKind.Compact, Strings.Compact.GetLocalizedResource()); + ListViewSizeKinds.Add(ListViewSizeKind.Small, Strings.Small.GetLocalizedResource()); + ListViewSizeKinds.Add(ListViewSizeKind.Medium, Strings.Medium.GetLocalizedResource()); + ListViewSizeKinds.Add(ListViewSizeKind.Large, Strings.Large.GetLocalizedResource()); + ListViewSizeKinds.Add(ListViewSizeKind.ExtraLarge, Strings.ExtraLarge.GetLocalizedResource()); } var stringValue = ListViewSizeKinds.GetValueOrDefault(value)!; return stringValue; } - public static string Get(TilesViewSizeKind value) + public static string Get(CardsViewSizeKind value) { - if (TilesViewSizeKinds.Count == 0) + if (CardsViewSizeKinds.Count == 0) { - TilesViewSizeKinds.Add(TilesViewSizeKind.Small, "Small".GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.Small, Strings.Small.GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.Medium, Strings.Medium.GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.Large, Strings.Large.GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.ExtraLarge, Strings.ExtraLarge.GetLocalizedResource()); } - var stringValue = TilesViewSizeKinds.GetValueOrDefault(value)!; + var stringValue = CardsViewSizeKinds.GetValueOrDefault(value)!; return stringValue; } @@ -59,18 +62,18 @@ public static string Get(GridViewSizeKind value) { if (GridViewSizeKinds.Count == 0) { - GridViewSizeKinds.Add(GridViewSizeKind.Small, "Small".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Medium, "Medium".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Three, "Medium+".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Four, "Medium++".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Five, "Medium+++".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Six, "Medium++++".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Seven, "Medium+++++".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Large, "Large".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Nine, "Large+".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Ten, "Large++".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.Eleven, "Large+++".GetLocalizedResource()); - GridViewSizeKinds.Add(GridViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Small, Strings.Small.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Medium, Strings.Medium.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Three, Strings.MediumP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Four, Strings.MediumPP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Five, Strings.MediumPPP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Six, Strings.MediumPPPP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Seven, Strings.MediumPPPPP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Large, Strings.Large.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Nine, Strings.LargeP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Ten, Strings.LargePP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.Eleven, Strings.LargePPP.GetLocalizedResource()); + GridViewSizeKinds.Add(GridViewSizeKind.ExtraLarge, Strings.ExtraLarge.GetLocalizedResource()); } var stringValue = GridViewSizeKinds.GetValueOrDefault(value)!; @@ -81,11 +84,11 @@ public static string Get(ColumnsViewSizeKind value) { if (ColumnsViewSizeKinds.Count == 0) { - ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Compact, "Compact".GetLocalizedResource()); - ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Small, "Small".GetLocalizedResource()); - ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Medium, "Medium".GetLocalizedResource()); - ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Large, "Large".GetLocalizedResource()); - ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource()); + ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Compact, Strings.Compact.GetLocalizedResource()); + ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Small, Strings.Small.GetLocalizedResource()); + ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Medium, Strings.Medium.GetLocalizedResource()); + ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Large, Strings.Large.GetLocalizedResource()); + ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.ExtraLarge, Strings.ExtraLarge.GetLocalizedResource()); } var stringValue = ColumnsViewSizeKinds.GetValueOrDefault(value)!; diff --git a/src/Files.App/Data/Items/ListedItem.cs b/src/Files.App/Data/Items/ListedItem.cs index 488728e692c3..2078760eab2f 100644 --- a/src/Files.App/Data/Items/ListedItem.cs +++ b/src/Files.App/Data/Items/ListedItem.cs @@ -6,7 +6,6 @@ using FluentFTP; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media.Imaging; -using System.Drawing; using System.IO; using System.Text; using Windows.Storage; @@ -42,15 +41,15 @@ public string ItemTooltipText get { var tooltipBuilder = new StringBuilder(); - tooltipBuilder.AppendLine($"{"NameWithColon".GetLocalizedResource()} {Name}"); - tooltipBuilder.AppendLine($"{"ItemType".GetLocalizedResource()} {itemType}"); - tooltipBuilder.Append($"{"ToolTipDescriptionDate".GetLocalizedResource()} {ItemDateModified}"); + tooltipBuilder.AppendLine($"{Strings.NameWithColon.GetLocalizedResource()} {Name}"); + tooltipBuilder.AppendLine($"{Strings.ItemType.GetLocalizedResource()} {itemType}"); + tooltipBuilder.Append($"{Strings.ToolTipDescriptionDate.GetLocalizedResource()} {ItemDateModified}"); if (!string.IsNullOrWhiteSpace(FileSize)) - tooltipBuilder.Append($"{Environment.NewLine}{"SizeLabel".GetLocalizedResource()} {FileSize}"); - if (SyncStatusUI.SyncStatus is not CloudDriveSyncStatus.FileOnline and not CloudDriveSyncStatus.FolderOnline && !string.IsNullOrWhiteSpace(DimensionsDisplay)) - tooltipBuilder.Append($"{Environment.NewLine}{"PropertyDimensionsColon".GetLocalizedResource()} {DimensionsDisplay}"); + tooltipBuilder.Append($"{Environment.NewLine}{Strings.SizeLabel.GetLocalizedResource()} {FileSize}"); + if (!string.IsNullOrWhiteSpace(ImageDimensions)) + tooltipBuilder.Append($"{Environment.NewLine}{Strings.PropertyDimensionsColon.GetLocalizedResource()} {ImageDimensions}"); if (SyncStatusUI.LoadSyncStatus) - tooltipBuilder.Append($"{Environment.NewLine}{"StatusWithColon".GetLocalizedResource()} {syncStatusUI.SyncStatusString}"); + tooltipBuilder.Append($"{Environment.NewLine}{Strings.StatusWithColon.GetLocalizedResource()} {syncStatusUI.SyncStatusString}"); return tooltipBuilder.ToString(); } @@ -167,7 +166,7 @@ public CloudDriveSyncStatusUI SyncStatusUI // This is used to avoid passing a null value to AutomationProperties.Name, which causes a crash public string SyncStatusString { - get => string.IsNullOrEmpty(SyncStatusUI?.SyncStatusString) ? "CloudDriveSyncStatus_Unknown".GetLocalizedResource() : SyncStatusUI.SyncStatusString; + get => string.IsNullOrEmpty(SyncStatusUI?.SyncStatusString) ? Strings.CloudDriveSyncStatus_Unknown.GetLocalizedResource() : SyncStatusUI.SyncStatusString; } private BitmapImage fileImage; @@ -277,7 +276,7 @@ public string FileSize } } - public string FileSizeDisplay => string.IsNullOrEmpty(FileSize) ? "ItemSizeNotCalculated".GetLocalizedResource() : FileSize; + public string FileSizeDisplay => string.IsNullOrEmpty(FileSize) ? Strings.ItemSizeNotCalculated.GetLocalizedResource() : FileSize; public long FileSizeBytes { get; set; } @@ -330,39 +329,35 @@ public ObservableCollection ItemProperties set => SetProperty(ref itemProperties, value); } - public string DimensionsDisplay + private string imageDimensions; + public string ImageDimensions { - get - { - int imageHeight = 0; - int imageWidth = 0; + get => imageDimensions; + set => SetProperty(ref imageDimensions, value); + } - var isImageFile = FileExtensionHelpers.IsImageFile(FileExtension); - if (isImageFile) - { - try - { - // TODO: Consider to use 'System.Kind' instead. - using FileStream fileStream = new(ItemPath, FileMode.Open, FileAccess.Read, FileShare.Read); - using Image image = Image.FromStream(fileStream, false, false); - - if (image is not null) - { - imageHeight = image.Height; - imageWidth = image.Width; - } - } - catch { } - } + private string fileVersion; + public string FileVersion + { + get => fileVersion; + set => SetProperty(ref fileVersion, value); + } + private string mediaDuration; + public string MediaDuration + { + get => mediaDuration; + set => SetProperty(ref mediaDuration, value); + } - return - isImageFile && - imageWidth > 0 && - imageHeight > 0 - ? $"{imageWidth} \u00D7 {imageHeight}" - : string.Empty; - } + /// + /// Contextual property that changes based on the item type. + /// + private string contextualProperty; + public string ContextualProperty + { + get => contextualProperty; + set => SetProperty(ref contextualProperty, value); } /// @@ -386,19 +381,19 @@ public override string ToString() string suffix; if (IsRecycleBinItem) { - suffix = "RecycleBinItemAutomation".GetLocalizedResource(); + suffix = Strings.RecycleBinItemAutomation.GetLocalizedResource(); } else if (IsShortcut) { - suffix = "ShortcutItemAutomation".GetLocalizedResource(); + suffix = Strings.ShortcutItemAutomation.GetLocalizedResource(); } else if (IsLibrary) { - suffix = "Library".GetLocalizedResource(); + suffix = Strings.Library.GetLocalizedResource(); } else { - suffix = PrimaryItemAttribute == StorageItemTypes.File ? "Folder".GetLocalizedResource() : "FolderItemAutomation".GetLocalizedResource(); + suffix = PrimaryItemAttribute == StorageItemTypes.File ? Strings.Folder.GetLocalizedResource() : "FolderItemAutomation".GetLocalizedResource(); } return $"{Name}, {suffix}"; @@ -485,7 +480,7 @@ public FtpItem(FtpListItem item, string folder) : base(null) PrimaryItemAttribute = isFile ? StorageItemTypes.File : StorageItemTypes.Folder; ItemPropertiesInitialized = false; - var itemType = isFile ? "File".GetLocalizedResource() : "Folder".GetLocalizedResource(); + var itemType = isFile ? Strings.File.GetLocalizedResource() : Strings.Folder.GetLocalizedResource(); if (isFile && Name.Contains('.', StringComparison.Ordinal)) { itemType = FileExtension.Trim('.') + " " + itemType; @@ -564,7 +559,7 @@ public LibraryItem(LibraryLocationItem library) : base(null) ItemPath = library.Path; ItemNameRaw = library.Text; PrimaryItemAttribute = StorageItemTypes.Folder; - ItemType = "Library".GetLocalizedResource(); + ItemType = Strings.Library.GetLocalizedResource(); LoadCustomIcon = true; CustomIcon = library.Icon; //CustomIconSource = library.IconSource; @@ -771,24 +766,24 @@ public override string Name } public interface IGitItem { - public bool StatusPropertiesInitialized { get ; set; } + public bool StatusPropertiesInitialized { get; set; } public bool CommitPropertiesInitialized { get; set; } - public Style? UnmergedGitStatusIcon{ get; set; } + public Style? UnmergedGitStatusIcon { get; set; } - public string? UnmergedGitStatusName{ get; set; } + public string? UnmergedGitStatusName { get; set; } - public DateTimeOffset? GitLastCommitDate{ get; set; } + public DateTimeOffset? GitLastCommitDate { get; set; } - public string? GitLastCommitDateHumanized{ get; set; } + public string? GitLastCommitDateHumanized { get; set; } - public string? GitLastCommitMessage{ get; set; } + public string? GitLastCommitMessage { get; set; } - public string? GitLastCommitAuthor{ get; set; } + public string? GitLastCommitAuthor { get; set; } - public string? GitLastCommitSha{ get; set; } + public string? GitLastCommitSha { get; set; } - public string? GitLastCommitFullSha{ get; set; } + public string? GitLastCommitFullSha { get; set; } public string ItemPath { diff --git a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs index 5f350b9dba5e..c8895e1acb0f 100644 --- a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs +++ b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs @@ -218,7 +218,7 @@ public Type GetLayoutType(string path, bool changeLayoutMode = true) { FolderLayoutModes.DetailsView => typeof(DetailsLayoutPage), FolderLayoutModes.ListView => typeof(GridLayoutPage), - FolderLayoutModes.TilesView => typeof(GridLayoutPage), + FolderLayoutModes.CardsView => typeof(GridLayoutPage), FolderLayoutModes.GridView => typeof(GridLayoutPage), FolderLayoutModes.ColumnView => typeof(ColumnsLayoutPage), _ => typeof(DetailsLayoutPage) @@ -252,14 +252,14 @@ public void ToggleLayoutModeGridView(bool manuallySet) LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.GridView)); } - public void ToggleLayoutModeTiles(bool manuallySet) + public void ToggleLayoutModeCards(bool manuallySet) { IsAdaptiveLayoutEnabled &= !manuallySet; - // Tiles View - LayoutMode = FolderLayoutModes.TilesView; + // Cards View + LayoutMode = FolderLayoutModes.CardsView; - LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.TilesView)); + LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.CardsView)); } public void ToggleLayoutModeList(bool manuallySet) @@ -578,4 +578,4 @@ private bool SetProperty(Func prop, Actio return true; } } -} +} \ No newline at end of file diff --git a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs index a69fd2c1b79a..6dec2955adff 100644 --- a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs +++ b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs @@ -7,6 +7,50 @@ public static class LayoutSizeKindHelper { private static ILayoutSettingsService LayoutSettingsService { get; } = Ioc.Default.GetRequiredService(); + /// + /// Gets the desired icon size for the requested layout + /// + /// + /// + public static uint GetIconSize(FolderLayoutModes folderLayoutMode) + { + return folderLayoutMode switch + { + // Details + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium => 20, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large => 24, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // List + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Medium => 20, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Large => 24, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // Columns + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Medium => 20, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Large => 24, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // Card + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Small => 64, + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Medium => 64, + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Large => 80, + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.ExtraLarge => 96, + + // Grid + FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small => 96, + FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large => 128, + + _ => 256, + }; + } + /// /// Gets the desired height for items in the Details View /// @@ -93,45 +137,6 @@ public static int GetListViewRowHeight(ListViewSizeKind listViewSizeKind) } } - /// - /// Gets the desired icon size for the requested layout - /// - /// - /// - public static uint GetIconSize(FolderLayoutModes folderLayoutMode) - { - return folderLayoutMode switch - { - // Details - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Compact => Constants.ShellIconSizes.Small, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small => Constants.ShellIconSizes.Small, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium => 20, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large => 24, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, - - // List - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact => Constants.ShellIconSizes.Small, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Small => Constants.ShellIconSizes.Small, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Medium => 20, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Large => 24, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, - - // Columns - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Compact => Constants.ShellIconSizes.Small, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Small => Constants.ShellIconSizes.Small, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Medium => 20, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Large => 24, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, - - // Grid and Tiles - FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small => 96, - FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large => 128, - FolderLayoutModes.TilesView => 96, - - _ => 256, - }; - } - /// /// Gets the desired height for items in the Columns View /// @@ -155,15 +160,5 @@ public static int GetColumnsViewRowHeight(ColumnsViewSizeKind columnsViewSizeKin return 32; } } - - /// - /// Gets the desired width for items in the Tiles View - /// - /// - /// - public static int GetTilesViewItemWidth(TilesViewSizeKind tilesViewSizeKind) - { - return 260; - } } } \ No newline at end of file diff --git a/src/Files.App/Services/Settings/LayoutSettingsService.cs b/src/Files.App/Services/Settings/LayoutSettingsService.cs index 912607b6e3a3..fb637fe98cf7 100644 --- a/src/Files.App/Services/Settings/LayoutSettingsService.cs +++ b/src/Files.App/Services/Settings/LayoutSettingsService.cs @@ -307,9 +307,9 @@ public ListViewSizeKind ListViewSize set => Set(value); } - public TilesViewSizeKind TilesViewSize + public CardsViewSizeKind CardsViewSize { - get => Get(TilesViewSizeKind.Small); + get => Get(CardsViewSizeKind.Small); set => Set(value); } diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index 47ffdc413c7d..b4f3d9cbbc1d 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -1058,9 +1058,6 @@ Details (Ctrl+Shift+1) - - Tiles (Ctrl+Shift+2) - Date deleted @@ -1658,15 +1655,6 @@ Home - - Ctrl+Shift+1 - - - Ctrl+Shift+2 - - - Ctrl+Shift+6 - The archive extraction completed successfully. @@ -1724,8 +1712,8 @@ Columns - - Tiles + + Cards Open folders in new tab @@ -2585,8 +2573,8 @@ Switch to details view - - Switch to tiles view + + Switch to cards view Switch to list view @@ -3726,9 +3714,6 @@ Questions & discussions - - Additional sizes are not yet available for the Tiles View. - Compact Used to describe layout sizes diff --git a/src/Files.App/UserControls/InnerNavigationToolbar.xaml b/src/Files.App/UserControls/InnerNavigationToolbar.xaml index e8a20252bad2..a740239b5d5f 100644 --- a/src/Files.App/UserControls/InnerNavigationToolbar.xaml +++ b/src/Files.App/UserControls/InnerNavigationToolbar.xaml @@ -28,7 +28,7 @@ - + @@ -733,14 +733,14 @@ - + + ToolTipService.ToolTip="{x:Bind Commands.LayoutCards.LabelWithHotKey, Mode=OneWay}"> @@ -950,21 +950,62 @@ - - + - - + x:Name="CardsView" + Spacing="4" + Visibility="{x:Bind ViewModel.IsCardsLayout, Mode=OneWay}"> + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index 3200a142cc35..4dce5023dc40 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -40,7 +40,7 @@ public sealed class ShellViewModel : ObservableObject, IDisposable private readonly AsyncManualResetEvent gitChangedEvent; private readonly DispatcherQueue dispatcherQueue; private readonly JsonElement defaultJson = JsonSerializer.SerializeToElement("{}"); - private readonly string folderTypeTextLocalized = "Folder".GetLocalizedResource(); + private readonly string folderTypeTextLocalized = Strings.Folder.GetLocalizedResource(); private Task? aProcessQueueAction; private Task? gitProcessQueueAction; @@ -610,7 +610,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => if (e.ValueState is SizeChangedValueState.None) { matchingItem.FileSizeBytes = 0; - matchingItem.FileSize = "ItemSizeNotCalculated".GetLocalizedResource(); + matchingItem.FileSize = Strings.ItemSizeNotCalculated.GetLocalizedResource(); } else if (e.ValueState is SizeChangedValueState.Final || (long)e.NewSize > matchingItem.FileSizeBytes) { @@ -977,7 +977,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48; // TODO Remove this property when all the layouts can support different icon sizes - var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView || folderSettings.LayoutMode == FolderLayoutModes.ListView || folderSettings.LayoutMode == FolderLayoutModes.ColumnView; + var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView || folderSettings.LayoutMode == FolderLayoutModes.ListView || folderSettings.LayoutMode == FolderLayoutModes.ColumnView || folderSettings.LayoutMode == FolderLayoutModes.CardsView; byte[]? result = null; @@ -1140,7 +1140,8 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item) var syncStatus = await CheckCloudDriveSyncStatusAsync(matchingStorageFile); var fileFRN = await FileTagsHelper.GetFileFRN(matchingStorageFile); var fileTag = FileTagsHelper.ReadFileTag(item.ItemPath); - var itemType = (item.ItemType == "Folder".GetLocalizedResource()) ? item.ItemType : matchingStorageFile.DisplayType; + var itemType = (item.ItemType == Strings.Folder.GetLocalizedResource()) ? item.ItemType : matchingStorageFile.DisplayType; + var extraProperties = await GetExtraProperties(matchingStorageFile); cts.Token.ThrowIfCancellationRequested(); @@ -1152,6 +1153,27 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => item.FileFRN = fileFRN; item.FileTags = fileTag; item.IsElevationRequired = CheckElevationRights(item); + item.ImageDimensions = extraProperties?.Result["System.Image.Dimensions"]?.ToString() ?? string.Empty; + item.FileVersion = extraProperties?.Result["System.FileVersion"]?.ToString() ?? string.Empty; + item.MediaDuration = ulong.TryParse(extraProperties?.Result["System.Media.Duration"]?.ToString(), out ulong duration) + ? TimeSpan.FromTicks((long)duration).ToString(@"hh\:mm\:ss") + : string.Empty; + + switch (true) + { + case var _ when !string.IsNullOrEmpty(item.ImageDimensions): + item.ContextualProperty = $"{Strings.PropertyDimensions.GetLocalizedResource()}: {item.ImageDimensions}"; + break; + case var _ when !string.IsNullOrEmpty(item.MediaDuration): + item.ContextualProperty = $"{Strings.PropertyDuration.GetLocalizedResource()}: {item.MediaDuration}"; + break; + case var _ when !string.IsNullOrEmpty(item.FileVersion): + item.ContextualProperty = $"{Strings.PropertyVersion.GetLocalizedResource()}: {item.FileVersion}"; + break; + default: + item.ContextualProperty = $"{Strings.Modified.GetLocalizedResource()}: {item.ItemDateModified}"; + break; + } }, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low); @@ -1186,7 +1208,8 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => var syncStatus = await CheckCloudDriveSyncStatusAsync(matchingStorageFolder); var fileFRN = await FileTagsHelper.GetFileFRN(matchingStorageFolder); var fileTag = FileTagsHelper.ReadFileTag(item.ItemPath); - var itemType = (item.ItemType == "Folder".GetLocalizedResource()) ? item.ItemType : matchingStorageFolder.DisplayType; + var itemType = (item.ItemType == Strings.Folder.GetLocalizedResource()) ? item.ItemType : matchingStorageFolder.DisplayType; + cts.Token.ThrowIfCancellationRequested(); await dispatcherQueue.EnqueueOrInvokeAsync(() => @@ -1196,6 +1219,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => item.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); item.FileFRN = fileFRN; item.FileTags = fileTag; + item.ContextualProperty = $"{Strings.Modified.GetLocalizedResource()}: {item.ItemDateModified}"; }, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low); @@ -1588,23 +1612,23 @@ private async Task EnumerateItemsFromStandardFolderAsync(string path, Cance else if (res == FileSystemStatusCode.Unauthorized) { await DialogDisplayHelper.ShowDialogAsync( - "AccessDenied".GetLocalizedResource(), - "AccessDeniedToFolder".GetLocalizedResource()); + Strings.AccessDenied.GetLocalizedResource(), + Strings.AccessDeniedToFolder.GetLocalizedResource()); return -1; } else if (res == FileSystemStatusCode.NotFound) { await DialogDisplayHelper.ShowDialogAsync( - "FolderNotFoundDialog/Title".GetLocalizedResource(), - "FolderNotFoundDialog/Text".GetLocalizedResource()); + Strings.FolderNotFoundDialog_Title.GetLocalizedResource(), + Strings.FolderNotFoundDialog_Text.GetLocalizedResource()); return -1; } else { await DialogDisplayHelper.ShowDialogAsync( - "DriveUnpluggedDialog/Title".GetLocalizedResource(), + Strings.DriveUnpluggedDialog_Title.GetLocalizedResource(), res.ErrorCode.ToString()); return -1; @@ -1705,7 +1729,7 @@ await DialogDisplayHelper.ShowDialogAsync( if (hFile == IntPtr.Zero) { - await DialogDisplayHelper.ShowDialogAsync("DriveUnpluggedDialog/Title".GetLocalizedResource(), ""); + await DialogDisplayHelper.ShowDialogAsync(Strings.DriveUnpluggedDialog_Title.GetLocalizedResource(), ""); return -1; } @@ -1717,8 +1741,8 @@ await DialogDisplayHelper.ShowDialogAsync( if (filesAndFolders.Count == 0 && errorCode == 0x5) { await DialogDisplayHelper.ShowDialogAsync( - "AccessDenied".GetLocalizedResource(), - "AccessDeniedToFolder".GetLocalizedResource()); + Strings.AccessDenied.GetLocalizedResource(), + Strings.AccessDeniedToFolder.GetLocalizedResource()); return -1; } @@ -1908,6 +1932,14 @@ public async Task CheckCloudDriveSyncStatusAsync(IStorageI return (CloudDriveSyncStatus)syncStatus; } + private async Task>?> GetExtraProperties(IStorageItem matchingStorageItem) + { + if (matchingStorageItem is BaseStorageFile file && file.Properties != null) + return await FilesystemTasks.Wrap(() => file.Properties.RetrievePropertiesAsync(["System.Image.Dimensions", "System.Media.Duration", "System.FileVersion"]).AsTask()); + + return null; + } + private async Task WatchForStorageFolderChangesAsync(BaseStorageFolder? rootFolder) { if (rootFolder is null) diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index 4a770a16bc85..c4edf27c4e80 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -251,6 +251,7 @@ private void UserSettingsService_OnSettingChangedEvent(object? sender, SettingCh case nameof(UserSettingsService.LayoutSettingsService.DetailsViewSize): case nameof(UserSettingsService.LayoutSettingsService.ListViewSize): case nameof(UserSettingsService.LayoutSettingsService.ColumnsViewSize): + case nameof(UserSettingsService.LayoutSettingsService.CardsViewSize): case nameof(UserSettingsService.LayoutSettingsService.GridViewSize): OnPropertyChanged(nameof(IsLayoutSizeCompact)); OnPropertyChanged(nameof(IsLayoutSizeSmall)); @@ -389,13 +390,13 @@ x.Item is ZipStorageFile || x.Item is ZipStorageFolder) || ZipStorageFolder.IsZipPath(pathBoxItem.Path)) { - e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), pathBoxItem.Title); + e.DragUIOverride.Caption = string.Format(Strings.CopyToFolderCaptionText.GetLocalizedResource(), pathBoxItem.Title); e.AcceptedOperation = DataPackageOperation.Copy; } else { e.DragUIOverride.IsCaptionVisible = true; - e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), pathBoxItem.Title); + e.DragUIOverride.Caption = string.Format(Strings.MoveToFolderCaptionText.GetLocalizedResource(), pathBoxItem.Title); // Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well. e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy; } @@ -658,7 +659,7 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p var flyoutItem = new MenuFlyoutItem { Icon = new FontIcon { Glyph = "\uE7BA" }, - Text = "SubDirectoryAccessDenied".GetLocalizedResource(), + Text = Strings.SubDirectoryAccessDenied.GetLocalizedResource(), //Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlErrorTextForegroundBrush"], FontSize = 12 }; @@ -729,11 +730,11 @@ public async Task CheckPathInputAsync(string currentInput, string currentSelecte var command = Commands[code]; if (command == Commands.None) - await DialogDisplayHelper.ShowDialogAsync("InvalidCommand".GetLocalizedResource(), - string.Format("InvalidCommandContent".GetLocalizedResource(), code)); + await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidCommand.GetLocalizedResource(), + string.Format(Strings.InvalidCommandContent.GetLocalizedResource(), code)); else if (!command.IsExecutable) - await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedResource(), - string.Format("CommandNotExecutableContent".GetLocalizedResource(), command.Code)); + await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocalizedResource(), + string.Format(Strings.CommandNotExecutableContent.GetLocalizedResource(), command.Code)); else await command.ExecuteAsync(); @@ -749,7 +750,7 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes if (normalizedInput != shellPage.ShellViewModel.WorkingDirectory || shellPage.CurrentPageType == typeof(HomePage)) { - if (normalizedInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || normalizedInput.Equals("Home".GetLocalizedResource(), StringComparison.OrdinalIgnoreCase)) + if (normalizedInput.Equals("Home", StringComparison.OrdinalIgnoreCase) || normalizedInput.Equals(Strings.Home.GetLocalizedResource(), StringComparison.OrdinalIgnoreCase)) { SavePathToHistory("Home"); shellPage.NavigateHome(); @@ -768,7 +769,7 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes var matchingDrive = drivesViewModel.Drives.Cast().FirstOrDefault(x => PathNormalization.NormalizePath(normalizedInput).StartsWith(PathNormalization.NormalizePath(x.Path), StringComparison.Ordinal)); if (matchingDrive is not null && matchingDrive.Type == Data.Items.DriveType.CDRom && matchingDrive.MaxSpace == ByteSizeLib.ByteSize.FromBytes(0)) { - bool ejectButton = await DialogDisplayHelper.ShowDialogAsync("InsertDiscDialog/Title".GetLocalizedResource(), string.Format("InsertDiscDialog/Text".GetLocalizedResource(), matchingDrive.Path), "InsertDiscDialog/OpenDriveButton".GetLocalizedResource(), "Close".GetLocalizedResource()); + bool ejectButton = await DialogDisplayHelper.ShowDialogAsync(Strings.InsertDiscDialog_Title.GetLocalizedResource(), string.Format(Strings.InsertDiscDialog_Text.GetLocalizedResource(), matchingDrive.Path), Strings.InsertDiscDialog_OpenDriveButton.GetLocalizedResource(), Strings.Close.GetLocalizedResource()); if (ejectButton) DriveHelpers.EjectDeviceAsync(matchingDrive.Path); return; @@ -804,13 +805,13 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes try { if (!await Windows.System.Launcher.LaunchUriAsync(new Uri(currentInput))) - await DialogDisplayHelper.ShowDialogAsync("InvalidItemDialogTitle".GetLocalizedResource(), - string.Format("InvalidItemDialogContent".GetLocalizedResource(), Environment.NewLine, resFolder.ErrorCode.ToString())); + await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLocalizedResource(), + string.Format(Strings.InvalidItemDialogContent.GetLocalizedResource(), Environment.NewLine, resFolder.ErrorCode.ToString())); } catch (Exception ex) when (ex is UriFormatException || ex is ArgumentException) { - await DialogDisplayHelper.ShowDialogAsync("InvalidItemDialogTitle".GetLocalizedResource(), - string.Format("InvalidItemDialogContent".GetLocalizedResource(), Environment.NewLine, resFolder.ErrorCode.ToString())); + await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLocalizedResource(), + string.Format(Strings.InvalidItemDialogContent.GetLocalizedResource(), Environment.NewLine, resFolder.ErrorCode.ToString())); } } } @@ -924,7 +925,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag { suggestions = new List() { new NavigationBarSuggestionItem() { Text = shellpage.ShellViewModel.WorkingDirectory, - PrimaryDisplay = "NavigationToolbarVisiblePathNoResults".GetLocalizedResource() } }; + PrimaryDisplay = Strings.NavigationToolbarVisiblePathNoResults.GetLocalizedResource() } }; } // NavigationBarSuggestions becoming empty causes flickering of the suggestion box @@ -977,7 +978,7 @@ public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPag NavigationBarSuggestions.Add(new NavigationBarSuggestionItem() { Text = shellpage.ShellViewModel.WorkingDirectory, - PrimaryDisplay = "NavigationToolbarVisiblePathNoResults".GetLocalizedResource() + PrimaryDisplay = Strings.NavigationToolbarVisiblePathNoResults.GetLocalizedResource() }); }); } @@ -992,12 +993,12 @@ private void FolderSettings_PropertyChanged(object? sender, PropertyChangedEvent LayoutThemedIcon = instanceViewModel.FolderSettings.LayoutMode switch { FolderLayoutModes.ListView => Commands.LayoutList.ThemedIconStyle!, - FolderLayoutModes.TilesView => Commands.LayoutTiles.ThemedIconStyle!, + FolderLayoutModes.CardsView => Commands.LayoutCards.ThemedIconStyle!, FolderLayoutModes.ColumnView => Commands.LayoutColumns.ThemedIconStyle!, FolderLayoutModes.GridView => Commands.LayoutGrid.ThemedIconStyle!, _ => Commands.LayoutDetails.ThemedIconStyle! }; - OnPropertyChanged(nameof(IsTilesLayout)); + OnPropertyChanged(nameof(IsCardsLayout)); OnPropertyChanged(nameof(IsListLayout)); OnPropertyChanged(nameof(IsColumnLayout)); OnPropertyChanged(nameof(IsGridLayout)); @@ -1055,7 +1056,7 @@ public List SelectedItems public bool IsInfFile => SelectedItems is not null && SelectedItems.Count == 1 && FileExtensionHelpers.IsInfFile(SelectedItems.First().FileExtension) && !InstanceViewModel.IsPageTypeRecycleBin; public bool IsFont => SelectedItems is not null && SelectedItems.Any() && SelectedItems.All(x => FileExtensionHelpers.IsFontFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin; - public bool IsTilesLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.TilesView; + public bool IsCardsLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.CardsView; public bool IsColumnLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.ColumnView; public bool IsGridLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.GridView; public bool IsDetailsLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.DetailsView; @@ -1070,28 +1071,32 @@ public List SelectedItems (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Small) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Small) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Small) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.Small); public bool IsLayoutSizeMedium => (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Medium) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Medium) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Medium) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.Medium); public bool IsLayoutSizeLarge => (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Large) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Large) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Large) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.Large); public bool IsLayoutSizeExtraLarge => (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.ExtraLarge) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.ExtraLarge) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.ExtraLarge) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.ExtraLarge); public string ExtractToText - => IsSelectionArchivesOnly ? SelectedItems.Count > 1 ? string.Format("ExtractToChildFolder".GetLocalizedResource(), $"*{Path.DirectorySeparatorChar}") : string.Format("ExtractToChildFolder".GetLocalizedResource() + "\\", Path.GetFileNameWithoutExtension(selectedItems.First().Name)) : "ExtractToChildFolder".GetLocalizedResource(); + => IsSelectionArchivesOnly ? SelectedItems.Count > 1 ? string.Format(Strings.ExtractToChildFolder.GetLocalizedResource(), $"*{Path.DirectorySeparatorChar}") : string.Format(Strings.ExtractToChildFolder.GetLocalizedResource() + "\\", Path.GetFileNameWithoutExtension(selectedItems.First().Name)) : Strings.ExtractToChildFolder.GetLocalizedResource(); public void Dispose() { diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index c38181d24653..86703032b7f4 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -39,6 +39,7 @@ public abstract class BaseLayoutPage : Page, IBaseLayoutPage, INotifyPropertyCha protected IFileTagsSettingsService FileTagsSettingsService { get; } = Ioc.Default.GetService()!; protected IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetService()!; + protected ILayoutSettingsService LayoutSettingsService { get; } = Ioc.Default.GetService()!; protected ICommandManager Commands { get; } = Ioc.Default.GetRequiredService(); public InfoPaneViewModel InfoPaneViewModel { get; } = Ioc.Default.GetRequiredService(); protected readonly IWindowContext WindowContext = Ioc.Default.GetRequiredService(); @@ -264,7 +265,7 @@ internal set UpdateSelectionSize(); SelectedItemsPropertiesViewModel.SelectedItemsCount = selectedItems.Count; - SelectedItemsPropertiesViewModel.SelectedItemsCountString = "SelectedItems".GetLocalizedFormatResource(selectedItems!.Count); + SelectedItemsPropertiesViewModel.SelectedItemsCountString = Strings.SelectedItems.GetLocalizedFormatResource(selectedItems!.Count); if (selectedItems.Count == 1) { @@ -477,7 +478,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) if (!navigationArguments.IsLayoutSwitch) { var displayName = App.LibraryManager.TryGetLibrary(navigationArguments.SearchPathParam, out var lib) ? lib.Text : navigationArguments.SearchPathParam; - await ParentShellPageInstance.UpdatePathUIToWorkingDirectoryAsync(null, string.Format("SearchPagePathBoxOverrideText".GetLocalizedResource(), navigationArguments.SearchQuery, displayName)); + await ParentShellPageInstance.UpdatePathUIToWorkingDirectoryAsync(null, string.Format(Strings.SearchPagePathBoxOverrideText.GetLocalizedResource(), navigationArguments.SearchQuery, displayName)); var searchInstance = new Utils.Storage.FolderSearch { Query = navigationArguments.SearchQuery, @@ -756,7 +757,7 @@ private void AddNewFileTagsToMenu(CommandBarFlyout contextMenu) contextMenu.SecondaryCommands.Insert(index, new AppBarSeparator()); contextMenu.SecondaryCommands.Insert(index + 1, new AppBarButton() { - Label = "EditTags".GetLocalizedResource(), + Label = Strings.EditTags.GetLocalizedResource(), Content = new ThemedIcon() { Style = (Style)Application.Current.Resources["App.ThemedIcons.TagEdit"], @@ -842,7 +843,7 @@ private async Task AddShellMenuItemsAsync(List s if (overflowItemFlyout.Items.Count > 0 && UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu) { - overflowItem.Label = "ShowMoreOptions".GetLocalizedResource(); + overflowItem.Label = Strings.ShowMoreOptions.GetLocalizedResource(); overflowItem.IsEnabled = true; } else @@ -887,7 +888,7 @@ private async Task AddShellMenuItemsAsync(List s { ThemedIconStyle = "App.ThemedIcons.OpenWith" }.ToThemedIcon(); - openWithOverflow.Label = "OpenWith".GetLocalizedResource(); + openWithOverflow.Label = Strings.OpenWith.GetLocalizedResource(); } } @@ -1067,41 +1068,41 @@ private async void Item_DragOver(object sender, DragEventArgs e) if (item.IsExecutable || item.IsScriptFile) { - e.DragUIOverride.Caption = $"{"OpenWith".GetLocalizedResource()} {item.Name}"; + e.DragUIOverride.Caption = $"{Strings.OpenWith.GetLocalizedResource()} {item.Name}"; e.AcceptedOperation = DataPackageOperation.Link; } // Items from the same drive as this folder are dragged into this folder, so we move the items instead of copy else if (e.Modifiers.HasFlag(DragDropModifiers.Alt) || e.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift)) { - e.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), item.Name); + e.DragUIOverride.Caption = string.Format(Strings.LinkToFolderCaptionText.GetLocalizedResource(), item.Name); e.AcceptedOperation = DataPackageOperation.Link; } else if (e.Modifiers.HasFlag(DragDropModifiers.Control)) { - e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name); + e.DragUIOverride.Caption = string.Format(Strings.CopyToFolderCaptionText.GetLocalizedResource(), item.Name); e.AcceptedOperation = DataPackageOperation.Copy; } else if (e.Modifiers.HasFlag(DragDropModifiers.Shift)) { - e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name); + e.DragUIOverride.Caption = string.Format(Strings.MoveToFolderCaptionText.GetLocalizedResource(), item.Name); // Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well. e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy; } else if (draggedItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder) || ZipStorageFolder.IsZipPath(item.ItemPath)) { - e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name); + e.DragUIOverride.Caption = string.Format(Strings.CopyToFolderCaptionText.GetLocalizedResource(), item.Name); e.AcceptedOperation = DataPackageOperation.Copy; } else if (draggedItems.AreItemsInSameDrive(item.ItemPath)) { - e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name); + e.DragUIOverride.Caption = string.Format(Strings.MoveToFolderCaptionText.GetLocalizedResource(), item.Name); // Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well. e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy; } else { - e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name); + e.DragUIOverride.Caption = string.Format(Strings.CopyToFolderCaptionText.GetLocalizedResource(), item.Name); e.AcceptedOperation = DataPackageOperation.Copy; } } diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs index 02a11423ccff..88ae5d878993 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs @@ -587,8 +587,8 @@ protected override void BaseFolderSettings_LayoutModeChangeRequested(object? sen case FolderLayoutModes.ListView: parent.FolderSettings.ToggleLayoutModeList(true); break; - case FolderLayoutModes.TilesView: - parent.FolderSettings.ToggleLayoutModeTiles(true); + case FolderLayoutModes.CardsView: + parent.FolderSettings.ToggleLayoutModeCards(true); break; case FolderLayoutModes.GridView: parent.FolderSettings.ToggleLayoutModeGridView(true); diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml b/src/Files.App/Views/Layouts/GridLayoutPage.xaml index 4a394e65df23..4480c00e1203 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml @@ -7,6 +7,7 @@ xmlns:controls="using:Files.App.Controls" xmlns:converters="using:Files.App.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:datamodels="using:Files.App.Data.Models" xmlns:filesystem="using:Files.App.Utils" xmlns:helpers="using:Files.App.Helpers" xmlns:i="using:Microsoft.Xaml.Interactivity" @@ -86,11 +87,6 @@ TrueValue="Visible" /> - - 0 - - - @@ -433,192 +429,247 @@ - - + + - - - - - - - - + - - - - + + - + + + - + + - - - - - - - - - - - - - - - - - - - - + + + - + - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -729,6 +780,65 @@ + + + + + + + + + diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index ee1435271b64..33fe4438c147 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -39,50 +39,108 @@ public sealed partial class GridLayoutPage : BaseGroupableLayoutPage protected override SemanticZoom RootZoom => RootGridZoom; + // List View properties + /// /// Row height in the List View layout /// - public int RowHeightListView - { - get => LayoutSizeKindHelper.GetListViewRowHeight(UserSettingsService.LayoutSettingsService.ListViewSize); - } + public int RowHeightListView => + LayoutSizeKindHelper.GetListViewRowHeight(LayoutSettingsService.ListViewSize); /// /// Icon Box size in the List View layout. The value is increased by 4px to account for icon overlays. /// - public int IconBoxSizeListView + public int IconBoxSizeListView => + (int)(LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.ListView) + 4); + + + + // Grid View properties + + /// + /// Item width in the Grid View layout + /// + public int ItemWidthGridView => + LayoutSizeKindHelper.GetGridViewItemWidth(LayoutSettingsService.GridViewSize); + + + + // Cards View properties + + /// + /// Gets the details box width for the Cards View layout based on the card size. + /// + public int CardsViewDetailsBoxWidth => LayoutSettingsService.CardsViewSize switch { - get => (int)(LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.ListView) + 4); - } + CardsViewSizeKind.Small => 196, + CardsViewSizeKind.Medium => 240, + CardsViewSizeKind.Large => 280, + CardsViewSizeKind.ExtraLarge => 320, + _ => 300 + }; /// - /// Item width in the Tiles View layout + /// Gets the details box height for the Cards View layout based on the card size. /// - public int ItemWidthTilesView + public int CardsViewDetailsBoxHeight => LayoutSettingsService.CardsViewSize switch { - get => LayoutSizeKindHelper.GetTilesViewItemWidth(UserSettingsService.LayoutSettingsService.TilesViewSize); - } + CardsViewSizeKind.Small => 104, + CardsViewSizeKind.Medium => 144, + CardsViewSizeKind.Large => 144, + CardsViewSizeKind.ExtraLarge => 128, + _ => 128 + }; /// - /// Item width in the Grid View layout + /// Gets the icon box height for the Cards View layout based on the card size. /// - public int ItemWidthGridView + public int CardsViewIconBoxHeight => LayoutSettingsService.CardsViewSize switch { - get => LayoutSizeKindHelper.GetGridViewItemWidth(UserSettingsService.LayoutSettingsService.GridViewSize); - } + CardsViewSizeKind.Small => 104, + CardsViewSizeKind.Medium => 96, + CardsViewSizeKind.Large => 128, + CardsViewSizeKind.ExtraLarge => 160, + _ => 128 + }; - public bool IsPointerOver + /// + /// Gets the icon box width for the Cards View layout based on the card size. + /// + public int CardsViewIconBoxWidth => LayoutSettingsService.CardsViewSize switch { - get => (bool)GetValue(IsPointerOverProperty); - set => SetValue(IsPointerOverProperty, value); - } + CardsViewSizeKind.Small => 104, + CardsViewSizeKind.Medium => 240, + CardsViewSizeKind.Large => 280, + CardsViewSizeKind.ExtraLarge => 320, + _ => 128 + }; + + /// + /// Gets the orientation of cards in the Cards View layout. + /// + public Orientation CardsViewOrientation => UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Small + ? Orientation.Horizontal + : Orientation.Vertical; + + /// + /// Gets the maximum lines for item names in the Cards View layout. + /// + public int CardsViewItemNameMaxLines => + LayoutSettingsService.CardsViewSize == CardsViewSizeKind.ExtraLarge ? 1 : 2; + + /// + /// Gets the visibility for the contextual property string in the Cards View layout. + /// + public bool CardsViewShowContextualProperty=> + LayoutSettingsService.CardsViewSize != CardsViewSizeKind.Small; + + /// + /// Gets the icon size for item names in the Cards View layout. + /// + public int CardsViewIconSize => + (int)LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.CardsView); + - public static readonly DependencyProperty IsPointerOverProperty = - DependencyProperty.Register( - nameof(IsPointerOver), - typeof(bool), - typeof(GridLayoutPage), - new PropertyMetadata(false)); // Constructor @@ -181,10 +239,8 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang SetItemContainerStyle(); FolderSettings_IconSizeChanged(); } - if (e.PropertyName == nameof(ILayoutSettingsService.TilesViewSize)) + if (e.PropertyName == nameof(ILayoutSettingsService.CardsViewSize)) { - NotifyPropertyChanged(nameof(ItemWidthTilesView)); - // Update the container style to match the item size SetItemContainerStyle(); FolderSettings_IconSizeChanged(); @@ -205,7 +261,7 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang private void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e) { if (FolderSettings.LayoutMode == FolderLayoutModes.ListView - || FolderSettings.LayoutMode == FolderLayoutModes.TilesView + || FolderSettings.LayoutMode == FolderLayoutModes.CardsView || FolderSettings.LayoutMode == FolderLayoutModes.GridView) { // Set ItemTemplate @@ -220,7 +276,7 @@ private void SetItemTemplate() var newFileListStyle = FolderSettings.LayoutMode switch { FolderLayoutModes.ListView => (Style)Resources["VerticalLayoutGridView"], - FolderLayoutModes.TilesView => (Style)Resources["HorizontalLayoutGridView"], + FolderLayoutModes.CardsView => (Style)Resources["HorizontalLayoutGridView"], _ => (Style)Resources["HorizontalLayoutGridView"] }; @@ -239,8 +295,8 @@ private void SetItemTemplate() case FolderLayoutModes.ListView: FileList.ItemTemplate = ListViewBrowserTemplate; break; - case FolderLayoutModes.TilesView: - FileList.ItemTemplate = TilesBrowserTemplate; + case FolderLayoutModes.CardsView: + FileList.ItemTemplate = CardsBrowserTemplate; break; default: FileList.ItemTemplate = GridViewBrowserTemplate; @@ -250,7 +306,15 @@ private void SetItemTemplate() private void SetItemContainerStyle() { - if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact) + if (FolderSettings?.LayoutMode == FolderLayoutModes.CardsView) + { + // Toggle style to force item size to update + FileList.ItemContainerStyle = DefaultItemContainerStyle; + + // Set correct style + FileList.ItemContainerStyle = CardsItemContainerStyle; + } + else if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact) { // Toggle style to force item size to update FileList.ItemContainerStyle = DefaultItemContainerStyle; @@ -303,7 +367,7 @@ override public void StartRenameItem() TextBox? textBox = null; - // Handle layout differences between tiles browser and photo album + // Grid View if (FolderSettings.LayoutMode == FolderLayoutModes.GridView) { if (gridViewItem.FindDescendant("EditPopup") is not Popup popup) @@ -318,6 +382,7 @@ override public void StartRenameItem() popup.IsOpen = true; OldItemName = textBlock.Text; } + // List View else if (FolderSettings.LayoutMode == FolderLayoutModes.ListView) { textBox = gridViewItem.FindDescendant("ListViewTextBoxItemName") as TextBox; @@ -336,6 +401,7 @@ override public void StartRenameItem() return; } } + // Cards View else { textBox = gridViewItem.FindDescendant("TileViewTextBoxItemName") as TextBox; @@ -344,12 +410,10 @@ override public void StartRenameItem() textBox.Text = textBlock.Text; OldItemName = textBlock.Text; - textBlock.Visibility = Visibility.Collapsed; textBox.Visibility = Visibility.Visible; if (textBox.FindParent() is null) { - textBlock.Visibility = Visibility.Visible; textBox.Visibility = Visibility.Collapsed; return; } @@ -398,7 +462,7 @@ protected override void EndRename(TextBox textBox) if (textBlock is not null) textBlock.Opacity = (textBlock.DataContext as ListedItem)!.Opacity; } - else if (FolderSettings.LayoutMode == FolderLayoutModes.TilesView || FolderSettings.LayoutMode == FolderLayoutModes.ListView) + else if (FolderSettings.LayoutMode == FolderLayoutModes.CardsView || FolderSettings.LayoutMode == FolderLayoutModes.ListView) { TextBlock? textBlock = gridViewItem.FindDescendant("ItemName") as TextBlock; @@ -698,7 +762,7 @@ private void SelectionCheckbox_PointerCanceled(object sender, PointerRoutedEvent // To avoid crashes, disable scrolling when drag-and-drop if grouped. (#14484) private bool ShouldDisableScrollingWhenDragAndDrop => - FolderSettings?.LayoutMode is FolderLayoutModes.GridView or FolderLayoutModes.TilesView && + FolderSettings?.LayoutMode is FolderLayoutModes.GridView or FolderLayoutModes.CardsView && (ParentShellPageInstance?.ShellViewModel.FilesAndFolders.IsGrouped ?? false); protected override void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e) diff --git a/src/Files.App/Views/Settings/LayoutPage.xaml b/src/Files.App/Views/Settings/LayoutPage.xaml index 92f5a92914bf..cdb803006dda 100644 --- a/src/Files.App/Views/Settings/LayoutPage.xaml +++ b/src/Files.App/Views/Settings/LayoutPage.xaml @@ -64,7 +64,7 @@ - + diff --git a/src/Files.Shared/Helpers/FileExtensionHelpers.cs b/src/Files.Shared/Helpers/FileExtensionHelpers.cs index 232adf1f57e8..63225d85cf16 100644 --- a/src/Files.Shared/Helpers/FileExtensionHelpers.cs +++ b/src/Files.Shared/Helpers/FileExtensionHelpers.cs @@ -256,6 +256,16 @@ public static bool IsScriptFile(string? filePathToCheck) { return HasExtension(filePathToCheck, ".py", ".ahk"); } + + /// + /// Check if the file extension is a system file. + /// + /// + /// true if the filePathToCheck is a system file; otherwise, false. + public static bool IsSystemFile(string? filePathToCheck) + { + return HasExtension(filePathToCheck, ".dll", ".exe", ".sys", ".inf"); + } } }