From a499dceb02f181e64956431ed0c682dd7d2ce7d7 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 04 八月 2020 17:45:20 +0800
Subject: [PATCH] 2020-08-04-1

---
 HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs |  149 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 143 insertions(+), 6 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs
index f8baa06..664c342 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Music/UpdateThread.cs
@@ -21,7 +21,7 @@
             {
                 while (frame.Parent != null)
                 {
-                    A31MusicModel.LogMusic("宸插惎鍔ㄦ洿鏂伴煶涔愬垪琛ㄦ煇涓�鏉¢煶涔愮姸鎬佺殑绾跨▼");
+                    //A31MusicModel.LogMusic("宸插惎鍔ㄦ洿鏂伴煶涔愬垪琛ㄦ煇涓�鏉¢煶涔愮姸鎬佺殑绾跨▼");
                     System.Threading.Thread.Sleep(1000);
                     Application.RunOnMainThread(() =>
                     {
@@ -36,18 +36,18 @@
                                 if (a31MusicModel.A31PlayStatus.TrackURL == songNameBtn.Tag.ToString())
                                 {
                                     volIconBtn.Visible = true;
-                                    songNameBtn.TextColor = UI.Music.Color.SelectedColor;
+                                    songNameBtn.TextColor = UI.Music.MusicColor.SelectedColor;
                                     songNameBtn.X = Application.GetRealWidth(48);
                                     artistNameBtn.X = songNameBtn.Right;
-                                    artistNameBtn.TextColor = UI.Music.Color.SelectedColor;
+                                    artistNameBtn.TextColor = UI.Music.MusicColor.SelectedColor;
                                 }
                                 else
                                 {
                                     volIconBtn.Visible = false;
-                                    songNameBtn.TextColor = UI.Music.Color.MusicTxet14Color;
+                                    songNameBtn.TextColor = UI.Music.MusicColor.MusicTxet14Color;
                                     songNameBtn.X = Application.GetRealWidth(16);
                                     artistNameBtn.X = songNameBtn.Right;
-                                    artistNameBtn.TextColor = UI.Music.Color.MusicNoTxetColor;
+                                    artistNameBtn.TextColor = UI.Music.MusicColor.MusicNoTxetColor;
                                 }
 
 
@@ -60,6 +60,143 @@
             });
             updateSelectedMusicThread.Start();
         }
-       
+        /// <summary>
+        /// 鎾斁闊充箰
+        /// </summary>
+        /// <param name="middViewLayout">涓婁笅鎷夊姩鐖舵帶浠�</param>
+        /// <param name="musicSource">闊充箰婧�</param>
+        /// <param name="listName">鎾斁鍒楄〃鍚�</param>
+        /// <param name="musicList">鎾斁闊充箰鍒楄〃</param>
+        /// <param name="a31MusicModel">闊充箰鎾斁鍣�</param>
+        public static void playMusuc(VerticalRefreshLayout middViewLayout, string musicSource, string listName,List<MusicInfo> musicList, A31MusicModel a31MusicModel, FrameLayout frame=null)
+        {
+            for (int i = 0; i < musicList.Count; i++)
+            {
+                var songs = musicList[i];
+                if (songs == null)
+                {
+                    continue;
+                }
+                UI.Music.View.SongView songView = new UI.Music.View.SongView();
+                songView.SongFrameLayout(middViewLayout, songs);
+                switch (musicSource)
+                {
+                    case "鏈湴闊充箰":
+                        {
+                            songs.URL = "http://" + new Shared.Net.NetWiFi().IpAddress + ":" + com.hdl.on.Server.Port + "/" + songs.ID;
+                        }
+                        break;
+                    case "USB":
+                        {
+                            songView.clickBtn.Tag = i + 1;
+                        }
+                        break;
+                    case "鎴戠殑鍒楄〃":
+                        {
+                            ///鍒犻櫎鎺т欢
+                            var delBtn = new Button
+                            {
+                                BackgroundColor = MusicColor.MusicDelColor,
+                                Text = Language.StringByID(StringId.delMusic),
+                                TextColor = MusicColor.WhiteColor,
+                                TextSize = TextSize.Text16,
+                            };
+                            songView.musicViewFl.AddRightView(delBtn);
+                            delBtn.MouseUpEventHandler += (sender, e) =>
+                            {
+                                musicList.Remove(songs);
+                                A31MusicModel.Save();
+                                songView.musicViewFl.RemoveFromParent();
+                            };
+                        }
+                        break;
+                    case "鎾斁鍒楄〃":
+                        {
+                            songView.loveIcon.Visible = false;
+                            songView.addIcon.Visible = false;
+                            var wText = songView.songBtn.GetTextWidth() + Application.GetRealWidth(15);
+                            if (wText > Application.GetRealWidth(280))
+                            {
+                                wText = Application.GetRealWidth(280);//(姝屾洸+姝屾墜)瀹藉害鏈�澶у�兼椂220
+                            }
+                            songView.songBtn.Width = wText;
+                            songView.singerBtn.X = songView.songBtn.Right;
+                            songView.singerBtn.Width = Application.GetRealWidth(280) - wText;//姝屽悕闀垮害灏忎簬220鎵嶅彲浠ユ樉绀烘瓕鎵嬪嚭鏉�
+                            songView.singerBtn.Text = string.IsNullOrEmpty(songs.Artist) ? "-Unkonw" : "-" + songs.Artist.Trim();
+                            songView.clickBtn.Width = Application.GetRealWidth(344);
+                            songView.clickBtn.Tag = i + 1;//鏍囪鎾斁鍝竴棣栨瓕鏇�
+                        }
+                        break;
+                }
+
+                //娣诲姞鍠滅埍闊充箰鎺т欢
+                songView.loveIcon.MouseUpEventHandler += (sender, e) =>
+                {
+                    songView.loveIcon.IsSelected = !songView.loveIcon.IsSelected;
+                    if (songView.loveIcon.IsSelected)
+                    {
+                        ///鏌ユ壘闊充箰鏄惁瀛樺湪鍦ㄥ垪琛�
+                        var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
+                        if (music1 == null)
+                        {
+                            ///娌℃湁瀛樺湪灏辨坊鍔�
+                            A31MusicModel.Current.LoveMusicInfoList.Add(songs);
+                        }
+                    }
+                    else
+                    {
+                        ///鏌ユ壘闊充箰鏄惁瀛樺湪鍦ㄥ垪琛�
+                        var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
+                        if (music1 != null)
+                        {
+                            ///瀛樺湪灏卞垹闄�
+                            A31MusicModel.Current.LoveMusicInfoList.Remove(songs);
+                        }
+
+                        if (musicSource == "鎴戠殑鏈�鐖�")
+                        {
+                            songView.musicViewFl.RemoveFromParent();
+                        }
+
+                    }
+                    A31MusicModel.Save();
+                };
+                //娣诲姞鍒版垜鐨勫垪琛�
+                songView.addIcon.MouseUpEventHandler = (sender, e) =>
+                {
+                    new HDL_ON.UI.Music.View.DialogView { }.FieListView(songs);
+                };
+                ///鐐瑰嚮鎾斁浜嬩欢
+                songView.clickBtn.MouseUpEventHandler += (sender, e) =>
+                {
+                    System.Threading.Tasks.Task.Run(() =>
+                    {
+                        System.Threading.Thread.Sleep(50);
+                        Application.RunOnMainThread(() =>
+                        {
+                            //绉婚櫎鐣岄潰
+                            A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text;
+                            if (frame != null)
+                            {
+                                frame.RemoveFromParent();
+                            }
+                            MainPage.BasePageView.RemoveViewByTag("Music");
+                            System.Threading.Tasks.Task.Run(() =>
+                            {
+                                if (musicSource == "鏈湴闊充箰"|| musicSource == "鎴戠殑鏈�鐖�"|| musicSource == "鎴戠殑鍒楄〃")
+                                {
+                                    SendMethod.PushList(songs, listName, musicList, a31MusicModel,musicSource);
+                                }
+                                else if (musicSource == "USB"|| musicSource == "鎾斁鍒楄〃")
+                                {
+                                    SendMethod.ListMusicPlay(listName, songView.clickBtn.Tag, A31MusicModel.Current);
+                                }
+                            });
+                        });
+                    });
+                };
+
+            }
+        }
     }
 }

--
Gitblit v1.8.0