Exemplo n.º 1
0
 private static void ExitIfDirEmpty(DirectoryDataNode dir)
 {
     if (!dir.IsExpanded)
     {
         dir.Expand();
     }
     if (dir.Nodes.Count == 0)
     {
         Exit("Directory " + dir.NodeDirPath + " is empty.");
     }
 }
Exemplo n.º 2
0
        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);
        }