public void LoadForced()
        {
            RegistryKey folderKey = OptionCollection.FolderKey(path);

            string[] regNames = folderKey.GetValueNames();
            IOption  option;

            foreach (string regName in regNames)
            {
                RegistryValueKind kind     = folderKey.GetValueKind(regName);
                object            regValue = folderKey.GetValue(regName);
                switch (kind)
                {
                case RegistryValueKind.DWord:
                    option = new IntOption(path, regName, 0);
                    break;

                case RegistryValueKind.String:
                default:
                    option = new Option(path, regName, null);
                    break;
                }
                option.Value = regValue;
                options.Add(option);
            }
        }
예제 #2
0
        /// <summary>
        /// Загрузка значения параметра из реестра
        /// </summary>
        public void Load()
        {
            RegistryKey folderKey = OptionCollection.FolderKey(path);
            string      regValue  = folderKey.GetValue(name) as string;

            if (regValue != null)
            {
                val = regValue;
            }
            else
            {
                val = def;
                Save();
            }

            if (ValueChanged != null)
            {
                ValueChanged(this, new OptionEventArgs(val));
            }
        }
예제 #3
0
        /// <summary>
        /// Загрузка значения параметра из реестра
        /// </summary>
        public void Load()
        {
            RegistryKey folderKey = OptionCollection.FolderKey(path);
            object      regValue  = folderKey.GetValue(name);

            if (regValue != null)
            {
                if (regValue is int)
                {
                    val = (int)regValue;
                }
                else
                {
                    int res = def;
                    if (int.TryParse(regValue.ToString(), out res))
                    {
                        val = res;
                    }
                    else
                    {
                        val = def;
                        Save();
                    }
                }
            }
            else
            {
                val = def;
                Save();
            }

            if (ValueChanged != null)
            {
                ValueChanged(this, new OptionEventArgs(val));
            }
        }
예제 #4
0
        /// <summary>
        /// Сохранение в реестре
        /// </summary>
        public void Save()         //
        {
            RegistryKey folderKey = OptionCollection.FolderKey(path);

            folderKey.SetValue(name, val, DefaultKind);
        }