コード例 #1
0
        /// <summary>
        /// Builds the attributes for control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="node">The node.</param>
        private void BuildAttributesForControl(xControl control, TreeNode node)
        {
            var attributes = control.GetType().GetFields()
                             .Where(a =>
            {
                if (a.IsDefined(typeof(FormDesignerAttributeAttribute), true))
                {
                    var formDesignerAttribute = a.GetCustomAttributes(typeof(FormDesignerAttributeAttribute), true) as FormDesignerAttributeAttribute[];
                    if (formDesignerAttribute.Length > 0 &&
                        formDesignerAttribute[0].HideAttribute == false &&
                        //(formDesignerAttribute[0].ReleventControls.Contains(control.Type) || formDesignerAttribute[0].ReleventControls.Contains(ControlType.All)) &&
                        formDesignerAttribute[0].AttributeType == AttributeType.Common
                        )
                    {
                        return(true);
                    }
                }

                return(false);
            });

            node.Nodes.AddRange(attributes.Select(x => { return(new TreeNode(x.Name)
                {
                    Name = x.Name
                }); }).OrderBy(a => a.Text).ToArray());
        }