Esempio n. 1
0
        public static bool IsListeningSettingEnabled()
        {
            Setting       voiceRecognitionSetting = StoredProcedures.QuerySettingByName("Voice Activation");
            SettingOption chosenSetting           = voiceRecognitionSetting.GetSelectedOption();

            return(chosenSetting != null && chosenSetting.DisplayName == "Enabled");
        }
Esempio n. 2
0
        public static string AsJsonStr(this object obj, Action <SettingOption> option)
        {
            SettingOption settingOption = new SettingOption();

            option?.Invoke(settingOption);

            var setting = settingOption.BuildSettings();

            return(JsonConvert.SerializeObject(obj, setting));
        }
Esempio n. 3
0
        public static Setting QuerySetting(int ID = -1)
        {
            Setting setting = new Setting();
            List <SettingOption> SettingOptionList = new List <SettingOption>();
            string intID;

            if (ID == -1)
            {
                intID = "null";
            }
            else
            {
                intID = ID.ToString();
            }

            SqliteConnection conn = OpenDatabase();

            conn.Open();
            SqliteCommand command = conn.CreateCommand();

            command.CommandText = $"Select TSettings.settingID, TSettings.settingDisplayName,TSettingOptions.settingOptionID, TSettingOptions.optionDisplayName,TSettingOptions.isSelected From TSettings, TSettingOptions Where TSettings.settingID = COALESCE({intID}, TSettings.settingID) and TSettings.settingID = TSettingOptions.settingID;";
            using (SqliteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    SettingOption settingOption      = new SettingOption();
                    int           intSettingOptionID = int.Parse(reader["settingOptionID"].ToString());
                    settingOption.OptionID    = intSettingOptionID;
                    settingOption.DisplayName = reader["optionDisplayName"].ToString();
                    settingOption.IsSelected  = Convert.ToBoolean((long)reader["isSelected"]);
                    SettingOptionList.Add(settingOption);
                }
            }
            command.CommandText = $"Select TSettings.settingID, TSettings.settingDisplayName, TSettingOptions.optionDisplayName,TSettingOptions.isSelected From TSettings, TSettingOptions Where TSettings.settingID = COALESCE({intID}, TSettings.settingID) and TSettings.settingID = TSettingOptions.settingID;";
            using (SqliteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    int intSettingID = int.Parse(reader["settingID"].ToString());
                    setting.SettingID   = intSettingID;
                    setting.DisplayName = reader["settingDisplayName"].ToString();
                    setting.Options     = SettingOptionList;
                }
            }
            conn.Close();
            return(setting);
        }