From 52e317b95d830f8cd1156b403ff5a34fb8f9bccb Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 31 七月 2020 17:43:42 +0800
Subject: [PATCH] 2020-7-31-2
---
HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs | 224 +++-----------------------------------------------------
1 files changed, 12 insertions(+), 212 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs
index afca128..1fe9556 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Music/A31USBMusicList.cs
@@ -24,19 +24,6 @@
topView.topNameBtn.TextID = StringId.usb;
topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
{
-
- if (updateSelectedMusicThread != null)
- {
- try
- {
- if (updateSelectedMusicThread.IsAlive)
- {
- updateSelectedMusicThread.Abort();
- ///鍏抽棴绾跨▼
- }
- }
- catch { }
- }
this.RemoveFromParent();
};
middViewLayout = new VerticalRefreshLayout
@@ -86,97 +73,13 @@
{
number++;
var songs = A31MusicModel.Current.USBList[i];
- if (string.IsNullOrEmpty(songs.Title))
+ View.SongView songView = new View.SongView();
+ songView.SongFrameLayout(middViewLayout, songs);
+ // 娣诲姞鍠滅埍闊充箰鎺т欢
+ songView.loveIcon.MouseUpEventHandler += (sender, e) =>
{
- //闃叉姝屾洸鍚嶅瓧涓虹┖鎶涘紓甯�
- songs.Title = " ";
- }
- if (string.IsNullOrEmpty(songs.Artist))
- {
- //闃叉姝屾墜鍚嶅瓧涓虹┖鎶涘紓甯�
- songs.Artist = " ";
- }
- FrameLayout musicViewFl = new FrameLayout
- {
- Width = Application.GetRealWidth(375),
- Height = Application.GetRealHeight(44),
- };
- middViewLayout.AddChidren(musicViewFl);
- //鍒楄〃褰撳墠鎾斁闊充箰鍥炬爣
- Button playIconBtn = new Button
- {
- X = Application.GetRealWidth(16),
- Y = Application.GetRealHeight(10),
- Width = Application.GetMinRealAverage(24),
- Height = Application.GetMinRealAverage(24),
- UnSelectedImagePath = "MusicIcon/playStatus.png",
- Visible = false,
- Name = "playStatus",
- Tag = songs.URL,
- };
- musicViewFl.AddChidren(playIconBtn);
- //姝屾洸鎺т欢
- Button songBtn = new Button
- {
- X = Application.GetRealWidth(16),
- Y = Application.GetRealHeight(11),
- Width = Application.GetRealWidth(100),
- Height = Application.GetRealHeight(22),
- TextColor = Color.MusicTxet14Color,
- TextSize = TextSize.Text16,
- TextAlignment = TextAlignment.CenterLeft,
- Name = "song",
- Tag = songs.URL,
- Text = songs.Title.Trim()
- };
- musicViewFl.AddChidren(songBtn);
- var wText = songBtn.GetTextWidth();//鑾峰彇鏂囨湰瀹藉害
- ///(姝屾洸+姝屾墜)瀹藉害鏈�澶у�兼椂280
- if (wText > 280)
- {
-
- songBtn.Width = Application.GetRealWidth(280);
- }
- else
- {
- songBtn.Width = wText + 5;
- }
- //姝屾墜鎺т欢
- Button singerBtn = new Button
- {
- X = songBtn.Right,
- Y = Application.GetRealHeight(11),
- Width = Application.GetRealWidth(280 - songBtn.Width),
- Height = Application.GetRealHeight(22),
- TextColor = Color.MusicNoTxetColor,
- TextSize = TextSize.Text12,
- TextAlignment = TextAlignment.CenterLeft,
- //Text =("-" +songs.Artist).Trim(),
- Name = "singer",
- Tag = songs.URL,
- Text = "-" + songs.Artist.Trim()
- };
- musicViewFl.AddChidren(singerBtn);
- if (wText > 280)
- {
- ///姝屽悕闀垮害灏忎簬250鎵嶅彲浠ユ樉绀烘瓕鎵嬪嚭鏉�
- singerBtn.Width = Application.GetRealWidth(0);
- }
- //娣诲姞鍠滅埍闊充箰鎺т欢
- Button loveIcon = new Button
- {
- X = Application.GetRealWidth(291),
- Y = Application.GetRealHeight(8),
- Width = Application.GetMinRealAverage(28),
- Height = Application.GetMinRealAverage(28),
- UnSelectedImagePath = "MusicIcon/love.png",
- SelectedImagePath = "MusicIcon/loveSelected.png",
- };
- musicViewFl.AddChidren(loveIcon);
- loveIcon.MouseUpEventHandler += (sender, e) =>
- {
- loveIcon.IsSelected = !loveIcon.IsSelected;
- if (loveIcon.IsSelected)
+ songView.loveIcon.IsSelected = !songView.loveIcon.IsSelected;
+ if (songView.loveIcon.IsSelected)
{
///鏌ユ壘闊充箰鏄惁瀛樺湪鍦ㄥ垪琛�
var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
@@ -199,41 +102,14 @@
}
A31MusicModel.Save();
};
- var music = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
- if (music != null)
- {
- loveIcon.IsSelected = true;
- }
- else
- {
- loveIcon.IsSelected = false;
- }
-
//娣诲姞鍒版垜鐨勫垪琛�
- Button addIcon = new Button
- {
- X = Application.GetRealWidth(335),
- Y = Application.GetRealHeight(8),
- Width = Application.GetMinRealAverage(28),
- Height = Application.GetMinRealAverage(28),
- UnSelectedImagePath = "MusicIcon/addMusic1.png",
- };
- musicViewFl.AddChidren(addIcon);
- addIcon.MouseUpEventHandler = (sender, e) =>
+ songView.addIcon.MouseUpEventHandler = (sender, e) =>
{
new View.DialogView { }.FieListView(songs);
};
-
- //鐐瑰嚮鎺т欢
- Button clickBtn = new Button
- {
- Width = Application.GetRealWidth(280),
- Height = Application.GetRealHeight(44),
- Tag = number,//鏍囪鎾斁鍝竴棣栨瓕鏇�
- };
- musicViewFl.AddChidren(clickBtn);
+ songView.clickBtn.Tag = number;//鏍囪鎾斁鍝竴棣栨瓕鏇�
///鐐瑰嚮鎾斁浜嬩欢
- clickBtn.MouseUpEventHandler += (sender, e) =>
+ songView.clickBtn.MouseUpEventHandler += (sender, e) =>
{
System.Threading.Tasks.Task.Run(() =>
@@ -242,11 +118,11 @@
Application.RunOnMainThread(() =>
{
//绉婚櫎鐣岄潰
- A31MusicModel.Current.A31PlayStatus.Title = songBtn.Text;
+ A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text;
MainPage.BasePageView.RemoveViewByTag("Music");
System.Threading.Tasks.Task.Run(() =>
{
- SendMethod.ListMusicPlay("USBDiskQueue", clickBtn.Tag,A31MusicModel.Current);
+ SendMethod.ListMusicPlay("USBDiskQueue", songView.clickBtn.Tag, A31MusicModel.Current);
});
});
});
@@ -258,85 +134,9 @@
/// <summary>
/// 瀹氭椂鏇存柊褰撳墠鎾斁闊充箰
/// </summary>
- System.Threading.Thread updateSelectedMusicThread;
public void UpdateSelectedMusic()
{
- updateSelectedMusicThread = new System.Threading.Thread(() =>
- {
- while (this.Parent != null)
- {
- System.Threading.Thread.Sleep(1000);
- Application.RunOnMainThread(() =>
- {
- try
- {
- for (int i = 0; i < middViewLayout.ChildrenCount; i++)
- {
- FrameLayout view = (FrameLayout)middViewLayout.GetChildren(i);
- var volIconBtn = (Button)view.GetChildren(0);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button
- var songNameBtn = (Button)view.GetChildren(1);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button
- var artistNameBtn = (Button)view.GetChildren(2);//鐩存帴FrameLayout鐖舵帶浠舵壘鍒拌鎺т欢Button
- if (A31MusicModel.Current.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
- {
- volIconBtn.Visible = true;
- songNameBtn.TextColor = Color.SelectedColor;
- songNameBtn.X = Application.GetRealWidth(48);
- artistNameBtn.X = songNameBtn.Right;
- artistNameBtn.TextColor = Color.SelectedColor;
- }
- else
- {
- volIconBtn.Visible = false;
- songNameBtn.TextColor = Color.MusicTxet14Color;
- songNameBtn.X = Application.GetRealWidth(16);
- artistNameBtn.X = songNameBtn.Right;
- artistNameBtn.TextColor = Color.MusicNoTxetColor;
- }
-
-
- }
- }
- catch { }
-
- });
- }
- });
- updateSelectedMusicThread.Start();
- }
- /// <summary>
- /// 鏁版嵁灏佽
- /// </summary>
- /// <param name="tag"></param>
- void PlayStrinfg(object tag)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.AppendLine("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
- sb.AppendLine("<s:Body>");
- sb.AppendLine("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">");
- sb.AppendLine("<QueueName>USBDiskQueue</QueueName>");
- sb.AppendLine("<Index>" + tag + "</Index>");
- sb.AppendLine("</u:PlayQueueWithIndex>");
- sb.AppendLine("</s:Body>");
- sb.AppendLine("</s:Envelope>");
-
- Paly(sb.ToString());
- }
- /// <summary>
- /// 鎾斁鍛戒护
- /// </summary>
- /// <param name="s"></param>
- void Paly(string s)
- {
-
- System.Net.WebClient webClient = new System.Net.WebClient();
- webClient.Headers.Add("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\"");
- webClient.Headers.Add("CONTENT-TYPE", "text/xml;charset=\"utf-8\"");
- try
- {
- byte[] bytes = webClient.UploadData(new Uri("http://" + A31MusicModel.Current.IPAddress + ":" + A31MusicModel.Current.Port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes(s));
- var ab = System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
- }
- catch { }
+ UI2.FuntionControlView.Music.UpdateThread.updateThread(this, middViewLayout, A31MusicModel.Current);
}
}
--
Gitblit v1.8.0