44using Microsoft . UI . Xaml ;
55using System . Text . RegularExpressions ;
66using Files . App . Actions ;
7+ using static Files . App . Data . Items . ToolbarDefaultsTemplate ;
78
89namespace Files . App . Data . Items
910{
@@ -12,18 +13,6 @@ namespace Files.App.Data.Items
1213 /// </summary>
1314 public sealed partial class ToolbarItemDescriptor : ObservableObject
1415 {
15- public const string AlwaysVisibleContextId = "AlwaysVisible" ;
16- public const string FolderPagesContextId = "FolderPages" ;
17- public const string ArchiveFilesContextId = "ArchiveFiles" ;
18- public const string ScriptFilesContextId = "ScriptFiles" ;
19- public const string ImageFilesContextId = "ImageFiles" ;
20- public const string MediaFilesContextId = "MediaFiles" ;
21- public const string FontFilesContextId = "FontFiles" ;
22- public const string DriverFilesContextId = "DriverFiles" ;
23- public const string CertificateFilesContextId = "CertificateFiles" ;
24- public const string RecycleBinContextId = "RecycleBin" ;
25- public const string OtherContextsContextId = "OtherItems" ;
26-
2716 private const string GroupPrefix = "Group:" ;
2817 private const string IconAndLabelSuffix = "|label" ;
2918 private const string LabelOnlySuffix = "|labelonly" ;
@@ -139,7 +128,7 @@ public static IEnumerable<ToolbarItemDescriptor> GetAvailableItemsForContext(str
139128 }
140129
141130 public static bool IsKnownContextId ( string contextId )
142- => ContextOrder . Contains ( contextId , StringComparer . Ordinal ) ;
131+ => ToolbarDefaultsTemplate . ContextOrder . Contains ( contextId , StringComparer . Ordinal ) ;
143132
144133 public static bool IsOtherContextsId ( string contextId )
145134 => string . Equals ( contextId , OtherContextsContextId , StringComparison . Ordinal ) ;
@@ -180,15 +169,6 @@ public static string ResolveContextId(string identifier, ICommandManager command
180169 return OtherContextsContextId ;
181170 }
182171
183- public static Dictionary < string , List < string > > CreateDefaultIdentifiersByContext ( )
184- => ContextOrder
185- . ToDictionary (
186- static contextId => contextId ,
187- static contextId => DefaultIdentifiersByContext . TryGetValue ( contextId , out var identifiers )
188- ? identifiers . ToList ( )
189- : [ ] ,
190- StringComparer . Ordinal ) ;
191-
192172 public static Dictionary < string , List < string > > MigrateLegacyIdentifiersByContext ( IReadOnlyList < string > identifiers , ICommandManager commandManager )
193173 {
194174 var migrated = ContextOrder
@@ -265,21 +245,6 @@ public static (string Identifier, ToolbarItemDisplayMode DisplayMode) ParseSetti
265245 return null ;
266246 }
267247
268- public static readonly string [ ] ContextOrder =
269- [
270- AlwaysVisibleContextId ,
271- FolderPagesContextId ,
272- ArchiveFilesContextId ,
273- ScriptFilesContextId ,
274- ImageFilesContextId ,
275- MediaFilesContextId ,
276- FontFilesContextId ,
277- DriverFilesContextId ,
278- CertificateFilesContextId ,
279- RecycleBinContextId ,
280- OtherContextsContextId ,
281- ] ;
282-
283248 private static string GetContextId ( CommandGroup group , ICommandManager commandManager )
284249 => group . Name switch
285250 {
@@ -402,62 +367,6 @@ or CommandCodes.OpenStorageSenseFromSidebar
402367 _ => OtherContextsContextId ,
403368 } ;
404369
405- // Default toolbar item identifiers grouped by context, matching the original hardcoded XAML layout.
406- public static readonly IReadOnlyDictionary < string , string [ ] > DefaultIdentifiersByContext =
407- new Dictionary < string , string [ ] > ( StringComparer . Ordinal )
408- {
409- [ AlwaysVisibleContextId ] =
410- [
411- WithLabel ( CreateGroupIdentifier ( nameof ( CommandGroups . NewItem ) ) ) ,
412- SeparatorIdentifier ,
413- nameof ( CommandCodes . CutItem ) ,
414- nameof ( CommandCodes . CopyItem ) ,
415- nameof ( CommandCodes . PasteItem ) ,
416- nameof ( CommandCodes . Rename ) ,
417- nameof ( CommandCodes . ShareItem ) ,
418- nameof ( CommandCodes . DeleteItem ) ,
419- nameof ( CommandCodes . OpenProperties ) ,
420- ] ,
421- [ ArchiveFilesContextId ] =
422- [
423- WithLabel ( CreateGroupIdentifier ( nameof ( CommandGroups . Extract ) ) ) ,
424- ] ,
425- [ ScriptFilesContextId ] =
426- [
427- WithLabel ( nameof ( CommandCodes . RunWithPowershell ) ) ,
428- WithLabel ( nameof ( CommandCodes . EditInNotepad ) ) ,
429- ] ,
430- [ ImageFilesContextId ] =
431- [
432- WithLabel ( CreateGroupIdentifier ( nameof ( CommandGroups . SetAs ) ) ) ,
433- WithLabel ( nameof ( CommandCodes . SetAsSlideshowBackground ) ) ,
434- WithLabel ( nameof ( CommandCodes . RotateLeft ) ) ,
435- WithLabel ( nameof ( CommandCodes . RotateRight ) ) ,
436- ] ,
437- [ MediaFilesContextId ] =
438- [
439- WithLabel ( nameof ( CommandCodes . PlayAll ) ) ,
440- ] ,
441- [ FontFilesContextId ] =
442- [
443- WithLabel ( nameof ( CommandCodes . InstallFont ) ) ,
444- ] ,
445- [ DriverFilesContextId ] =
446- [
447- WithLabel ( nameof ( CommandCodes . InstallInfDriver ) ) ,
448- ] ,
449- [ CertificateFilesContextId ] =
450- [
451- WithLabel ( nameof ( CommandCodes . InstallCertificate ) ) ,
452- ] ,
453- [ RecycleBinContextId ] =
454- [
455- WithLabel ( nameof ( CommandCodes . EmptyRecycleBin ) ) ,
456- WithLabel ( nameof ( CommandCodes . RestoreAllRecycleBin ) ) ,
457- WithLabel ( nameof ( CommandCodes . RestoreRecycleBin ) ) ,
458- ] ,
459- } ;
460-
461370 }
462371
463372}
0 commit comments