using System; using System.Collections.Generic; using System.Text; using Shared; using Shared.SimpleControl.R; using Shared.SimpleControl.Pad.Music; using Shared.SimpleControl.Pad; namespace SmartHome.UI.SimpleControl.Pad.Music { class A31Rename : FrameLayout { //当前选择的按键 Button selecteButton = null; public void show(A31MusicModel a31) { var topFrameLayout = new FrameLayout { Height = Application.GetRealHeight(100), BackgroundColor = SkinStyle.Current.MainColor, }; AddChidren(topFrameLayout); var RadiolistName = new Button { TextID = MyInternationalizationString.radiolistName, }; topFrameLayout.AddChidren(RadiolistName); var complete = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(100), X = Application.GetRealWidth(480), Gravity = Gravity.CenterVertical, TextID=MyInternationalizationString.complete, }; topFrameLayout.AddChidren(complete); complete.MouseUpEventHandler += (sender, e) => { if (selecteButton == null) { return; } a31.Name = selecteButton.Text; System.Threading.Tasks.Task.Run(() => { try { new System.Net.WebClient().DownloadData("http://" + a31.IPAddress + "/httpapi.asp?command=setDeviceName:" + a31.Name); } catch { } }); RemoveFromParent(); }; 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.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; var middle = new VerticalScrolViewLayout(); middle.Y = topFrameLayout.Bottom; middle.Height = Application.GetRealHeight(Application.DesignHeight - 100-150); middle.BackgroundColor = 0xff2F2F2F; AddChidren(middle); var customLayout = new RowLayout { Height = Application.GetRealHeight(100), }; middle.AddChidren(customLayout); var custom = new Button { Height = Application.GetRealHeight(100), X = Application.GetRealWidth(30), TextAlignment = TextAlignment.CenterLeft, TextID=MyInternationalizationString.custom, }; customLayout.AddChidren(custom); EventHandler eventHandler = (sender, e) => { if (selecteButton != null) { selecteButton.Parent.BackgroundColor = 0x00000000; } selecteButton = sender as Button; selecteButton.Parent.BackgroundColor = 0xff525252; }; List deviceName = new List(); deviceName.AddRange (new string [] { Language.StringByID(MyInternationalizationString.Bedroom), Language.StringByID(MyInternationalizationString.Studyroom), Language.StringByID(MyInternationalizationString.Office), Language.StringByID(MyInternationalizationString.Livingroom), Language.StringByID(MyInternationalizationString.Meetingroom), Language.StringByID(MyInternationalizationString.Kitchen), Language.StringByID(MyInternationalizationString.Bathroom), }); if (!deviceName.Contains(a31.Name)) { deviceName.Add(a31.Name); } foreach (string s in deviceName) { var toiletyout = new RowLayout { Height = Application.GetRealHeight(100), }; middle.AddChidren(toiletyout); var button = new Button { Height = Application.GetRealHeight(100), X = Application.GetRealWidth(30), TextAlignment = TextAlignment.CenterLeft, Text = s, }; toiletyout.AddChidren(button); button.MouseUpEventHandler += eventHandler; if (s == a31.Name) { //选择 eventHandler(button, new MouseEventArgs { }); } } custom.MouseUpEventHandler += (sender, e) => { Dialog window = new Dialog(); window.Show(); var frameLayout = new FrameLayout { Width = Application.GetRealWidth(580), Height = Application.GetRealHeight(300), X = Application.GetRealWidth(1380), Y = Application.GetRealHeight(450), BackgroundColor = 0xffffffff, }; window.AddChidren(frameLayout); var Modifyname = new Button { Width = Application.GetRealWidth(580), Height = Application.GetRealHeight(80), TextID=MyInternationalizationString.Modifyname, Y = Application.GetRealHeight(10), TextColor = 0xff000000, TextSize = 20, }; frameLayout.AddChidren(Modifyname); var devicename = new EditText { Width = Application.GetRealWidth(540), Height = Application.GetRealHeight(80), Y = Application.GetRealHeight(80), X = Application.GetRealWidth(20), Gravity = Gravity.CenterVertical, BackgroundColor = 0xffcccccc, TextColor = 0xff000000, }; frameLayout.AddChidren(devicename); var ther1 = new Button { Height = Application.GetRealHeight(2), Y = Application.GetRealHeight(218), BackgroundColor = 0xff666666, }; frameLayout.AddChidren(ther1); var cancelrow = new RowLayout { Y = Application.GetRealHeight(220), Height = Application.GetRealHeight(80), Width = Application.GetRealWidth(289), BackgroundColor = 0xffcccccc, }; frameLayout.AddChidren(cancelrow); var cancel = new Button { TextID=MyInternationalizationString.cancel, TextColor = 0xff000000, TextSize = 18, }; cancelrow.AddChidren(cancel); cancel.MouseUpEventHandler += (sender1, e1) => { window.Close(); }; var ther = new Button { Y = Application.GetRealHeight(220), Height = Application.GetRealHeight(80), Width = Application.GetRealWidth(2), X = Application.GetRealHeight(289), BackgroundColor = 0xff666666, }; frameLayout.AddChidren(ther); var confirmrow = new RowLayout { Y = Application.GetRealHeight(220), X = Application.GetRealWidth(291), Height = Application.GetRealHeight(80), Width = Application.GetRealWidth(289), BackgroundColor = 0xffcccccc, }; frameLayout.AddChidren(confirmrow); var confirm = new Button { TextID=MyInternationalizationString.confirm, TextColor = 0xff000000, TextSize = 18, }; confirmrow.AddChidren(confirm); confirm.MouseUpEventHandler += (sender1, e1) => { //如果不存在就添加 if (devicename.Text!=""&& !deviceName.Contains(devicename.Text)) { deviceName.Add(devicename.Text); var toiletyout = new RowLayout { Height = Application.GetRealHeight(100), }; middle.AddChidren(toiletyout); var button = new Button { Height = Application.GetRealHeight(100), X = Application.GetRealWidth(30), TextAlignment = TextAlignment.CenterLeft, Text = devicename.Text, }; toiletyout.AddChidren(button); button.MouseUpEventHandler += eventHandler; //选择当前添加的按键 eventHandler(button, new MouseEventArgs { }); window.Close(); } }; }; } } }