From 66c0db35365980f240d7cfe6dd59961812f20c97 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 03 六月 2020 17:51:36 +0800 Subject: [PATCH] 2020-06-03-1 --- HDL_ON/UI/Music/MusicMain.cs | 37 +++-- .vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm | 0 .vs/HDL_APP_Project/xs/sqlite3/storage.ide | 0 .vs/HDL_APP_Project/xs/UserPrefs.xml | 22 +- .vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal | 0 HDL_ON/UI/Music/View/DialogView.cs | 303 +++++++++++++++++++++++++++++++++++++++---- 6 files changed, 307 insertions(+), 55 deletions(-) diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml index 3e02710..8085efa 100644 --- a/.vs/HDL_APP_Project/xs/UserPrefs.xml +++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml @@ -1,11 +1,12 @@ 锘�<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default"> - <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/Music/MusicMain.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/Music/View/DialogView.cs"> <Files> - <File FileName="HDL_ON/UI/Music/SendMethod.cs" Line="457" Column="52" /> - <File FileName="../鏃х増鏈琈usic/MyMusic.cs" Line="754" Column="70" /> - <File FileName="HDL_ON/UI/Music/A31MusicModel.cs" Line="159" Column="15" /> - <File FileName="HDL_ON/UI/Music/View/DialogView.cs" Line="673" Column="1" /> - <File FileName="HDL_ON/UI/Music/MusicMain.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/UI/Music/SendMethod.cs" Line="203" Column="76" /> + <File FileName="../鏃х増鏈琈usic/MyMusic.cs" Line="263" Column="145" /> + <File FileName="HDL_ON/UI/Music/A31MusicModel.cs" Line="199" Column="6" /> + <File FileName="HDL_ON/UI/Music/MusicMain.cs" Line="361" Column="99" /> + <File FileName="HDL_ON/UI/UI0-Public/PublicAssmebly.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/UI/Music/View/DialogView.cs" Line="1" Column="1" /> </Files> <Pads> <Pad Id="ProjectPad"> @@ -16,8 +17,9 @@ <Node name="Entity" expanded="True" /> <Node name="UI" expanded="True"> <Node name="Music" expanded="True"> - <Node name="View" expanded="True" /> - <Node name="MusicMain.cs" selected="True" /> + <Node name="View" expanded="True"> + <Node name="DialogView.cs" selected="True" /> + </Node> </Node> <Node name="UI0-Public" expanded="True" /> <Node name="UI2" expanded="True"> @@ -27,9 +29,7 @@ </Node> <Node name="HDL-ON_Android" expanded="True"> <Node name="Assets" expanded="True"> - <Node name="Phone" expanded="True"> - <Node name="MusicIcon" expanded="True" /> - </Node> + <Node name="Phone" expanded="True" /> </Node> </Node> </Node> diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide index 8068f2e..eca1dbb 100644 --- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide +++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide Binary files differ diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm index 6c15581..dd912aa 100644 --- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm +++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm Binary files differ diff --git a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal index 7e09e7e..63a15b6 100644 --- a/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal +++ b/.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal Binary files differ diff --git a/HDL_ON/UI/Music/MusicMain.cs b/HDL_ON/UI/Music/MusicMain.cs index dff60b5..0f4d98f 100644 --- a/HDL_ON/UI/Music/MusicMain.cs +++ b/HDL_ON/UI/Music/MusicMain.cs @@ -45,7 +45,7 @@ /// <summary> /// 鏄剧ず鍔犺浇鐣岄潰 /// </summary> - public static Loading Loading = new Loading(); + public static Loading loading = new Loading(); VerticalRefreshLayout verticalRefresh; public void Show() @@ -72,11 +72,10 @@ verticalRefresh.BeginHeaderRefreshingAction += () => { - SeachMusic(); - verticalRefresh.EndHeaderRefreshing(); + SeachMusic(false); }; - this.AddChidren(Loading); + this.AddChidren(loading); if (A31MusicModel.A31MusicModelList.Count == 0) { @@ -137,7 +136,7 @@ if (Yes) { //涓轰簡绗竴娆¤繘鏉og涓�涓�; - Loading.Start(); + loading.Start(); } SendMethod.Seach((obj) => { @@ -145,12 +144,17 @@ { readServerOrClientMode(); A31MusicModel.Save(); + if (!Yes) + { + ///绛夊緟璺戝畬鍦ㄥ叧闂� + verticalRefresh.EndHeaderRefreshing(); + } Application.RunOnMainThread(() => { if (Yes) { //涓轰簡绗竴娆¤繘鏉og涓�涓�; - Loading.Hide(); + loading.Hide(); } verticalRefresh.RemoveAll(); for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) @@ -199,12 +203,20 @@ musicView.songNameBtn.Text = a31player.A31PlayStatus.Title; musicView.musicNameBtn.Text = a31player.Name; musicView.regionBtn.TextID = StringId.region; - + EventHandler<MouseEventArgs> clickMergence = (sender, e) => { - new View.DialogView { }.PlayMergence(); + if (a31player.ServerClientType == 0) + { + new View.DialogView { }.PlayMergence(); + } + else if (a31player.ServerClientType == 1) + { + new View.DialogView { }.DetachPlayMergence(a31player); + + } }; musicView.mergeBjBtn.MouseUpEventHandler += clickMergence; musicView.mergeBtn.MouseUpEventHandler += clickMergence; @@ -312,11 +324,11 @@ { a31player.ServerClientType = 0; var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); - if (result == null) + if (result == null && result == "Failed") { result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); } - if (result != null) + if (result != null && result != "Failed") { a31player.Slave = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); } @@ -383,10 +395,7 @@ } } - catch (Exception e) - { - var ss = e.Message; - } + catch { } } } diff --git a/HDL_ON/UI/Music/View/DialogView.cs b/HDL_ON/UI/Music/View/DialogView.cs index 0d75a38..3b45ea7 100644 --- a/HDL_ON/UI/Music/View/DialogView.cs +++ b/HDL_ON/UI/Music/View/DialogView.cs @@ -396,6 +396,8 @@ } confirmBtn.MouseUpEventHandler += (sender, e) => { + + if (playList1.Count <= 1) { new PublicAssmebly().TipMsgAutoClose("鑷冲皯閫変腑涓や釜浠ヤ笂鎾斁鍣�", false); @@ -415,7 +417,7 @@ if (playList2.Count == 0) { - PlayerView(dialog, playList1, playList1); + SelectedPlayerView(dialog, playList1, playList1); } else if (playList2.Count == 1) { @@ -425,16 +427,16 @@ } else { - PlayerView(dialog, playList1, playList2); + SelectedPlayerView(dialog, playList1, playList2); } }; } /// <summary> /// 閫変腑涓绘挱鏀惧櫒鐨勭晫闈� /// </summary> - /// <param name="musicList1"></param> - /// /// <param name="musicList2">鏄剧ず鎾斁鍣ㄥ垪琛�</param> - void PlayerView(Dialog dialogF, List<A31MusicModel> musicList1, List<A31MusicModel> musicList2) + /// <param name="musicList1">鏄剧ず灏嗚缁勫悎鐨勬挱鏀惧櫒鍒楄〃</param> + /// /// <param name="musicList2">鏄剧ず鍦ㄦ挱鏀鹃煶涔愭挱鏀惧櫒鍒楄〃</param> + void SelectedPlayerView(Dialog dialogF, List<A31MusicModel> musicList1, List<A31MusicModel> musicList2) { //涓绘帶浠� @@ -592,10 +594,9 @@ } dialogF.Close(); dialog.Close(); + var serverMusic = selectedBtn.Tag as A31MusicModel; Threading(serverMusic, musicList1); - - }; } @@ -607,25 +608,16 @@ /// <param name="musicList1"></param> void Threading(A31MusicModel serverMusic, List<A31MusicModel> musicList1) { + MusicMain.loading.Start("閰嶇疆涓�..."); + bool _if = false; System.Threading.Tasks.Task.Run(() => { try { - - var IP = ""; - if (serverMusic.ServerClientType == -1) - { - IP = serverMusic.MainPlayIP; - } - else - { - IP = serverMusic.IPAddress; - } - - var statusEx = SendMethod.OpenWeb("http://" + IP + "/httpapi.asp?command=getStatusEx"); + var statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx"); if (statusEx == null) { - statusEx = SendMethod.OpenWeb("http://" + IP + "/httpapi.asp?command=getStatusEx"); + statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx"); } if (statusEx == null) { @@ -650,6 +642,7 @@ //杩囨护鎺変富鎾斁鍣�; continue; } + System.Threading.Thread.Sleep(1000);//绛夊緟涓�绉掑啀鍙戞暟鎹� if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid)) { if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid)) @@ -659,16 +652,16 @@ } } DateTime dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 10 * 1000) + while ((DateTime.Now - dateTime).TotalMilliseconds < 12 * 1000) { System.Threading.Thread.Sleep(1000); try { var result = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); - if (result != null) + if (result != null && result != "Failed") { var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); - if (tmepSlaves != null && tmepSlaves.slave_list != null) + if (tmepSlaves != null && tmepSlaves.slave_list != null && tmepSlaves.slave_list.Count != 0) { string str = serverMusic.Name; for (int j = 0; j < A31MusicModel.A31MusicModelList.Count; j++) @@ -676,7 +669,7 @@ var music = A31MusicModel.A31MusicModelList[j]; if (music.UniqueDeviceName == serverMusic.UniqueDeviceName) { - + music.ServerClientType = 1; music.Slave = tmepSlaves; //杩囨护鎺変富鎾斁鍣�; @@ -692,6 +685,7 @@ music.IsOnLine = false; music.IPAddress = slave_Ifon.ip; music.MainPlayIP = serverMusic.IPAddress; + _if = true; } } serverMusic.MainPlayName = str; @@ -699,6 +693,8 @@ break; } } + + } catch { } } @@ -708,17 +704,264 @@ { Application.RunOnMainThread(() => { - MainPage.BasePageView.RemoveViewByTag("MusicMain"); - var musicMain = new MusicMain(); - MainPage.BasePageView.AddChidren(musicMain); - musicMain.Show(); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + MusicMain.loading.Hide(); + ///鍙互鎻愮ず閰嶇疆澶辫触; + if (_if) + { + //閰嶇疆鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈� + MainPage.BasePageView.RemoveViewByTag("MusicMain"); + var musicMain = new MusicMain(); + MainPage.BasePageView.AddChidren(musicMain); + musicMain.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + } }); } }); } - + /// <summary> + /// 鍒嗗紑缁勫悎鐨勬挱鏀惧櫒鐨勭晫闈� + /// </summary> + public void DetachPlayMergence(A31MusicModel a31player) + { + //涓绘帶浠� + Dialog dialog = new Dialog() + { + BackgroundColor = Color.PopupBackgroundColor, + }; + dialog.Show(); + //鐖舵帶浠� + FrameLayout frame = new FrameLayout { }; + dialog.AddChidren(frame); + frame.MouseUpEventHandler += (sen, e) => + { + dialog.Close(); + }; + //鐧借壊蹇埗鎺т欢 + FrameLayout dialogFra = new FrameLayout() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealHeight(397), + Width = Application.GetRealWidth(344), + Height = Application.GetRealHeight(250), + BackgroundColor = Color.WhiteColor, + Radius = (uint)Application.GetRealHeight(12), + }; + frame.AddChidren(dialogFra); + //鏄剧ず澶撮儴淇℃伅鐖舵帶浠� + FrameLayout topFra = new FrameLayout() + { + Width = Application.GetRealWidth(344), + Height = Application.GetRealHeight(50), + }; + dialogFra.AddChidren(topFra); + //鍙栨秷鎺т欢 + Button cancelnBtn = new Button + { + X = Application.GetRealWidth(20), + Y = Application.GetRealHeight(15), + Width = Application.GetRealWidth(60), + Height = Application.GetRealHeight(20), + TextID = StringId.cancelMusic, + TextAlignment = TextAlignment.CenterLeft, + TextColor = Color.MusicNoTxetColor, + TextSize = TextSize.Text14, + }; + topFra.AddChidren(cancelnBtn); + cancelnBtn.MouseUpEventHandler += (sen, e) => + { + dialog.Close(); + }; + //鏍囬鎺т欢 + Button txetBtn = new Button + { + X = cancelnBtn.Right + Application.GetRealWidth(20), + Y = Application.GetRealHeight(14), + Width = Application.GetRealWidth(152), + Height = Application.GetRealHeight(22), + TextColor = Color.TextColor, + TextSize = TextSize.Text16, + TextAlignment = TextAlignment.Center, + //TextID = StringId.selectedMergence, + IsBold = true, + Text= a31player.Name, + }; + topFra.AddChidren(txetBtn); + + //纭鎺т欢 + Button confirmBtn = new Button + { + X = Application.GetRealWidth(344 - 60 - 20), + Y = Application.GetRealHeight(15), + Width = Application.GetRealWidth(60), + Height = Application.GetRealHeight(20), + TextID = StringId.confirmMusic, + TextAlignment = TextAlignment.CenterRight, + TextColor = Color.SelectedColor, + TextSize = TextSize.Text14, + }; + topFra.AddChidren(confirmBtn); + + VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout + { + Y = Application.GetRealHeight(50), + Height = dialogFra.Height - Application.GetRealHeight(50), + Width = Application.GetRealWidth(344), + }; + dialogFra.AddChidren(verticalScrolViewLayout); + var slaveList= new List<Slave>(); + for (int i = 0; i < a31player.Slave.slave_list.Count; i++) + { + var slave = a31player.Slave.slave_list[i]; + RowLayout PlayRow = new RowLayout + { + Height = Application.GetRealHeight(50), + LineColor = Color.WhiteColor, + SubViewWidth = Application.GetRealWidth(80),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� + }; + verticalScrolViewLayout.AddChidren(PlayRow); + + + //鎾斁鍣ㄥ悕绉版帶浠� + Button PlayNameBtn = new Button + { + X = Application.GetRealWidth(20), + Y = Application.GetRealHeight(15), + Width = Application.GetRealWidth(150), + Height = Application.GetRealHeight(20), + TextColor = Color.TextColor, + TextSize = TextSize.Text14, + TextAlignment = TextAlignment.CenterLeft, + Text = slave.name, + }; + PlayRow.AddChidren(PlayNameBtn); + + + //閫変腑鍥炬爣鎺т欢 + Button selectedIconBtn = new Button + { + X = Application.GetRealWidth(303), + Y = Application.GetRealHeight(11), + Width = Application.GetMinRealAverage(28), + Height = Application.GetMinRealAverage(28), + UnSelectedImagePath = "MusicIcon/noSelectedIcon.png", + SelectedImagePath = "MusicIcon/selectedIcon.png", + }; + PlayRow.AddChidren(selectedIconBtn); + + ///鍔犲ぇ鍑犵偣鑼冨洿 + Button clickBtn = new Button + { + Height = Application.GetRealHeight(50), + Tag = slave.uuid.Replace("uuid:", ""), + }; + PlayRow.AddChidren(clickBtn); + + clickBtn.MouseUpEventHandler += (sender, e) => + { + clickBtn.IsSelected = !clickBtn.IsSelected; + selectedIconBtn.IsSelected = clickBtn.IsSelected; + var uuid = slaveList.Find((obj) => obj.uuid.Replace("uuid:", "") == clickBtn.Tag.ToString()); + if (selectedIconBtn.IsSelected) + { + if (uuid == null) + { + slaveList.Add(slave); + } + } + else + { + if (uuid != null) + { + slaveList.Remove(slave); + } + } + }; + //绾� + Button lineBtn = new Button + { + Y = PlayRow.Height - 1, + X = Application.GetRealWidth(20), + Width = Application.GetRealWidth(304), + Height = 1, + BackgroundColor = Color.LineColor, + }; + PlayRow.AddChidren(lineBtn); + } + confirmBtn.MouseUpEventHandler += (sender, e) => + { + if (slaveList.Count == 0) + { + new PublicAssmebly().TipMsgAutoClose("杩樻病鏈夐�夋嫨瑙i櫎缁勬挱鏀惧櫒", false); + return; + } + dialog.Close(); + + MusicMain.loading.Start("瑙i櫎涓�..."); + bool _if = false; + System.Threading.Tasks.Task.Run(() => + { + try + { + for (int i = 0; i < slaveList.Count; i++) + { + var clientMusic = slaveList[i]; + if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.ip)) + { + if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.ip)) + { + + } + } + System.Threading.Thread.Sleep(2000);//绛夊緟2绉掑啀鍙戞暟鎹� + + } + DateTime dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalMilliseconds < 10 * 1000) + { + System.Threading.Thread.Sleep(1000); + try + { + var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList"); + if (result != null && result != "Failed") + { + var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result); + if (tmepSlaves != null && tmepSlaves.slave_list.Count == 0) + { + _if = true;//瑙i櫎鎴愬姛 + A31MusicModel.Save(); + break; + } + } + + + } + catch { } + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + MusicMain.loading.Hide(); + ///鍙互鎻愮ず瑙i櫎澶辫触; + if (_if) + { + //瑙i櫎鎴愬姛鎵嶅彲浠ュ埛鏂扮晫闈� + MainPage.BasePageView.RemoveViewByTag("MusicMain"); + var musicMain = new MusicMain(); + MainPage.BasePageView.AddChidren(musicMain); + musicMain.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + } + }); + } + }); + + }; + } } [System.Serializable] public class A31Wifi鈥� { -- Gitblit v1.8.0