using System; using System.Collections.Generic; using System.Text; using Shared; using Shared.SimpleControl.R; using Shared.SimpleControl.Phone.Music; using Shared.SimpleControl.Phone; namespace SmartHome.UI.SimpleControl.Phone.Music { class A31Rename : FrameLayout { //当前选择的按键 Button selecteButton = null; public void show (A31MusicModel a31) { 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 RadiolistName = new Button { TextID = MyInternationalizationString.radiolistName, TextColor = SkinStyle.Current.MusicTextColor, }; topFrameLayout.AddChidren (RadiolistName); 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); complete.MouseUpEventHandler += (sender, e) => { if (selecteButton == null) { return; } a31.Name = selecteButton.Text; System.Threading.Tasks.Task.Run (() => { try { new Shared.Net.MyWebClient ().DownloadData ("http://" + a31.IPAddress + "/httpapi.asp?command=setDeviceName:" + a31.Name); } catch { } }); this.Parent.RemoveAt (Parent.ChildrenCount - 4); this.Parent.RemoveAt (Parent.ChildrenCount - 3); this.Parent.RemoveAt (Parent.ChildrenCount - 2); 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 - 136); middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout; AddChidren (middle); var customLayout = new RowLayout { Height = Application.GetRealHeight (100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; middle.AddChidren (customLayout); var custom = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, TextID = MyInternationalizationString.custom, TextColor = SkinStyle.Current.MusicTextColor, }; customLayout.AddChidren (custom); var next = new Button { Width = Application.GetRealWidth (87), Height = Application.GetRealHeight (100), UnSelectedImagePath = "MusicIcon/Next.png", SelectedImagePath = "MusicIcon/NextSelecte.png", X = Application.GetRealWidth (550), }; customLayout.AddChidren (next); EventHandler eventHandler = (sender, e) => { if (selecteButton != null) { selecteButton.Parent.BackgroundColor = 0x00000000; } selecteButton = sender as Button; selecteButton.Parent.BackgroundColor = SkinStyle.Current.MusicselecteButtonColcor; }; 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), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; middle.AddChidren (toiletyout); var button = new Button { Height = Application.GetRealHeight (100), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, Text = s, TextColor = SkinStyle.Current.MusicTextColor, }; 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 (30), Y = Application.GetRealHeight (330), 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, TextColor=SkinStyle.Current.MusicTipTextColor, 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 =SkinStyle.Current.MusicTipBackgroundColor, Radius=1, BorderWidth=1, BorderColor=SkinStyle.Current.MusicEditBorderColor, //TextColor = 0xff000000, TextColor = SkinStyle.Current.MusicTipTextColor, }; 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, TextColor = SkinStyle.Current.MusicTipTextColor, }; 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, TextColor = SkinStyle.Current.MusicTipTextColor, }; 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), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; 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 (); } }; }; } } }