TypeConverters.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.ComponentModel;
  3. using System.Globalization;
  4. namespace CustomControls.Pattern
  5. {
  6. /// <summary>
  7. /// Scripts类型转换
  8. /// </summary>
  9. public class PatternScriptsTypeConverter : ExpandableObjectConverter
  10. {
  11. public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
  12. {
  13. if (destinationType == typeof(string) && value is XRPatternScripts) { return "(Pattern Scripts)"; }
  14. return base.ConvertTo(context, culture, value, destinationType);
  15. }
  16. }
  17. /// <summary>
  18. /// CodeOptions类型转化
  19. /// </summary>
  20. public class CodeOptionsTypeConverter : ExpandableObjectConverter
  21. {
  22. public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
  23. {
  24. if (destinationType == typeof(string) && value is CodeOptions) { return "(Options)"; }
  25. return base.ConvertTo(context, culture, value, destinationType);
  26. }
  27. }
  28. }