Exemplo n.º 1
0
 public OptionsTreeNode(AbstractOptions options)
 {
     this._options    = options;
     this.Tag         = options;
     this.ToolTipText = this.ToString();
     this.Text        = this.ToString();
     this.Name        = options.GetType().Name;
 }
Exemplo n.º 2
0
        private void LoadOptions()
        {
            List <Type> types = ReflectionHelper.GetSubClasses(typeof(AbstractOptions), this._applicationAssembly);

            foreach (Type type in types)
            {
                if (OptionsManager.GetManager().OptionsCollection.ContainsKey(type.Name))
                {
                    AbstractOptions options = OptionsManager.GetManager().OptionsCollection[type.Name];
                    this.tvOptions.Nodes.Add(new OptionsTreeNode(options));
                }
            }

            this._loaded = true;
        }
Exemplo n.º 3
0
        public void Initialize(string path, Assembly applicationAssembly)
        {
            _path = path;
            this.OptionsCollection.Clear();

            List <Type> types = ReflectionHelper.GetSubClasses(typeof(AbstractOptions), applicationAssembly);

            foreach (FileInfo fileInfo in new DirectoryInfo(path).GetFiles())
            {
                string optionsName = optionsName = fileInfo.Name.Remove(fileInfo.Name.IndexOf(".options"));

                Type curType = types.Find(new Predicate <Type>(t => t.Name.Equals(optionsName)));

                if (curType == null)
                {
                    continue;
                }

                AbstractOptions options = null;

                try
                {
                    string optionsPath = System.IO.Path.Combine(path, curType.Name + ".options");
                    options = Activator.CreateInstance(curType, optionsPath) as AbstractOptions;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("AbstractOptions options = Activator.CreateInstance(curType) as AbstractOptions;:\n\n" + ex);
                }

                options.Load();

                this.OptionsCollection.Add(curType.Name, options);

                types.Remove(curType);
            }

            foreach (Type type in types)
            {
                this.OptionsCollection.Add(type.Name, Activator.CreateInstance(type) as AbstractOptions);
            }

            this._form = new OptionsForm(applicationAssembly);
        }