예제 #1
0
        /// <summary>
        /// Reads config out of the user registry.
        /// </summary>
        private void ReadConfig()
        {
            string[] screensaverSettings = registryHandler.ReadSettings();

            // Ensures none unhandled NullException.
            if (screensaverSettings != null)
            {
                // Sets values for config view.
                isScreensaverActiveChecked = string.IsNullOrEmpty(screensaverSettings[0]) ?
                                             false : true;
                isScreensaverScreenLockChecked = string.IsNullOrEmpty(screensaverSettings[1]) ?
                                                 false : true;
                screensaverTimeOut = string.IsNullOrEmpty(screensaverSettings[2]) ?
                                     ZERO : (Convert.ToInt32(screensaverSettings[2]) / 60).ToString();
            }

            // Initializes all properties with values.
            else
            {
                isScreensaverActiveChecked     = false;
                isScreensaverScreenLockChecked = false;
                screensaverTimeOut             = ZERO;
            }

            // Updates the textboxes on config view.
            OnPropertyChanged(nameof(IsScreensaverActiveChecked));
            OnPropertyChanged(nameof(IsScreensaverScreenLockChecked));
            OnPropertyChanged(nameof(ScreensaverTimeOut));
        }
        /// <summary>
        /// Gets the lockscreen is active or not.
        /// </summary>
        /// <returns></returns>
        public static bool GetLockScreenActive()
        {
            string[] screensaverSettingsArray = registryHandler.ReadSettings();

            // Checks for null and keeps null exceptions away.
            if (screensaverSettingsArray == null || string.IsNullOrEmpty(screensaverSettingsArray[1]))
            {
                return(false);
            }

            // Returns true or false.
            return(screensaverSettingsArray[1].Contains("1"));
        }