Ejemplo n.º 1
0
        //小工具菜单点击事件集合
        private void Tool_Click(object sender, EventArgs e)
        {
            int index = MusicDate.Items.IndexOf(MusicDate.FocusedItem);

            Model.MusicInfo   info = musicInfos[index];
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            switch (item.Name)
            {
            case "play": SelectItem();  break;

            case "nextplay": GetIndex(false); break;

            case "openDic": OpenFile(info); break;

            case "remove":
                MusicDate.Items.RemoveAt(index);
                info = musicInfos[index];
                bll.Delete(info);
                // 刷新界面
                break;

            case "delete": bll.Remove(info);  break;
            }
        }
Ejemplo n.º 2
0
        //记录路径
        private void SelectMusic_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog
            {
                InitialDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                Filter           = "媒体文件|*.mp3",//;*.wav;*.wma;*.avi;*.mpg;*.asf;*.wmv";
                Multiselect      = true
            };

            if (open.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < open.FileNames.Length; i++)
                {
                    //获取完整路径
                    string path = open.FileNames[i];
                    if (!bll.Myexists(musicInfos, path))
                    {
                        Model.MusicInfo music = bll.SingleAdd(path);
                        music.Id = musicInfos.Count;
                        musicInfos.Add(music);
                        string       ID   = musicInfos.Count > 10 ? musicInfos.Count.ToString() : "0" + (musicInfos.Count - 1);
                        ListViewItem item = new ListViewItem(ID);
                        item.SubItems.Add(music.Mname.Split('-')[1]);
                        item.SubItems.Add(music.Author);
                        item.SubItems.Add(music.Album);
                        item.SubItems.Add(music.Mtime);
                        item.SubItems.Add(music.Msize);
                        MusicDate.Items.Add(item);
                        bll.Add(music);
                    }
                }
                lanumber.Text = "共" + musicInfos.Count + "首";
            }
        }
Ejemplo n.º 3
0
        private Model.MusicInfo StampInfo(int index = -1)
        {
            //返回指定的索引来获取音乐信息
            if (index == -1)
            {
                index = MusicDate.Items.IndexOf(MusicDate.FocusedItem);
            }
            if (index < 0)
            {
                return(null);
            }
            //根据指定的索引打印出对应的音乐信息
            Model.MusicInfo info       = musicInfos[index];
            string          musictitle = info.Mname.Split('-')[1];

            MusicName.Text           = musictitle.Length > 10 ? musictitle.Substring(0, 10) + "..." : musictitle;
            author.Text              = info.Author.Length > 5 ? info.Author.Substring(0, 5) + "..." : info.Author;
            lbEndTime.Text           = info.Mtime;
            albumart.BackgroundImage = info.Image;
            pbigimage.Image          = info.Bigimage;
            // 没有歌词
            if (bll.GetLrc(info))
            {
                liy = null;
            }
            liy = info.Lyric;
            //把对应的歌曲的编号放入到图片的tag
            albumart.Tag = index;
            return(info);
        }
Ejemplo n.º 4
0
 //双击加载信息,并且播放
 private void MusicDate_DoubleClick(object sender, EventArgs e)
 {
     //获取对应的信息打印对应到位置
     globalInfo = StampInfo();
     WMP.URL    = globalInfo.Path;
     WMP.Ctlcontrols.play();
 }
Ejemplo n.º 5
0
 private void SelectItem()
 {
     if (MusicDate.SelectedItems.Count > 0)//选择了一个音乐
     {
         globalInfo = StampInfo();
         WMP.URL    = globalInfo.Path;
         WMP.Ctlcontrols.play();
     }
     else
     {
         MessageBox.Show("未选择歌曲");
     }
 }
Ejemplo n.º 6
0
        private void GetIndex(bool isup)
        {
            int index = -1;

            if (MusicDelay.Count <= 0)
            {
                switch ((int)order)
                {
                case 0:
                case 1:
                    if (isup)
                    {
                        index = Convert.ToInt32(albumart.Tag) - 1 >= 0 ? Convert.ToInt32(albumart.Tag) - 1 : musicInfos.Count - 1;
                    }
                    else
                    {
                        index = Convert.ToInt32(albumart.Tag) + 1 > musicInfos.Count - 1 ? 0 : Convert.ToInt32(albumart.Tag) + 1;
                    }
                    break;

                case 2: index = Convert.ToInt32(albumart.Tag); break;

                case 3: index = random.Next(0, musicInfos.Count); break;
                }
            }
            else
            {
                index = MusicDelay.Dequeue();
            }
            //清空歌词
            globalInfo.Lyric = null;
            liy.Clear();
            LlrcShow.Items.Clear();
            if (index != -1)
            {
                globalInfo = StampInfo(index);
                WMP.URL    = globalInfo.Path;
                WMP.Ctlcontrols.play();
            }
        }
Ejemplo n.º 7
0
        private void OpenFile(Model.MusicInfo info)
        {
            string v_OpenFolderPath = bll.OPenDirectory(info.Path);

            System.Diagnostics.Process.Start("explorer.exe", v_OpenFolderPath);
        }