public static string GetSettingValue(SettingEnum setting) { var settingName = SettingHelper.GetString(setting); string settingValue = null; using (var dbConnection = new SQLiteConnection(DataSource)) { dbConnection.Open(); using (var transaction = dbConnection.BeginTransaction()) { using (var command = new SQLiteCommand(dbConnection)) { command.CommandText = "SELECT setting_value FROM setting WHERE setting_name = ?"; command.Parameters.Add(new SQLiteParameter(DbType.String, "setting_name") { Value = settingName }); using (var reader = command.ExecuteReader()) { while (reader.Read()) { if (reader["setting_value"] != null && !Convert.IsDBNull(reader["setting_value"])) { settingValue = Convert.ToString(reader["setting_value"]); } } } } transaction.Commit(); } } return(settingValue); }
private void UpdateSetting(SettingEnum setting) { switch (setting) { case SettingEnum.HeaderVisibility: if (!Settings.Default.HeaderVisibility) { HexEdit.HeaderVisibility = Visibility.Collapsed; } else { HexEdit.HeaderVisibility = Visibility.Visible; } Settings.Default.HeaderVisibility = HexEdit.HeaderVisibility == Visibility.Visible; break; case SettingEnum.ReadOnly: HexEdit.ReadOnlyMode = Settings.Default.ReadOnly; HexEdit.ClearAllChange(); HexEdit.RefreshView(); break; } }
public static void SetSettingValue(SettingEnum setting, string value) { var settingName = SettingHelper.GetString(setting); using (var dbConnection = new SQLiteConnection(DataSource)) { dbConnection.Open(); using (var transaction = dbConnection.BeginTransaction()) { using (var command = new SQLiteCommand(dbConnection)) { command.CommandText = "UPDATE setting SET setting_value = ? WHERE setting_name = ?"; command.Parameters.Add(new SQLiteParameter(DbType.String, "setting_value") { Value = value }); command.Parameters.Add(new SQLiteParameter(DbType.String, "setting_name") { Value = settingName }); command.ExecuteNonQuery(); } transaction.Commit(); } } }
private void UpdateSetting(SettingEnum setting) { switch (setting) { case SettingEnum.HeaderVisibility: HexEdit.HeaderVisibility = !Settings.Default.HeaderVisibility ? Visibility.Collapsed : Visibility.Visible; Settings.Default.HeaderVisibility = HexEdit.HeaderVisibility == Visibility.Visible; break; case SettingEnum.ReadOnly: HexEdit.ReadOnlyMode = Settings.Default.ReadOnly; HexEdit.ClearAllChange(); HexEdit.RefreshView(); break; case SettingEnum.StatusBarVisibility: HexEdit.StatusBarVisibility = !Settings.Default.StatusBarVisibility ? Visibility.Collapsed : Visibility.Visible; Settings.Default.StatusBarVisibility = HexEdit.StatusBarVisibility == Visibility.Visible; break; } }
public void SetSetting <T>(SettingEnum settingEnum, T value) { var strName = settingEnum.ToString(); var strValue = Equals(value, default(T)) ? null : value.ToString(); var newValues = Data.Where(pair => !Equals(pair.Key, strName)).ToList(); newValues.Add(new KeyValuePair <string, string>(strName, strValue)); Data = ImmutableSortedList.FromValues(newValues); }
public string GetSetting(Guid userID, SettingEnum setting) { Guid setID = Setting.GetSettingID(setting); using (CommonDomain domain = new CommonDomain()) { UserSetting us = domain.UserSettings.Where(u => u.UserID == userID && u.SettingID == setID).SingleOrDefault(); if (us == null) return string.Empty; else return us.Value; } }
public static Guid GetSettingID(SettingEnum value) { switch (value) { case SettingEnum.MainGridAreaSize: return MainGridAreaSize; default: return Guid.Empty; } }
private static void SetSingleProperty(SettingEnum setting, String value) { if (Settings.ContainsKey(setting)) { Settings[setting] = value; } else { Settings.Add(setting, value); } }
public static T Get <T>(this ISettingsProvider provider, SettingEnum setting) { Type?type = typeof(T); if (type.IsValueType) { type = Nullable.GetUnderlyingType(typeof(T)); if (type == null) { throw new ArgumentException("Type parameter must be a type accepting null values.", nameof(T)); } } var value = provider[setting.ToString()]; return(value != null ? (T)Convert.ChangeType(value, type, CultureInfo.InvariantCulture) : default);
public T GetSetting <T>(SettingEnum settingEnum, T defaultValue) { string stringValue; if (!Data.TryGetValue(settingEnum.ToString(), out stringValue)) { return(defaultValue); } if (null == stringValue) { return(default(T)); } if (typeof(T).IsEnum) { return((T)Enum.Parse(typeof(T), stringValue)); } return((T)Convert.ChangeType(stringValue, typeof(T))); }
public void SaveSetting(Guid userID, SettingEnum setting, string value) { Guid setID = Setting.GetSettingID(setting); using (CommonDomain domain = new CommonDomain()) { UserSetting us = domain.UserSettings.Where(u => u.UserID == userID && u.SettingID == setID).SingleOrDefault(); if (us == null) { us = new UserSetting(); us.ID = Guid.NewGuid(); us.UserID = userID; us.SettingID = setID; us.Value = value; domain.UserSettings.InsertOnSubmit(us); domain.SubmitChanges(); } else { us.Value = value; domain.SubmitChanges(); } } }
public static string GetString(SettingEnum setting) { switch (setting) { case SettingEnum.MassRenameString: return("mass_rename_string"); case SettingEnum.StartupRefresh: return("startup_refresh"); case SettingEnum.AutoFetchGooglePlay: return("auto_fetch_google_play"); case SettingEnum.GroupResults: return("group_results"); case SettingEnum.SubdirGroup: return("subdir_group"); case SettingEnum.RefreshDays: return("refresh_days"); case SettingEnum.WindowLocX: return("window_loc_x"); case SettingEnum.WindowLocY: return("window_loc_y"); case SettingEnum.WindowSizeWidth: return("window_size_width"); case SettingEnum.WindowSizeHeight: return("window_size_height"); case SettingEnum.WindowMaximized: return("window_maximized"); case SettingEnum.WindowMinimized: return("window_minimized"); case SettingEnum.LicenceEmail: return("licence_email"); case SettingEnum.LicenceCode: return("licence_code"); case SettingEnum.ExportDelimiter: return("export_delimiter"); case SettingEnum.ExportFilename: return("export_filename"); case SettingEnum.BottomPanelHeight: return("bottom_panel_height"); case SettingEnum.ColumnWidthFilename: return("column_width_filename"); case SettingEnum.ColumnWidthPackage: return("column_width_package"); case SettingEnum.ColumnWidthInternalname: return("column_width_internalname"); case SettingEnum.ColumnWidthGoogleplayname: return("column_width_googleplayname"); case SettingEnum.ColumnWidthCategory: return("column_width_category"); case SettingEnum.ColumnWidthLocalversion: return("column_width_localversion"); case SettingEnum.ColumnWidthLatestversion: return("column_width_latestversion"); case SettingEnum.ColumnWidthPrice: return("column_width_price"); case SettingEnum.ColumnWidthGoogleplayfetch: return("column_width_googleplayfetch"); case SettingEnum.ColumnSortIndex: return("column_sort_index"); default: throw new NotImplementedException(); } }
partial void OnLoaded() { if (this.ID == MainGridAreaSize) Value = SettingEnum.MainGridAreaSize; else Value = SettingEnum.Nothing; }
/// <summary> /// Sets setting value /// </summary> public void SetConfig(object value, SettingEnum name) { settings.Find(item => item.Name.Equals(name)).Value = Convert.ChangeType(value, value.GetType()); }
/// <summary> /// Gets setting with boolean value /// </summary> public bool GetBoolValue(SettingEnum name) { return(Convert.ToBoolean(settings.Find(item => item.Name.Equals(name)).Value)); }
/// <summary> /// Gets setting with int value /// </summary> public int GetIntValue(SettingEnum name) { return(Convert.ToInt32(settings.Find(item => item.Name.Equals(name)).Value)); }
/// <summary> /// Gets setting with string value /// </summary> public string GetStringValue(SettingEnum name) { return((string)settings.Find(item => item.Name.Equals(name)).Value); }
public Setting(SettingEnum name, object value) { this.Name = name; this.Value = value; }