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