Exemplo n.º 1
0
        private Control AddEnumInputControl(IUserOption option)
        {
            ComboBox box = new ComboBox();

            box.DropDownStyle = ComboBoxStyle.DropDownList;

            foreach (object val in Enum.GetValues(option.DataType))
            {
                if (ExtensionAttributeHelper.HasNullValueAttribute(option.DataType, val))
                {
                    box.Items.Add(new ComboBoxItemEx <object>(val, o => ""));
                    if (option.Value == null || option.Value == val)
                    {
                        box.SelectedIndex = box.Items.Count - 1;
                    }
                }
                else
                {
                    box.Items.Add(new ComboBoxItemEx <object>(val, o => Enum.GetName(option.DataType, o)));
                    if (option.Value != null && option.Value.Equals(val))
                    {
                        box.SelectedIndex = box.Items.Count - 1;
                    }
                }
            }

            box.SelectedIndexChanged += (sender, e) => OnVirtualPropertyValueChanged(sender as Control);

            return(box);
        }
Exemplo n.º 2
0
        private void CreateExtensionMethodNodes(Type type, Node node)
        {
            foreach (var method in ExtensionAttributeHelper.GetExtendableMethods(type))
            {
                var methodNode = new Node {
                    Text = method.Name, Name = method.Name, Tag = method
                };

                string description = ExtensionAttributeHelper.GetExtensionDescription(method);

                if (string.IsNullOrEmpty(description) == false)
                {
                    SetToolTip(methodNode, description);
                }
                node.Nodes.Add(methodNode);

                methodNodes.Add(method, methodNode);
            }
        }
Exemplo n.º 3
0
        private void Populate()
        {
            listTypes.Items.Clear();
            listTypes.Items.Add("    NO ITERATOR (one per project)");
            var emptyNamespaceList = new List <string>();

            var generatorIterators =
                ExtensionAttributeHelper.GetGeneratorIteratorTypes(Project.Instance.ReferencedAssemblies);

            foreach (var type in generatorIterators.OrderBy(t => t.FullName))
            {
                listTypes.Items.Add(Utility.GetDemangledGenericTypeName(type, emptyNamespaceList));
                var alternativeForms = ExtensionAttributeHelper.GetAlternativeForms(type);

                foreach (Type alternativeForm in alternativeForms.OrderBy(t => t.FullName))
                {
                    listTypes.Items.Add(Utility.GetDemangledGenericTypeName(alternativeForm, emptyNamespaceList));
                }
            }
        }
Exemplo n.º 4
0
        public void Populate()
        {
            ClearTree();

            var extendableTypes = ExtensionAttributeHelper.GetAllExtendableTypes(Project.Instance.ReferencedAssemblies);

            treeAPI.BeginUpdate();
            foreach (Type type in extendableTypes)
            {
                if (typeNodes.ContainsKey(type))
                {
                    continue;
                }

                Node parent   = FindOrCreateNamespaceNode(type);
                Node typeNode = CreateTypeNode(type, Project.Instance.GetVirtualPropertiesFor(type));

                parent.Nodes.Add(typeNode);
            }
            treeAPI.EndUpdate();
        }
Exemplo n.º 5
0
        public bool CanAddNewVirtualProperty()
        {
            Node selectedNode = treeAPI.SelectedNode;

            if (selectedNode == null)
            {
                return(false);
            }

            Node currentNode = selectedNode;

            while (currentNode != null)
            {
                if (currentNode.Tag is Type)
                {
                    return(ExtensionAttributeHelper.CanAddVirtualProperties(currentNode.Tag as Type));
                }

                currentNode = currentNode.Parent;
            }

            return(false);
        }