@@ -32,6 +32,10 @@ public static async Task<List<ShellNewEntry>> GetNewContextMenuEntries()
3232 }
3333 }
3434 }
35+ if ( ! newMenuItems . Any ( x => ".txt" . Equals ( x . Extension , StringComparison . OrdinalIgnoreCase ) ) )
36+ {
37+ newMenuItems . Add ( await CreateShellNewEntry ( ".txt" , null , null , null ) ) ;
38+ }
3539 return newMenuItems ;
3640 }
3741
@@ -68,20 +72,23 @@ private static async Task<ShellNewEntry> GetShellNewRegistryEntries(RegistryKey
6872 return null ;
6973 }
7074
71- private static async Task < ShellNewEntry > ParseShellNewRegistryEntry ( RegistryKey key , RegistryKey root )
75+ private static Task < ShellNewEntry > ParseShellNewRegistryEntry ( RegistryKey key , RegistryKey root )
7276 {
7377 var valueNames = key . GetValueNames ( ) ;
7478
7579 if ( ! valueNames . Contains ( "NullFile" , StringComparer . OrdinalIgnoreCase ) &&
7680 ! valueNames . Contains ( "Name" , StringComparer . OrdinalIgnoreCase ) &&
7781 ! valueNames . Contains ( "FileName" , StringComparer . OrdinalIgnoreCase ) &&
78- ! valueNames . Contains ( "Command" , StringComparer . OrdinalIgnoreCase ) )
82+ ! valueNames . Contains ( "Command" , StringComparer . OrdinalIgnoreCase ) &&
83+ ! valueNames . Contains ( "ItemName" , StringComparer . OrdinalIgnoreCase ) &&
84+ ! valueNames . Contains ( "Data" , StringComparer . OrdinalIgnoreCase ) )
7985 {
8086 return null ;
8187 }
8288
8389 var extension = root . Name . Substring ( root . Name . LastIndexOf ( '\\ ' ) + 1 ) ;
8490 var fileName = ( string ) key . GetValue ( "FileName" ) ;
91+ var command = ( string ) key . GetValue ( "Command" ) ;
8592
8693 byte [ ] data = null ;
8794 var dataObj = key . GetValue ( "Data" ) ;
@@ -100,6 +107,11 @@ private static async Task<ShellNewEntry> ParseShellNewRegistryEntry(RegistryKey
100107 }
101108 }
102109
110+ return CreateShellNewEntry ( extension , fileName , command , data ) ;
111+ }
112+
113+ private static async Task < ShellNewEntry > CreateShellNewEntry ( string extension , string ? fileName , string ? command , byte [ ] ? data )
114+ {
103115 var folder = await SafetyExtensions . IgnoreExceptions ( ( ) => ApplicationData . Current . LocalFolder . CreateFolderAsync ( "extensions" , CreationCollisionOption . OpenIfExists ) . AsTask ( ) ) ;
104116 var sampleFile = folder is not null ? await SafetyExtensions . IgnoreExceptions ( ( ) => folder . CreateFileAsync ( "file" + extension , CreationCollisionOption . OpenIfExists ) . AsTask ( ) ) : null ;
105117
@@ -121,7 +133,7 @@ private static async Task<ShellNewEntry> ParseShellNewRegistryEntry(RegistryKey
121133 Extension = extension ,
122134 Template = fileName ,
123135 Name = displayType ,
124- Command = ( string ) key . GetValue ( "Command" ) ,
136+ Command = command ,
125137 IconBase64 = iconString ,
126138 Data = data
127139 } ;
0 commit comments