Beispiel #1
0
        public void SetCtls(AIEntity entity)
        {
            if (InvokeRequired)
            {
                this.Invoke(new Action(() =>
                {
                    SetCtls(entity);
                }));
                return;
            }
            LV_AI.Items.Clear();
            var properties = entity.GetType().GetProperties();

            foreach (var p in properties)
            {
                var attr = Attribute.GetCustomAttribute(p, typeof(DescriptionAttribute));
                if (null != attr)
                {
                    var desc = (DescriptionAttribute)attr;
                    if (Convert.ToBoolean(p.GetValue(entity)))
                    {
                        LV_AI.Items.Add(new ListViewItem(new string[] { desc.Name, string.Format("{0}{1}", p.GetValue(entity), desc.Unit) }));
                    }
                }
            }
        }