Esempio n. 1
0
        private void comboBoxAlbumList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxAlbumList.SelectedIndex < 0)
            {
                return;
            }

            listViewUserMusicList.Items.Clear();

            //显示音乐列表
            string strMusicList = ListHelper.GetMusicList(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(), comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString());


            if (strMusicList != "")
            {
                string[] strsContent = strMusicList.Split('|');

                for (int i = 0; i < strsContent.Length; i++)
                {
                    if (strsContent[i] != "")
                    {
                        //string strID = strsContent[i].Substring(0, 3);
                        //string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4).Substring(3);

                        string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4);

                        ////去掉开头的0
                        //while (strID[0] == '0')
                        //{
                        //    strID = strID.Substring(1, strID.Length - 1);
                        //}

                        ListViewItem item = new ListViewItem(strName);
                        //item.SubItems.Add(strName);

                        //将音频文件路径存入tag属性
                        //将目录和文件名拼接起来,自动匹配mp3,wma,mid格式
                        string strAudioFilePath = null;
                        strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(),
                                                                                                                                   comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i]));


                        if (strAudioFilePath == "")
                        {
                            item.Tag = MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(),
                                                                                   comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i]);
                        }
                        else
                        {
                            item.Tag = strAudioFilePath;
                        }


                        listViewUserMusicList.Items.Add(item);
                    }
                }

                Array.Clear(strsContent, 0, strsContent.Length);
            }
        }
Esempio n. 2
0
        //选择专辑后,显示音乐列表
        private void comboBoxAlbumList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxAlbumList.SelectedIndex < 0)
            {
                return;
            }

            StrLastMusicianList = comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString();
            StrLastAlbumList    = comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString();

            _configHelper.Write("LastMusicianList", StrLastMusicianList);
            _configHelper.Write("LastAlbumList", StrLastAlbumList);

            if (StrLastAlbumList == "")
            {
                return;
            }

            listViewMusicList.Items.Clear();


            //显示音乐列表
            string strMusicList = ListHelper.GetMusicList(StrLastMusicianList, StrLastAlbumList);

            //清除WMP中的音乐列表
            axWindowsMediaPlayer1.currentPlaylist.clear();

            if (strMusicList != "")
            {
                string[] strsContent = strMusicList.Split('|');

                for (int i = 0; i < strsContent.Length; i++)
                {
                    if (strsContent[i] != "")
                    {
                        //ListViewItem item = new ListViewItem((i + 1).ToString());
                        //item.SubItems.Add(strsContent[i].Remove(strsContent[i].Length - 4, 4));

                        //string strID = strsContent[i].Substring(0, 3);
                        //string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4).Substring(3);

                        string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4);

                        ////去掉开头的0
                        //while (strID[0] == '0')
                        //{
                        //    strID = strID.Substring(1, strID.Length - 1);
                        //}

                        ListViewItem item = new ListViewItem(strName);
                        //item.SubItems.Add(strName);

                        //将音频文件路径存入tag属性
                        //将目录和文件名拼接起来,自动匹配mp3,wma,mid格式
                        string strAudioFilePath = null;
                        strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(),
                                                                                                                                   comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i]));


                        if (strAudioFilePath == "")
                        {
                            item.Tag = MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(),
                                                                                   comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i]);
                        }
                        else
                        {
                            item.Tag = strAudioFilePath;
                        }


                        listViewMusicList.Items.Add(item);
                        //axWindowsMediaPlayer1.currentPlaylist.appendItem(axWindowsMediaPlayer1.newMedia(strAudioFilePath));
                    }
                }

                Array.Clear(strsContent, 0, strsContent.Length);
            }



            /*
             *
             * try
             * {
             *
             *  //显示经文列表,读取文件中的内容并显示到listView中
             *  string strSelectedFileName = comboBoxLectionList.Items[comboBoxLectionList.SelectedIndex].ToString();
             *  if (strSelectedFileName == "")
             *  {
             *      //空白,清空
             *      listViewLectionList.Items.Clear();
             *  }
             *  else if (strSelectedFileName == _strCreateNewList)
             *  {
             *      //空白,清空
             *      listViewLectionList.Items.Clear();
             *
             *      ////新建经文列表
             *      ////弹出窗口让用户输入播经文列表名
             *
             *
             *      ShowNewList(CreateNewList());
             *
             *
             *
             *  }
             *  else
             *  {
             *      //空白,清空
             *      listViewLectionList.Items.Clear();
             *
             *      //显示经文列表
             *      string strFileContent = ListHelper.ReadFileContent(strSelectedFileName + ".txt");
             *      if (strFileContent != "")
             *      {
             *          string[] strContent = strFileContent.Split('|');
             *
             *          for (int i = 0; i < strContent.Length; i++)
             *          {
             *              ListViewItem item = new ListViewItem((i + 1).ToString());
             *              item.SubItems.Add(strContent[i]);
             *
             *              listViewLectionList.Items.Add(item);
             *          }
             *      }
             *  }
             *
             *  StrLastLectionList = strSelectedFileName;
             *  _configHelper.Write("LastLectionList", strSelectedFileName);
             *
             * }
             * catch (Exception)
             * {
             * }
             *
             */
        }
Esempio n. 3
0
        private void buttonSearchMusic_Click(object sender, EventArgs e)
        {
            if (textBoxSearchCondition.Text == "")
            {
                return;
            }

            listViewMusicList.Items.Clear();

            string strList = "";

            if (radioButtonSearchByName.Checked)
            {
                strList = MusicHelper.SearchMusicByName(textBoxSearchCondition.Text);
            }
            else
            {
                strList = MusicHelper.SearchMusicByLyrics(textBoxSearchCondition.Text);
            }


            if (strList != "")
            {
                string[] strsMusic = strList.Split('|');
                for (int i = 0; i < strsMusic.Length; i++)
                {
                    if (strsMusic[i] == "")
                    {
                    }
                    else
                    {
                        FileInfo fileInfo = new FileInfo(strsMusic[i]);

                        //string strID = fileInfo.Name.Substring(0, 3);
                        //string strName = fileInfo.Name.Remove(fileInfo.Name.Length - 4, 4);

                        string strName = strsMusic[i].Remove(strsMusic[i].Length - 4, 4);
                        int    iIndex  = strName.LastIndexOf('\\', strName.LastIndexOf('\\', (strName.LastIndexOf('\\', strName.Length - 1) - 1)) - 1);
                        strName = strName.Substring(iIndex);


                        ////去掉开头的0
                        //while (strID[0] == '0')
                        //{
                        //    strID = strID.Substring(1, strID.Length - 1);
                        //}

                        ListViewItem item = new ListViewItem(strName);

                        string strAudioFilePath = null;
                        strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(strsMusic[i]);
                        if (strAudioFilePath == "")
                        {
                            item.Tag = strsMusic[i];
                        }
                        else
                        {
                            item.Tag = strAudioFilePath;
                        }

                        //item.Tag = strsMusic[i];

                        //将音频文件路径存入tag属性
                        //将目录和文件名拼接起来,自动匹配mp3,wma,mid格式
                        //string strAudioFilePath = null;

                        //strAudioFilePath = strsMusic[i];

                        //item.Tag = strsMusic[i];

                        //strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(MusicHelper.GetLyricFilePathByLyricFileName(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text,
                        //listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text, strsMusic[i]));

                        //if (strAudioFilePath == "")
                        //{
                        //    item.Tag = strsMusic[i];

                        ////    item.Tag = MusicHelper.GetLyricFilePathByLyricFileName(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text,
                        ////listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text, strsMusic[i]);
                        //}
                        //else
                        //{
                        //    item.Tag = strAudioFilePath;
                        //}

                        listViewMusicList.Items.Add(item);
                    }
                }
                Array.Clear(strsMusic, 0, strsMusic.Length);
            }
        }
Esempio n. 4
0
        private void listViewAlbumList_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.listViewMusicList.Items.Clear();

            if (listViewAlbumList.Items.Count <= 0 || listViewAlbumList.SelectedIndices.Count == 0 || listViewAlbumList.SelectedIndices[0] < 0)
            {
                return;
            }

            try
            {
                string strList = ListHelper.GetMusicList(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text, listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text);

                if (strList != "")
                {
                    string[] strsMusic = strList.Split('|');
                    for (int i = 0; i < strsMusic.Length; i++)
                    {
                        if (strsMusic[i] == "")
                        {
                        }
                        else
                        {
                            //string strID = strsMusic[i].Substring(0, 3);
                            //string strName = strsMusic[i].Remove(strsMusic[i].Length - 4, 4).Substring(3);
                            string strName = strsMusic[i].Remove(strsMusic[i].Length - 4, 4);


                            ////去掉开头的0
                            //while (strID[0] == '0')
                            //{
                            //    strID = strID.Substring(1, strID.Length - 1);
                            //}

                            //ListViewItem item = new ListViewItem(strID);
                            //item.SubItems.Add(strName);
                            ListViewItem item = new ListViewItem(strName);


                            //将音频文件路径存入tag属性
                            //将目录和文件名拼接起来,自动匹配mp3,wma,mid格式
                            string strAudioFilePath = null;
                            strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(MusicHelper.GetLyricFilePathByLyricFileName(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text,
                                                                                                                                       listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text, strsMusic[i]));
                            if (strAudioFilePath == "")
                            {
                                item.Tag = MusicHelper.GetLyricFilePathByLyricFileName(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text,
                                                                                       listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text, strsMusic[i]);
                            }
                            else
                            {
                                item.Tag = strAudioFilePath;
                            }

                            listViewMusicList.Items.Add(item);
                        }
                    }
                    Array.Clear(strsMusic, 0, strsMusic.Length);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }