private void AddMusicToFlowLayoutPanel(string MusicPath) { MusicPanel MusicPanel = new MusicPanel(MusicPath); MusicPanel.DoubleClick += MusicPanel_DoubleClick; MusicPanel.Click += MusicPanel_Click; MusicPanel.MouseClick += MusicPanel_MouseClick; FlowLayoutPanelMusic.Controls.Add(MusicPanel); }
private void MusicPanel_Click(object sender, EventArgs e) { MusicPanel ClickedMusic = sender as MusicPanel; foreach (MusicPanel musicPanel in FlowLayoutPanelMusic.Controls) { musicPanel.BackColor = Color.Transparent; } ClickedMusic.BackColor = Color.FromArgb(28, 28, 28); }
private void MusicPanel_DoubleClick(object sender, EventArgs e) { MusicPanel ClickedMusic = sender as MusicPanel; for (int i = 0; i < FlowLayoutPanelMusic.Controls.Count; i++) { if (FlowLayoutPanelMusic.Controls[i] == ClickedMusic) { CurrentPlayingMusicIndex = i; MusicInitialize(ClickedMusic.MusicPath); } FlowLayoutPanelMusic.Controls[i].BackColor = Color.Transparent; } ClickedMusic.BackColor = Color.FromArgb(28, 28, 28); }
private void MusicPanel_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { MusicPanel ClickedMusic = sender as MusicPanel; // Change the Background color of the Clicked Music Panel, and reset the others background color foreach (MusicPanel musicPanel in FlowLayoutPanelMusic.Controls) { musicPanel.BackColor = Color.Transparent; } ClickedMusic.BackColor = Color.FromArgb(28, 28, 28); // Show the Context Menu Strip, on the Clicked Music Panel Point PointLowerLeft = new Point(0, ClickedMusic.Height); PointLowerLeft = ClickedMusic.PointToScreen(PointLowerLeft); this.MusicPanelContextMenuStrip.Show(PointLowerLeft); } }