GridClient client { get { return instance.Client; } }\r
Dictionary<UUID, TreeNode> FolderNodes = new Dictionary<UUID, TreeNode>();\r
\r
+ private UUID ignoreRenameUpdate = UUID.Zero;\r
private InventoryManager Manager;\r
private OpenMetaverse.Inventory Inventory;\r
private TreeNode invRootNode;\r
\r
void Store_OnInventoryObjectUpdated(InventoryBase oldObject, InventoryBase newObject)\r
{\r
+ if (newObject.UUID == ignoreRenameUpdate)\r
+ {\r
+ ignoreRenameUpdate = UUID.Zero;\r
+ return;\r
+ }\r
+\r
if (InvokeRequired)\r
{\r
BeginInvoke(new MethodInvoker(delegate()\r
InventoryFolder folder = (InventoryFolder)node.Tag;\r
ctxInv.Items.Clear();\r
\r
- ToolStripMenuItem ctxItem = new ToolStripMenuItem("Refresh", null, OnInvContextClick);\r
+ ToolStripMenuItem ctxItem;\r
+\r
+ ctxItem = new ToolStripMenuItem("Refresh", null, OnInvContextClick);\r
ctxItem.Name = "refresh";\r
ctxInv.Items.Add(ctxItem);\r
\r
if (folder.PreferredType == AssetType.Unknown)\r
{\r
ctxItem = new ToolStripMenuItem("Delete", null, OnInvContextClick);\r
- ctxItem.Name = "delete";\r
+ ctxItem.Name = "delete_folder";\r
ctxInv.Items.Add(ctxItem);\r
}\r
\r
ctxInv.Items.Add(ctxItem);\r
}\r
\r
+ if (folder.PreferredType == AssetType.Unknown)\r
+ {\r
+ ctxItem = new ToolStripMenuItem("Rename", null, OnInvContextClick);\r
+ ctxItem.Name = "rename_folder";\r
+ ctxInv.Items.Add(ctxItem);\r
+ }\r
+\r
+ ctxInv.Show(invTree, new Point(e.X, e.Y));\r
+ }\r
+ else if (node.Tag is InventoryItem)\r
+ {\r
+ InventoryItem item = (InventoryItem)node.Tag;\r
+ ctxInv.Items.Clear();\r
+\r
+ ToolStripMenuItem ctxItem;\r
+\r
+ ctxItem = new ToolStripMenuItem("Delete", null, OnInvContextClick);\r
+ ctxItem.Name = "delete_item";\r
+ ctxInv.Items.Add(ctxItem);\r
+\r
+ ctxItem = new ToolStripMenuItem("Rename", null, OnInvContextClick);\r
+ ctxItem.Name = "rename_item";\r
+ ctxInv.Items.Add(ctxItem);\r
\r
ctxInv.Show(invTree, new Point(e.X, e.Y));\r
+\r
}\r
Logger.Log("Right click on node: " + node.Name, Helpers.LogLevel.Debug, client);\r
}\r
return;\r
}\r
\r
+ string cmd = ((ToolStripMenuItem)sender).Name;\r
+\r
if (invTree.SelectedNode.Tag is InventoryFolder)\r
{\r
InventoryFolder f = (InventoryFolder)invTree.SelectedNode.Tag;\r
- string cmd = ((ToolStripMenuItem)sender).Name;\r
\r
switch (cmd)\r
{\r
client.Inventory.RequestFolderContents(f.UUID, f.OwnerID, true, true, InventorySortOrder.ByDate);\r
break;\r
\r
- case "delete":\r
+ case "delete_folder":\r
client.Inventory.MoveFolder(f.UUID, client.Inventory.FindFolderForType(AssetType.TrashFolder), f.Name);\r
break;\r
\r
case "empty_trash":\r
- client.Inventory.EmptyTrash();\r
+ {\r
+ DialogResult res = MessageBox.Show("Are you sure you want to empty your trash?", "Confirmation", MessageBoxButtons.OKCancel);\r
+ if (res == DialogResult.OK)\r
+ {\r
+ client.Inventory.EmptyTrash();\r
+ }\r
+ }\r
break;\r
\r
case "empty_lost_found":\r
- client.Inventory.EmptyLostAndFound();\r
+ {\r
+ DialogResult res = MessageBox.Show("Are you sure you want to empty your lost and found folder?", "Confirmation", MessageBoxButtons.OKCancel);\r
+ if (res == DialogResult.OK)\r
+ {\r
+ client.Inventory.EmptyLostAndFound();\r
+ }\r
+ }\r
+ break;\r
+\r
+ case "rename_folder":\r
+ invTree.SelectedNode.BeginEdit();\r
break;\r
\r
}\r
}\r
+ else if (invTree.SelectedNode.Tag is InventoryItem)\r
+ {\r
+ InventoryItem item = (InventoryItem)invTree.SelectedNode.Tag;\r
\r
- }\r
+ switch(cmd)\r
+ {\r
+ case "delete_item":\r
+ client.Inventory.MoveItem(item.UUID, client.Inventory.FindFolderForType(AssetType.TrashFolder));\r
+ break;\r
\r
+ case "rename_item":\r
+ invTree.SelectedNode.BeginEdit();\r
+ break;\r
+ }\r
+ }\r
+ }\r
#endregion\r
\r
\r
}\r
}\r
\r
+ private void invTree_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)\r
+ {\r
+ if (e.Node != null &&\r
+ e.Node.Tag is InventoryFolder &&\r
+ ((InventoryFolder)e.Node.Tag).PreferredType != AssetType.Unknown)\r
+ {\r
+ e.CancelEdit = true;\r
+ }\r
+ }\r
+\r
+ private void invTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)\r
+ {\r
+ if (string.IsNullOrEmpty(e.Label))\r
+ {\r
+ e.CancelEdit = true;\r
+ return;\r
+ }\r
+\r
+ if (e.Node.Tag is InventoryFolder)\r
+ {\r
+ InventoryFolder f = (InventoryFolder)e.Node.Tag;\r
+ f.Name = e.Label;\r
+ ignoreRenameUpdate = f.UUID;\r
+ client.Inventory.MoveFolder(f.UUID, f.ParentUUID, f.Name);\r
+ }\r
+ else if (e.Node.Tag is InventoryItem)\r
+ {\r
+ InventoryItem item = (InventoryItem)e.Node.Tag;\r
+ item.Name = e.Label;\r
+ ignoreRenameUpdate = item.UUID;\r
+ client.Inventory.MoveItem(item.UUID, item.ParentUUID, item.Name);\r
+ }\r
+\r
+ }\r
+\r
+ private void invTree_KeyUp(object sender, KeyEventArgs e)\r
+ {\r
+ if (e.KeyCode == Keys.F2 && invTree.SelectedNode != null)\r
+ {\r
+ invTree.SelectedNode.BeginEdit();\r
+ }\r
+ }\r
+\r
+ #region Drag and Drop\r
private void invTree_ItemDrag(object sender, ItemDragEventArgs e)\r
{\r
invTree.SelectedNode = e.Item as TreeNode;\r
- invTree.DoDragDrop(e.Item, DragDropEffects.Copy);\r
+ if (invTree.SelectedNode.Tag is InventoryFolder && ((InventoryFolder)invTree.SelectedNode.Tag).PreferredType != AssetType.Unknown)\r
+ {\r
+ return;\r
+ }\r
+ invTree.DoDragDrop(e.Item, DragDropEffects.Move);\r
+ }\r
+\r
+ private void invTree_DragDrop(object sender, DragEventArgs e)\r
+ {\r
+ TreeNode sourceNode = e.Data.GetData(typeof(TreeNode)) as TreeNode;\r
+ if (sourceNode == null) return;\r
+\r
+ Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));\r
+ TreeNode destinationNode = ((TreeView)sender).GetNodeAt(pt);\r
+\r
+ if (destinationNode == null) return;\r
+\r
+ if (sourceNode == destinationNode) return;\r
+\r
+ // If droping to item within folder drop to its folder\r
+ if (destinationNode.Tag is InventoryItem)\r
+ {\r
+ destinationNode = destinationNode.Parent;\r
+ }\r
+\r
+ InventoryFolder dest = destinationNode.Tag as InventoryFolder;\r
+\r
+ if (dest == null) return;\r
+\r
+ if (sourceNode.Tag is InventoryItem)\r
+ {\r
+ InventoryItem item = (InventoryItem)sourceNode.Tag;\r
+ client.Inventory.MoveItem(item.UUID, dest.UUID);\r
+ }\r
+ else if (sourceNode.Tag is InventoryFolder)\r
+ {\r
+ InventoryFolder f = (InventoryFolder)sourceNode.Tag;\r
+ client.Inventory.MoveFolder(f.UUID, dest.UUID);\r
+ }\r
+ }\r
+\r
+ private void invTree_DragEnter(object sender, DragEventArgs e)\r
+ {\r
+ TreeNode node = e.Data.GetData(typeof(TreeNode)) as TreeNode;\r
+ if (node == null)\r
+ {\r
+ e.Effect = DragDropEffects.None;\r
+ }\r
+ else\r
+ {\r
+ e.Effect = DragDropEffects.Move;\r
+ }\r
}\r
\r
- }\r
+ TreeNode highlightedNode = null;\r
+\r
+ private void invTree_DragOver(object sender, DragEventArgs e)\r
+ {\r
+ TreeNode node = e.Data.GetData(typeof(TreeNode)) as TreeNode;\r
+ if (node == null)\r
+ {\r
+ e.Effect = DragDropEffects.None;\r
+ }\r
+\r
+ Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));\r
+ TreeNode destinationNode = ((TreeView)sender).GetNodeAt(pt);\r
+\r
+ if (highlightedNode != destinationNode)\r
+ {\r
+ if (highlightedNode != null)\r
+ {\r
+ highlightedNode.BackColor = invTree.BackColor;\r
+ highlightedNode = null;\r
+ }\r
+\r
+ highlightedNode = destinationNode;\r
+ highlightedNode.BackColor = Color.LightSlateGray;\r
+ }\r
+\r
+ if (destinationNode == null)\r
+ {\r
+ e.Effect = DragDropEffects.None;\r
+ return;\r
+ }\r
+\r
+ e.Effect = DragDropEffects.Move;\r
+\r
+ }\r
+ #endregion\r
+\r
+ }\r
\r
// Create a node sorter that implements the IComparer interface.\r
public class InvNodeSorter : IComparer\r