private void listBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { //select the item under the mouse pointer listBox1.SelectedIndex = listBox1.IndexFromPoint(e.Location); if (listBox1.SelectedIndex != -1) { var loc = e.Location; loc.Offset(listBox1.Location); viewfileinfo view = new viewfileinfo(); this.contextMenuStrip1.Show(this, loc); } } }
private void viewToolStripMenuItem_Click(object sender, EventArgs e) { viewfileinfo view = new viewfileinfo(); WMPLib.IWMPMedia media = axWindowsMediaPlayer1.newMedia(paths[listBox1.SelectedIndex]); view.attr[0] = media.getItemInfo("Track").ToString(); view.attr[1] = media.getItemInfo("Disc").ToString(); view.attr[2] = media.getItemInfo("BPM").ToString(); view.attr[3] = media.name.ToString(); view.attr[4] = media.getItemInfo("Artist").ToString(); view.attr[5] = media.getItemInfo("Album").ToString(); view.attr[6] = media.getItemInfo("Album Artist").ToString(); view.attr[7] = media.getItemInfo("Year").ToString(); view.attr[8] = media.getItemInfo("Genre").ToString(); view.attr[9] = media.getItemInfo("Comment").ToString(); view.attr[10] = media.getItemInfo("Composer").ToString(); view.attr[11] = media.getItemInfo("Publisher").ToString(); view.attr[12] = paths[listBox1.SelectedIndex]; view.Show(); }