Files
libremetaverse/libsecondlife-cs/examples/TestClient/Commands/InventoryCommand.cs
lonecoder c9054f3b70 Added full InstantMessageDialog enum info.
Added new InstantMessage override for sending dialog responses.
Added InventoryCommand to TestClient
Added response to InventoryOffer messages for TestClient, but it appears to be cosmetic and has nothing to do with the actual inventory transfer.

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@819 52acb1d6-8a22-11de-b505-999d5b087335
2007-01-09 04:56:12 +00:00

60 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Xml;
using System.Xml.Serialization;
using libsecondlife;
using libsecondlife.Packets;
using libsecondlife.InventorySystem;
namespace libsecondlife.TestClient
{
public class InventoryCommand : Command
{
public InventoryCommand(TestClient testClient)
{
Name = "i";
Description = "Prints out inventory.";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
Client.Inventory.DownloadInventory();
StringBuilder result = new StringBuilder();
PrintFolder(Client.Inventory.GetRootFolder(), result, 0);
return result.ToString();
}
void PrintFolder(InventoryFolder folder, StringBuilder output, int indenting)
{
Indent(output, indenting);
output.Append(folder.Name);
output.Append("\n");
foreach (InventoryBase b in folder.GetContents())
{
InventoryItem item = b as InventoryItem;
if (item != null)
{
Indent(output, indenting + 1);
output.Append(item.Name);
output.Append("\n");
continue;
}
InventoryFolder subFolder = b as InventoryFolder;
if (subFolder != null)
PrintFolder(subFolder, output, indenting + 1);
}
}
void Indent(StringBuilder output, int indenting)
{
for (int count = 0; count < indenting; count++)
{
output.Append(" ");
}
}
}
}