private void menuItem_AddToPreviousCollection_Click(object sender, EventArgs e) { ListViewItem lvi = listview_Textures.SelectedItems[0]; System.Diagnostics.Debug.Assert(lvi != null); Editor.TextureCollection collection = GetTextureCollection(m_collection_added_to); collection.AddTexture(lvi.Text); }
private void listview_Textures_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (listview_Textures.FocusedItem.Bounds.Contains(e.Location) == true) { string selected_texture = listview_Textures.SelectedItems[0].Text; //Clear context menu so we can add items to it m_texture_context_menu.MenuItems.Clear(); //Add "Add to Previous" if there's a previous and it still exists and this texture's not in it if (!String.IsNullOrEmpty(m_collection_added_to)) { Editor.TextureCollection collection = GetTextureCollection(m_collection_added_to); if ((collection != null) && !collection.Contains(selected_texture)) { m_texture_context_menu.MenuItems.Add(new MenuItem("Add to '" + EscapeAmpersands(m_collection_added_to) + "'", menuItem_AddToPreviousCollection_Click)); } } //Add "Add to Collection" if there are collections that this texture isn't already in MenuItem menuItem_Add = new MenuItem("Add to Collection"); foreach (Editor.TextureCollection collection in editor.TextureCollections) { if (!collection.Contains(selected_texture)) { menuItem_Add.MenuItems.Add(EscapeAmpersands(collection.Name), menuItem_AddToCollection_Click); } } if (menuItem_Add.MenuItems.Count > 0) { m_texture_context_menu.MenuItems.Add(menuItem_Add); } //Add "Remove from Collection" if there's a selected collection and it contails the selected texture if (comboBox_TextureCollection.SelectedIndex > -1) { Editor.TextureCollection collection = GetSelectedTextureCollection(); if (collection.Contains(selected_texture)) { m_texture_context_menu.MenuItems.Add(new MenuItem("Remove from Collection", menuItem_DeleteFromCollection_Click)); } } //If there are no items, add one if (m_texture_context_menu.MenuItems.Count == 0) { MenuItem empty_item = new MenuItem("All texture collections already contain this texture"); empty_item.Enabled = false; m_texture_context_menu.MenuItems.Add(empty_item); } //Show the menu m_texture_context_menu.Show((Control)sender, e.Location); } } }
private void menuItem_AddToCollection_Click(object sender, EventArgs e) { if (listview_Textures.SelectedItems.Count > 0) { ListViewItem lvi = listview_Textures.SelectedItems[0]; System.Diagnostics.Debug.Assert(lvi != null); Editor.TextureCollection collection = editor.TextureCollections.Find(c => EscapeAmpersands(c.Name) == ((MenuItem)sender).Text); collection.AddTexture(lvi.Text); m_collection_added_to = collection.Name; } }
private void button_DeleteCollection_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure you want to delete colleciton '" + comboBox_TextureCollection.SelectedItem + "'?", "Delete Texture Collection", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Editor.TextureCollection collection = GetSelectedTextureCollection(); editor.TextureCollections.Remove(collection); comboBox_TextureCollection.Items.Remove(comboBox_TextureCollection.SelectedItem); comboBox_TextureCollection.SelectedItem = -1; ListViewUpdate(); CollectionControlsUpdate(); } }
private void ListViewUpdate() { string filter_text = textBox_Filter.Text; listview_Textures.BeginUpdate(); listview_Textures.Items.Clear(); if (comboBox_TextureCollection.SelectedIndex > -1) { Editor.TextureCollection collection = GetSelectedTextureCollection(); foreach (string texture in collection.EnumerateTexturesSorted()) { ListViewItem item = m_list_items.FirstOrDefault(i => i.Text == texture); if (item != null) { listview_Textures.Items.Add(item); } } } else if (string.IsNullOrEmpty(filter_text)) { foreach (ListViewItem item in m_list_items) { listview_Textures.Items.Add(item); } } else { foreach (ListViewItem item in m_list_items) { if (System.Globalization.CultureInfo.CurrentCulture.CompareInfo.IndexOf(item.Text, filter_text, System.Globalization.CompareOptions.IgnoreCase) >= 0) { listview_Textures.Items.Add(item); } } } listview_Textures.EndUpdate(); }
private void menuItem_DeleteFromCollection_Click(object sender, EventArgs e) { Editor.TextureCollection collection = GetSelectedTextureCollection(); collection.RemoveTexture(listview_Textures.SelectedItems[0].Text); ListViewUpdate(); }