@@ -32,6 +32,10 @@ public static async Task<List<ShellNewEntry>> GetNewContextMenuEntries()
32
32
}
33
33
}
34
34
}
35
+ if ( ! newMenuItems . Any ( x => ".txt" . Equals ( x . Extension , StringComparison . OrdinalIgnoreCase ) ) )
36
+ {
37
+ newMenuItems . Add ( await CreateShellNewEntry ( ".txt" , null , null , null ) ) ;
38
+ }
35
39
return newMenuItems ;
36
40
}
37
41
@@ -68,20 +72,23 @@ private static async Task<ShellNewEntry> GetShellNewRegistryEntries(RegistryKey
68
72
return null ;
69
73
}
70
74
71
- private static async Task < ShellNewEntry > ParseShellNewRegistryEntry ( RegistryKey key , RegistryKey root )
75
+ private static Task < ShellNewEntry > ParseShellNewRegistryEntry ( RegistryKey key , RegistryKey root )
72
76
{
73
77
var valueNames = key . GetValueNames ( ) ;
74
78
75
79
if ( ! valueNames . Contains ( "NullFile" , StringComparer . OrdinalIgnoreCase ) &&
76
80
! valueNames . Contains ( "Name" , StringComparer . OrdinalIgnoreCase ) &&
77
81
! 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 ) )
79
85
{
80
86
return null ;
81
87
}
82
88
83
89
var extension = root . Name . Substring ( root . Name . LastIndexOf ( '\\ ' ) + 1 ) ;
84
90
var fileName = ( string ) key . GetValue ( "FileName" ) ;
91
+ var command = ( string ) key . GetValue ( "Command" ) ;
85
92
86
93
byte [ ] data = null ;
87
94
var dataObj = key . GetValue ( "Data" ) ;
@@ -100,6 +107,11 @@ private static async Task<ShellNewEntry> ParseShellNewRegistryEntry(RegistryKey
100
107
}
101
108
}
102
109
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
+ {
103
115
var folder = await SafetyExtensions . IgnoreExceptions ( ( ) => ApplicationData . Current . LocalFolder . CreateFolderAsync ( "extensions" , CreationCollisionOption . OpenIfExists ) . AsTask ( ) ) ;
104
116
var sampleFile = folder is not null ? await SafetyExtensions . IgnoreExceptions ( ( ) => folder . CreateFileAsync ( "file" + extension , CreationCollisionOption . OpenIfExists ) . AsTask ( ) ) : null ;
105
117
@@ -121,7 +133,7 @@ private static async Task<ShellNewEntry> ParseShellNewRegistryEntry(RegistryKey
121
133
Extension = extension ,
122
134
Template = fileName ,
123
135
Name = displayType ,
124
- Command = ( string ) key . GetValue ( "Command" ) ,
136
+ Command = command ,
125
137
IconBase64 = iconString ,
126
138
Data = data
127
139
} ;
0 commit comments