using System;
using System.Threading;
using libsecondlife;
namespace libsecondlife
{
class InventoryTools
{
InventoryManager iManager = null;
public InventoryTools(SecondLife client)
{
iManager = client.Inventory;
iManager.RequestFolderContents(iManager.Store.RootFolder, client.Network.AgentID, true, false, false, InventorySortOrder.ByName);
}
public void CreateNotecard(string name, string desc, string body)
{
iManager.BeginCreateItemFromAsset(CreateNotecardAsset(body), name, desc, AssetType.Notecard, InventoryType.Notecard, iManager.FindFolderForType(AssetType.Notecard), this.ItemCreatedCallback);
}
public void ItemCreatedCallback(bool success, InventoryItem item)
{
}
///
///
///
public static byte[] CreateNotecardAsset (string body)
{
// Format the string body into Linden text
string lindenText = "Linden text version 1\n";
lindenText += "{\n";
lindenText += "LLEmbeddedItems version 1\n";
lindenText += "{\n";
lindenText += "count 0\n";
lindenText += "}\n";
lindenText += "Text length " + body.Length + "\n";
lindenText += body;
lindenText += "}\n";
// Assume this is a string, add 1 for the null terminator
byte[] stringBytes = System.Text.Encoding.UTF8.GetBytes((string)lindenText);
byte[] assetData = new byte[stringBytes.Length + 1];
Array.Copy(stringBytes, 0, assetData, 0, stringBytes.Length);
return assetData;
}
}
}