Exemplo n.º 1
0
 /// <summary>
 /// Set the STNode node that needs to be displayed
 /// </summary>
 /// <param name="node">target node</param>
 public void SetNode(STNode node)
 {
     if (node == this._STNode)
     {
         return;
     }
     m_nInfoOffsetY = m_nPropertyOffsetY = 0;
     m_nInfoVHeight = m_nPropertyVHeight = 0;
     m_rect_link    = m_rect_help = Rectangle.Empty;
     m_str_desc     = m_str_err = null;
     this._STNode   = node;
     if (node != null)
     {
         m_type           = node.GetType();
         m_lst_item       = this.GetProperties(node);
         m_node_attribute = this.GetNodeAttribute(node);
         this.SetItemRectangle();
         m_b_current_draw_info = m_lst_item.Count == 0 || this._InfoFirstOnDraw;
         if (this._AutoColor)
         {
             this._ItemSelectedColor = this._STNode.TitleColor;
         }
     }
     else
     {
         m_type = null;
         m_lst_item.Clear();
         m_node_attribute = null;
     }
     this.Invalidate();
 }
Exemplo n.º 2
0
        private STNodeAttribute GetNodeAttribute(STNode node)
        {
            if (node == null)
            {
                return(null);
            }
            Type t = node.GetType();

            foreach (var v in t.GetCustomAttributes(true))
            {
                if (!(v is STNodeAttribute))
                {
                    continue;
                }
                return((STNodeAttribute)v);
            }
            return(null);
        }
Exemplo n.º 3
0
        private List <STNodePropertyDescriptor> GetProperties(STNode node)
        {
            List <STNodePropertyDescriptor> lst = new List <STNodePropertyDescriptor>();

            if (node == null)
            {
                return(lst);
            }
            Type t = node.GetType();

            foreach (var p in t.GetProperties())
            {
                var attrs = p.GetCustomAttributes(true);
                foreach (var a in attrs)
                {
                    if (!(a is STNodePropertyAttribute))
                    {
                        continue;
                    }
                    var    attr = a as STNodePropertyAttribute;
                    object obj  = Activator.CreateInstance(attr.DescriptorType);
                    if (!(obj is STNodePropertyDescriptor))
                    {
                        throw new ArgumentException("[STNodePropertyAttribute.DescriptorType] parameter value must be the type of [STNodePropertyDescriptor] or its subclass");
                    }
                    var desc = (STNodePropertyDescriptor)Activator.CreateInstance(attr.DescriptorType);
                    desc.Node         = node;
                    desc.Name         = attr.Name;
                    desc.Description  = attr.Description;
                    desc.PropertyInfo = p;
                    desc.Control      = this;
                    lst.Add(desc);
                }
            }
            return(lst);
        }