private void RebuildIconSubmenu() { this.miIcon.MenuItems.Clear(); foreach (Image img in this.imgList) { IconMenuItem imi = new IconMenuItem("", img); imi.Click += new EventHandler(iconChange_Click); this.miIcon.MenuItems.Add(imi); } this.newIconItem = new IconMenuItem("New...", null, new EventHandler(iconChange_Click)); this.miIcon.MenuItems.Add(this.newIconItem); }
private void defaultPlatform_Click(object sender, System.EventArgs e) { IconMenuItem mItem = sender as IconMenuItem; if (mItem != null) { if (!ListViewContainsItem(this, mItem.Text)) { AddDefaultPlatform(mItem.Text); } else { ListViewItem selItem = FindPlatform(mItem.Text); if (selItem != null) { this.SelectedItems.Clear(); selItem.Selected = true; } } } }
private void iconChange_Click(object sender, EventArgs e) { if (!(sender is IconMenuItem)) { return; } IconMenuItem imi = sender as IconMenuItem; int imgIndex = 0; if (imi == this.newIconItem) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { try { Image img = Image.FromFile(ofd.FileName); this.imageList.Images.Add(img); this.imgList.Add(img); RebuildIconSubmenu(); imgIndex = this.imgList.IndexOf(img); } catch { MOG_Prompt.PromptResponse("Error", ofd.FileName + " is not a valid image file"); return; } } } else { imgIndex = this.imgList.IndexOf(imi.Image); } foreach (ListViewItem item in this.SelectedItems) { item.ImageIndex = imgIndex; } }