//
// Radegast Metaverse Client
-// Copyright (c) 2009, Radegast Development Team
+// Copyright (c) 2009-2014, Radegast Development Team
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
private RadegastInstance instance;
private GridClient client { get { return instance.Client; } }
private InventoryNotecard notecard;
- private AssetNotecard recievedNotecard;
+ private AssetNotecard receivedNotecard;
private Primitive prim;
public Notecard(RadegastInstance instance, InventoryNotecard notecard)
{
if (InvokeRequired)
{
- BeginInvoke(new MethodInvoker(delegate()
- {
- Assets_OnAssetReceived(transfer, asset);
- }
- ));
+ if (!instance.MonoRuntime || IsHandleCreated)
+ BeginInvoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
return;
}
{
AssetNotecard n = (AssetNotecard)asset;
n.Decode();
- recievedNotecard = n;
+ receivedNotecard = n;
string noteText = string.Empty;
rtbContent.Clear();
titem.Name = item.UUID.ToString(); ;
titem.Tag = item;
titem.Click += new EventHandler(attachmentMenuItem_Click);
+
+ var saveToInv = new ToolStripMenuItem("Save to inventory");
+ saveToInv.Click += (object xsender, EventArgs xe) =>
+ {
+ client.Inventory.RequestCopyItemFromNotecard(UUID.Zero,
+ notecard.UUID,
+ client.Inventory.FindFolderForType(item.AssetType),
+ item.UUID,
+ Inventory_OnInventoryItemCopied);
+ };
+
+ titem.DropDownItems.Add(saveToInv);
tbtnAttachments.DropDownItems.Add(titem);
}
}
else
{
UpdateStatus("Failed");
- rtbContent.Text = "Failed to download notecard.";
+ rtbContent.Text = "Failed to download notecard. " + transfer.Status;
+ }
+ }
+
+ private void Inventory_OnInventoryItemCopied(InventoryBase item)
+ {
+ if (InvokeRequired)
+ {
+ if (!instance.MonoRuntime || IsHandleCreated)
+ BeginInvoke(new MethodInvoker(() => Inventory_OnInventoryItemCopied(item)));
+ return;
+ }
+
+ if (null == item) return;
+
+ instance.TabConsole.DisplayNotificationInChat(
+ string.Format("{0} saved to inventory", item.Name),
+ ChatBufferTextStyle.Invisible);
+
+ tlblStatus.Text = "Saved";
+
+ if (item is InventoryNotecard)
+ {
+ Notecard nc = new Notecard(instance, (InventoryNotecard)item);
+ nc.pnlKeepDiscard.Visible = true;
+ nc.ShowDetached();
}
}
Landmark ln = new Landmark(instance, (InventoryLandmark)item);
ln.ShowDetached();
break;
+
+ case AssetType.Notecard:
+ client.Inventory.RequestCopyItemFromNotecard(UUID.Zero,
+ notecard.UUID,
+ notecard.ParentUUID,
+ item.UUID,
+ Inventory_OnInventoryItemCopied);
+ break;
}
}
}
n.BodyText = rtbContent.Text;
n.EmbeddedItems = new List<InventoryItem>();
- if (recievedNotecard != null)
+ if (receivedNotecard != null)
{
- for (int i = 0; i < recievedNotecard.EmbeddedItems.Count; i++)
+ for (int i = 0; i < receivedNotecard.EmbeddedItems.Count; i++)
{
- n.EmbeddedItems.Add(recievedNotecard.EmbeddedItems[i]);
+ n.EmbeddedItems.Add(receivedNotecard.EmbeddedItems[i]);
int indexChar = 0xdc00 + i;
n.BodyText += (char)0xdbc0;
n.BodyText += (char)indexChar;
{
if (InvokeRequired)
{
- BeginInvoke(new MethodInvoker(delegate() { UpdateStatus(status); }));
+ if (!instance.MonoRuntime || IsHandleCreated)
+ BeginInvoke(new MethodInvoker(() => UpdateStatus(status)));
return;
}
instance.TabConsole.DisplayNotificationInChat("Notecard status: " + status, ChatBufferTextStyle.Invisible);
instance.TabConsole.DisplayNotificationInChat("Editing notecard", ChatBufferTextStyle.Invisible);
}
+ private void btnKeep_Click(object sender, EventArgs e)
+ {
+ Retach();
+ }
+
+ private void btnDiscard_Click(object sender, EventArgs e)
+ {
+ client.Inventory.MoveItem(notecard.UUID, client.Inventory.FindFolderForType(FolderType.Trash), notecard.Name);
+ Retach();
+ }
}
}