PropDescriptor.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.ComponentModel;
  3. namespace FWindSoft.WinForm
  4. {
  5. internal class PropDescriptor : PropertyDescriptor
  6. {
  7. private PropertyItem m_Prop;
  8. public PropDescriptor(PropertyItem prop, Attribute[] attrs)
  9. : base(prop.Name, attrs)
  10. {
  11. m_Prop = prop;
  12. }
  13. #region 重写抽象方法
  14. public override bool CanResetValue(object component)
  15. {
  16. return false;
  17. }
  18. public override object GetValue(object component)
  19. {
  20. return this.m_Prop.Value;
  21. }
  22. public override void ResetValue(object component)
  23. {
  24. }
  25. public override void SetValue(object component, object value)
  26. {
  27. this.m_Prop.Value = value;
  28. }
  29. public override bool ShouldSerializeValue(object component)
  30. {
  31. return false;
  32. }
  33. public override object GetEditor(Type editorBaseType)
  34. {
  35. return this.m_Prop.Editor ?? base.GetEditor(editorBaseType);
  36. }
  37. #endregion
  38. #region 重写属性
  39. public override Type ComponentType
  40. {
  41. get { return this.GetType(); }
  42. }
  43. public override bool IsReadOnly
  44. {
  45. get { return this.m_Prop.IsReadOnly; }
  46. }
  47. public override Type PropertyType
  48. {
  49. get { return m_Prop.Value.GetType(); }
  50. }
  51. /// <summary>
  52. /// 重写分类
  53. /// </summary>
  54. public override string Category
  55. {
  56. get { return this.m_Prop.Category; }
  57. }
  58. /// <summary>
  59. /// 显示名称
  60. /// </summary>
  61. public override string DisplayName
  62. {
  63. get { return this.m_Prop.DisplayName; }
  64. }
  65. public override TypeConverter Converter
  66. {
  67. get { return this.m_Prop.Convert; }
  68. }
  69. public override string Description
  70. {
  71. get { return this.m_Prop.Description; }
  72. }
  73. public override bool IsBrowsable
  74. {
  75. get { return this.m_Prop.IsVisible; }
  76. }
  77. #endregion
  78. }
  79. }