using System; using Shared; using Shared.SimpleControl; using Shared.SimpleControl.R; namespace SmartHome.UI.SimpleControl.Phone { public class Etid : FrameLayout { Button IocnClickButton = new Button (); EditText sceneTextBox; public string name = ""; public byte munber; public void Show (YIPanel yipanel,YiPanelScene scene,Action action) { ///定义一个变量记录当前场景名称和图标索引; name = scene.Name; munber = scene.IconIndex; 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 { TextID = MyInternationalizationString.etidscene, TextColor = SkinStyle.Current.MusicTextColor, //Text = "编辑场景", TextSize = 17, }; 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) => { var scenename = sceneTextBox.Text.Trim (); if (string.IsNullOrEmpty (scenename)) { new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.thename), Language.StringByID (MyInternationalizationString.Close)).Show (); return; } ///发送修改场景名称命令 if (name != scenename) { scene.Name = sceneTextBox.Text.Trim (); System.Threading.Tasks.Task.Run (() => { try { var bytes = new byte [24]; bytes [0] = scene.LargeClass; bytes [1] = 1; bytes [2] = scene.Channelnumber; bytes [3] = 0; var pathBytes = System.Text.Encoding.UTF8.GetBytes (scene.Name); Array.Copy (pathBytes, 0, bytes, 4, pathBytes.Length > 20 ? 20 : pathBytes.Length); Control.ControlBytesSend (Command.YIPanelDeviceModify, yipanel.SubnetID, yipanel.DeviceID, bytes); } catch { } }); } ///发送修改场景图标命令 if (munber != scene.IconIndex) { System.Threading.Tasks.Task.Run (() => { try { var iconbytes = new byte [5]; iconbytes [0] = scene.LargeClass; iconbytes [1] = 1; iconbytes [2] = scene.Channelnumber; iconbytes [3] = 8; iconbytes [4] = scene.IconIndex; var iocndata = Control.ControlBytesSendHasReturn (Command.YIPanelDeviceModify, yipanel.SubnetID, yipanel.DeviceID, iconbytes); } catch { } }); } RemoveFromParent (); action (); }; var hdl = new Button { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (486), Gravity = Gravity.CenterVertical, //UnSelectedImagePath = MainPage.LogoString, }; topFrameLayout.AddChidren (hdl); var tempFrameLayout = new FrameLayout { Y = topFrameLayout.Bottom, Height = Application.GetRealHeight (1136 - 126), //BackgroundImagePath = "MusicIcon/HomepageBackgroun.png", BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout, }; AddChidren (tempFrameLayout); #region ------- var txet = new Button { Width = Application.GetRealWidth (200), Height = Application.GetRealHeight (60), X = Application.GetRealWidth (30), Y=Application.GetRealHeight(40), //Text="场景信息", TextAlignment=TextAlignment.CenterLeft, TextID = MyInternationalizationString.sceneinformation, }; tempFrameLayout.AddChidren (txet); var sceneicon = new Button { Y = txet.Y + txet.Height + Application.GetRealHeight (40), Height = Application.GetRealHeight (80), Width = Application.GetRealWidth (83), UnSelectedImagePath = $"Yipanel/{scene.IconIndex}.png", X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, }; tempFrameLayout.AddChidren (sceneicon); sceneTextBox = new EditText{ Y = txet.Y + txet.Height + Application.GetRealHeight (40), Width = Application.GetRealWidth (440), Height = Application.GetRealHeight (80), X = sceneicon.X + sceneicon.Width + Application.GetRealWidth (30), Radius = (uint)Application.GetRealHeight (2), Text = scene.Name, //BorderWidth = 1, //BorderColor = 0xff838383, TextColor = 0xff838383, //TextAlignment = TextAlignment.Center, }; tempFrameLayout.AddChidren (sceneTextBox); var btnline = new Button { Y = sceneTextBox.Bottom, Width = Application.GetRealWidth (440), Height = Application.GetRealHeight (2), X = sceneicon.X + sceneicon.Width + Application.GetRealWidth (30), BackgroundColor = SkinStyle.Current.MusicTopFrameLayout, }; tempFrameLayout.AddChidren (btnline); var selectedicon = new Button { Width = Application.GetRealWidth (200), Height = Application.GetRealHeight (60), X = Application.GetRealWidth (30), Y = sceneTextBox.Y+sceneTextBox.Height+ Application.GetRealHeight (100), //Text = "选中图标", TextAlignment = TextAlignment.CenterLeft, TextID = MyInternationalizationString.selectedicon, }; tempFrameLayout.AddChidren (selectedicon); #endregion var iconlistview = new FrameLayout { Y = selectedicon.Y + selectedicon.Height + Application.GetRealHeight (30), Height = Application.GetRealHeight (320), Width = Application.GetRealWidth (640-120), X = Application.GetRealWidth (60), //BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout, //BorderWidth = 2, //BorderColor = 0xffffffff, }; tempFrameLayout.AddChidren (iconlistview); var middle = new VerticalScrolViewLayout (); iconlistview.AddChidren (middle); int k = 1; for (int i = 1; i <= 3; i++) { var iconfra = new FrameLayout { Height = Application.GetRealHeight (100), }; middle.AddChidren (iconfra); for (int j = 1; j <= 4; j++) { var sceneiconbtn = new Button { Height = Application.GetRealHeight (80), Width = Application.GetRealWidth (83), UnSelectedImagePath = $"Yipanel/{k}.png", SelectedImagePath = $"Yipanel/{k}Selected.png", Gravity = Gravity.CenterVertical, X = Application.GetRealWidth (37 * j + (83 * (j - 1))), Tag = k, }; iconfra.AddChidren (sceneiconbtn); k++; ///显示之前状态 if (scene.IconIndex== (byte)int.Parse (sceneiconbtn.Tag.ToString ())) { IocnClickButton.IsSelected = false; IocnClickButton = sceneiconbtn; sceneiconbtn.IsSelected = true; } sceneiconbtn.MouseDownEventHandler += (sender, e) => { IocnClickButton.IsSelected = false; IocnClickButton = sceneiconbtn; sceneiconbtn.IsSelected = true; scene.IconIndex = (byte)int.Parse (sceneiconbtn.Tag.ToString ()); sceneicon.UnSelectedImagePath = $"Yipanel/{scene.IconIndex}.png"; }; } } 
 } } }