1
1
using System ;
2
2
using System . Collections . Generic ;
3
- using System . Diagnostics ;
4
- using System . Linq ;
5
3
using System . Windows . Forms ;
6
4
using CommunityToolkit . Mvvm . Input ;
7
5
using Flow . Launcher . Core ;
8
6
using Flow . Launcher . Core . Configuration ;
9
7
using Flow . Launcher . Core . Resource ;
10
8
using Flow . Launcher . Helper ;
9
+ using Flow . Launcher . Infrastructure ;
11
10
using Flow . Launcher . Infrastructure . UserSettings ;
12
11
using Flow . Launcher . Plugin ;
13
12
using Flow . Launcher . Plugin . SharedModels ;
14
- using Microsoft . Win32 ;
15
13
using OpenFileDialog = System . Windows . Forms . OpenFileDialog ;
16
- using System . Windows . Input ;
17
-
18
14
19
15
namespace Flow . Launcher . SettingPages . ViewModels ;
20
16
@@ -25,16 +21,13 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
25
21
private readonly IPortable _portable ;
26
22
private readonly Internationalization _translater ;
27
23
28
- public ICommand OpenImeSettingsCommand { get ; }
29
-
30
24
public SettingsPaneGeneralViewModel ( Settings settings , Updater updater , IPortable portable , Internationalization translater )
31
25
{
32
26
Settings = settings ;
33
27
_updater = updater ;
34
28
_portable = portable ;
35
29
_translater = translater ;
36
30
UpdateEnumDropdownLocalizations ( ) ;
37
- OpenImeSettingsCommand = new RelayCommand ( OpenImeSettings ) ;
38
31
}
39
32
40
33
public class SearchWindowScreenData : DropdownDataGeneric < SearchWindowScreens > { }
@@ -187,21 +180,22 @@ public string Language
187
180
UpdateEnumDropdownLocalizations ( ) ;
188
181
}
189
182
}
190
-
183
+
184
+ #region Korean IME
185
+
191
186
// The new Korean IME used in Windows 11 has compatibility issues with WPF. This issue is difficult to resolve within
192
187
// WPF itself, but it can be avoided by having the user switch to the legacy IME at the system level. Therefore,
193
188
// we provide guidance and a direct button for users to make this change themselves. If the relevant registry key does
194
189
// not exist (i.e., the Korean IME is not installed), this setting will not be shown at all.
195
- #region Korean IME
190
+
196
191
public bool LegacyKoreanIMEEnabled
197
192
{
198
- get => IsLegacyKoreanIMEEnabled ( ) ;
193
+ get => Win32Helper . IsLegacyKoreanIMEEnabled ( ) ;
199
194
set
200
195
{
201
- Debug . WriteLine ( $ "[DEBUG] LegacyKoreanIMEEnabled changed: { value } ") ;
202
- if ( SetLegacyKoreanIMEEnabled ( value ) )
196
+ if ( Win32Helper . SetLegacyKoreanIMEEnabled ( value ) )
203
197
{
204
- OnPropertyChanged ( nameof ( LegacyKoreanIMEEnabled ) ) ;
198
+ OnPropertyChanged ( ) ;
205
199
OnPropertyChanged ( nameof ( KoreanIMERegistryValueIsZero ) ) ;
206
200
}
207
201
else
@@ -212,13 +206,13 @@ public bool LegacyKoreanIMEEnabled
212
206
}
213
207
}
214
208
215
- public bool KoreanIMERegistryKeyExists => IsKoreanIMEExist ( ) ;
209
+ public bool KoreanIMERegistryKeyExists => Win32Helper . IsKoreanIMEExist ( ) ;
216
210
217
211
public bool KoreanIMERegistryValueIsZero
218
212
{
219
213
get
220
214
{
221
- object value = GetLegacyKoreanIMERegistryValue ( ) ;
215
+ object value = Win32Helper . GetLegacyKoreanIMERegistryValue ( ) ;
222
216
if ( value is int intValue )
223
217
{
224
218
return intValue == 0 ;
@@ -232,90 +226,12 @@ public bool KoreanIMERegistryValueIsZero
232
226
}
233
227
}
234
228
235
- bool IsKoreanIMEExist ( )
236
- {
237
- return GetLegacyKoreanIMERegistryValue ( ) != null ;
238
- }
239
-
240
- bool IsLegacyKoreanIMEEnabled ( )
241
- {
242
- object value = GetLegacyKoreanIMERegistryValue ( ) ;
243
-
244
- if ( value is int intValue )
245
- {
246
- return intValue == 1 ;
247
- }
248
- else if ( value != null && int . TryParse ( value . ToString ( ) , out int parsedValue ) )
249
- {
250
- return parsedValue == 1 ;
251
- }
252
-
253
- return false ;
254
- }
255
-
256
- bool SetLegacyKoreanIMEEnabled ( bool enable )
257
- {
258
- const string subKeyPath = @"Software\Microsoft\input\tsf\tsf3override\{A028AE76-01B1-46C2-99C4-ACD9858AE02F}" ;
259
- const string valueName = "NoTsf3Override5" ;
260
-
261
- try
262
- {
263
- using ( RegistryKey key = Registry . CurrentUser . CreateSubKey ( subKeyPath ) )
264
- {
265
- if ( key != null )
266
- {
267
- int value = enable ? 1 : 0 ;
268
- key . SetValue ( valueName , value , RegistryValueKind . DWord ) ;
269
- return true ;
270
- }
271
- else
272
- {
273
- Debug . WriteLine ( $ "[IME DEBUG] Failed to create or open registry key: { subKeyPath } ") ;
274
- }
275
- }
276
- }
277
- catch ( Exception ex )
278
- {
279
- Debug . WriteLine ( $ "[IME DEBUG] Exception occurred while setting registry: { ex . Message } ") ;
280
- }
281
-
282
- return false ;
283
- }
284
-
285
- private object GetLegacyKoreanIMERegistryValue ( )
286
- {
287
- const string subKeyPath = @"Software\Microsoft\input\tsf\tsf3override\{A028AE76-01B1-46C2-99C4-ACD9858AE02F}" ;
288
- const string valueName = "NoTsf3Override5" ;
289
-
290
- try
291
- {
292
- using ( RegistryKey key = Registry . CurrentUser . OpenSubKey ( subKeyPath ) )
293
- {
294
- if ( key != null )
295
- {
296
- return key . GetValue ( valueName ) ;
297
- }
298
- }
299
- }
300
- catch ( Exception ex )
301
- {
302
- Debug . WriteLine ( $ "[IME DEBUG] Exception occurred: { ex . Message } ") ;
303
- }
304
-
305
- return null ;
306
- }
307
-
229
+ [ RelayCommand ]
308
230
private void OpenImeSettings ( )
309
231
{
310
- try
311
- {
312
- Process . Start ( new ProcessStartInfo ( "ms-settings:regionlanguage" ) { UseShellExecute = true } ) ;
313
- }
314
- catch ( Exception e )
315
- {
316
- Debug . WriteLine ( $ "Error opening IME settings: { e . Message } ") ;
317
- }
232
+ Win32Helper . OpenImeSettings ( ) ;
318
233
}
234
+
319
235
#endregion
320
236
321
237
public bool ShouldUsePinyin
0 commit comments