Example #1
0
        private void addScriptButton_Click(object sender, EventArgs e)
        {
            ScriptManifestReference newScriptRef = new ScriptManifestReference("new script reference");

            TreeNode selNode = this.scriptsTreeView.SelectedNode;
            TreeNodeCollection targetNodeCollection = this.scriptsTreeView.Nodes;
            ScriptRepositoryCategory targetCat = this.repository.DefaultCategory;
            if (selNode != null)
            {
                if (selNode.Tag is ScriptRepositoryCategory)
                {
                    targetNodeCollection =selNode.Nodes;
                    targetCat = (ScriptRepositoryCategory)selNode.Tag;
                }
                else if (selNode.Parent != null && selNode.Parent.Tag is ScriptRepositoryCategory)
                {
                    targetNodeCollection = selNode.Parent.Nodes;
                    targetCat = (ScriptRepositoryCategory)selNode.Parent.Tag;
                }
            }

            targetCat.Scripts.Add(newScriptRef);
            TreeNode tn = this.addScriptToTreeView(newScriptRef, targetNodeCollection);
            this.scriptsTreeView.SelectedNode = tn;
            tn.BeginEdit();
        }
Example #2
0
        private TreeNode addScriptToTreeView(ScriptManifestReference script, TreeNodeCollection parentNodeCollection)
        {
            TreeNode tn = new TreeNode(script.ToString());
            tn.ImageKey = tn.SelectedImageKey = "manifest_link";
            tn.Tag = script;
            parentNodeCollection.Add(tn);

            return tn;
        }