예제 #1
0
        protected virtual void UpdateDescription()
        {
            itemDescriptionTextBox.Text   = string.Empty;
            pluginDescriptionTextBox.Text = string.Empty;
            pluginTextBox.Text            = string.Empty;
            versionTextBox.Text           = string.Empty;

            if (typesTreeView.SelectedNode != null)
            {
                var    node     = typesTreeView.SelectedNode;
                string category = node.Tag as string;
                if (category != null)
                {
                    itemDescriptionTextBox.Text = string.Join(" - ", node.Name.Split(new[] { CreatableAttribute.Categories.SplitToken }, StringSplitOptions.RemoveEmptyEntries));
                }
                Type type = node.Tag as Type;
                if (type != null)
                {
                    string description = ItemAttribute.GetDescription(type);
                    var    version     = ItemAttribute.GetVersion(type);
                    var    plugin      = ApplicationManager.Manager.GetDeclaringPlugin(type);
                    if (description != null)
                    {
                        itemDescriptionTextBox.Text = description;
                    }
                    if (plugin != null)
                    {
                        pluginTextBox.Text            = plugin.Name;
                        pluginDescriptionTextBox.Text = plugin.Description;
                    }
                    if (version != null)
                    {
                        versionTextBox.Text = version.ToString();
                    }
                }
            }
            else if (typesTreeView.Nodes.Count == 0)
            {
                itemDescriptionTextBox.Text = "No types found";
            }
        }
예제 #2
0
        private void NewItemDialog_Load(object sender, EventArgs e)
        {
            if (isInitialized)
            {
                return;
            }

            // Sorted by hasOrdering to create category nodes first with concrete ordering.
            // Items with categoryname without ordering are inserted afterwards correctly
            var categories =
                from type in ApplicationManager.Manager.GetTypes(typeof(IItem))
                where CreatableAttribute.IsCreatable(type)
                let category = CreatableAttribute.GetCategory(type)
                               let hasOrdering                       = category.Contains(CreatableAttribute.Categories.OrderToken)
                                                            let name = ItemAttribute.GetName(type)
                                                                       let priority = CreatableAttribute.GetPriority(type)
                                                                                      let version = ItemAttribute.GetVersion(type)
                                                                                                    orderby category, hasOrdering descending, priority, name, version ascending
            group type by category into categoryGroup
            select categoryGroup;

            var rootNode = CreateCategoryTree(categories);

            CreateItemNodes(rootNode, categories);

            foreach (TreeNode topNode in rootNode.Nodes)
            {
                treeNodes.Add(topNode);
            }
            foreach (var node in treeNodes)
            {
                typesTreeView.Nodes.Add((TreeNode)node.Clone());
            }

            typesTreeView.TreeViewNodeSorter = new ItemTreeNodeComparer();
            typesTreeView.Sort();

            isInitialized = true;
        }