123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.MicroShare
- {
- public class frmWebMp3 : LYFZ.Software.UI.MicroShare.frmWebMp3
- {
- public frmWebMp3() {
- this.Shown += frmWebMp3_Shown;
- this.dataGridViewEx1.CellMouseClick += dataGridViewEx1_CellMouseClick;
- this.FormClosed += frmWebMp3_FormClosed;
- }
- string musicPlay = "http://wx.lyfz.net/";
- void frmWebMp3_FormClosed(object sender, FormClosedEventArgs e)
- {
- this.webBrowser1.Url = new Uri(musicPlay+"music.html?audio=1");
- }
- void dataGridViewEx1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
- {
- DataGridViewRow row = this.dataGridViewEx1.Rows[e.RowIndex];
- if (row.Tag != null && row.Tag.ToString().Length>1)
- {
- this.webBrowser1.ScrollBarsEnabled = false;
- if (e.ColumnIndex == 2)
- {
- // LYFZ.WinAPI.CustomPublicMethod.RunStart(row.Tag.ToString());
- this.webBrowser1.Url = new Uri(musicPlay + "music.html?audio=" + row.Tag.ToString());
- }
- else if (e.ColumnIndex == 3)
- {
- WebMP3Path = row.Tag.ToString().Trim();
- Mp3Name = row.Cells[0].Value.ToString();
- this.webBrowser1.Url = new Uri(musicPlay + "music.html?audio=1");
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- }
- }
- }
- }
- void frmWebMp3_Shown(object sender, EventArgs e)
- {
- BindMP3List();
- }
- string _webMP3Path = "";
- /// <summary>
- ///
- /// </summary>
- public string WebMP3Path
- {
- get { return _webMP3Path; }
- set { _webMP3Path = value; }
- }
- string mp3Name = "";
- public string Mp3Name
- {
- get { return mp3Name; }
- set { mp3Name = value; }
- }
- static dynamic TemplatesJson = null;
- void BindMP3List()
- {
- this.dataGridViewEx1.Rows.Clear();
- if (TemplatesJson == null)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- backgroundWorker.ReportProgress(0, "正在获取音乐...");
- try
- {
- string retTemplates = LYFZ.WinAPI.CustomPublicMethod.HttpWebRequestGET(FrmMicroShare.domainName + "/music", Encoding.UTF8);
- TemplatesJson = Newtonsoft.Json.JsonConvert.DeserializeObject(retTemplates);
- if (TemplatesJson.code != 0)
- {
- MessageBoxCustom.Show("获取网络音乐失败:" + TemplatesJson.info, backgroundWorker: backgroundWorker);
- TemplatesJson = null;
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show("获取网络音乐出错:" + ex.Message, backgroundWorker: backgroundWorker);
- }
- });
- }
- if (TemplatesJson != null)
- {
- foreach (var mp3 in TemplatesJson.data)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.CreateCells(this.dataGridViewEx1);
- row.Cells[0].Value = mp3.title;
- row.Cells[1].Value = mp3.author;
- row.Cells[2].Value = "试听";
- row.Cells[3].Value = "选择";
- row.Tag = mp3.url;
- this.dataGridViewEx1.Rows.Add(row);
- }
- }
- }
- }
- }
|