示例#1
0
        private ContextMenu CreateContextMenu(ResourceNode node)
        {
            ContextMenu cm = new ContextMenu();

            if (node.Is(ResourceType.Folder))
            {
                if (node.Is(ResourceType.Image))
                {
                    cm.Items.Add(MakeMenuItem(PackIconKind.ImageAdd, "导入图片", Commands.ImportFile, node));
                }
                else if (node.Is(ResourceType.Font))
                {
                    cm.Items.Add(MakeMenuItem(PackIconKind.FormatFont, "导入字体", Commands.ImportFile, node));
                }
                else if (node.Is(ResourceType.ShaderSource))
                {
                    cm.Items.Add(MakeMenuItem(PackIconKind.NoteAddOutline, "导入Shader", Commands.ImportFile, node));
                }
                else if (node.Is(ResourceType.ThreeDAssets))
                {
                    cm.Items.Add(MakeMenuItem(PackIconKind.Codepen, "导入3D模型", Commands.ImportFile, node));
                }

                cm.Items.Add(MakeMenuItem(PackIconKind.CreateNewFolderOutline, "新建文件夹", Commands.InputFolderName, node));
            }
            else
            {
                cm.Items.Add(MakeMenuItem(PackIconKind.TrashCanOutline, "删除", Commands.RemoveResourceNode, node));
                cm.Items.Add(MakeMenuItem(PackIconKind.RenameBox, "重命名", Commands.RenameResourceNodeDlg, node));
            }
            return(cm);
        }
示例#2
0
        private void CommandBinding_Executed_RenameResourceNode(object sender, ExecutedRoutedEventArgs e)
        {
            string selectPath = ResourceFilesTree.SelectItemPath;

            if (ResourceFilesTree.SelectItemPath == null)
            {
                return;
            }

            ResourceNode targetNode = ViewModel.Library.ResouceFilesRoot.Find(selectPath);
            string       ext        = Path.GetExtension(selectPath);
            string       newName    = (string)(e.Parameter);

            if (!targetNode.Is(ResourceType.Folder))
            {
                targetNode.Name = newName + ext;
            }
            ResourceFilesTree.SelectItemPath = Path.GetDirectoryName(ResourceFilesTree.SelectItemPath) + targetNode.Name;
            dh.IsOpen = false;
        }