Esempio n. 1
0
        private void 삭제ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lvMusic.SelectedItems.Count <= 0)
            {
                MessageBox.Show("선택된 노래가 없습니다");
                return;
            }
            int index = lvMusic.SelectedIndices[0]; // 선택된 첫번째 레코드의 인덱스

            //index = LV.FocusedItem.Index;
            foreach (ListViewItem row in lvMusic.SelectedItems)
            {
                lvMusic.Items.Remove(row);       // 선택한 행 삭제
            }
            ExtensionClass.listView_No(lvMusic); // 번호 다시 매기기
            if (index > lvMusic.Items.Count - 1)
            {
                index = lvMusic.Items.Count - 1;
            }
            if (lvMusic.Items.Count != 0)
            {
                lvMusic.Items[index].Selected = true;
                lvMusic.Items[index].EnsureVisible();
            }

            if (lvMusic.Items.Count == 0)
            {
                btnPrevious.Enabled = false;
                btnNext.Enabled     = false;

                form_Mini.btnMiniPrevious.Enabled = false;
                form_Mini.btnMiniNext.Enabled     = false;

                if (this.wavePlayer == null)
                {
                    btnPlay.Enabled = false;

                    form_Mini.btnMiniPlay.Enabled = false;
                }
            }
        }
Esempio n. 2
0
        public void PlayMusic(string audioFile)
        {
            MusicFile     = audioFile;
            PlayingMusic  = audioFile;
            GetWavePlayer = wavePlayer;
            GetReader     = reader;

            lblInfo.Visible = false;

            if (MusicFile != string.Empty)
            {
                if (File.Exists(MusicFile))
                {
                    musicBar.Value = 0;

                    Load_MusicInfo();

                    if (this.wavePlayer != null)
                    {
                        CleanUp();
                    }

                    Debug.Assert(this.wavePlayer == null);

                    this.wavePlayer = new WaveOut();
                    this.reader     = new AudioFileReader(MusicFile);
                    //this.reader.Volume = volumeSlider1.Value / 100.0F;
                    wavePlayer.Volume = volumeSlider.Value / 100.0F;
                    this.wavePlayer.Init(reader);
                    this.wavePlayer.PlaybackStopped += wavePlayer_PlaybackStopped;
                    this.wavePlayer.Play();
                    timer1.Enabled = true;

                    //btnPlay.Text = "ll";
                    btnPlay.IconChar = FontAwesome.Sharp.IconChar.PauseCircle;
                    form_Mini.btnMiniPlay.IconChar = FontAwesome.Sharp.IconChar.PauseCircle;

                    btnCheck.PerformClick();
                }
                else
                {
                    if (MessageBox.Show("파일을 찾을 수 없습니다. 목록에서 삭제하시겠습니까?\n(파일이 삭제되었거나 다른 위치로 이동되었습니다.)", "나도가수다", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
                    {
                        switch (modeNum)
                        {
                        case 0:
                            if (index < lvMusic.Items.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                index++;
                                lvMusic.Items[index].Selected = true;
                                PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                            }
                            break;

                        case 1:
                            break;

                        case 2:
                            if (index < lvMusic.Items.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                index++;
                                lvMusic.Items[index].Selected = true;
                                PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                            }
                            else if (index == lvMusic.Items.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                index = 0;
                                lvMusic.Items[index].Selected = true;
                                PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                            }
                            break;

                        case 3:
                            if (shuffleindex == randomList.Count - 1)
                            {
                                ExtensionClass.shuffle(randomList);
                                shuffleindex = -1;
                            }
                            else if (shuffleindex < randomList.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                shuffleindex++;
                                lvMusic.Items[randomList[shuffleindex]].Selected = true;
                                index = lvMusic.SelectedItems[0].Index;
                                PlayMusic(lvMusic.Items[randomList[shuffleindex]].SubItems[3].Text);
                            }
                            break;
                        }
                    }
                    else
                    {
                        lvMusic.Items.RemoveAt(index);
                        ExtensionClass.listView_No(lvMusic);  // 번호 다시 매기기
                        if (index > lvMusic.Items.Count - 1)
                        {
                            index = lvMusic.Items.Count - 1;
                        }
                        if (lvMusic.Items.Count != 0)
                        {
                            lvMusic.Items[index].Selected = true;
                            lvMusic.Items[index].EnsureVisible();
                        }
                        if (this.wavePlayer == null && lvMusic.Items.Count == 0)
                        {
                            btnPrevious.Enabled = false;
                            btnNext.Enabled     = false;
                            btnPlay.Enabled     = false;
                        }
                    }
                }
            }
        }