Esempio n. 1
0
        /// <summary>
        /// 获取歌曲列表
        /// </summary>
        /// <param name="page"></param>
        private void GetList(int page)
        {
            StartProcessBar();
            pageNum.Text = "第" + page + "页";
            resultListView.Items.Clear();
            toolStripStatusLabel1.Text = "搜索中...";
            List <ListViewItem> listViewItems = new List <ListViewItem>();


            var songs = tblSearch.SelectedIndex == 0 ? provider.SearchSongs(txtSearchBox.Text, page, 20) : provider.SearchSongsList(txtSongListUrl.Text);

            songs.ForEach(item =>
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text         = item.name;
                lvi.SubItems.Add(item.singer);
                lvi.SubItems.Add(item.rate + "kb");
                lvi.SubItems.Add((item.size / (1024 * 1024)).ToString("F2") + "MB"); //将文件大小装换成MB的单位
                TimeSpan ts = new TimeSpan(0, 0, (int)item.duration);                //把秒数换算成分钟数
                lvi.SubItems.Add(ts.Minutes + ":" + ts.Seconds.ToString("00"));
                lvi.SubItems.Add(item.source);
                lvi.Tag = item;
                listViewItems.Add(lvi);
            });


            UpdateUI(listViewItems);

            if (songs.Count == 0)
            {
                toolStripStatusLabel1.Text = "未找到记录";
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取歌曲列表
        /// </summary>
        public void GetList(int page)
        {
            StartProcessBar();
            lblPageIndex.Text = "第" + page + "页";
            lvSongs.Items.Clear();
            tsLable.Text = "搜索中。。。";
            List <ListViewItem> listViewItems = new List <ListViewItem>();

            var songs = provider.SearchSongs(txtSearch.Text, page, 15);

            songs.ForEach(item =>
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Text         = item.SongName;
                lvi.SubItems.Add(item.Singer);
                lvi.SubItems.Add(item.Rate + "kb");
                lvi.SubItems.Add((item.Size / (1024 * 1024)).ToString("F2") + "MB"); //将文件大小装换成MB的单位

                TimeSpan ts = new TimeSpan(0, 0, (int)item.Duration);                //把秒转换成分钟
                lvi.SubItems.Add(ts.Minutes + ":" + ts.Seconds.ToString("00"));
                lvi.SubItems.Add(item.Source);
                lvi.Tag = item;
                listViewItems.Add(lvi);
            });

            UpdateUI(listViewItems);
        }
Esempio n. 3
0
        public IActionResult Search(string keyword)
        {
            MusicProviders    provider = MusicProviders.Instance;
            List <MergedSong> list     = provider.SearchSongs(keyword, 1, 20);

            foreach (var item in list)
            {
                foreach (var item2 in item.items)
                {
                    item2.url = provider.getDownloadUrl(item2);
                }
            }
            return(View(list));
        }
Esempio n. 4
0
        /// <summary>
        /// 获取歌曲列表
        /// </summary>
        /// <param name="page"></param>
        private void GetList(int page)
        {
            StartProcessBar();
            this.labPageIndex.Content = "第 " + page + " 页";
            var songs = provider.SearchSongs(txtSearch.Text, page, 20);

            resultListView.Items.Clear();
            this.resultListView.Dispatcher.Invoke(new Action(() =>
            {
                songs.ForEach(item =>
                {
                    this.resultListView.Items.Add(item);
                });
                this.nextPage.IsEnabled = songs.Count > 0;
            }));
        }