コード例 #1
0
        private void AddResourceButton_Click(object sender, EventArgs e)
        {
            var dlg = new AddResourceEntryDialog();

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                int          imageindex = RepositoryIcons.GetImageIndexForResourceType(Path.GetExtension(dlg.ResourceName).Replace(".", ""));
                TreeNode     n          = new TreeNode(dlg.ResourceName, imageindex, imageindex);
                ResourceItem i          = new ResourceItem("", dlg.HeaderFilepath, dlg.ContentFilepath);
                i.EntryType = EntryTypeEnum.Added;
                n.Tag       = i;

                if (ResourceTree.SelectedNode == null || ResourceTree.SelectedNode.Parent == null)
                {
                    ResourceTree.Nodes[0].Nodes.Add(n);
                }
                else if (ResourceTree.SelectedNode.Tag as ResourceItem != null)
                {
                    if ((ResourceTree.SelectedNode.Tag as ResourceItem).IsFolder)
                    {
                        ResourceTree.SelectedNode.Nodes.Add(n);
                    }
                    else if (ResourceTree.SelectedNode.Parent == null)
                    {
                        ResourceTree.Nodes[0].Nodes.Add(n);
                    }
                    else
                    {
                        ResourceTree.SelectedNode.Parent.Nodes.Add(n);
                    }
                }

                n.EnsureVisible();
                ResourceTree.SelectedNode = n;
                ResourceTree.Focus();
            }
        }
コード例 #2
0
ファイル: PackageEditorDialog.cs プロジェクト: kanbang/Colt
        private void AddResourceButton_Click(object sender, EventArgs e)
        {
            var dlg = new AddResourceEntryDialog();
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                int imageindex = RepositoryIcons.GetImageIndexForResourceType((ResourceTypes)Enum.Parse(typeof(ResourceTypes), Path.GetExtension(dlg.ResourceName).Replace(".", "")));
                TreeNode n = new TreeNode(dlg.ResourceName, imageindex, imageindex);
                ResourceItem i = new ResourceItem("", dlg.HeaderFilepath, dlg.ContentFilepath);
                i.EntryType = EntryTypeEnum.Added;
                n.Tag = i;

                if (ResourceTree.SelectedNode == null || ResourceTree.SelectedNode.Parent == null)
                    ResourceTree.Nodes[0].Nodes.Add(n);
                else if (ResourceTree.SelectedNode.Tag as ResourceItem != null)
                {
                    if ((ResourceTree.SelectedNode.Tag as ResourceItem).IsFolder)
                        ResourceTree.SelectedNode.Nodes.Add(n);
                    else if (ResourceTree.SelectedNode.Parent == null)
                        ResourceTree.Nodes[0].Nodes.Add(n);
                    else
                        ResourceTree.SelectedNode.Parent.Nodes.Add(n);
                }

                n.EnsureVisible();
                ResourceTree.SelectedNode = n;
                ResourceTree.Focus();
            }
        }