本文整理汇总了C#中NBTExplorer.Model.DataNode类的典型用法代码示例。如果您正苦于以下问题:C# DataNode类的具体用法?C# DataNode怎么用?C# DataNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataNode类属于NBTExplorer.Model命名空间,在下文中一共展示了DataNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindBlock
public FindBlock (DataNode searchRoot)
{
InitializeComponent();
_searchRoot = searchRoot;
_groupX = new CoordinateGroup() {
RegionBox = _regionXTextBox,
ChunkBox = _chunkXTextBox,
BlockBox = _blockXTextBox,
LocalChunkBox = _localChunkXTextBox,
LocalBlockBox = _localBlockXTextBox,
};
_groupZ = new CoordinateGroup() {
RegionBox = _regionZTextBox,
ChunkBox = _chunkZTextBox,
BlockBox = _blockZTextBox,
LocalChunkBox = _localChunkZTextBox,
LocalBlockBox = _localBlockZTextBox,
};
ApplyRegion(_groupX, "0", true);
ApplyRegion(_groupZ, "0", true);
Validate();
}
示例2: Process
public override bool Process(DataNode dataNode, ConsoleOptions options)
{
string value = options.Values[0];
TagDataNode tagDataNode = dataNode as TagDataNode;
return tagDataNode.Parse(value);
}
示例3: FindReplace
public FindReplace (MainForm main, NodeTreeController controller, DataNode searchRoot)
{
InitializeComponent();
_main = main;
_mainController = controller;
_mainSearchRoot = searchRoot;
_findController = new RuleTreeController(treeView1);
treeView1.NodeMouseDoubleClick += (s, e) => {
_findController.EditSelection();
};
//_findController.VirtualRootDisplay = "Find Rules";
_replaceController = new NodeTreeController(treeView2);
treeView2.NodeMouseDoubleClick += (s, e) => {
_replaceController.EditSelection();
};
_replaceController.VirtualRootDisplay = "Replacement Tags";
_explorerStrip.Renderer = new ToolStripExplorerRenderer();
_explorerStrip.ImageList = _mainController.IconList;
_explorerManager = new ExplorerBarController(_explorerStrip, _mainController.IconRegistry, _mainController.IconList, searchRoot);
_explorerManager.SearchRootChanged += (s, e) => {
_mainSearchRoot = _explorerManager.SearchRoot;
Reset();
};
}
示例4: Process
public override bool Process (DataNode dataNode, ConsoleOptions options)
{
if (options.Values.Count == 0)
return false;
string jsonPath = options.Values[0];
using (FileStream stream = File.OpenWrite(jsonPath)) {
using (StreamWriter writer = new StreamWriter(stream)) {
if (dataNode is TagDataNode) {
TagDataNode tagNode = dataNode as TagDataNode;
WriteNbtTag(writer, tagNode.Tag);
}
else if (dataNode is NbtFileDataNode) {
dataNode.Expand();
TagNodeCompound root = new TagNodeCompound();
foreach (DataNode child in dataNode.Nodes) {
TagDataNode childTagNode = child as TagDataNode;
if (childTagNode == null)
continue;
if (childTagNode.Tag != null)
root.Add(childTagNode.NodeName, childTagNode.Tag);
}
WriteNbtTag(writer, root);
}
}
}
return true;
}
示例5: CanProcess
public override bool CanProcess (DataNode dataNode)
{
if (!(dataNode is TagListDataNode))
return false;
return true;
}
示例6: ExpandDataNode
private DataNode ExpandDataNode(DataNode dataNode, string tagPath)
{
string[] pathParts = tagPath.Split('/');
DataNode curTag = dataNode;
curTag.Expand();
foreach (var part in pathParts) {
TagDataNode.Container container = curTag as TagDataNode.Container;
if (curTag == null)
throw new Exception("Invalid tag path");
DataNode childTag = null;
foreach (var child in curTag.Nodes) {
if (child.NodePathName == part)
childTag = child;
}
if (childTag == null)
throw new Exception("Invalid tag path");
curTag.Expand();
}
return curTag;
}
示例7: CanProcess
public override bool CanProcess(DataNode dataNode)
{
if (!(dataNode is TagDataNode) || !dataNode.CanEditNode)
return false;
if (dataNode is TagByteArrayDataNode || dataNode is TagIntArrayDataNode)
return false;
return true;
}
示例8: ExplorerBarController
public ExplorerBarController (ToolStrip toolStrip, IconRegistry registry, ImageList iconList, DataNode rootNode)
{
_explorerStrip = toolStrip;
_registry = registry;
_iconList = iconList;
_rootNode = rootNode;
Initialize();
}
示例9: Print
public static string Print(DataNode node, bool showType)
{
if (!_key.ContainsKey(node.GetType()))
return "";
if (showType)
return "<" + _key[node.GetType()] + "> " + node.NodeDisplay;
else
return node.NodeDisplay;
}
示例10: Process
public override bool Process (DataNode dataNode, ConsoleOptions options)
{
Console.WriteLine(TypePrinter.Print(dataNode, options.ShowTypes));
if (dataNode.IsContainerType) {
foreach (var child in dataNode.Nodes)
Console.WriteLine(" | " + TypePrinter.Print(child, options.ShowTypes));
}
return true;
}
示例11: PrintSubTree
private void PrintSubTree (DataNode dataNode, ConsoleOptions options, string indent, bool last)
{
Console.WriteLine(indent + " + " + TypePrinter.Print(dataNode, options.ShowTypes));
indent += last ? " " : " |";
int cnt = 0;
dataNode.Expand();
foreach (DataNode child in dataNode.Nodes) {
cnt++;
PrintSubTree(child, options, indent, cnt == dataNode.Nodes.Count);
}
}
示例12: Process
public override bool Process (DataNode dataNode, ConsoleOptions options)
{
TagListDataNode listNode = dataNode as TagListDataNode;
listNode.Clear();
foreach (string value in options.Values) {
TagNode tag = TagDataNode.DefaultTag(listNode.Tag.ValueType);
TagDataNode tagData = TagDataNode.CreateFromTag(tag);
if (!tagData.Parse(value))
return false;
if (!listNode.AppendTag(tagData.Tag))
return false;
}
return true;
}
示例13: Search
private DataNode Search (DataNode node)
{
if (node is DirectoryDataNode) {
DirectoryDataNode dirNode = node as DirectoryDataNode;
if (!dirNode.IsExpanded)
dirNode.Expand();
foreach (var subNode in dirNode.Nodes) {
DataNode resultNode = Search(subNode);
if (resultNode != null)
return resultNode;
}
return null;
}
else if (node is RegionFileDataNode) {
RegionFileDataNode regionNode = node as RegionFileDataNode;
int rx, rz;
if (!RegionFileDataNode.RegionCoordinates(regionNode.NodePathName, out rx, out rz))
return null;
if (rx != _groupX.Region.Value || rz != _groupZ.Region.Value)
return null;
if (!regionNode.IsExpanded)
regionNode.Expand();
foreach (var subNode in regionNode.Nodes) {
DataNode resultNode = Search(subNode);
if (resultNode != null)
return resultNode;
}
return null;
}
else if (node is RegionChunkDataNode) {
RegionChunkDataNode chunkNode = node as RegionChunkDataNode;
if (chunkNode.X != _groupX.LocalChunk.Value || chunkNode.Z != _groupZ.LocalChunk.Value)
return null;
return chunkNode;
}
return null;
}
示例14: RefreshChildNodes
private void RefreshChildNodes(TreeNode node, DataNode dataNode)
{
Dictionary<DataNode, TreeNode> currentNodes = new Dictionary<DataNode, TreeNode>();
foreach (TreeNode child in node.Nodes) {
if (child.Tag is DataNode)
currentNodes.Add(child.Tag as DataNode, child);
}
node.Nodes.Clear();
foreach (DataNode child in dataNode.Nodes) {
if (!currentNodes.ContainsKey(child))
node.Nodes.Add(CreateUnexpandedNode(child));
else
node.Nodes.Add(currentNodes[child]);
}
foreach (TreeNode child in node.Nodes)
child.ContextMenuStrip = BuildNodeContextMenu(child.Tag as DataNode);
if (node.Nodes.Count == 0 && dataNode.HasUnexpandedChildren) {
ExpandNode(node);
node.Expand();
}
}
示例15: PasteIntoNodePred
private bool PasteIntoNodePred(DataNode dataNode, out GroupCapabilities caps)
{
caps = dataNode.PasteIntoNodeCapabilities;
return (dataNode != null) && dataNode.CanPasteIntoNode;
}