private void FillCategories(ObjectInventory.Entry entry, IndentedComboBox.Item item) { if (!entry.IsDirectory) { return; } if (entry.Deleted) { return; } IndentedComboBox.Item item2 = new IndentedComboBox.Item(); item2.Tag = entry; item2.Text = entry.DisplayName; item2.Image = entry.Icon; item.Add(item2); int num = 0; Inventory.Entry[] children = entry.Children; for (int i = 0; i < children.Length; i++) { ObjectInventory.Entry entry2 = (ObjectInventory.Entry)children[i]; if (entry2.IsDirectory) { this.FillCategories(entry2, item2); } else { num++; } } if (num > 0) { item2.SubText = "(" + num + ")"; } }
private void objectTree_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) { ObjectInventory.Entry entry = (ObjectInventory.Entry)e.Node.Tag; if (!this.IsNotRootEntry(entry)) { e.CancelEdit = true; } }
private void parentButton_Click(object sender, EventArgs e) { ObjectInventory.Entry entry = (ObjectInventory.Entry) this.categoryComboBox.SelectedItem.Tag; if (entry.IsValid) { this.categoryComboBox.SelectedItem = this.FindCategory((ObjectInventory.Entry)entry.Parent); } }
private void buttonRenameFolder_Click(object sender, EventArgs e) { ObjectInventory.Entry entry = (ObjectInventory.Entry) this.objectTree.Value; if (this.IsNotRootEntry(entry)) { return; } this.objectTree.SelectedNode.BeginEdit(); }
private void objectList_AfterLabelEdit(object sender, LabelEditEventArgs e) { if (e.CancelEdit) { return; } ObjectInventory.Entry entry = (ObjectInventory.Entry) this.objectList.Items[e.Item].Tag; entry.DisplayName = e.Label; this.UpdateProperties(); }
private void objectTree_AfterSelect(object sender, TreeViewEventArgs e) { if (this.m_dragging) { return; } ObjectInventory.Entry entry = (ObjectInventory.Entry)e.Node.Tag; this.m_root = entry; this.objectList.Entries = entry.Children; }
private void objectTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (e.CancelEdit) { return; } ObjectInventory.Entry entry = (ObjectInventory.Entry)e.Node.Tag; if (entry != null && entry.IsValid) { entry.DisplayName = e.Label; } }
private void objectList_SelectedIndexChanged(object sender, EventArgs e) { if (this.objectList.SelectedItems.Count == 0) { this.m_currentEntry = null; } else { this.m_currentEntry = (ObjectInventory.Entry) this.objectList.SelectedItems[0].Tag; } this.UpdateProperties(); }
private void objectList_DoubleClick(object sender, EventArgs e) { if (this.objectList.SelectedItems.Count == 0) { return; } ObjectInventory.Entry entry = (ObjectInventory.Entry) this.objectList.SelectedItems[0].Tag; if (entry.IsDirectory) { this.categoryComboBox.SelectedItem = this.FindCategory(entry); } }
private IndentedComboBox.Item FindCategory(ObjectInventory.Entry entry) { foreach (IndentedComboBox.Item current in this.categoryComboBox.GetItems()) { ObjectInventory.Entry entry2 = (ObjectInventory.Entry)current.Tag; if (entry2.Pointer == entry.Pointer) { return(current); } } return(null); }
private void objectTree_ItemDrag(object sender, ItemDragEventArgs e) { TreeNode treeNode = (TreeNode)e.Item; ObjectInventory.Entry entry = (ObjectInventory.Entry)treeNode.Tag; if (!this.IsNotRootEntry(entry)) { return; } this.OnDragStart(); this.objectTree.DoDragDrop(entry, DragDropEffects.Move); }
public ParamObjectInventoryTree(ObjectInventory.Entry searchDirectory) { this.InitializeComponent(); this.label1.Text = Localizer.Localize(this.label1.Text); this.label2.Text = Localizer.Localize(this.label2.Text); this.label3.Text = Localizer.Localize(this.label3.Text); this.label4.Text = Localizer.Localize(this.label4.Text); this.FillCategories((ObjectInventory.Entry)ObjectInventory.Instance.Root, this.categoryComboBox.Root); this.m_SearchItem = new IndentedComboBox.Item(); this.m_SearchItem.Tag = searchDirectory; this.m_SearchItem.Image = searchDirectory.Icon; this.SearchCriteria = searchDirectory.DisplayName; this.categoryComboBox.Root.Add(this.m_SearchItem); this.categoryComboBox.UpdateItems(); }
private void buttonNewFolder_Click(object sender, EventArgs e) { ObjectInventory.Entry entry = (ObjectInventory.Entry) this.objectTree.Value; if (!this.IsValidEntry(entry)) { return; } ObjectInventory.Entry entry2 = ObjectInventory.Instance.CreateDirectory(entry); if (!this.IsNotRootEntry(entry2)) { return; } entry2.DisplayName = "New folder"; this.objectTree.AddEntry(entry2); this.objectTree.SelectedNode.BeginEdit(); }
private void buttonAddTags_Click(object sender, EventArgs e) { if (MainForm.Instance.CurrentTool != ToolObject.Instance) { MessageBox.Show("The object tool must be active to perform this action."); return; } EditorObjectSelection selection = ToolObject.Instance.Selection; if (!selection.IsValid || selection.Count == 0) { MessageBox.Show("Must select one or more objects in the map to perform this action."); return; } using (PromptForm promptForm = new PromptForm("List of tags to add to selection")) { if (promptForm.ShowDialog() == DialogResult.OK) { string[] array = promptForm.Input.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (!string.IsNullOrEmpty(promptForm.Input)) { foreach (EditorObject current in selection.GetObjects()) { ObjectInventory.Entry entry = current.Entry; List <string> list = new List <string>(entry.Tags.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string item = array2[i]; if (!list.Contains(item)) { list.Add(item); } } list.Sort(); entry.Tags = string.Join(",", list.ToArray()); } } } } }
private void buttonDeleteFolder_Click(object sender, EventArgs e) { ObjectInventory.Entry entry = (ObjectInventory.Entry) this.objectTree.Value; if (!this.IsNotRootEntry(entry)) { return; } if (entry.Count > 0) { MessageBox.Show("Cannot delete a directory that is not empty."); return; } if (MessageBox.Show("Do you really want to delete the directory '" + entry.DisplayName + "'?", "Delete confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } entry.Deleted = true; this.objectTree.RemoveEntry(entry); }
private List <ObjectInventory.Entry> GetDragContent(IDataObject data) { List <ObjectInventory.Entry> list = new List <ObjectInventory.Entry>(); if (data.GetDataPresent(typeof(ObjectInventory.Entry))) { ObjectInventory.Entry item = data.GetData(typeof(ObjectInventory.Entry)) as ObjectInventory.Entry; list.Add(item); } else { if (data.GetDataPresent(typeof(ObjectInventory.Entry[]))) { ObjectInventory.Entry[] collection = data.GetData(typeof(ObjectInventory.Entry[])) as ObjectInventory.Entry[]; list.AddRange(collection); } } return(list); }
private void objectTree_DragDrop(object sender, DragEventArgs e) { Win32.SendMessage(this.objectTree.Handle, 4378, 0, 0); if (e.Effect != DragDropEffects.Move) { return; } Point pt = this.objectTree.PointToClient(new Point(e.X, e.Y)); TreeNode nodeAt = this.objectTree.GetNodeAt(pt); if (nodeAt == null) { return; } ObjectInventory.Entry entry; if (this.m_treeInsertMarkNode == null) { entry = (ObjectInventory.Entry)nodeAt.Tag; } else { entry = (ObjectInventory.Entry)nodeAt.Parent.Tag; } List <ObjectInventory.Entry> dragContent = this.GetDragContent(e.Data); foreach (ObjectInventory.Entry current in dragContent) { if (this.IsNotRootEntry(current)) { ObjectInventory.Entry entry2 = entry; while (entry2 != null && entry2.IsValid) { if (entry2 == current) { return; } entry2 = (ObjectInventory.Entry)entry2.Parent; } this.objectTree.BeginUpdate(); this.objectList.BeginUpdate(); this.objectTree.RemoveEntry(current); this.objectList.RemoveEntry(current); current.Parent = entry; if (this.m_treeInsertMarkNode != null) { int num = 0; Inventory.Entry[] children = entry.Children; for (int i = 0; i < children.Length; i++) { Inventory.Entry x = children[i]; if (x == (Inventory.Entry) this.m_treeInsertMarkNode.Tag) { entry.SetChildIndex(current, this.m_treeInsertMarkAfter ? (num + 1) : num); break; } num++; } } this.objectTree.AddEntry(current); this.objectTree.EndUpdate(); this.objectList.EndUpdate(); } } }