コード例 #1
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;
        }
コード例 #2
0
        private void CommandBinding_Executed_NewFolder(object sender, ExecutedRoutedEventArgs e)
        {
            var          selectPath    = ResourceFilesTree.SelectItemPath;
            var          parentNode    = ViewModel.Library.ResouceFilesRoot.Find(selectPath);
            string       newFolderName = (string)(e.Parameter);
            ResourceNode sourceNode    = (e.OriginalSource as Button).Tag as ResourceNode;

            if (parentNode == null)
            {
                parentNode = ViewModel.Library.ResourceFilesSubRoot(sourceNode.ResourceType);
            }
            if (parentNode.GetChild(newFolderName) == null)
            {
                ResourceNode node = new ResourceNode(newFolderName, sourceNode.ResourceType);
                parentNode.Children.Add(node);
            }
            else
            {
                ViewModel.LogData.Add(LogLevel.Warn, "[{0}]下已存在同名目录[{1}]", selectPath.Replace(".", "/"), newFolderName);
            }
            dh.IsOpen = false;
        }