using System; using Shared; using Shared.SimpleControl.R; namespace Shared.SimpleControl.Phone.Music { class A31WifiPassword : FrameLayout { public void Show (string pas) { AddChidren (new Button { Height = Application.GetRealHeight (36), BackgroundColor = SkinStyle.Current.MusicTopFrameLayout, }); var topFrameLayout = new FrameLayout { Height = Application.GetRealHeight (90), Y = Application.GetRealHeight (36), BackgroundColor = SkinStyle.Current.MusicTopFrameLayout, }; AddChidren (topFrameLayout); var btnTitle = new Button { TextColor = SkinStyle.Current.MusicTextColor, Text = "WI-FI PASSWORD", }; topFrameLayout.AddChidren (btnTitle); var back = new Button { Width = Application.GetRealWidth (82), Height = Application.GetRealHeight (89), X = Application.GetRealWidth (10), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/HomepageBack.png", }; topFrameLayout.AddChidren (back); back.MouseDownEventHandler += (sender, e) => { RemoveFromParent (); }; var complete = new Button { Width = Application.GetRealWidth (110), Height = Application.GetRealHeight (100), X = Application.GetRealWidth (530), Gravity = Gravity.CenterVertical, TextID = MyInternationalizationString.complete, TextColor = SkinStyle.Current.MusicTextColor, }; topFrameLayout.AddChidren (complete); var frameLayout = new FrameLayout { Y = topFrameLayout.Bottom, Height = Application.GetRealHeight (Application.DesignHeight - 126), BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout, }; AddChidren (frameLayout); var flBackgroundColor = new FrameLayout { Y = Application.GetRealHeight (100), Height = Application.GetRealHeight (80), BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout, BorderWidth = 1, BorderColor = 0xff66e9d8,// SkinStyle.Current.MusicEditBorderColor, Radius = 1, }; frameLayout.AddChidren (flBackgroundColor); var wifipas = new Button { Width = Application.GetRealWidth (150), Height = Application.GetRealHeight (80), X = Application.GetRealWidth (30), Gravity = Gravity.CenterVertical, TextID = MyInternationalizationString.wifipassword, TextColor = SkinStyle.Current.MusicTextColor, //Text = "Wi-Fi密码:" }; flBackgroundColor.AddChidren (wifipas); var username = new EditText { Width = Application.GetRealWidth (320), Height = Application.GetRealHeight (80), X = Application.GetRealWidth (180), TextAlignment = TextAlignment.CenterLeft, //Radius = (uint)Application.GetRealHeight(6), //BackgroundColor = SkinStyle.Current.MusicEditTextBackgroundColor, PlaceholderText="Wi-Fi password", Text=pas==""? "":pas, PlaceholderTextColor = SkinStyle.Current.MusicEditTextPlaceholderTextColor, TextColor = SkinStyle.Current.MusicTextColor, BorderWidth = 1, BorderColor = SkinStyle.Current.MusicEditBorderColor, Radius = 1, }; flBackgroundColor.AddChidren (username); var btndel = new Button { Width = Application.GetRealWidth (89), Height = Application.GetRealHeight (86), X = Application.GetRealWidth (520), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/delpas.png", }; flBackgroundColor.AddChidren (btndel); btndel.MouseUpEventHandler += (sender, e) => { username.Text = ""; }; complete.MouseUpEventHandler += (sender, e) => { var textstr = username.Text.Trim (); if (textstr != "" && textstr.Length < 8) { //密码长度需要大于8位; new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.passwordlength), Language.StringByID (MyInternationalizationString.Close)).Show (); return; } MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load)); System.Threading.Tasks.Task.Run (() => { if (textstr != "") { openWeb ("http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setNetwork:1:" + textstr); } else { openWeb ("http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setNetwork:0:"); } Application.RunOnMainThread (() => { MainPage.Loading.Hide (); MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1); MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1); MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1); MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1); MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1); }); }); }; var tiptext = new Button { Y = Application.GetRealHeight (115+80), Height = Application.GetRealHeight (80), Width=Application.GetRealWidth(530), X = Application.GetRealWidth (30), TextColor = SkinStyle.Current.MusicTextColor, TextID = MyInternationalizationString.passwordlength, TextAlignment = TextAlignment.CenterLeft, //Text="the password must contain at least 8 characters.", //密码必须至少包含8个字符。 }; frameLayout.AddChidren (tiptext); } string openWeb (string url) { try { var webClient = new Shared.Net.MyWebClient (4000); return webClient.DownloadString (url); } catch (Exception e) { System.Console.WriteLine (e.Message); return null; } } } }