/// <summary> /// Occurs when user Right-Clicks an item and chooses Download /// Connects to SL to download a single InventoryItem /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void downloadToolStripMenuItem_Click(object sender, EventArgs e) { try { if (!String.IsNullOrEmpty((String)treeView1.SelectedNode.Tag)) { if ((((String)treeView1.SelectedNode.Tag) == "notecard") || (((String)treeView1.SelectedNode.Tag) == "lsl") || (((String)treeView1.SelectedNode.Tag) == "snapshot") || (((String)treeView1.SelectedNode.Tag) == "texture") || (((String)treeView1.SelectedNode.Tag) == "rootcategory")) { //Get the SLMIV object for this item Item SLMIVItem; InventoryNotecard notecard; string ObjectsKey = treeView1.SelectedNode.Name; int ivalue = 0; MIUtils.OD_treeindex.TryGetValue(ObjectsKey, out ivalue); MIUtils.INV_TYPE objtype = new MIUtils.INV_TYPE(); Object objectinfo = new Object(); if (ivalue != -1) { objectinfo = MIUtils.GetMyInventoryObject(ivalue, out objtype); if (objtype == MIUtils.INV_TYPE.ITEM) { SLMIVItem = ((Item)objectinfo); Console.WriteLine("[SLMIV]: Retreiving " + treeView1.SelectedNode.Text + ", " + treeView1.SelectedNode.Name); //Check to make sure currently online if (client.Network.Connected) { LLUUID uuid = new LLUUID(); uuid = LLUUID.Parse(treeView1.SelectedNode.Name); InventoryItem item = new InventoryItem(uuid); if (libsecItemDict.TryGetValue(uuid, out item)) { if ((item.AssetType == AssetType.Notecard) || (item.AssetType == AssetType.LSLText)) { frmNotecardEditor notecEdfrm = new frmNotecardEditor(item, this.client, this.netcom, imageListTreeView); notecEdfrm.ItemTreeNode = treeView1.SelectedNode;//Pass the TreeNode so it has its fullpath notecEdfrm.Show(); } else if (item.AssetType == AssetType.Texture) { //Show ImageViewerForm iviewer = new ImageViewerForm(item, client, netcom, imageListTreeView, imageCache); iviewer.ItemTreeNode = treeView1.SelectedNode;//Pass the TreeNode so it has its fullpath iviewer.Show(); } } } else { MessageBox.Show("Can not download because you are not currently connected to the online grid.", "Can Not Download", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { //Exception ?? Really? Please tell me why MessageBox.Show("ERROR: Can not download because the selected item in the inventory tree [" + treeView1.SelectedNode.Text + "] is not found in MIUtils.OD_treeindex.", "Can Not Download", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Can not download because the selected item in the inventory tree [" + treeView1.SelectedNode.Text + "] is not a Notecard or LSL script.", "Can Not Download", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception) { } }
/// <summary> /// Event occurs when a mouse button is pressed down /// Right-Click events handled here with ContextMenuStrip /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void treeView1_MouseDown(object sender, MouseEventArgs e) { try { try { //Copy the node selected... selectedTreeNode = (TreeNode)(treeView1.GetNodeAt(e.X, e.Y).Clone()); //***DO SELECTION STUFF*** int startingImage = selectedTreeNode.ImageIndex; selectedTreeNode.SelectedImageIndex = startingImage; //Set Selection... treeView1.SelectedNode = selectedTreeNode; treeView1.Update(); //Get Folder or Item Object Info tbOutput.Clear(); string ObjectsKey = selectedTreeNode.Name; int ivalue = 0; MIUtils.OD_treeindex.TryGetValue(ObjectsKey, out ivalue); MIUtils.INV_TYPE objtype = new MIUtils.INV_TYPE(); Object objectinfo = new Object(); if (ivalue != -1) { objectinfo = MIUtils.GetMyInventoryObject(ivalue, out objtype); if (objtype == MIUtils.INV_TYPE.FOLDER) { tbOutput.AppendText(((Folder)objectinfo).ToString()); } else//must be item... { tbOutput.AppendText(((Item)objectinfo).ToString()); } } //If the starting image was a folder, then update... if (startingImage == 0 || startingImage == 1) { if (selectedTreeNode.IsExpanded) { selectedTreeNode.ImageIndex = 1;//then open folder } else { selectedTreeNode.ImageIndex = 0;//if closed folder } } #region If RIGHT-CLICK... //If RIGHT-CLICK... if (e.Button == MouseButtons.Right) { //***DISPLAY RIGHT-CLICK CONTEXTMENU*** try { //Copy the node selected... selectedTreeNode = (TreeNode)(treeView1.GetNodeAt(e.X, e.Y).Clone()); fullpath_ofnode = treeView1.GetNodeAt(e.X, e.Y).FullPath; //Let's select this node instead of the last selected node //treeView1.SelectedNode = selectedTreeNode; //treeView1.Update(); //Display the contextmenu if it is not the Trash can... if (selectedTreeNode.Text == "Trash" || selectedTreeNode.Text == "TrashFolder") { DialogResult dResult = MessageBox.Show("Empty Trash?", "Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dResult == DialogResult.Yes) { //Delete all of the nodes under Trash foreach (TreeNode originalNode in this.selectedTreeNode.Nodes) { RemoveTreeViewNode(originalNode); } //Log it Logs.LogEntry("Empty Trash", File.AppendText(Common.MainLog)); } else if (dResult == DialogResult.No) { } else if (dResult == DialogResult.Cancel) { } } else //not Trash can { //Do we enable 'Open' ??... if (objtype == MIUtils.INV_TYPE.FOLDER) { this.openToolStripMenuItem.Enabled = false; } else//must be item... { //Let's enable the Open choice this.openToolStripMenuItem.Enabled = true; //Let's disable the open if there is no image attached if (((Item)objectinfo).type != "landmark") { //Create SLMIVImage which reads the ImageLog SLMIVImage NodeImage = new SLMIVImage(Common.ImageLog); if (NodeImage.sbImageLog.ToString().IndexOf(selectedTreeNode.Name) != -1) { this.openToolStripMenuItem.Enabled = true; } else this.openToolStripMenuItem.Enabled = false; } //Let's examine for Download feature for Notecards, LSL, and other if (((Item)objectinfo).type == "notecard" || ((Item)objectinfo).type == "lsl" || ((Item)objectinfo).type == "lsltext" || ((Item)objectinfo).type == "texture" || ((Item)objectinfo).type == "snapshot") { this.downloadToolStripMenuItem.Enabled = true; } else { this.downloadToolStripMenuItem.Enabled = false; } } //now show RIGHTCLICK MENU... this.ContextMenuStrip = contextMenuStrip1; // this.ContextMenuStrip.Show();//FIX: stop first display somewhere else //Need to refresh or ToolTips will be lost treeView1.Refresh(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion If RIGHT-CLICK... //Scroll to the last line and right justified tbOutput.AppendText("\r\n"); tbOutput.ScrollToCaret(); } catch (Exception) { //If clicking on nothing in treeview1, exception is thrown } } catch (Exception ex) { MessageBox.Show("treeView1_MouseDown Error: " + ex.Message, "MouseDown Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }