コード例 #1
0
        private async void LoadMusicPanels(List <MusicElement> URLS)
        {
            panel2.Controls.Clear();

            PictureBox pb = new PictureBox()
            {
                Size     = new Size(Parent.Width, Parent.Height),
                Location = new Point(0, 0),
                Padding  = new Padding(Width / 2 - 32 - SystemInformation.VerticalScrollBarWidth, (Height - this.VerticalScroll.Value) / 4, 0, 0),
                Image    = Properties.Resources._5,
                Anchor   = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom)
            };

            panel2.Controls.Add(pb);

            foreach (var i in URLS.Reverse <MusicElement>())
            {
                MusicPanel panel = new MusicPanel()
                {
                    URL = i.URL, TrackName = i.trackName, Author = i.author, Duration = i.duration
                };

                panel2.Controls.Add(panel);

                await Task.Delay(1);
            }

            panel2.Controls.OfType <MusicPanel>().AsParallel().ForAll(x =>
            {
                x.Click       += Panel_Click;
                x.DoubleClick += btn_Play_Click;
                x.Controls.OfType <Control>().AsParallel().ForAll(y => { y.Click += Panel_Click; y.DoubleClick += btn_Play_Click; });
            });
            pb.Dispose();
        }
コード例 #2
0
        private void SelectPanel(MusicPanel panel)
        {
            if (curPanel != null && curPanel != playingPanel)
            {
                curPanel.BackColor = SystemColors.ControlLightLight;
            }

            curPanel = panel;

            if (curPanel != playingPanel)
            {
                curPanel.BackColor = Color.Green;
            }

            index = panel2.Controls.IndexOf(curPanel);
        }
コード例 #3
0
 private void btn_Play_Click(object sender, EventArgs e)
 {
     if (curPanel != null)
     {
         if (wmp.playState == WMPPlayState.wmppsPaused)
         {
             button1.Text = "Pause";
         }
         if (playingPanel != null)
         {
             playingPanel.BackColor = SystemColors.Control;
         }
         playingPanel           = curPanel;
         playingPanel.BackColor = Color.Beige;
         lbl_Title.Text         = curPanel.TrackName;
         lbl_Compositor.Text    = curPanel.Author;
         wmp.URL = curPanel.URL;
         wmp.controls.play();
     }
 }
コード例 #4
0
        private void Panel_Click(object sender, EventArgs e)
        {
            MusicPanel panel = sender.GetType() != typeof(MusicPanel) ? (MusicPanel)((Control)sender).Parent : (MusicPanel)sender;

            SelectPanel(panel);
        }