コード例 #1
0
            public override void LoadSetting(ISettingsSource settings, bool areSettingsEffective, TextBox control)
            {
                object settingVal = areSettingsEffective
                    ? Setting.ValueOrDefault(settings)
                    : Setting[settings];

                control.Text = ConvertToString(settingVal);
            }
コード例 #2
0
            public override void LoadSetting(ISettingsSource settings, NumericUpDown control)
            {
                object?settingVal = settings.SettingLevel == SettingLevel.Effective
                    ? Setting.ValueOrDefault(settings)
                    : Setting[settings];

                control.Value = (int)settingVal;
            }
コード例 #3
0
            public override void LoadSetting(ISettingsSource settings, TextBox control)
            {
                object?settingVal = settings.SettingLevel == SettingLevel.Effective
                    ? Setting.ValueOrDefault(settings)
                    : Setting[settings];

                control.Text = ConvertToString(settingVal);
            }
コード例 #4
0
ファイル: StringSetting.cs プロジェクト: uhml/gitextensions
            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;
            }
コード例 #5
0
            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);
                }
            }
コード例 #6
0
        public string this[ISettingsSource settings]
        {
            get
            {
                return(settings.GetString(Name, null));
            }

            set
            {
                settings.SetString(Name, value);
            }
        }
コード例 #7
0
ファイル: BoolSetting.cs プロジェクト: xatazch/gitextensions
        public bool?this[ISettingsSource settings]
        {
            get
            {
                return(settings.GetBool(Name));
            }

            set
            {
                settings.SetBool(Name, value);
            }
        }
コード例 #8
0
            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;
                }
            }
コード例 #9
0
        public T ValueOrDefault(ISettingsSource settings)
        {
            object settingVal = this[settings];

            if (settingVal == null)
            {
                return(DefaultValue);
            }
            else
            {
                return((T)settingVal);
            }
        }
コード例 #10
0
ファイル: BoolSetting.cs プロジェクト: zlolik/gitextensions
            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;
            }
コード例 #11
0
            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);
            }
コード例 #12
0
            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;
            }
コード例 #13
0
            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;
            }
コード例 #14
0
        public object this[ISettingsSource settings]
        {
            get
            {
                return(settings.GetValue(Name, null, s =>
                {
                    return ConvertFromString(s);
                }));
            }

            set
            {
                settings.SetValue(Name, value, i => { return(ConvertToString(i)); });
            }
        }
コード例 #15
0
            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);
            }
コード例 #16
0
            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;
            }
コード例 #17
0
        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()); });
            }
        }
コード例 #18
0
ファイル: BoolSetting.cs プロジェクト: xatazch/gitextensions
            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);
            }
コード例 #19
0
        public object?this[ISettingsSource settings]
        {
            get
            {
                string?stringValue = settings.GetValue(Name);

                return(ConvertFromString(stringValue));
            }

            set
            {
                string?stringValue = ConvertToString(value);

                settings.SetValue(Name, stringValue);
            }
        }
コード例 #20
0
 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;
     }
 }
コード例 #21
0
        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);
        }
コード例 #22
0
        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); });
            }
        }
コード例 #23
0
            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;
            }
コード例 #24
0
            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);
                }
            }
コード例 #25
0
 public string this[ISettingsSource settings]
 {
     get => settings.GetString(Name, null);
コード例 #26
0
 public bool?this[ISettingsSource settings]
 {
     get => settings.GetBool(Name);
コード例 #27
0
 /// <summary>
 /// Loads setting value from settings to Control
 /// </summary>
 public abstract void LoadSetting(ISettingsSource settings, bool areSettingsEffective, T control);
コード例 #28
0
 /// <summary>
 /// Saves value from Control to settings
 /// </summary>
 public abstract void SaveSetting(ISettingsSource settings, bool areSettingsEffective, TControl control);
コード例 #29
0
 /// <summary>
 /// Saves value from Control to settings
 /// </summary>
 public void SaveSetting(ISettingsSource settings, bool areSettingsEffective)
 {
     SaveSetting(settings, areSettingsEffective, Control);
 }
コード例 #30
0
 public string ValueOrDefault(ISettingsSource settings)
 {
     return(this[settings] ?? DefaultValue);
 }