Пример #1
0
        /// <summary>
        /// adds a setting to this settings object
        /// </summary>
        /// <param name="name">property name</param>
        /// <param name="val">start value of the property</param>
        /// <param name="desc">property description</param>
        /// <param name="category">property category</param>
        /// <param name="update">event handler to recieve the PropertyValueChanged event</param>
        /// <param name="reflect">if true, an internal event handler will be created - the refObj must not be null and the name must be the name of a property of the type that refObj is</param>
        /// <param name="refObj">the object that will recieve the changed property values</param>
        public void AddSetting(
            string name,
            object val,
            string desc,
            string category,
            ValueChangedDelegate update,
            bool reflect,
            object refObj)
        {
            name = name.Replace(" ", "");             // take out all spaces

            Setting setting;

            if (!settings.ContainsKey(name))
            {
                setting        = new Setting(val, desc, category);
                settings[name] = setting;
            }
            else
            {
                setting             = settings[name];
                setting.Value       = val;
                setting.Description = desc;
            }

            if (update != null)
            {
                setting.ValueChanged += update;
            }

            if (reflect && refObj != null)
            {
                propObj[name]            = new PropObj(refObj, name);
                this[name].ValueChanged += reflectEvent;
            }
        }
Пример #2
0
		/// <summary>
		/// adds a setting to this settings object
		/// </summary>
		/// <param name="name">property name</param>
		/// <param name="val">start value of the property</param>
		/// <param name="desc">property description</param>
		/// <param name="category">property category</param>
		/// <param name="eh">event handler to recieve the PropertyValueChanged event</param>
		/// <param name="reflect">if true, an internal event handler will be created - the refObj must not be null and the name must be the name of a property of the type that refObj is</param>
		/// <param name="refObj">the object that will recieve the changed property values</param>
		public void AddSetting(string name,object val,string desc,string category,ValueChangedDelegate eh, bool reflect,object refObj)
		{
			//take out all spaces
			name = name.Replace(" ","");

			settings[name]=new Setting(val,desc,category,eh);
			if(reflect && refObj!=null)
			{
				propObj[name]=new PropObj(refObj,name);
				this[name].ValueChanged+=new ValueChangedDelegate(reflectEvent);
			}
		}