void menuItem_Click(object sender, EventArgs e) { ToolStripItem menuItem = (ToolStripItem)sender; string name = listView1.SelectedItems[0].Text; if (menuItem.Name == "play") { SingleConnection.send(name); // send the name of the song that pressed this.Hide(); Buttons_Form bf = new Buttons_Form(); bf.ShowDialog(); } if (menuItem.Name == "Play from the last viewing point") { SingleConnection.send(name + "#" + this.movie_time_dict[name]); this.Hide(); this.time = (this.movie_time_dict[name] / 3) + 1; Console.WriteLine(this.time); this.with_for = true; using (Loading_Form f_load = new Loading_Form(SaveData)) { f_load.ShowDialog(this); } Buttons_Form bf = new Buttons_Form(); bf.ShowDialog(); } if (menuItem.Name == "Download for later viewing") { this.Hide(); SingleConnection.send("Download@" + name); this.with_for = false; Thread download_thread = new Thread(new ThreadStart(this.download)); download_thread.Start(); using (Loading_Form f_load = new Loading_Form(SaveData)) { f_load.ShowDialog(this); } Select_Video_Form f1 = new Select_Video_Form(); f1.ShowDialog(); } if (menuItem.Name == "Play without connection") { SingleConnection.send("play_without_connection!" + name); this.Hide(); Buttons_Form bf = new Buttons_Form(); bf.ShowDialog(); } }
private void listView1_MouseClick(object sender, MouseEventArgs e) { string name = listView1.SelectedItems[0].Text; if (e.Button == MouseButtons.Right) { ContextMenuStrip menuStrip = new ContextMenuStrip(); ToolStripMenuItem menuItem1 = new ToolStripMenuItem("Play"); menuStrip.Items.Add(menuItem1); menuItem1.Click += new EventHandler(menuItem_Click); menuItem1.Name = "play"; if (video_is_download(name)) { ToolStripMenuItem menuItem4 = new ToolStripMenuItem("Play without connection"); menuStrip.Items.Add(menuItem4); menuItem4.Click += new EventHandler(menuItem_Click); menuItem4.Name = "Play without connection"; } else { ToolStripMenuItem menuItem4 = new ToolStripMenuItem("Download for later viewing"); menuStrip.Items.Add(menuItem4); menuItem4.Click += new EventHandler(menuItem_Click); menuItem4.Name = "Download for later viewing"; } if (this.movie_time_dict.ContainsKey(name)) { ToolStripMenuItem menuItem2 = new ToolStripMenuItem("Play from the last viewing point- " + this.movie_time_dict[name] + " sec"); menuStrip.Items.Add(menuItem2); menuItem2.Click += new EventHandler(menuItem_Click); menuItem2.Name = "Play from the last viewing point"; } if (this.movie_rate_dict.ContainsKey(name)) { ToolStripMenuItem menuItem3 = new ToolStripMenuItem("Rate: " + this.movie_rate_dict[name]); menuStrip.Items.Add(menuItem3); } this.ContextMenuStrip = menuStrip; } else { SingleConnection.send(name); // send the name of the song that pressed this.Hide(); Buttons_Form bf = new Buttons_Form(); bf.Show(); } }