using System; using System.Collections.Generic; using System.Text; using Shared.SimpleControl.Phone; using Shared; using Shared.SimpleControl.R; using SmartHome.UI.SimpleControl.Phone.Music; namespace Shared.SimpleControl.Phone.Music { /// ///源选择界面 /// class SourcePage : Shared.FrameLayout { /// /// 显示出当前界面 /// /// public void Show(MusicModel musicModel) { AddChidren(new Button() { Height = Application.GetRealHeight(36), BackgroundColor = SkinStyle.Current.MusicTopFrameLayout, }); var topFrameLayout = new FrameLayout() { Height = Application.GetRealHeight(100), Y = Application.GetRealHeight(36), BackgroundColor = SkinStyle.Current.MusicTopFrameLayout, }; AddChidren(topFrameLayout); var back = new Button { Width = Application.GetMinRealAverage(72), Height = Application.GetMinRealAverage(89), X = Application.GetRealWidth(10), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/PlayBack.png", }; topFrameLayout.AddChidren(back); back.MouseDownEventHandler += (sender, o) => { RemoveFromParent(); }; //源标题 var titleBtn = new Button { Width = Application.GetRealWidth(200), Height = Application.GetRealHeight(150), TextID = MyInternationalizationString.MusicSource, Gravity = Gravity.Center, TextColor = SkinStyle.Current.MusicTextColor, }; topFrameLayout.AddChidren(titleBtn); //中间滑动栏 var frameLayout = new FrameLayout(); frameLayout.Y = Application.GetRealHeight(136); frameLayout.Height= Application.GetRealHeight (Application.DesignHeight-136); //frameLayout.BackgroundImagePath = "MusicIcon/HomepageBackgroun.png"; frameLayout.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout; this.AddChidren(frameLayout); var middle = new VerticalScrolViewLayout (); frameLayout.AddChidren (middle); #region SD var rowSD = new RowLayout { Height = Application.GetRealHeight(100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; middle.AddChidren(rowSD); var SDhoto = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/card.png", SelectedImagePath = "MusicIcon/cardSelected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(30), Gravity = Gravity.CenterVertical, }; rowSD.AddChidren(SDhoto); //SD卡源图标 var musicSD = new Button { Height = Application.GetRealHeight(100), TextID = MyInternationalizationString.SDcard, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(130), TextColor = SkinStyle.Current.MusicTextColor, }; rowSD.AddChidren(musicSD); //读取SD卡列表 var readSDList = new Button { Width = Application.GetRealWidth(65), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/Listreading.png", SelectedImagePath = "MusicIcon/ListreadingSelected.png", X = Application.GetRealWidth(365), Gravity = Gravity.CenterVertical, }; rowSD.AddChidren(readSDList); //刷新SD卡列表 var refreshSDList = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/refurbish.png", SelectedImagePath = "MusicIcon/refurbishSelected.png", X = Application.GetRealWidth(460), Gravity = Gravity.CenterVertical, }; rowSD.AddChidren(refreshSDList); refreshSDList.MouseUpEventHandler += (sender, e) => { refreshSDList.IsSelected = true; MainPage.Loading.Start(); System.Threading.Tasks.Task.Run(() => { Control.ControlBytesSend(Command.ControlMusicModel, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*S1UPDATELIST")); System.Threading.Thread.Sleep(4000); Application.RunOnMainThread(() => { MainPage.Loading.Hide(); refreshSDList.IsSelected = false; }); }); }; var nextSD = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Homepagedown.png", SelectedImagePath = "MusicIcon/HomepagedownSelected.png", X = Application.GetRealWidth(550), }; rowSD.AddChidren(nextSD); var sdContentSD = new VerticalScrolViewLayout { Width = LayoutParams.MatchParent, Height = 0, BackgroundColor =SkinStyle.Current.MusicMiddleBackgroundColor, }; readSDList.MouseUpEventHandler += (sender, e) => { readSDList.IsSelected = true; MainPage.Loading.Start(); System.Threading.Tasks.Task.Run(() => { readPlayList(musicModel, 1); Application.RunOnMainThread(() => { MainPage.Loading.Hide(); readSDList.IsSelected = false; nextSD.IsSelected = true; for (int i = 0; i < musicModel.SDCardListList.Count; i++) { var rowLa = new RowLayout { Height = Application.GetRealHeight(100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; sdContentSD.AddChidren(rowLa); var number = new Button { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, Text = musicModel.SDCardListList[i].name, TextColor = SkinStyle.Current.MusicTextColor, }; rowLa.AddChidren(number); string typeAndListNumber = musicModel.SDCardListList[i].number; number.MouseUpEventHandler += (sender1, e1) => { Button button = (Button)sender1; Songlist songlist = new Songlist { }; MainPage.MainFrameLayout.AddChidren(songlist); songlist.Show(musicModel.SDCardSongList.FindAll((song) => { return song.number.StartsWith(typeAndListNumber); }), musicModel, 1); }; var numbernext = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", X = Application.GetRealWidth(550), Tag = musicModel, }; rowLa.AddChidren(numbernext); ////歌曲列表 numbernext.MouseDownEventHandler += (sender1, e1) => { Button button = (Button)sender1; Songlist songlist = new Songlist { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(songlist); songlist.Show(musicModel.SDCardSongList.FindAll((song) => { return song.number.StartsWith(typeAndListNumber); }), musicModel, 1); }; } sdContentSD.Height = Application.GetRealHeight(musicModel.SDCardListList.Count * 100); }); }); }; nextSD.MouseUpEventHandler += (sender, e) => { nextSD.IsSelected = !nextSD.IsSelected; if (nextSD.IsSelected) { for (int i = 0; i < musicModel.SDCardListList.Count; i++) { var rowLa = new RowLayout { Height = Application.GetRealHeight(100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; sdContentSD.AddChidren(rowLa); var number = new Button { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, Text = musicModel.SDCardListList[i].name, TextColor = SkinStyle.Current.MusicTextColor, }; rowLa.AddChidren(number); string typeAndListNumber = musicModel.SDCardListList[i].number; number.MouseDownEventHandler += (sender1, e1) => { Button button = (Button)sender1; Songlist songlist = new Songlist { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(songlist); songlist.Show(musicModel.SDCardSongList.FindAll((song) => { return song.number.StartsWith(typeAndListNumber); }), musicModel, 1); }; var numbernext = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", X = Application.GetRealWidth(550), Tag = musicModel, }; rowLa.AddChidren(numbernext); //歌曲列表 numbernext.MouseDownEventHandler += (sender1, e1) => { Button button = (Button)sender1; Songlist songlist = new Songlist { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(songlist); songlist.Show(musicModel.SDCardSongList.FindAll((song) => { return song.number.StartsWith(typeAndListNumber); }), musicModel, 1); }; } sdContentSD.Height = Application.GetRealHeight(musicModel.SDCardListList.Count * 100); } else { readSDList.IsSelected = false; sdContentSD.Height = 0; } }; middle.AddChidren(sdContentSD); #endregion #region Nas var nasrowlayout = new RowLayout { LineColor = SkinStyle.Current.MusicRowLayoutLineColor, Height = Application.GetRealHeight(100), }; middle.AddChidren(nasrowlayout); var nas = new Button { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), //Text = "NAS", TextID = MyInternationalizationString.NAS, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(130), TextColor = SkinStyle.Current.MusicTextColor, }; nasrowlayout.AddChidren(nas); var nashoto = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/nas.png", SelectedImagePath = "MusicIcon/nasSelected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(30), Gravity = Gravity.CenterVertical, }; nasrowlayout.AddChidren(nashoto); var readListNAS = new Button { Width = Application.GetRealWidth(65), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/Listreading.png", SelectedImagePath = "MusicIcon/ListreadingSelected.png", X = Application.GetRealWidth(365), Gravity = Gravity.CenterVertical, }; nasrowlayout.AddChidren(readListNAS); var nextnas = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Homepagedown.png", SelectedImagePath = "MusicIcon/HomepagedownSelected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(550), Gravity = Gravity.CenterVertical, }; nasrowlayout.AddChidren(nextnas); var sdContentNAS = new VerticalScrolViewLayout { Height = 0, BackgroundColor = SkinStyle.Current.MusicMiddleBackgroundColor, }; readListNAS.MouseUpEventHandler += (sender, e) => { readListNAS.IsSelected = true; MainPage.Loading.Start(); System.Threading.Tasks.Task.Run(() => { readPlayList(musicModel, 2); Application.RunOnMainThread(() => { MainPage.Loading.Hide(); readListNAS.IsSelected = false; nextnas.IsSelected = true; for (int i = 0; i < musicModel.NASListList.Count; i++) { var NASrowLayout = new RowLayout { Height = Application.GetRealHeight(100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; sdContentNAS.AddChidren(NASrowLayout); var listNSA = new Button { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, X = Application.GetRealWidth(30), Text = musicModel.NASListList[i].name, TextColor = SkinStyle.Current.MusicTextColor, }; NASrowLayout.AddChidren(listNSA); string ListNumberNas = musicModel.NASListList[i].number; listNSA.MouseUpEventHandler += (sender1, e1) => { Songlist NASmusic = new Songlist { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(NASmusic); NASmusic.Show(musicModel.NasSongList.FindAll((music) => { return music.number.StartsWith(ListNumberNas); }), musicModel, 2); }; var numbernext = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", X = Application.GetRealWidth(550), Tag = musicModel, }; NASrowLayout.AddChidren(numbernext); ////歌曲列表 numbernext.MouseDownEventHandler += (sender1, e1) => { Button button = (Button)sender1; Songlist Nassonglist = new Songlist { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(Nassonglist); Nassonglist.Show(musicModel.NasSongList.FindAll((song) => { return song.number.StartsWith(ListNumberNas); }), musicModel, 2); }; } sdContentNAS.Height = Application.GetRealHeight(musicModel.NASListList.Count * 100); }); }); }; nextnas.MouseUpEventHandler += (sender, e) => { nextnas.IsSelected = !nextnas.IsSelected; if (nextnas.IsSelected) { for (int i = 0; i < musicModel.NASListList.Count; i++) { var rowLa = new RowLayout { LineColor = SkinStyle.Current.MusicRowLayoutLineColor, Height = Application.GetRealHeight(100), }; sdContentNAS.AddChidren(rowLa); var number = new Button { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, Text = musicModel.NASListList[i].name, TextColor = SkinStyle.Current.MusicTextColor, }; rowLa.AddChidren(number); string typeAndListNumber = musicModel.NASListList[i].number; number.MouseDownEventHandler += (sender1, e1) => { Button button = (Button)sender1; Songlist songlist = new Songlist { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(songlist); songlist.Show(musicModel.NasSongList.FindAll((song) => { return song.number.StartsWith(typeAndListNumber); }), musicModel, 2); }; var numbernext = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", X = Application.GetRealWidth(550), Tag = musicModel, }; rowLa.AddChidren(numbernext); //歌曲列表 numbernext.MouseDownEventHandler += (sender1, e1) => { Button button = (Button)sender1; Songlist songlist = new Songlist { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(songlist); songlist.Show(musicModel.NasSongList.FindAll((song) => { return song.number.StartsWith(typeAndListNumber); }), musicModel, 2); }; } sdContentNAS.Height = Application.GetRealHeight(musicModel.NASListList.Count * 100); } else { readListNAS.UnSelectedImagePath = "MusicIcon/Listreading.png"; sdContentNAS.Height = 0; } }; middle.AddChidren(sdContentNAS); var refurbishNAS = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/refurbish.png", SelectedImagePath = "MusicIcon/refurbishSelected.png", X = Application.GetRealWidth(460), Gravity = Gravity.CenterVertical, }; nasrowlayout.AddChidren(refurbishNAS); refurbishNAS.MouseUpEventHandler += (sender, e) => { refurbishNAS.IsSelected = true; MainPage.Loading.Start(); System.Threading.Tasks.Task.Run(() => { Control.ControlBytesSend(Command.ControlMusicModel, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*S2UPDATELIST")); System.Threading.Thread.Sleep(4000); Application.RunOnMainThread(() => { MainPage.Loading.Hide(); refurbishNAS.IsSelected = false; }); }); }; #endregion #region 蓝牙 var bluetoothrowlayout = new RowLayout { LineColor = SkinStyle.Current.MusicRowLayoutLineColor, Height = Application.GetRealHeight(100), }; middle.AddChidren(bluetoothrowlayout); var bluetoothhoto = new Button { Width = Application.GetRealWidth(61), Height = Application.GetRealHeight(81), UnSelectedImagePath = "MusicIcon/bluetooth.png", SelectedImagePath = "MusicIcon/bluetoothselected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Gravity = Gravity.CenterVertical, }; bluetoothrowlayout.AddChidren(bluetoothhoto); var bluetooth = new Button { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), TextID = MyInternationalizationString.Musicbluetooth, TextSize = 15, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(130), TextColor = SkinStyle.Current.MusicTextColor, }; bluetoothrowlayout.AddChidren(bluetooth); var nextbluetooth = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(550), Gravity = Gravity.CenterVertical, }; bluetoothrowlayout.AddChidren(nextbluetooth); bluetooth.MouseUpEventHandler += (sender, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); PlayPage playPage = new PlayPage { }; MainPage.MainFrameLayout.AddChidren(playPage); playPage.Show(musicModel, new List()); playPage.SourceId = 8; }; nextbluetooth.MouseUpEventHandler += (sender, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); PlayPage playPage = new PlayPage { }; MainPage.MainFrameLayout.AddChidren(playPage); playPage.Show(musicModel,new List()); playPage.SourceId = 8; }; #endregion #region FM收音机 var FMowlayout = new RowLayout { LineColor = SkinStyle.Current.MusicRowLayoutLineColor, Height = Application.GetRealHeight(100), }; middle.AddChidren(FMowlayout); var FM = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/FM.png", SelectedImagePath = "MusicIcon/FMselected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(30), Gravity = Gravity.CenterVertical, }; FMowlayout.AddChidren(FM); var FMtooth = new Button { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), //Text="收音机", TextID = MyInternationalizationString.MusicFM, TextSize = 15, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(130), TextColor = SkinStyle.Current.MusicTextColor, }; FMowlayout.AddChidren(FMtooth); FMtooth.MouseUpEventHandler += (sender, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); Control.ControlBytesSend(Command.ControlMusicModel, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*Z1SRC5")); RadioPage playMusicRadio = new RadioPage { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(playMusicRadio); playMusicRadio.Show(musicModel); }; var nextFM = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(550), Gravity = Gravity.CenterVertical, }; FMowlayout.AddChidren(nextFM); nextFM.MouseUpEventHandler += (sender, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); Control.ControlBytesSend(Command.ControlMusicModel, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*Z1SRC5")); RadioPage playMusicRadio = new RadioPage { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, }; MainPage.MainFrameLayout.AddChidren(playMusicRadio); playMusicRadio.Show(musicModel); }; #endregion #region CD var CDrowlayout = new RowLayout { LineColor = SkinStyle.Current.MusicRowLayoutLineColor, Height = Application.GetRealHeight(100), }; middle.AddChidren(CDrowlayout); var CDhoto = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/CD.png", SelectedImagePath = "MusicIcon/CDSelected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(30), Gravity = Gravity.CenterVertical, }; CDrowlayout.AddChidren(CDhoto); var CD = new Button { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), //Text = "CD", TextID = MyInternationalizationString.MusicCD, TextSize = 15, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(130), TextColor = SkinStyle.Current.MusicTextColor, }; CDrowlayout.AddChidren(CD); var nextCD = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(550), Gravity = Gravity.CenterVertical, }; CDrowlayout.AddChidren(nextCD); nextCD.MouseUpEventHandler += (sedner, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); PlayPage playMusicCD = new PlayPage { }; MainPage.MainFrameLayout.AddChidren(playMusicCD); playMusicCD.Show(musicModel, new List()); playMusicCD.SourceId = 6; }; CD.MouseUpEventHandler += (semder, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); PlayPage playPage = new PlayPage { }; MainPage.MainFrameLayout.AddChidren(playPage); playPage.Show(musicModel, new List()); playPage.SourceId = 6; }; #endregion #region FD光纤 var FDrowlayout = new RowLayout { LineColor = SkinStyle.Current.MusicRowLayoutLineColor, Height = Application.GetRealHeight(100), }; middle.AddChidren(FDrowlayout); var FDhoto = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(76), UnSelectedImagePath = "MusicIcon/FD.png", SelectedImagePath = "MusicIcon/FDSelected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(30), Gravity = Gravity.CenterVertical, }; FDrowlayout.AddChidren(FDhoto); var FD = new Button { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), //Text = "FD", TextID = MyInternationalizationString.MusicFD, TextSize = 15, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(130), TextColor = SkinStyle.Current.MusicTextColor, }; FDrowlayout.AddChidren(FD); FD.MouseUpEventHandler += (sender, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); PlayPage playPage = new PlayPage { }; MainPage.MainFrameLayout.AddChidren(playPage); playPage.Show(musicModel, new List()); playPage.SourceId = 9; }; var nextFD = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(550), Gravity = Gravity.CenterVertical, }; FDrowlayout.AddChidren(nextFD); nextFD.MouseUpEventHandler += (sender, e) => { //先移除当前控件的前面那个控件 this.Parent.RemoveAt(this.Parent.ChildrenCount - 2); //当前控件界面 this.RemoveFromParent(); PlayPage playPage = new PlayPage { }; MainPage.MainFrameLayout.AddChidren(playPage); playPage.Show(musicModel, new List()); playPage.SourceId = 9; }; #endregion #region 我的最爱 var rowList = new RowLayout { LineColor = SkinStyle.Current.MusicRowLayoutLineColor, Height = Application.GetRealHeight(100), }; //middle.AddChidren(rowList); var likehoto = new Button { Width = Application.GetRealWidth(105), Height = Application.GetRealHeight(113), UnSelectedImagePath = "MusicIcon/like.png", SelectedImagePath = "MusicIcon/likeSelected.png", TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(20), Gravity = Gravity.CenterVertical, }; rowList.AddChidren(likehoto); var likedList = new Button { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), TextID = MyInternationalizationString.Musiclike, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(130), }; rowList.AddChidren(likedList); likedList.MouseDownEventHandler += (sender, e) => { LikeList likeList = new LikeList { }; MainPage.MainFrameLayout.AddChidren(likeList); likeList.Show(musicModel); }; var nextlike = new Button { Width = Application.GetRealWidth(87), Height = Application.GetRealHeight(100), UnSelectedImagePath = "MusicIcon/Next.png", X = Application.GetRealWidth(550), }; rowList.AddChidren(nextlike); nextlike.MouseDownEventHandler += (sender, e) => { LikeList likeList = new LikeList { }; MainPage.MainFrameLayout.AddChidren(likeList); likeList.Show(musicModel); }; #endregion } /// /// 读取列表 /// /// 音乐对象 /// 源号 void readPlayList(MusicModel musicModel, int sourceID) { List listMusicTypeName = new List(); List listMusicListName = new List(); List listMusicSongName = new List(); #region 读取类型 //int typeNum = 0; ////读取类型 //while (true) //{ // typeNum++; // string typeNumStr = ""; // if (typeNum < 10) // { // typeNumStr = "00" + typeNum.ToString(); // } // else if (typeNum < 100) // { // typeNumStr = "0" + typeNum.ToString(); // } // else // { // typeNumStr = typeNumStr.ToString(); // } // byte[] bytes = Control.ControlBytesSendHasReturn(Command.ControlMusicModel2, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*Z011TYPE" + typeNumStr + "1")); // if (bytes == null) // { // return; // } // int count = 0; // for (int i = 15; i < bytes.Length - 1;) // { // if (bytes[i] == 0x00 && bytes[i + 1] == 0x03) // { // //如果读取到结束符的时候,就退出 // break; // } // count += 2; // //unicode码顺序要对换,要不有乱码 // byte b = bytes[i]; // bytes[i] = bytes[i + 1]; // bytes[i + 1] = b; // //每个字符有两个byte // i += 2; // } // //反馈回来的类型名 // string content = System.Text.Encoding.Unicode.GetString(bytes, 15, count); // if (null == listMusicTypeName.Find((kv) => { return kv.number == typeNumStr; })) // { // listMusicTypeName.Add(new KeyAndValue { number = typeNumStr, name = content }); // } // if (bytes[12] == (byte)'1') // { // //已经读取完成,退出读取音乐类型 // break; // } //} #endregion listMusicTypeName.Add(new KeyAndValue { number = "001", name = "Default" }); #region 读取列表 //读取列表 for (int i = 0; i < listMusicTypeName.Count; i++) { string typeNumberString = listMusicTypeName[i].number; int listCount = 0; while (true) { listCount++; string listNumberStr = ""; if (listCount < 10) { listNumberStr = "00" + listCount; } else if (listCount < 100) { listNumberStr = "0" + listCount; } else { listNumberStr = listCount.ToString(); } byte[] bytes = Control.ControlBytesSendHasReturn(Command.ControlMusicModel2, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*Z01" + sourceID + "LIST" + typeNumberString + listNumberStr + "1")); if (bytes == null) { //当前可能是丢包,读取下一条 break; } int count = 0; for (int j = 15 + 3; j < bytes.Length - 1;) { if (bytes[j] == 0x00 && bytes[j + 1] == 0x03) { //如果读取到结束符的时候,就退出 break; } count += 2; //unicode码顺序要对换,要不有乱码 byte b = bytes[j]; bytes[j] = bytes[j + 1]; bytes[j + 1] = b; //每个字符有两个byte j += 2; } //反馈回来的类型名 string content = System.Text.Encoding.Unicode.GetString(bytes, 15 + 3, count); if (null == listMusicListName.Find((kv) => { return kv.number == typeNumberString + listNumberStr; })) { listMusicListName.Add(new KeyAndValue { number = typeNumberString + listNumberStr, name = content }); } if (bytes[12 + 3] == (byte)'1') { //已经读取完成,退出读取音乐类型 break; } } } #endregion #region 读取音乐 //读取音乐 for (int i = 0; i < listMusicListName.Count; i++) { string listNumberString = listMusicListName[i].number; int songCount = 0; while (true) { songCount++; string songNumberStr = ""; if (songCount < 10) { songNumberStr = "00" + songCount; } else if (songCount < 100) { songNumberStr = "0" + songCount; } else { songNumberStr = songCount.ToString(); } byte[] bytes = Control.ControlBytesSendHasReturn(Command.ControlMusicModel2, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*Z01" + sourceID + "SONG" + listNumberString + songNumberStr + "1")); if (bytes == null) { //当前可能是丢包,读取下一条 break; } int count = 0; for (int j = 15 + 3 + 3; j < bytes.Length - 1;) { if (bytes[j] == 0x00 && bytes[j + 1] == 0x03) { break; } count += 2; byte b = bytes[j]; bytes[j] = bytes[j + 1]; bytes[j + 1] = b; j += 2; } //反馈回来的类型名 string content = System.Text.Encoding.Unicode.GetString(bytes, 15 + 3 + 3, count); if (null == listMusicSongName.Find((kv) => { return kv.number == listNumberString + songNumberStr; })) { listMusicSongName.Add(new KeyAndValue { number = listNumberString + songNumberStr, name = content }); if (bytes[12 + 3 + 3] == (byte)'1') { //已经读取完成,退出读取音乐类型 break; } } } } #endregion if (sourceID == 1) { //SD卡播放列表 musicModel.SDCardTypeList = listMusicTypeName; musicModel.SDCardListList = listMusicListName; musicModel.SDCardSongList = listMusicSongName; } else { //Nas播放列表 musicModel.NASTypeList = listMusicTypeName; musicModel.NASListList = listMusicListName; musicModel.NasSongList = listMusicSongName; } //读取列表完成,重新保存起来 string saveRoomUIName = "Room_" + Room.CurrentRoom.Name; Shared.IO.FileUtils.WriteFileByBytes(saveRoomUIName, Shared.SimpleControl.CommonPage.MyEncodingUTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(Room.CurrentRoom))); } } }