1
1
using Microsoft . Toolkit . Uwp . Notifications ;
2
2
using Microsoft . Win32 ;
3
- using Microsoft . Windows . Themes ;
4
3
using RegistryUtils ;
5
4
using System ;
6
5
using System . Collections . Generic ;
18
17
using Text_Grab . Views ;
19
18
using Wpf . Ui ;
20
19
using Wpf . Ui . Appearance ;
21
- using Wpf . Ui . Extensions ;
22
20
23
21
namespace Text_Grab ;
24
22
@@ -27,6 +25,12 @@ namespace Text_Grab;
27
25
/// </summary>
28
26
public partial class App : System . Windows . Application
29
27
{
28
+ #region Fields
29
+
30
+ readonly static Settings _defaultSettings = AppUtilities . TextGrabSettings ;
31
+
32
+ #endregion Fields
33
+
30
34
#region Properties
31
35
32
36
public List < int > HotKeyIds { get ; set ; } = new ( ) ;
@@ -38,7 +42,7 @@ public partial class App : System.Windows.Application
38
42
39
43
public static void DefaultLaunch ( )
40
44
{
41
- TextGrabMode defaultLaunchSetting = Enum . Parse < TextGrabMode > ( Settings . Default . DefaultLaunch , true ) ;
45
+ TextGrabMode defaultLaunchSetting = Enum . Parse < TextGrabMode > ( _defaultSettings . DefaultLaunch , true ) ;
42
46
43
47
switch ( defaultLaunchSetting )
44
48
{
@@ -65,7 +69,7 @@ public static void DefaultLaunch()
65
69
}
66
70
public static void SetTheme ( object ? sender = null , EventArgs ? e = null )
67
71
{
68
- bool gotTheme = Enum . TryParse < AppTheme > ( Settings . Default . AppTheme . ToString ( ) , true , out AppTheme currentAppTheme ) ;
72
+ bool gotTheme = Enum . TryParse ( _defaultSettings . AppTheme . ToString ( ) , true , out AppTheme currentAppTheme ) ;
69
73
70
74
if ( ! gotTheme )
71
75
return ;
@@ -135,8 +139,8 @@ private static async Task<bool> HandleStartupArgs(string[] args)
135
139
if ( arg == "--windowless" )
136
140
{
137
141
isQuiet = true ;
138
- Settings . Default . FirstRun = false ;
139
- Settings . Default . Save ( ) ;
142
+ _defaultSettings . FirstRun = false ;
143
+ _defaultSettings . Save ( ) ;
140
144
}
141
145
142
146
if ( currentArgument . Contains ( "ToastActivated" ) )
@@ -151,7 +155,7 @@ private static async Task<bool> HandleStartupArgs(string[] args)
151
155
return true ;
152
156
}
153
157
154
- bool isStandardMode = Enum . TryParse < TextGrabMode > ( currentArgument , true , out TextGrabMode launchMode ) ;
158
+ bool isStandardMode = Enum . TryParse ( currentArgument , true , out TextGrabMode launchMode ) ;
155
159
156
160
if ( isStandardMode )
157
161
{
@@ -195,8 +199,8 @@ private static void ShowAndSetFirstRun()
195
199
FirstRunWindow frw = new ( ) ;
196
200
frw . Show ( ) ;
197
201
198
- Settings . Default . FirstRun = false ;
199
- Settings . Default . Save ( ) ;
202
+ _defaultSettings . FirstRun = false ;
203
+ _defaultSettings . Save ( ) ;
200
204
}
201
205
202
206
private static async Task < bool > TryToOpenFile ( string possiblePath , bool isQuiet )
@@ -253,14 +257,14 @@ async void appStartup(object sender, StartupEventArgs e)
253
257
if ( handledArgument )
254
258
{
255
259
// arguments were passed, so don't show firstRun dialog
256
- Settings . Default . FirstRun = false ;
257
- Settings . Default . Save ( ) ;
260
+ _defaultSettings . FirstRun = false ;
261
+ _defaultSettings . Save ( ) ;
258
262
return ;
259
263
}
260
264
261
- if ( Settings . Default . FirstRun )
265
+ if ( _defaultSettings . FirstRun )
262
266
{
263
- Settings . Default . CorrectToLatin = LanguageUtilities . IsCurrentLanguageLatinBased ( ) ;
267
+ _defaultSettings . CorrectToLatin = LanguageUtilities . IsCurrentLanguageLatinBased ( ) ;
264
268
ShowAndSetFirstRun ( ) ;
265
269
return ;
266
270
}
@@ -277,11 +281,11 @@ private void CurrentDispatcherUnhandledException(object sender, DispatcherUnhand
277
281
278
282
private bool HandleNotifyIcon ( )
279
283
{
280
- if ( Settings . Default . RunInTheBackground && NumberOfRunningInstances < 2 )
284
+ if ( _defaultSettings . RunInTheBackground && NumberOfRunningInstances < 2 )
281
285
{
282
286
NotifyIconUtilities . SetupNotifyIcon ( ) ;
283
287
284
- if ( Settings . Default . StartupOnLogin )
288
+ if ( _defaultSettings . StartupOnLogin )
285
289
return true ;
286
290
}
287
291
@@ -295,11 +299,11 @@ private void LaunchFromToast(ToastNotificationActivatedEventArgsCompat toastArgs
295
299
return ;
296
300
297
301
// Need to dispatch to UI thread if performing UI operations
298
- Dispatcher . BeginInvoke ( ( Action ) ( ( ) =>
302
+ Dispatcher . BeginInvoke ( ( ) =>
299
303
{
300
304
EditTextWindow mtw = new ( argsInvoked ) ;
301
305
mtw . Show ( ) ;
302
- } ) ) ;
306
+ } ) ;
303
307
}
304
308
#endregion Methods
305
309
}
0 commit comments