终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
1.6 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. namespace BeDesignerSCADA.Common
  8. {
  9. /// <summary>
  10. /// 编辑脚本时获取控件属性
  11. /// </summary>
  12. public class PropertyHelper
  13. {
  14. public static string[] ableProperties = new string[]
  15. { "IsChecked", "Value", "CurValue", "StatusValue", "NumberValue", "Text",
  16. "Direction","RefreshData","ChangedText","Content"
  17. };
  18. public static List<ControlName> GetCustomerControlProperty(List<FrameworkElement> selectItems)
  19. {
  20. List<ControlName> result = new List<ControlName>();
  21. foreach (var control in selectItems)
  22. {
  23. var typeCtl = control.GetType();
  24. if (typeCtl.GetProperties().Count(p => ableProperties.Contains(p.Name)) == 0)
  25. continue;
  26. var pare = new ControlName(control.Name, null);
  27. result.Add(pare);
  28. pare.Properties = typeCtl.GetProperties()
  29. .Where(p => ableProperties.Contains(p.Name))
  30. .Select(x => new ControlName(x.Name, pare)).ToList();
  31. }
  32. return result;
  33. }
  34. }
  35. public class ControlName
  36. {
  37. public ControlName(string name, ControlName parent)
  38. {
  39. Name = name;
  40. Parent = parent;
  41. }
  42. public ControlName Parent { get; set; }
  43. public string Name { get; set; }
  44. public IEnumerable<ControlName> Properties { get; set; }
  45. }
  46. }