using System; using System.ComponentModel; namespace FWindSoft.WinForm { public class PropertyItem { private object m_Value; public event EventHandler OnValueChanged; public PropertyItem() { this.Name = string.Empty; this.DisplayName = String.Empty; this.Category = string.Empty; this.IsVisible = true; this.IsReadOnly = false; } public PropertyItem(string name, object value) : this() { this.Name = name; this.Value = value; this.DisplayName = name; } public PropertyCollection Owner { get; internal set; } #region 特殊处理属性值 /// /// 属性值 /// public object Value { get { return this.m_Value; } set { ValueChangedArgs args = new ValueChangedArgs(this.m_Value, value, this.Owner); bool changed = this.m_Value!=value; this.m_Value = value; if (changed && OnValueChanged != null) { OnValueChanged(this, args); } } } #endregion #region 属性维护 /// /// 属性名称 /// public string Name { get; set; } /// /// 是否可编辑 /// public bool IsReadOnly { get; set; } /// /// 是否可见 /// public bool IsVisible { get; set; } /// /// 分类 /// public string Category { get; set; } /// /// 编辑器 /// public virtual object Editor { get; set; } /// /// 属性名显示 /// public string DisplayName { get; set; } /// /// 提示信息 /// public string Description { get; set; } /// /// 类型转换 /// public TypeConverter Convert { get; set; } #endregion } public class ValueChangedArgs : HandledEventArgs { public ValueChangedArgs(object oldValue,object newValue,PropertyCollection collection) { this.OldValue = oldValue; this.NewValue = newValue; this.ReferenceItems = collection; } /// /// 旧值 /// public object OldValue { get; private set; } /// /// 新值 /// public object NewValue { get; private set; } /// /// 关联项目集合 /// public PropertyCollection ReferenceItems { get; private set; } } }