SystemSettings code moved from [system] repository to [system-settings]
[platform/core/csapi/system-settings.git] / Tizen.System.SystemSettings / Tizen.System.SystemSettings / SystemSettings.cs
1 using System;
2
3 namespace Tizen.System
4 {
5     /// <summary>
6     /// The System Settings API provides APIs for sharing configuration over a system
7     /// </summary>
8     /// <remarks>
9     /// System Settings API provides functions for getting the system configuration related to user preferences.
10     /// The main features of the System Settings API include accessing system-wide configurations, such as ringtones, wallpapers, and etc
11     /// </remarks>
12     public static class SystemSettings
13     {
14         /// <summary>
15         /// The file path of the current ringtone
16         /// </summary>
17         public static string IncomingCallRingtone
18         {
19             get
20             {
21                 string filePath;
22                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.IncomingCallRingtone, out filePath);
23                 if (res != SystemSettingsError.None)
24                 {
25                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get IncomingCallRingtone system setting value.");
26                 }
27                 return filePath;
28             }
29             set
30             {
31                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.IncomingCallRingtone, value);
32                 if (res != SystemSettingsError.None)
33                 {
34                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set IncomingCallRingtone system setting.");
35                 }
36             }
37         }
38
39         /// <summary>
40         /// The file path of the current home screen wallpaper
41         /// </summary>
42         public static string WallpaperHomeScreen
43         {
44             get
45             {
46                 string filePath;
47                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.WallpaperHomeScreen, out filePath);
48                 if (res != SystemSettingsError.None)
49                 {
50                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get WallpaperHomeScreen system setting value.");
51                 }
52                 return filePath;
53             }
54             set
55             {
56                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.WallpaperHomeScreen, value);
57                 if (res != SystemSettingsError.None)
58                 {
59                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set WallpaperHomeScreen system setting.");
60                 }
61             }
62         }
63
64         /// <summary>
65         /// The file path of the current lock screen wallpaper
66         /// </summary>
67         public static string WallpaperLockScreen
68         {
69             get
70             {
71                 string filePath;
72                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.WallpaperLockScreen, out filePath);
73                 if (res != SystemSettingsError.None)
74                 {
75                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get WallpaperLockScreen system setting value.");
76                 }
77                 return filePath;
78             }
79             set
80             {
81                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.WallpaperLockScreen, value);
82                 if (res != SystemSettingsError.None)
83                 {
84                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set WallpaperLockScreen system setting.");
85                 }
86             }
87         }
88
89         /// <summary>
90         /// The current system font size
91         /// </summary>
92         public static SystemSettingsFontSize FontSize
93         {
94             get
95             {
96                 int fontSize;
97                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.FontSize, out fontSize);
98                 if (res != SystemSettingsError.None)
99                 {
100                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get FontSize system setting value.");
101                 }
102                 return (SystemSettingsFontSize)fontSize;
103             }
104             set
105             {
106                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.FontSize, (int)value);
107                 if (res != SystemSettingsError.None)
108                 {
109                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set FontSize system setting.");
110                 }
111             }
112         }
113
114         /// <summary>
115         /// The current system font type
116         /// </summary>
117         public static string FontType
118         {
119             get
120             {
121                 string fontType;
122                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.FontType, out fontType);
123                 if (res != SystemSettingsError.None)
124                 {
125                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get FontType system setting value.");
126                 }
127                 return fontType;
128             }
129             set
130             {
131                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.FontType, value);
132                 if (res != SystemSettingsError.None)
133                 {
134                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set FontType system setting.");
135                 }
136             }
137         }
138
139         /// <summary>
140         /// Indicates whether the motion service is activated
141         /// </summary>
142         public static bool MotionActivationEnabled
143         {
144             get
145             {
146                 bool isMotionServiceActivated;
147                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.MotionActivationEnabled, out isMotionServiceActivated);
148                 if (res != SystemSettingsError.None)
149                 {
150                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get MotionActivation system setting value.");
151                 }
152                 return isMotionServiceActivated;
153             }
154             set
155             {
156                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.MotionActivationEnabled, value);
157                 if (res != SystemSettingsError.None)
158                 {
159                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set MotionActivation system setting.");
160                 }
161             }
162         }
163
164         /// <summary>
165         /// The file path of the current email alert ringtone
166         /// </summary>
167         public static string EmailAlertRingtone
168         {
169             get
170             {
171                 string filePath;
172                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.EmailAlertRingtone, out filePath);
173                 if (res != SystemSettingsError.None)
174                 {
175                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get EmailAlertRingtone system setting value.");
176                 }
177                 return filePath;
178             }
179             set
180             {
181                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.EmailAlertRingtone, value);
182                 if (res != SystemSettingsError.None)
183                 {
184                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set EmailAlertRingtone system setting.");
185                 }
186             }
187         }
188         /// <summary>
189         /// Indicates whether the USB debugging is enabled (Since 2.4)
190         /// </summary>
191         public static bool UsbDebuggingEnabled
192         {
193             get
194             {
195                 bool isusbDebuggingEnabled;
196                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.UsbDebuggingEnabled, out isusbDebuggingEnabled);
197                 if (res != SystemSettingsError.None)
198                 {
199                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get UsbDebuggingEnabled system setting value.");
200                 }
201                 return isusbDebuggingEnabled;
202             }
203             set
204             {
205                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.UsbDebuggingEnabled, value);
206                 if (res != SystemSettingsError.None)
207                 {
208                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set UsbDebuggingEnabled system setting.");
209                 }
210             }
211         }
212
213         /// <summary>
214         /// Indicates whether the 3G data network is enabled (Since 2.4)
215         /// </summary>
216         public static bool Data3GNetworkEnabled
217         {
218             get
219             {
220                 bool is3GDataEnabled;
221                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.Data3GNetworkEnabled, out is3GDataEnabled);
222                 if (res != SystemSettingsError.None)
223                 {
224                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get Data3GNetworkEnabled system setting value.");
225                 }
226                 return is3GDataEnabled;
227             }
228             set
229             {
230                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.Data3GNetworkEnabled, value);
231                 if (res != SystemSettingsError.None)
232                 {
233                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set Data3GNetworkEnabled system setting.");
234                 }
235             }
236         }
237
238         /// <summary>
239         /// Indicates lockscreen app pkg name
240         /// </summary>
241         public static string LockscreenApp
242         {
243             get
244             {
245                 string pkgName;
246                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LockscreenApp, out pkgName);
247                 if (res != SystemSettingsError.None)
248                 {
249                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LockscreenApp system setting value.");
250                 }
251                 return pkgName;
252             }
253             set
254             {
255                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LockscreenApp, value);
256                 if (res != SystemSettingsError.None)
257                 {
258                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LockscreenApp system setting.");
259                 }
260             }
261         }
262
263         /// <summary>
264         /// The current system default font type (only support Get)
265         /// </summary>
266         public static string DefaultFontType
267         {
268             get
269             {
270                 string defaultFontType;
271                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.DefaultFontType, out defaultFontType);
272                 if (res != SystemSettingsError.None)
273                 {
274                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get DefaultFontType system setting value.");
275                 }
276                 return defaultFontType;
277             }
278         }
279
280         /// <summary>
281         /// Indicates the current country setting in the \<LANGUAGE\>_\<REGION\> syntax.
282         /// The country setting is in the ISO 639-2 format,
283         /// and the region setting is in the ISO 3166-1 alpha-2 format
284         /// </summary>
285         public static string LocaleCountry
286         {
287             get
288             {
289                 string countrySetting;
290                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LocaleCountry, out countrySetting);
291                 if (res != SystemSettingsError.None)
292                 {
293                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleCountry system setting value.");
294                 }
295                 return countrySetting;
296             }
297             set
298             {
299                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LocaleCountry, value);
300                 if (res != SystemSettingsError.None)
301                 {
302                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleCountry system setting.");
303                 }
304             }
305         }
306
307         /// <summary>
308         /// Indicates the current language setting in the \<LANGUAGE\>_\<REGION\> syntax.
309         /// The language setting is in the ISO 639-2 format
310         /// and the region setting is in the ISO 3166-1 alpha-2 format.
311         /// </summary>
312         public static string LocaleLanguage
313         {
314             get
315             {
316                 string languageSetting;
317                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LocaleLanguage, out languageSetting);
318                 if (res != SystemSettingsError.None)
319                 {
320                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleLanguage system setting value.");
321                 }
322                 return languageSetting;
323             }
324             set
325             {
326                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LocaleLanguage, value);
327                 if (res != SystemSettingsError.None)
328                 {
329                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleLanguage system setting.");
330                 }
331             }
332         }
333
334         /// <summary>
335         /// Indicates whether the 24-hour clock is used.
336         /// If the value is false, the 12-hour clock is used.
337         /// </summary>
338         public static bool LocaleTimeFormat24HourEnabled
339         {
340             get
341             {
342                 bool is24HrFormat;
343                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.LocaleTimeFormat24HourEnabled, out is24HrFormat);
344                 if (res != SystemSettingsError.None)
345                 {
346                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleTimeFormat24Hour system setting value.");
347                 }
348                 return is24HrFormat;
349             }
350             set
351             {
352                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.LocaleTimeFormat24HourEnabled, value);
353                 if (res != SystemSettingsError.None)
354                 {
355                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleTimeFormat24Hour system setting.");
356                 }
357             }
358         }
359
360         /// <summary>
361         /// Indicates the current time zone. Eg. "Pacific/Tahiti"
362         /// </summary>
363         public static string LocaleTimeZone
364         {
365             get
366             {
367                 string timeZone;
368                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.LocaleTimeZone, out timeZone);
369                 if (res != SystemSettingsError.None)
370                 {
371                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LocaleTimeZone system setting value.");
372                 }
373                 return timeZone;
374             }
375             set
376             {
377                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.LocaleTimeZone, value);
378                 if (res != SystemSettingsError.None)
379                 {
380                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LocaleTimeZone system setting.");
381                 }
382             }
383         }
384         /// <summary>
385         /// Indicates whether the screen lock sound is enabled on the device. ex) LCD on/off sound
386         /// </summary>
387         public static bool SoundLockEnabled
388         {
389             get
390             {
391                 bool isSoundLockEnabled;
392                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.SoundLockEnabled, out isSoundLockEnabled);
393                 if (res != SystemSettingsError.None)
394                 {
395                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundLock system setting value.");
396                 }
397                 return isSoundLockEnabled;
398             }
399         }
400
401         /// <summary>
402         /// Indicates whether the device is in the silent mode.
403         /// </summary>
404         public static bool SoundSilentModeEnabled
405         {
406             get
407             {
408                 bool isSilent;
409                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.SoundSilentModeEnabled, out isSilent);
410                 if (res != SystemSettingsError.None)
411                 {
412                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundSilentMode system setting value.");
413                 }
414                 return isSilent;
415             }
416         }
417
418         /// <summary>
419         /// Indicates whether the screen touch sound is enabled on the device.
420         /// </summary>
421         public static bool SoundTouchEnabled
422         {
423             get
424             {
425                 bool isTouchSoundEnabled;
426                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.SoundTouchEnabled, out isTouchSoundEnabled);
427                 if (res != SystemSettingsError.None)
428                 {
429                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundTouch system setting value.");
430                 }
431                 return isTouchSoundEnabled;
432             }
433         }
434
435         /// <summary>
436         /// Indicates whether rotation control is automatic.
437         /// </summary>
438         public static bool DisplayScreenRotationAutoEnabled
439         {
440             get
441             {
442                 bool isRotationAutomatic;
443                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.DisplayScreenRotationAutoEnabled, out isRotationAutomatic);
444                 if (res != SystemSettingsError.None)
445                 {
446                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get DisplayScreenRotationAuto system setting value.");
447                 }
448                 return isRotationAutomatic;
449             }
450         }
451
452         /// <summary>
453         /// Indicates device name.
454         /// </summary>
455         public static string DeviceName
456         {
457             get
458             {
459                 string deviceName;
460                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.DeviceName, out deviceName);
461                 if (res != SystemSettingsError.None)
462                 {
463                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get DeviceName system setting value.");
464                 }
465                 return deviceName;
466             }
467         }
468         /// <summary>
469         /// Indicates whether the device user has enabled motion feature.
470         /// </summary>
471         public static bool MotionEnabled
472         {
473             get
474             {
475                 bool isMotionEnabled;
476                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.MotionEnabled, out isMotionEnabled);
477                 if (res != SystemSettingsError.None)
478                 {
479                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get MotionEnabled system setting value.");
480                 }
481                 return isMotionEnabled;
482             }
483         }
484
485         /// <summary>
486         /// Indicates whether Wi-Fi-related notifications are enabled on the device.
487         /// </summary>
488         public static bool NetworkWifiNotificationEnabled
489         {
490             get
491             {
492                 bool isWifiNotificationEnabled;
493                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.NetworkWifiNotificationEnabled, out isWifiNotificationEnabled);
494                 if (res != SystemSettingsError.None)
495                 {
496                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get NetworkWifiNotification system setting value.");
497                 }
498                 return isWifiNotificationEnabled;
499             }
500         }
501
502         /// <summary>
503         /// Indicates whether the device is in the flight mode.
504         /// </summary>
505         public static bool NetworkFlightModeEnabled
506         {
507             get
508             {
509                 bool isFlightModeEnabled;
510                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.NetworkFlightModeEnabled, out isFlightModeEnabled);
511                 if (res != SystemSettingsError.None)
512                 {
513                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get NetworkFlightMode system setting value.");
514                 }
515                 return isFlightModeEnabled;
516             }
517         }
518
519         /// <summary>
520         /// Indicates the backlight time (in seconds). The following values can be used: 15, 30, 60, 120, 300, and 600.
521         /// </summary>
522         public static int ScreenBacklightTime
523         {
524             get
525             {
526                 int backlightTime;
527                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.ScreenBacklightTime, out backlightTime);
528                 if (res != SystemSettingsError.None)
529                 {
530                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get ScreenBacklightTime system setting value.");
531                 }
532                 return backlightTime;
533             }
534             set
535             {
536                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.ScreenBacklightTime, value);
537                 if (res != SystemSettingsError.None)
538                 {
539                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set ScreenBacklightTime system setting.");
540                 }
541             }
542         }
543
544         /// <summary>
545         /// Indicates the file path of the current notification tone set by the user.
546         /// </summary>
547         public static string SoundNotification
548         {
549             get
550             {
551                 string filePath;
552                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.SoundNotification, out filePath);
553                 if (res != SystemSettingsError.None)
554                 {
555                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundNotification system setting value.");
556                 }
557                 return filePath;
558             }
559             set
560             {
561                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.SoundNotification, value);
562                 if (res != SystemSettingsError.None)
563                 {
564                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set SoundNotification system setting.");
565                 }
566             }
567         }
568
569         /// <summary>
570         /// Indicates the time period for notification repetitions.
571         /// </summary>
572         public static int SoundNotificationRepetitionPeriod
573         {
574             get
575             {
576                 int notificationRepetitionPeriod;
577                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.SoundNotificationRepetitionPeriod, out notificationRepetitionPeriod);
578                 if (res != SystemSettingsError.None)
579                 {
580                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get SoundNotificationRepetitionPeriod system setting value.");
581                 }
582                 return notificationRepetitionPeriod;
583             }
584             set
585             {
586                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.SoundNotificationRepetitionPeriod, value);
587                 if (res != SystemSettingsError.None)
588                 {
589                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set SoundNotificationRepetitionPeriod system setting.");
590                 }
591             }
592         }
593
594         /// <summary>
595         /// Indicates the current lock state
596         /// </summary>
597         public static SystemSettingsIdleLockState LockState
598         {
599             get
600             {
601                 int LockState;
602                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.LockState, out LockState);
603                 if (res != SystemSettingsError.None)
604                 {
605                     Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get LockState system setting value.");
606                 }
607                 return (SystemSettingsIdleLockState)LockState;
608             }
609             set
610             {
611                 SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueInt(SystemSettingsKeys.LockState, (int)value);
612                 if (res != SystemSettingsError.None)
613                 {
614                     throw SystemSettingsExceptionFactory.CreateException(res, "unable to set LockState system setting.");
615                 }
616             }
617         }
618
619         private static readonly Interop.Settings.SystemSettingsChangedCallback s_incomingCallRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
620         {
621             string path = SystemSettings.IncomingCallRingtone;
622             IncomingCallRingtoneChangedEventArgs eventArgs = new IncomingCallRingtoneChangedEventArgs(path);
623             s_incomingCallRingtoneChanged?.Invoke(null, eventArgs);
624         };
625         private static event EventHandler<IncomingCallRingtoneChangedEventArgs> s_incomingCallRingtoneChanged;
626         /// <summary>
627         /// IncomingCallRingtoneChanged event is triggered when the file path of the incoming ringtone is changed
628         /// </summary>
629         /// <param name="sender"></param>
630         /// <param name="e">A IncomingCallRingtoneChangedEventArgs object that contains the key & changed value</param>
631         public static event EventHandler<IncomingCallRingtoneChangedEventArgs> IncomingCallRingtoneChanged
632         {
633             add
634             {
635                 if (s_incomingCallRingtoneChanged == null)
636                 {
637                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.IncomingCallRingtone, s_incomingCallRingtoneChangedCallback, IntPtr.Zero);
638                     if (ret != SystemSettingsError.None)
639                     {
640                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
641                     }
642                 }
643                 s_incomingCallRingtoneChanged += value;
644             }
645
646             remove
647             {
648                 s_incomingCallRingtoneChanged -= value;
649                 if (s_incomingCallRingtoneChanged == null)
650                 {
651                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.IncomingCallRingtone);
652                     if (ret != SystemSettingsError.None)
653                     {
654                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
655                     }
656                 }
657             }
658         }
659
660         private static readonly Interop.Settings.SystemSettingsChangedCallback s_wallpaperHomeScreenChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
661         {
662             string path = SystemSettings.WallpaperHomeScreen;
663             WallpaperHomeScreenChangedEventArgs eventArgs = new WallpaperHomeScreenChangedEventArgs(path);
664             s_wallpaperHomeScreenChanged?.Invoke(null, eventArgs);
665         };
666         private static event EventHandler<WallpaperHomeScreenChangedEventArgs> s_wallpaperHomeScreenChanged;
667         /// <summary>
668         /// WallpaperHomeScreenChanged event is triggered when the file path of the current home screen wallpaper is changed
669         /// </summary>
670         /// <param name="sender"></param>
671         /// <param name="e">A WallpaperHomeScreenChangedEventArgs object that contains the key & changed value</param>
672         public static event EventHandler<WallpaperHomeScreenChangedEventArgs> WallpaperHomeScreenChanged
673         {
674             add
675             {
676                 if (s_wallpaperHomeScreenChanged == null)
677                 {
678                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.WallpaperHomeScreen, s_wallpaperHomeScreenChangedCallback, IntPtr.Zero);
679                     if (ret != SystemSettingsError.None)
680                     {
681                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
682                     }
683                 }
684                 s_wallpaperHomeScreenChanged += value;
685             }
686
687             remove
688             {
689                 s_wallpaperHomeScreenChanged -= value;
690                 if (s_wallpaperHomeScreenChanged == null)
691                 {
692                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.WallpaperHomeScreen);
693                     if (ret != SystemSettingsError.None)
694                     {
695                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
696                     }
697                 }
698             }
699         }
700
701         private static readonly Interop.Settings.SystemSettingsChangedCallback s_wallpaperLockScreenChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
702         {
703             string path = SystemSettings.WallpaperLockScreen;
704             WallpaperLockScreenChangedEventArgs eventArgs = new WallpaperLockScreenChangedEventArgs(path);
705             s_wallpaperLockScreenChanged?.Invoke(null, eventArgs);
706         };
707         private static event EventHandler<WallpaperLockScreenChangedEventArgs> s_wallpaperLockScreenChanged;
708         /// <summary>
709         /// WallpaperLockScreenChanged event is triggered when the file path of the current lock screen wallpaper is changed
710         /// </summary>
711         /// <param name="sender"></param>
712         /// <param name="e">A WallpaperLockScreenChangedEventArgs object that contains the key & changed value</param>
713         public static event EventHandler<WallpaperLockScreenChangedEventArgs> WallpaperLockScreenChanged
714         {
715             add
716             {
717                 if (s_wallpaperLockScreenChanged == null)
718                 {
719                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.WallpaperLockScreen, s_wallpaperLockScreenChangedCallback, IntPtr.Zero);
720                     if (ret != SystemSettingsError.None)
721                     {
722                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
723                     }
724                 }
725                 s_wallpaperLockScreenChanged += value;
726             }
727
728             remove
729             {
730                 s_wallpaperLockScreenChanged -= value;
731                 if (s_wallpaperLockScreenChanged == null)
732                 {
733                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.WallpaperLockScreen);
734                     if (ret != SystemSettingsError.None)
735                     {
736                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
737                     }
738                 }
739             }
740         }
741
742         private static readonly Interop.Settings.SystemSettingsChangedCallback s_fontSizeChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
743         {
744             SystemSettingsFontSize fontSize = SystemSettings.FontSize;
745             FontSizeChangedEventArgs eventArgs = new FontSizeChangedEventArgs(fontSize);
746             s_fontSizeChanged?.Invoke(null, eventArgs);
747         };
748         private static event EventHandler<FontSizeChangedEventArgs> s_fontSizeChanged;
749         /// <summary>
750         /// FontSizeChanged event is triggered when the current system font size is changed
751         /// </summary>
752         /// <param name="sender"></param>
753         /// <param name="e">A FontSizeChangedEventArgs object that contains the key & changed value</param>
754         public static event EventHandler<FontSizeChangedEventArgs> FontSizeChanged
755         {
756             add
757             {
758                 if (s_fontSizeChanged == null)
759                 {
760                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.FontSize, s_fontSizeChangedCallback, IntPtr.Zero);
761                     if (ret != SystemSettingsError.None)
762                     {
763                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
764                     }
765                 }
766                 s_fontSizeChanged += value;
767             }
768
769             remove
770             {
771                 s_fontSizeChanged -= value;
772                 if (s_fontSizeChanged == null)
773                 {
774                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.FontSize);
775                     if (ret != SystemSettingsError.None)
776                     {
777                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
778                     }
779                 }
780             }
781         }
782
783         private static readonly Interop.Settings.SystemSettingsChangedCallback s_fontTypeChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
784         {
785             string fontType = SystemSettings.FontType;
786             FontTypeChangedEventArgs eventArgs = new FontTypeChangedEventArgs(fontType);
787             s_fontTypeChanged?.Invoke(null, eventArgs);
788         };
789         private static event EventHandler<FontTypeChangedEventArgs> s_fontTypeChanged;
790         /// <summary>
791         /// FontTypeChanged event is triggered when the current system font type is changed
792         /// </summary>
793         /// <param name="sender"></param>
794         /// <param name="e">A FontTypeChangedEventArgs object that contains the key & changed value</param>
795         public static event EventHandler<FontTypeChangedEventArgs> FontTypeChanged
796         {
797             add
798             {
799                 if (s_fontTypeChanged == null)
800                 {
801                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.FontType, s_fontTypeChangedCallback, IntPtr.Zero);
802                     if (ret != SystemSettingsError.None)
803                     {
804                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
805                     }
806                 }
807                 s_fontTypeChanged += value;
808             }
809
810             remove
811             {
812                 s_fontTypeChanged -= value;
813                 if (s_fontTypeChanged == null)
814                 {
815                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.FontType);
816                     if (ret != SystemSettingsError.None)
817                     {
818                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
819                     }
820                 }
821             }
822         }
823
824         private static readonly Interop.Settings.SystemSettingsChangedCallback s_motionActivationChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
825         {
826             bool motionActivation = SystemSettings.MotionActivationEnabled;
827             MotionActivationSettingChangedEventArgs eventArgs = new MotionActivationSettingChangedEventArgs(motionActivation);
828             s_motionActivationChanged?.Invoke(null, eventArgs);
829         };
830         private static event EventHandler<MotionActivationSettingChangedEventArgs> s_motionActivationChanged;
831         /// <summary>
832         /// MotionActivationChanged event is triggered when the motion service status is changed
833         /// </summary>
834         /// <param name="sender"></param>
835         /// <param name="e">A MotionActivationChangedEventArgs object that contains the key & changed value</param>
836         public static event EventHandler<MotionActivationSettingChangedEventArgs> MotionActivationSettingChanged
837         {
838             add
839             {
840                 if (s_motionActivationChanged == null)
841                 {
842                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.MotionActivationEnabled, s_motionActivationChangedCallback, IntPtr.Zero);
843                     if (ret != SystemSettingsError.None)
844                     {
845                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
846                     }
847                 }
848                 s_motionActivationChanged += value;
849             }
850
851             remove
852             {
853                 s_motionActivationChanged -= value;
854                 if (s_motionActivationChanged == null)
855                 {
856                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.MotionActivationEnabled);
857                     if (ret != SystemSettingsError.None)
858                     {
859                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
860                     }
861                 }
862             }
863         }
864
865         private static readonly Interop.Settings.SystemSettingsChangedCallback s_emailAlertRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
866         {
867             string emailAlertRingtone = SystemSettings.EmailAlertRingtone;
868             EmailAlertRingtoneChangedEventArgs eventArgs = new EmailAlertRingtoneChangedEventArgs(emailAlertRingtone);
869             s_emailAlertRingtoneChanged?.Invoke(null, eventArgs);
870         };
871         private static event EventHandler<EmailAlertRingtoneChangedEventArgs> s_emailAlertRingtoneChanged;
872         /// <summary>
873         /// EmailAlertRingtoneChanged event is triggered when the file path of the current email alert ringtone is changed
874         /// </summary>
875         /// <param name="sender"></param>
876         /// <param name="e">A EmailAlertRingtoneChangedEventArgs object that contains the key & changed value</param>
877         public static event EventHandler<EmailAlertRingtoneChangedEventArgs> EmailAlertRingtoneChanged
878         {
879             add
880             {
881                 if (s_emailAlertRingtoneChanged == null)
882                 {
883                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.EmailAlertRingtone, s_emailAlertRingtoneChangedCallback, IntPtr.Zero);
884                     if (ret != SystemSettingsError.None)
885                     {
886                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
887                     }
888                 }
889                 s_emailAlertRingtoneChanged += value;
890             }
891
892             remove
893             {
894                 s_emailAlertRingtoneChanged -= value;
895                 if (s_emailAlertRingtoneChanged == null)
896                 {
897                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.EmailAlertRingtone);
898                     if (ret != SystemSettingsError.None)
899                     {
900                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
901                     }
902                 }
903             }
904         }
905
906         private static readonly Interop.Settings.SystemSettingsChangedCallback s_usbDebuggingSettingChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
907         {
908             bool usbDebuggingEnabled = SystemSettings.UsbDebuggingEnabled;
909             UsbDebuggingSettingChangedEventArgs eventArgs = new UsbDebuggingSettingChangedEventArgs(usbDebuggingEnabled);
910             s_usbDebuggingSettingChanged?.Invoke(null, eventArgs);
911         };
912         private static event EventHandler<UsbDebuggingSettingChangedEventArgs> s_usbDebuggingSettingChanged;
913         /// <summary>
914         /// UsbDebuggingSettingChangedEventArgs event is triggered when the USB debugging status is changed
915         /// </summary>
916         /// <param name="sender"></param>
917         /// <param name="e">A UsbDebuggingSettingChangedEventArgs object that contains the key & changed value</param>
918         public static event EventHandler<UsbDebuggingSettingChangedEventArgs> UsbDebuggingSettingChanged
919         {
920             add
921             {
922                 if (s_usbDebuggingSettingChanged == null)
923                 {
924                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.UsbDebuggingEnabled, s_usbDebuggingSettingChangedCallback, IntPtr.Zero);
925                     if (ret != SystemSettingsError.None)
926                     {
927                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
928                     }
929                 }
930                 s_usbDebuggingSettingChanged += value;
931             }
932
933             remove
934             {
935                 s_usbDebuggingSettingChanged -= value;
936                 if (s_usbDebuggingSettingChanged == null)
937                 {
938                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.UsbDebuggingEnabled);
939                     if (ret != SystemSettingsError.None)
940                     {
941                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
942                     }
943                 }
944             }
945         }
946
947         private static readonly Interop.Settings.SystemSettingsChangedCallback s_data3GNetworkSettingChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
948         {
949             bool data3GEnabled = SystemSettings.Data3GNetworkEnabled;
950             Data3GNetworkSettingChangedEventArgs eventArgs = new Data3GNetworkSettingChangedEventArgs(data3GEnabled);
951             s_data3GNetworkSettingChanged?.Invoke(null, eventArgs);
952         };
953         private static event EventHandler<Data3GNetworkSettingChangedEventArgs> s_data3GNetworkSettingChanged;
954         /// <summary>
955         /// Data3GNetworkSettingChanged event is triggered when the 3G data network status is changed
956         /// </summary>
957         /// <param name="sender"></param>
958         /// <param name="e">A Data3GNetworkSettingChangedEventArgs object that contains the key & changed value</param>
959         public static event EventHandler<Data3GNetworkSettingChangedEventArgs> Data3GNetworkSettingChanged
960         {
961             add
962             {
963                 if (s_data3GNetworkSettingChanged == null)
964                 {
965                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.Data3GNetworkEnabled, s_data3GNetworkSettingChangedCallback, IntPtr.Zero);
966                     if (ret != SystemSettingsError.None)
967                     {
968                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
969                     }
970                 }
971                 s_data3GNetworkSettingChanged += value;
972             }
973
974             remove
975             {
976                 s_data3GNetworkSettingChanged -= value;
977                 if (s_data3GNetworkSettingChanged == null)
978                 {
979                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.Data3GNetworkEnabled);
980                     if (ret != SystemSettingsError.None)
981                     {
982                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
983                     }
984                 }
985             }
986         }
987
988         private static readonly Interop.Settings.SystemSettingsChangedCallback s_lockscreenAppChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
989         {
990             string lockScreenApp = SystemSettings.LockscreenApp;
991             LockscreenAppChangedEventArgs eventArgs = new LockscreenAppChangedEventArgs(lockScreenApp);
992             s_lockscreenAppChanged?.Invoke(null, eventArgs);
993         };
994         private static event EventHandler<LockscreenAppChangedEventArgs> s_lockscreenAppChanged;
995         /// <summary>
996         /// LockscreenAppChanged event is triggered when the lockscreen app pkg name is changed
997         /// </summary>
998         /// <param name="sender"></param>
999         /// <param name="e">A LockscreenAppChangedEventArgs object that contains the key & changed value</param>
1000         public static event EventHandler<LockscreenAppChangedEventArgs> LockscreenAppChanged
1001         {
1002             add
1003             {
1004                 if (s_lockscreenAppChanged == null)
1005                 {
1006                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LockscreenApp, s_lockscreenAppChangedCallback, IntPtr.Zero);
1007                     if (ret != SystemSettingsError.None)
1008                     {
1009                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1010                     }
1011                 }
1012                 s_lockscreenAppChanged += value;
1013             }
1014
1015             remove
1016             {
1017                 s_lockscreenAppChanged -= value;
1018                 if (s_lockscreenAppChanged == null)
1019                 {
1020                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LockscreenApp);
1021                     if (ret != SystemSettingsError.None)
1022                     {
1023                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1024                     }
1025                 }
1026             }
1027         }
1028
1029         private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeCountryChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1030         {
1031             string localeCountry = SystemSettings.LocaleCountry;
1032             LocaleCountryChangedEventArgs eventArgs = new LocaleCountryChangedEventArgs(localeCountry);
1033             s_localeCountryChanged?.Invoke(null, eventArgs);
1034         };
1035         private static event EventHandler<LocaleCountryChangedEventArgs> s_localeCountryChanged;
1036         /// <summary>
1037         /// LocaleCountryChanged event is triggered when the current country setting in the \<LANGUAGE\>_\<REGION\> syntax, is changed
1038         /// </summary>
1039         /// <param name="sender"></param>
1040         /// <param name="e">A LocaleCountryChangedEventArgs object that contains the key & changed value</param>
1041         public static event EventHandler<LocaleCountryChangedEventArgs> LocaleCountryChanged
1042         {
1043             add
1044             {
1045                 if (s_localeCountryChanged == null)
1046                 {
1047                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleCountry, s_localeCountryChangedCallback, IntPtr.Zero);
1048                     if (ret != SystemSettingsError.None)
1049                     {
1050                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1051                     }
1052                 }
1053                 s_localeCountryChanged += value;
1054             }
1055
1056             remove
1057             {
1058                 s_localeCountryChanged -= value;
1059                 if (s_localeCountryChanged == null)
1060                 {
1061                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleCountry);
1062                     if (ret != SystemSettingsError.None)
1063                     {
1064                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1065                     }
1066                 }
1067             }
1068         }
1069
1070         private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeLanguageChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1071         {
1072             string localeLanguage = SystemSettings.LocaleLanguage;
1073             LocaleLanguageChangedEventArgs eventArgs = new LocaleLanguageChangedEventArgs(localeLanguage);
1074             s_localeLanguageChanged?.Invoke(null, eventArgs);
1075         };
1076         private static event EventHandler<LocaleLanguageChangedEventArgs> s_localeLanguageChanged;
1077         /// <summary>
1078         /// LocaleLanguageChanged event is triggered when the current language setting in the \<LANGUAGE\>_\<REGION\> syntax, is changed
1079         /// </summary>
1080         /// <param name="sender"></param>
1081         /// <param name="e">A LocaleLanguageChangedEventArgs object that contains the key & changed value</param>
1082         public static event EventHandler<LocaleLanguageChangedEventArgs> LocaleLanguageChanged
1083         {
1084             add
1085             {
1086                 if (s_localeLanguageChanged == null)
1087                 {
1088                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleLanguage, s_localeLanguageChangedCallback, IntPtr.Zero);
1089                     if (ret != SystemSettingsError.None)
1090                     {
1091                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1092                     }
1093                 }
1094                 s_localeLanguageChanged += value;
1095             }
1096
1097             remove
1098             {
1099                 s_localeLanguageChanged -= value;
1100                 if (s_localeLanguageChanged == null)
1101                 {
1102                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleLanguage);
1103                     if (ret != SystemSettingsError.None)
1104                     {
1105                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1106                     }
1107                 }
1108             }
1109         }
1110
1111         private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeTimeFormat24HourChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1112         {
1113             bool localeTimeFormat24Hour = SystemSettings.LocaleTimeFormat24HourEnabled;
1114             LocaleTimeFormat24HourSettingChangedEventArgs eventArgs = new LocaleTimeFormat24HourSettingChangedEventArgs(localeTimeFormat24Hour);
1115             s_localeTimeFormat24HourChanged?.Invoke(null, eventArgs);
1116         };
1117         private static event EventHandler<LocaleTimeFormat24HourSettingChangedEventArgs> s_localeTimeFormat24HourChanged;
1118         /// <summary>
1119         /// LocaleTimeFormat24HourChanged event is triggered when the time format is changed
1120         /// </summary>
1121         /// <param name="sender"></param>
1122         /// <param name="e">A LocaleTimeFormat24HourChangedEventArgs object that contains the key & changed value</param>
1123         public static event EventHandler<LocaleTimeFormat24HourSettingChangedEventArgs> LocaleTimeFormat24HourSettingChanged
1124         {
1125             add
1126             {
1127                 if (s_localeTimeFormat24HourChanged == null)
1128                 {
1129                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleTimeFormat24HourEnabled, s_localeTimeFormat24HourChangedCallback, IntPtr.Zero);
1130                     if (ret != SystemSettingsError.None)
1131                     {
1132                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1133                     }
1134                 }
1135                 s_localeTimeFormat24HourChanged += value;
1136             }
1137
1138             remove
1139             {
1140                 s_localeTimeFormat24HourChanged -= value;
1141                 if (s_localeTimeFormat24HourChanged == null)
1142                 {
1143                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleTimeFormat24HourEnabled);
1144                     if (ret != SystemSettingsError.None)
1145                     {
1146                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1147                     }
1148                 }
1149             }
1150         }
1151
1152         private static readonly Interop.Settings.SystemSettingsChangedCallback s_localeTimeZoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1153         {
1154             string localeTimeZone = SystemSettings.LocaleTimeZone;
1155             LocaleTimeZoneChangedEventArgs eventArgs = new LocaleTimeZoneChangedEventArgs(localeTimeZone);
1156             s_localeTimeZoneChanged?.Invoke(null, eventArgs);
1157         };
1158         private static event EventHandler<LocaleTimeZoneChangedEventArgs> s_localeTimeZoneChanged;
1159         /// <summary>
1160         /// LocaleTimeZoneChanged event is triggered when the  current time zone is changed
1161         /// </summary>
1162         /// <param name="sender"></param>
1163         /// <param name="e">A LocaleTimeZoneChangedEventArgs object that contains the key & changed value</param>
1164         public static event EventHandler<LocaleTimeZoneChangedEventArgs> LocaleTimeZoneChanged
1165         {
1166             add
1167             {
1168                 if (s_localeTimeZoneChanged == null)
1169                 {
1170                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LocaleTimeZone, s_localeTimeZoneChangedCallback, IntPtr.Zero);
1171                     if (ret != SystemSettingsError.None)
1172                     {
1173                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1174                     }
1175                 }
1176                 s_localeTimeZoneChanged += value;
1177             }
1178
1179             remove
1180             {
1181                 s_localeTimeZoneChanged -= value;
1182                 if (s_localeTimeZoneChanged == null)
1183                 {
1184                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LocaleTimeZone);
1185                     if (ret != SystemSettingsError.None)
1186                     {
1187                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1188                     }
1189                 }
1190             }
1191         }
1192
1193         private static readonly Interop.Settings.SystemSettingsChangedCallback s_timeChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1194         {
1195             //bool motionActivation = SystemSettings.Time;
1196             TimeChangedEventArgs eventArgs = new TimeChangedEventArgs();
1197             s_timeChanged?.Invoke(null, eventArgs);
1198         };
1199         private static event EventHandler<TimeChangedEventArgs> s_timeChanged;
1200         /// <summary>
1201         /// TimeChanged event is triggered when the system time is changed
1202         /// </summary>
1203         /// <param name="sender"></param>
1204         /// <param name="e">A TimeChangedEventArgs object that contains the key & changed value</param>
1205         public static event EventHandler<TimeChangedEventArgs> TimeChanged
1206         {
1207             add
1208             {
1209                 if (s_timeChanged == null)
1210                 {
1211                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.Time, s_timeChangedCallback, IntPtr.Zero);
1212                     if (ret != SystemSettingsError.None)
1213                     {
1214                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1215                     }
1216                 }
1217                 s_timeChanged += value;
1218             }
1219
1220             remove
1221             {
1222                 s_timeChanged -= value;
1223                 if (s_timeChanged == null)
1224                 {
1225                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.Time);
1226                     if (ret != SystemSettingsError.None)
1227                     {
1228                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1229                     }
1230                 }
1231             }
1232         }
1233
1234         private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundLockChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1235         {
1236             bool soundLock = SystemSettings.SoundLockEnabled;
1237             SoundLockSettingChangedEventArgs eventArgs = new SoundLockSettingChangedEventArgs(soundLock);
1238             s_soundLockChanged?.Invoke(null, eventArgs);
1239         };
1240         private static event EventHandler<SoundLockSettingChangedEventArgs> s_soundLockChanged;
1241         /// <summary>
1242         /// SoundLockChanged event is triggered when the screen lock sound enabled status is changed
1243         /// </summary>
1244         /// <param name="sender"></param>
1245         /// <param name="e">A SoundLockChangedEventArgs object that contains the key & changed value</param>
1246         public static event EventHandler<SoundLockSettingChangedEventArgs> SoundLockSettingChanged
1247         {
1248             add
1249             {
1250                 if (s_soundLockChanged == null)
1251                 {
1252                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundLockEnabled, s_soundLockChangedCallback, IntPtr.Zero);
1253                     if (ret != SystemSettingsError.None)
1254                     {
1255                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1256                     }
1257                 }
1258                 s_soundLockChanged += value;
1259             }
1260
1261             remove
1262             {
1263                 s_soundLockChanged -= value;
1264                 if (s_soundLockChanged == null)
1265                 {
1266                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundLockEnabled);
1267                     if (ret != SystemSettingsError.None)
1268                     {
1269                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1270                     }
1271                 }
1272             }
1273         }
1274
1275         private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundSilentModeChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1276         {
1277             bool soundSilentMode = SystemSettings.SoundSilentModeEnabled;
1278             SoundSilentModeSettingChangedEventArgs eventArgs = new SoundSilentModeSettingChangedEventArgs(soundSilentMode);
1279             s_soundSilentModeChanged?.Invoke(null, eventArgs);
1280         };
1281         private static event EventHandler<SoundSilentModeSettingChangedEventArgs> s_soundSilentModeChanged;
1282         /// <summary>
1283         /// SoundSilentModeChanged event is triggered when the silent mode status is changed
1284         /// </summary>
1285         /// <param name="sender"></param>
1286         /// <param name="e">A SoundSilentModeChangedEventArgs object that contains the key & changed value</param>
1287         public static event EventHandler<SoundSilentModeSettingChangedEventArgs> SoundSilentModeSettingChanged
1288         {
1289             add
1290             {
1291                 if (s_soundSilentModeChanged == null)
1292                 {
1293                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundSilentModeEnabled, s_soundSilentModeChangedCallback, IntPtr.Zero);
1294                     if (ret != SystemSettingsError.None)
1295                     {
1296                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1297                     }
1298                 }
1299                 s_soundSilentModeChanged += value;
1300             }
1301
1302             remove
1303             {
1304                 s_soundSilentModeChanged -= value;
1305                 if (s_soundSilentModeChanged == null)
1306                 {
1307                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundSilentModeEnabled);
1308                     if (ret != SystemSettingsError.None)
1309                     {
1310                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1311                     }
1312                 }
1313             }
1314         }
1315
1316         private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundTouchChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1317         {
1318             bool soundTouch = SystemSettings.SoundTouchEnabled;
1319             SoundTouchSettingChangedEventArgs eventArgs = new SoundTouchSettingChangedEventArgs(soundTouch);
1320             s_soundTouchChanged?.Invoke(null, eventArgs);
1321         };
1322         private static event EventHandler<SoundTouchSettingChangedEventArgs> s_soundTouchChanged;
1323         /// <summary>
1324         /// SoundTouchChanged event is triggered when the screen touch sound enabled status is changed
1325         /// </summary>
1326         /// <param name="sender"></param>
1327         /// <param name="e">A SoundTouchChangedEventArgs object that contains the key & changed value</param>
1328         public static event EventHandler<SoundTouchSettingChangedEventArgs> SoundTouchSettingChanged
1329         {
1330             add
1331             {
1332                 if (s_soundTouchChanged == null)
1333                 {
1334                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundTouchEnabled, s_soundTouchChangedCallback, IntPtr.Zero);
1335                     if (ret != SystemSettingsError.None)
1336                     {
1337                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1338                     }
1339                 }
1340                 s_soundTouchChanged += value;
1341             }
1342
1343             remove
1344             {
1345                 s_soundTouchChanged -= value;
1346                 if (s_soundTouchChanged == null)
1347                 {
1348                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundTouchEnabled);
1349                     if (ret != SystemSettingsError.None)
1350                     {
1351                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1352                     }
1353                 }
1354             }
1355         }
1356
1357         private static readonly Interop.Settings.SystemSettingsChangedCallback s_displayScreenRotationAutoChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1358         {
1359             bool displayScreenRotationAuto = SystemSettings.DisplayScreenRotationAutoEnabled;
1360             DisplayScreenRotationAutoSettingChangedEventArgs eventArgs = new DisplayScreenRotationAutoSettingChangedEventArgs(displayScreenRotationAuto);
1361             s_displayScreenRotationAutoChanged?.Invoke(null, eventArgs);
1362         };
1363         private static event EventHandler<DisplayScreenRotationAutoSettingChangedEventArgs> s_displayScreenRotationAutoChanged;
1364         /// <summary>
1365         /// DisplayScreenRotationAutoChanged event is triggered when the automatic rotation control status is changed
1366         /// </summary>
1367         /// <param name="sender"></param>
1368         /// <param name="e">A DisplayScreenRotationAutoChangedEventArgs object that contains the key & changed value</param>
1369         public static event EventHandler<DisplayScreenRotationAutoSettingChangedEventArgs> DisplayScreenRotationAutoSettingChanged
1370         {
1371             add
1372             {
1373                 if (s_displayScreenRotationAutoChanged == null)
1374                 {
1375                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.DisplayScreenRotationAutoEnabled, s_displayScreenRotationAutoChangedCallback, IntPtr.Zero);
1376                     if (ret != SystemSettingsError.None)
1377                     {
1378                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1379                     }
1380                 }
1381                 s_displayScreenRotationAutoChanged += value;
1382             }
1383
1384             remove
1385             {
1386                 s_displayScreenRotationAutoChanged -= value;
1387                 if (s_displayScreenRotationAutoChanged == null)
1388                 {
1389                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.DisplayScreenRotationAutoEnabled);
1390                     if (ret != SystemSettingsError.None)
1391                     {
1392                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1393                     }
1394                 }
1395             }
1396         }
1397
1398         private static readonly Interop.Settings.SystemSettingsChangedCallback s_deviceNameChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1399         {
1400             string deviceName = SystemSettings.DeviceName;
1401             DeviceNameChangedEventArgs eventArgs = new DeviceNameChangedEventArgs(deviceName);
1402             s_deviceNameChanged?.Invoke(null, eventArgs);
1403         };
1404         private static event EventHandler<DeviceNameChangedEventArgs> s_deviceNameChanged;
1405         /// <summary>
1406         /// DeviceNameChanged event is triggered when the device name is changed
1407         /// </summary>
1408         /// <param name="sender"></param>
1409         /// <param name="e">A DeviceNameChangedEventArgs object that contains the key & changed value</param>
1410         public static event EventHandler<DeviceNameChangedEventArgs> DeviceNameChanged
1411         {
1412             add
1413             {
1414                 if (s_deviceNameChanged == null)
1415                 {
1416                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.DeviceName, s_deviceNameChangedCallback, IntPtr.Zero);
1417                     if (ret != SystemSettingsError.None)
1418                     {
1419                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1420                     }
1421                 }
1422                 s_deviceNameChanged += value;
1423             }
1424
1425             remove
1426             {
1427                 s_deviceNameChanged -= value;
1428                 if (s_deviceNameChanged == null)
1429                 {
1430                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.DeviceName);
1431                     if (ret != SystemSettingsError.None)
1432                     {
1433                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1434                     }
1435                 }
1436             }
1437         }
1438
1439         private static readonly Interop.Settings.SystemSettingsChangedCallback s_motionSettingChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1440         {
1441             bool motionEnabled = SystemSettings.MotionEnabled;
1442             MotionSettingChangedEventArgs eventArgs = new MotionSettingChangedEventArgs(motionEnabled);
1443             s_motionSettingChanged?.Invoke(null, eventArgs);
1444         };
1445         private static event EventHandler<MotionSettingChangedEventArgs> s_motionSettingChanged;
1446         /// <summary>
1447         /// MotionSettingChanged event is triggered when the motion feature enabled status is changed
1448         /// </summary>
1449         /// <param name="sender"></param>
1450         /// <param name="e">A MotionSettingChangedEventArgs object that contains the key & changed value</param>
1451         public static event EventHandler<MotionSettingChangedEventArgs> MotionSettingChanged
1452         {
1453             add
1454             {
1455                 if (s_motionSettingChanged == null)
1456                 {
1457                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.MotionEnabled, s_motionSettingChangedCallback, IntPtr.Zero);
1458                     if (ret != SystemSettingsError.None)
1459                     {
1460                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1461                     }
1462                 }
1463                 s_motionSettingChanged += value;
1464             }
1465
1466             remove
1467             {
1468                 s_motionSettingChanged -= value;
1469                 if (s_motionSettingChanged == null)
1470                 {
1471                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.MotionEnabled);
1472                     if (ret != SystemSettingsError.None)
1473                     {
1474                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1475                     }
1476                 }
1477             }
1478         }
1479
1480         private static readonly Interop.Settings.SystemSettingsChangedCallback s_networkWifiNotificationChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1481         {
1482             bool networkWifiNotification = SystemSettings.NetworkWifiNotificationEnabled;
1483             NetworkWifiNotificationSettingChangedEventArgs eventArgs = new NetworkWifiNotificationSettingChangedEventArgs(networkWifiNotification);
1484             s_networkWifiNotificationChanged?.Invoke(null, eventArgs);
1485         };
1486         private static event EventHandler<NetworkWifiNotificationSettingChangedEventArgs> s_networkWifiNotificationChanged;
1487         /// <summary>
1488         /// NetworkWifiNotificationChanged event is triggered when the Wi-Fi-related notifications enabled status is changed
1489         /// </summary>
1490         /// <param name="sender"></param>
1491         /// <param name="e">A NetworkWifiNotificationChangedEventArgs object that contains the key & changed value</param>
1492         public static event EventHandler<NetworkWifiNotificationSettingChangedEventArgs> NetworkWifiNotificationSettingChanged
1493         {
1494             add
1495             {
1496                 if (s_networkWifiNotificationChanged == null)
1497                 {
1498                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.NetworkWifiNotificationEnabled, s_networkWifiNotificationChangedCallback, IntPtr.Zero);
1499                     if (ret != SystemSettingsError.None)
1500                     {
1501                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1502                     }
1503                 }
1504                 s_networkWifiNotificationChanged += value;
1505             }
1506
1507             remove
1508             {
1509                 s_networkWifiNotificationChanged -= value;
1510                 if (s_networkWifiNotificationChanged == null)
1511                 {
1512                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.NetworkWifiNotificationEnabled);
1513                     if (ret != SystemSettingsError.None)
1514                     {
1515                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1516                     }
1517                 }
1518             }
1519         }
1520
1521         private static readonly Interop.Settings.SystemSettingsChangedCallback s_networkFlightModeChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1522         {
1523             bool networkFlightMode = SystemSettings.NetworkFlightModeEnabled;
1524             NetworkFlightModeSettingChangedEventArgs eventArgs = new NetworkFlightModeSettingChangedEventArgs(networkFlightMode);
1525             s_networkFlightModeChanged?.Invoke(null, eventArgs);
1526         };
1527         private static event EventHandler<NetworkFlightModeSettingChangedEventArgs> s_networkFlightModeChanged;
1528         /// <summary>
1529         /// NetworkFlightModeChanged event is triggered when the flight mode status is changed
1530         /// </summary>
1531         /// <param name="sender"></param>
1532         /// <param name="e">A NetworkFlightModeChangedEventArgs object that contains the key & changed value</param>
1533         public static event EventHandler<NetworkFlightModeSettingChangedEventArgs> NetworkFlightModeSettingChanged
1534         {
1535             add
1536             {
1537                 if (s_networkFlightModeChanged == null)
1538                 {
1539                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.NetworkFlightModeEnabled, s_networkFlightModeChangedCallback, IntPtr.Zero);
1540                     if (ret != SystemSettingsError.None)
1541                     {
1542                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1543                     }
1544                 }
1545                 s_networkFlightModeChanged += value;
1546             }
1547
1548             remove
1549             {
1550                 s_networkFlightModeChanged -= value;
1551                 if (s_networkFlightModeChanged == null)
1552                 {
1553                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.NetworkFlightModeEnabled);
1554                     if (ret != SystemSettingsError.None)
1555                     {
1556                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1557                     }
1558                 }
1559             }
1560         }
1561
1562         private static readonly Interop.Settings.SystemSettingsChangedCallback s_screenBacklightTimeChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1563         {
1564             int screenBacklightTime = SystemSettings.ScreenBacklightTime;
1565             ScreenBacklightTimeChangedEventArgs eventArgs = new ScreenBacklightTimeChangedEventArgs(screenBacklightTime);
1566             s_screenBacklightTimeChanged?.Invoke(null, eventArgs);
1567         };
1568         private static event EventHandler<ScreenBacklightTimeChangedEventArgs> s_screenBacklightTimeChanged;
1569         /// <summary>
1570         /// ScreenBacklightTimeChanged event is triggered when the backlight time is changed.
1571         /// </summary>
1572         /// <param name="sender"></param>
1573         /// <param name="e">A ScreenBacklightTimeChangedEventArgs object that contains the key & changed value</param>
1574         public static event EventHandler<ScreenBacklightTimeChangedEventArgs> ScreenBacklightTimeChanged
1575         {
1576             add
1577             {
1578                 if (s_screenBacklightTimeChanged == null)
1579                 {
1580                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.ScreenBacklightTime, s_screenBacklightTimeChangedCallback, IntPtr.Zero);
1581                     if (ret != SystemSettingsError.None)
1582                     {
1583                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1584                     }
1585                 }
1586                 s_screenBacklightTimeChanged += value;
1587             }
1588
1589             remove
1590             {
1591                 s_screenBacklightTimeChanged -= value;
1592                 if (s_screenBacklightTimeChanged == null)
1593                 {
1594                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.ScreenBacklightTime);
1595                     if (ret != SystemSettingsError.None)
1596                     {
1597                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1598                     }
1599                 }
1600             }
1601         }
1602
1603         private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundNotificationChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1604         {
1605             string soundNotification = SystemSettings.SoundNotification;
1606             SoundNotificationChangedEventArgs eventArgs = new SoundNotificationChangedEventArgs(soundNotification);
1607             s_soundNotificationChanged?.Invoke(null, eventArgs);
1608         };
1609         private static event EventHandler<SoundNotificationChangedEventArgs> s_soundNotificationChanged;
1610         /// <summary>
1611         /// SoundNotificationChanged event is triggered when the file path of the current notification tone set by the user is changed
1612         /// </summary>
1613         /// <param name="sender"></param>
1614         /// <param name="e">A SoundNotificationChangedEventArgs object that contains the key & changed value</param>
1615         public static event EventHandler<SoundNotificationChangedEventArgs> SoundNotificationChanged
1616         {
1617             add
1618             {
1619                 if (s_soundNotificationChanged == null)
1620                 {
1621                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundNotification, s_soundNotificationChangedCallback, IntPtr.Zero);
1622                     if (ret != SystemSettingsError.None)
1623                     {
1624                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1625                     }
1626                 }
1627                 s_soundNotificationChanged += value;
1628             }
1629
1630             remove
1631             {
1632                 s_soundNotificationChanged -= value;
1633                 if (s_soundNotificationChanged == null)
1634                 {
1635                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundNotification);
1636                     if (ret != SystemSettingsError.None)
1637                     {
1638                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1639                     }
1640                 }
1641             }
1642         }
1643
1644         private static readonly Interop.Settings.SystemSettingsChangedCallback s_soundNotificationRepetitionPeriodChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1645         {
1646             int soundNotificationRepetitionPeriod = SystemSettings.SoundNotificationRepetitionPeriod;
1647             SoundNotificationRepetitionPeriodChangedEventArgs eventArgs = new SoundNotificationRepetitionPeriodChangedEventArgs(soundNotificationRepetitionPeriod);
1648             s_soundNotificationRepetitionPeriodChanged?.Invoke(null, eventArgs);
1649         };
1650         private static event EventHandler<SoundNotificationRepetitionPeriodChangedEventArgs> s_soundNotificationRepetitionPeriodChanged;
1651         /// <summary>
1652         /// SoundNotificationRepetitionPeriodChanged event is triggered when the time period for notification repetitions is changed
1653         /// </summary>
1654         /// <param name="sender"></param>
1655         /// <param name="e">A SoundNotificationRepetitionPeriodChangedEventArgs object that contains the key & changed value</param>
1656         public static event EventHandler<SoundNotificationRepetitionPeriodChangedEventArgs> SoundNotificationRepetitionPeriodChanged
1657         {
1658             add
1659             {
1660                 if (s_soundNotificationRepetitionPeriodChanged == null)
1661                 {
1662                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.SoundNotificationRepetitionPeriod, s_soundNotificationRepetitionPeriodChangedCallback, IntPtr.Zero);
1663                     if (ret != SystemSettingsError.None)
1664                     {
1665                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1666                     }
1667                 }
1668                 s_soundNotificationRepetitionPeriodChanged += value;
1669             }
1670
1671             remove
1672             {
1673                 s_soundNotificationRepetitionPeriodChanged -= value;
1674                 if (s_soundNotificationRepetitionPeriodChanged == null)
1675                 {
1676                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.SoundNotificationRepetitionPeriod);
1677                     if (ret != SystemSettingsError.None)
1678                     {
1679                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1680                     }
1681                 }
1682             }
1683         }
1684
1685         private static readonly Interop.Settings.SystemSettingsChangedCallback s_lockStateChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
1686         {
1687             SystemSettingsIdleLockState lockState = SystemSettings.LockState;
1688             LockStateChangedEventArgs eventArgs = new LockStateChangedEventArgs(lockState);
1689             s_lockStateChanged?.Invoke(null, eventArgs);
1690         };
1691         private static event EventHandler<LockStateChangedEventArgs> s_lockStateChanged;
1692         /// <summary>
1693         /// LockStateChanged event is triggered when the current lock state is changed
1694         /// </summary>
1695         /// <param name="sender"></param>
1696         /// <param name="e">A LockStateChangedEventArgs object that contains the key & changed value</param>
1697         public static event EventHandler<LockStateChangedEventArgs> LockStateChanged
1698         {
1699             add
1700             {
1701                 if (s_lockStateChanged == null)
1702                 {
1703                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.LockState, s_lockStateChangedCallback, IntPtr.Zero);
1704                     if (ret != SystemSettingsError.None)
1705                     {
1706                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1707                     }
1708                 }
1709                 s_lockStateChanged += value;
1710             }
1711
1712             remove
1713             {
1714                 s_lockStateChanged -= value;
1715                 if (s_lockStateChanged == null)
1716                 {
1717                     SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.LockState);
1718                     if (ret != SystemSettingsError.None)
1719                     {
1720                         throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
1721                     }
1722                 }
1723             }
1724         }
1725     }
1726 }
1727