using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace BeDesignerSCADA.Common { /// /// 编辑脚本时获取控件属性 /// public class PropertyHelper { public static string[] ableProperties = new string[] { "IsChecked", "Value", "CurValue", "StatusValue", "NumberValue", "Text", "Direction","RefreshData","ChangedText","Content" }; public static List GetCustomerControlProperty(List selectItems) { List result = new List(); foreach (var control in selectItems) { var typeCtl = control.GetType(); if (typeCtl.GetProperties().Count(p => ableProperties.Contains(p.Name)) == 0) continue; var pare = new ControlName(control.Name, null); result.Add(pare); pare.Properties = typeCtl.GetProperties() .Where(p => ableProperties.Contains(p.Name)) .Select(x => new ControlName(x.Name, pare)).ToList(); } return result; } } public class ControlName { public ControlName(string name, ControlName parent) { Name = name; Parent = parent; } public ControlName Parent { get; set; } public string Name { get; set; } public IEnumerable Properties { get; set; } } }