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);
            }
        }
Exemple #2
0
        /// <summary>
        /// Cоздание раздела в реестре у родителького Folder
        /// </summary>
        /// <param name="parent">родителький Folder</param>
        /// <param name="name">название раздела реестра</param>
        public Folder(Folder parent, string name)
        {
            path      = parent.FullPath;
            this.name = name;

            folders = new FolderCollection(FullPath);
            options = new OptionCollection(FullPath);
        }
Exemple #3
0
        /// <summary>
        /// Cоздание раздела в реестре по указанному пути
        /// </summary>
        /// <param name="path">Путь в реестре</param>
        /// <param name="name">название раздела реестра</param>
        public Folder(string path, string name)
        {
            this.path = path;
            this.name = name;

            folders = new FolderCollection(FullPath);
            options = new OptionCollection(FullPath);
        }
        /// <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));
            }
        }
Exemple #5
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));
            }
        }
Exemple #6
0
        /// <summary>
        /// Сохранение в реестре
        /// </summary>
        public void Save()         //
        {
            RegistryKey folderKey = OptionCollection.FolderKey(path);

            folderKey.SetValue(name, val, DefaultKind);
        }
 public OptionEnumerator(OptionCollection oc)
 {
     this.oc = oc;
 }