public override void LoadSetting(ISettingsSource settings, bool areSettingsEffective, TextBox control) { object settingVal = areSettingsEffective ? Setting.ValueOrDefault(settings) : Setting[settings]; control.Text = ConvertToString(settingVal); }
public override void LoadSetting(ISettingsSource settings, NumericUpDown control) { object?settingVal = settings.SettingLevel == SettingLevel.Effective ? Setting.ValueOrDefault(settings) : Setting[settings]; control.Value = (int)settingVal; }
public override void LoadSetting(ISettingsSource settings, TextBox control) { object?settingVal = settings.SettingLevel == SettingLevel.Effective ? Setting.ValueOrDefault(settings) : Setting[settings]; control.Text = ConvertToString(settingVal); }
public override void LoadSetting(ISettingsSource settings, bool areSettingsEffective, TextBox control) { string settingVal = areSettingsEffective ? Setting.ValueOrDefault(settings) : Setting[settings]; control.Text = control.Multiline ? settingVal?.Replace("\n", Environment.NewLine) : settingVal; }
public override void SaveSetting(ISettingsSource settings, CredentialsControl control) { if (SettingLevelSupported(settings.SettingLevel)) { Setting.SaveValue(settings, control.UserName, control.Password); // Reload actual settings. LoadSetting(settings, control); } }
public string this[ISettingsSource settings] { get { return(settings.GetString(Name, null)); } set { settings.SetString(Name, value); } }
public bool?this[ISettingsSource settings] { get { return(settings.GetBool(Name)); } set { settings.SetBool(Name, value); } }
public override void LoadSetting(ISettingsSource settings, ComboBox control) { string settingVal = settings.SettingLevel == SettingLevel.Effective ? Setting.ValueOrDefault(settings) : Setting[settings]; control.SelectedIndex = Setting.Values.IndexOf(settingVal); if (control.SelectedIndex == -1) { control.Text = settingVal; } }
public T ValueOrDefault(ISettingsSource settings) { object settingVal = this[settings]; if (settingVal == null) { return(DefaultValue); } else { return((T)settingVal); } }
public override void SaveSetting(ISettingsSource settings, bool areSettingsEffective, CheckBox control) { var controlValue = control.GetNullableChecked(); if (areSettingsEffective) { if (Setting.ValueOrDefault(settings) == controlValue) { return; } } Setting[settings] = controlValue; }
public override void SaveSetting(ISettingsSource settings, bool areSettingsEffective, TextBox control) { var controlValue = control.Text; if (areSettingsEffective) { if (ConvertToString(Setting.ValueOrDefault(settings)).Equals(controlValue)) { return; } } Setting[settings] = ConvertFromString(controlValue); }
public override void SaveSetting(ISettingsSource settings, TextBox control) { var controlValue = control.Text; if (settings.SettingLevel == SettingLevel.Effective) { if (Setting.ValueOrDefault(settings) == controlValue) { return; } } Setting[settings] = controlValue; }
public override void SaveSetting(ISettingsSource settings, ComboBox control) { var controlValue = control.SelectedItem?.ToString(); if (settings.SettingLevel == SettingLevel.Effective) { if (Setting.ValueOrDefault(settings) == controlValue) { return; } } Setting[settings] = controlValue; }
public object this[ISettingsSource settings] { get { return(settings.GetValue(Name, null, s => { return ConvertFromString(s); })); } set { settings.SetValue(Name, value, i => { return(ConvertToString(i)); }); } }
public override void LoadSetting(ISettingsSource settings, bool areSettingsEffective, ComboBox control) { string settingVal; if (areSettingsEffective) { settingVal = Setting.ValueOrDefault(settings); } else { settingVal = Setting[settings]; } control.SelectedIndex = Setting.Values.IndexOf(settingVal); }
public override void LoadSetting(ISettingsSource settings, bool areSettingsEffective, TextBox control) { string settingVal; if (areSettingsEffective) { settingVal = Setting.ValueOrDefault(settings); } else { settingVal = Setting[settings]; } control.Text = settingVal; }
public T this[ISettingsSource settings] { get { return(settings.GetValue(Name, DefaultValue, s => { return (T)ConvertFromString(s); })); } set { settings.SetValue(Name, value, i => { return(i.ToString()); }); } }
public override void LoadSetting(ISettingsSource settings, bool areSettingsEffective, CheckBox control) { bool?settingVal; if (areSettingsEffective) { settingVal = Setting.ValueOrDefault(settings); } else { settingVal = Setting[settings]; } control.SetNullableChecked(settingVal); }
public object?this[ISettingsSource settings] { get { string?stringValue = settings.GetValue(Name); return(ConvertFromString(stringValue)); } set { string?stringValue = ConvertToString(value); settings.SetValue(Name, stringValue); } }
public override void LoadSetting(ISettingsSource settings, CredentialsControl control) { if (SettingLevelSupported(settings.SettingLevel)) { var credentials = Setting.GetValueOrDefault(settings); control.UserName = credentials.UserName; control.Password = credentials.Password; control.Enabled = true; } else { control.UserName = string.Empty; control.Password = string.Empty; control.Enabled = false; } }
public void SaveValue(ISettingsSource settings, string userName, string password) { if (settings.SettingLevel == SettingLevel.Effective) { var currentCredentials = GetValueOrDefault(settings); if (currentCredentials.UserName == userName && currentCredentials.Password == password) { return; } } var newCredentials = string.IsNullOrWhiteSpace(userName) ? null : new NetworkCredential(userName, password); SetCredentials(settings.SettingLevel, Name, newCredentials); }
public string this[ISettingsSource settings] { get { return(settings.GetValue(Name, DefaultValue, s => { if (string.IsNullOrEmpty(s)) { return DefaultValue; } return s; })); } set { settings.SetValue(Name, value, s => { return(s); }); } }
public override void LoadSetting(ISettingsSource settings, TextBox control) { if (control.ReadOnly) { // readonly controls can't be changed by the user, so there is no need to load settings return; } string settingVal = settings.SettingLevel == SettingLevel.Effective ? Setting.ValueOrDefault(settings) : Setting[settings]; if (settingVal == null && _useDefaultValueIfBlank) { settingVal = Setting.ValueOrDefault(settings); } control.Text = control.Multiline ? settingVal?.Replace("\n", Environment.NewLine) : settingVal; }
public override void LoadSetting(ISettingsSource settings, bool areSettingsEffective, TextBox control) { string settingVal; if (areSettingsEffective) { settingVal = Setting.ValueOrDefault(settings); } else { settingVal = Setting[settings]; } if (!control.Multiline) { control.Text = settingVal; } else { control.Text = settingVal.Replace("\n", Environment.NewLine); } }
public string this[ISettingsSource settings] { get => settings.GetString(Name, null);
public bool?this[ISettingsSource settings] { get => settings.GetBool(Name);
/// <summary> /// Loads setting value from settings to Control /// </summary> public abstract void LoadSetting(ISettingsSource settings, bool areSettingsEffective, T control);
/// <summary> /// Saves value from Control to settings /// </summary> public abstract void SaveSetting(ISettingsSource settings, bool areSettingsEffective, TControl control);
/// <summary> /// Saves value from Control to settings /// </summary> public void SaveSetting(ISettingsSource settings, bool areSettingsEffective) { SaveSetting(settings, areSettingsEffective, Control); }
public string ValueOrDefault(ISettingsSource settings) { return(this[settings] ?? DefaultValue); }