Ejemplo n.º 1
0
        public override CommandTreeNode InsertAfter(Command command, GinNameAttribute commandAttribute, CommandTreeNode nodeAfter)
        {
            TreeNode node = new TreeNode()
            {
                Text        = GetCommandName(command, commandAttribute),
                ToolTipText = commandAttribute.Description,
                ImageIndex  = 0,
                Tag         = new TreeNodeData()
                {
                    Command           = command,
                    CommandAttribute  = commandAttribute,
                    Property          = null,
                    PropertyAttribute = null,
                    AcceptedTypes     = null,
                    NotAcceptedTypes  = null
                }
            };
            TreeViewTreeNode afterNode = (TreeViewTreeNode)nodeAfter;
            int index = _node.Nodes.IndexOf(afterNode._node);

            if (index >= 0)
            {
                _node.Nodes.Insert(index + 1, node);
            }
            else
            {
                _node.Nodes.Add(node);
            }
            TreeViewTreeNode treeNode = new TreeViewTreeNode(node);

            ((TreeNodeData)node.Tag).Node = treeNode;
            return(treeNode);
        }
Ejemplo n.º 2
0
        public virtual string GetHumanReadableName()
        {
            GinNameAttribute attr = GetType().GetCustomAttributes(true).OfType <GinNameAttribute>().FirstOrDefault();

            if (attr == null)
            {
                return(null);
            }
            if (String.IsNullOrEmpty(Description))
            {
                return(attr.Name);
            }
            return(attr.Name + "(" + Description + ")");
        }
Ejemplo n.º 3
0
        public override CommandTreeNode AppendChild(Command command, GinNameAttribute commandAttribute, PropertyInfo property, GinArgumentAttribute propertyAttribute)
        {
            var         acceptNot        = property.GetCustomAttributes(typeof(GinArgumentCommandAcceptNotAttribute), false);
            List <Type> notAcceptedTypes = null;

            if (acceptNot != null)
            {
                notAcceptedTypes = new List <Type>();
                foreach (var item in acceptNot)
                {
                    notAcceptedTypes.Add(((GinArgumentCommandAcceptNotAttribute)item).NotAcceptedType);
                }
            }
            var         acceptOnly    = property.GetCustomAttributes(typeof(GinArgumentCommandAcceptOnlyAttribute), false);
            List <Type> acceptedTypes = null;

            if (acceptOnly != null)
            {
                acceptedTypes = new List <Type>();
                foreach (var item in acceptOnly)
                {
                    acceptedTypes.Add(((GinArgumentCommandAcceptOnlyAttribute)item).AcceptedType);
                }
            }
            TreeNode node = new TreeNode()
            {
                Text               = propertyAttribute.Name,
                ToolTipText        = propertyAttribute.Description,
                ImageIndex         = 1,
                SelectedImageIndex = 1,
                Tag = new TreeNodeData()
                {
                    Command           = command,
                    CommandAttribute  = commandAttribute,
                    Property          = property,
                    PropertyAttribute = propertyAttribute,
                    AcceptedTypes     = acceptedTypes.ToArray(),
                    NotAcceptedTypes  = notAcceptedTypes.ToArray()
                }
            };

            _node.Nodes.Add(node);
            TreeViewTreeNode treeNode = new TreeViewTreeNode(node);

            ((TreeNodeData)node.Tag).Node = treeNode;
            return(treeNode);
        }
Ejemplo n.º 4
0
        private CommandMetadata GetCommandMetadata(Type command)
        {
            CommandMetadata result = new CommandMetadata()
            {
                Desription = command.Name,
                Name       = command.Name
            };

            GinNameAttribute attr = command.GetCustomAttributes(true).OfType <GinNameAttribute>().FirstOrDefault();

            if (attr != null)
            {
                result.Desription = attr.Description;
                result.Name       = attr.Name;
                result.Group      = attr.Group;
            }
            return(result);
        }
Ejemplo n.º 5
0
        public override CommandTreeNode AppendChild(Command command, GinNameAttribute commandAttribute)
        {
            TreeNode node = new TreeNode()
            {
                Text        = GetCommandName(command, commandAttribute),
                ToolTipText = commandAttribute.Description,
                ImageIndex  = 0,
                Tag         = new TreeNodeData()
                {
                    Command           = command,
                    CommandAttribute  = commandAttribute,
                    Property          = null,
                    PropertyAttribute = null,
                    AcceptedTypes     = null,
                    NotAcceptedTypes  = null
                }
            };

            _node.Nodes.Add(node);
            TreeViewTreeNode treeNode = new TreeViewTreeNode(node);

            ((TreeNodeData)node.Tag).Node = treeNode;
            return(treeNode);
        }
Ejemplo n.º 6
0
 public abstract CommandTreeNode AppendChild(Command command, GinNameAttribute commandAttribute);
Ejemplo n.º 7
0
 public abstract CommandTreeNode AppendChild(Command command, GinNameAttribute commandAttribute, PropertyInfo property, GinArgumentAttribute propertyAttribute);
Ejemplo n.º 8
0
 public abstract CommandTreeNode InsertAfter(Command command, GinNameAttribute commandAttribute, CommandTreeNode nodeAfter);
Ejemplo n.º 9
0
 private string GetCommandName(Command command, GinNameAttribute commandAttribute)
 {
     return(command.GetHumanReadableName());
 }