using System; using Shared; using Shared.SimpleControl.R; using Shared.SimpleControl; using System.Collections.Generic; namespace SmartHome.UI.SimpleControl.Phone { public class LocalDeviceListPage : FrameLayout { public void Show (Action action, List devicelist, string name) { 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 LocallistName = new Button { Text = name, TextSize = 17, TextColor = SkinStyle.Current.MusicTextColor, }; topFrameLayout.AddChidren (LocallistName); 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 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 (); devicechannelnumber (name); AddDevice.Isbool = true; action (); }; var middle = new VerticalScrolViewLayout (); middle.Y = topFrameLayout.Bottom; middle.Height = Application.GetRealHeight (1136 - 136); middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout; AddChidren (middle); foreach (var device in devicelist) { if (Language.StringByID (MyInternationalizationString.AC) == name) { device.Type = DeviceType.HVAC; } else if (Language.StringByID (MyInternationalizationString.FoolHeat) == name) { device.Type = DeviceType.FoolHeat; } else if (Language.StringByID (MyInternationalizationString.MusicModel) == name) { device.Type = DeviceType.MusicModel; } else if (Language.StringByID (MyInternationalizationString.ReshAirRead) == name) { device.Type = DeviceType.FreshAir; } var deviceRowLayout = new RowLayout { Height = Application.GetRealHeight (100), BackgroundColor = 0xff323232, }; middle.AddChidren (deviceRowLayout); var devicetypename = new Button { Width = Application.GetRealWidth (200), Text = device.Name, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth (40), }; deviceRowLayout.AddChidren (devicetypename); var btnCheck = new Button { Width = Application.GetRealWidth (60), Height = Application.GetRealHeight (59), Gravity = Gravity.CenterVertical, X = Application.GetRealWidth (550), SelectedImagePath = "Light/CheckOn.png", UnSelectedImagePath = "Light/Check.png", }; deviceRowLayout.AddChidren (btnCheck); if (AddDevice.displaydevicelist.Find ((dev) => dev.Type == device.Type && dev.CommonLoopID == device.CommonLoopID) != null) { btnCheck.IsSelected = true; } EventHandler deviicetypeclick = (sender, e) => { btnCheck.IsSelected = !btnCheck.IsSelected; if (btnCheck.IsSelected) { if (null == AddDevice.displaydevicelist.Find ((dev) => dev.Type == device.Type && dev.CommonLoopID == device.CommonLoopID)) { AddDevice.displaydevicelist.Add (device); } } else { AddDevice.displaydevicelist.RemoveAll ((dev) => dev.Type == device.Type && dev.CommonLoopID == device.CommonLoopID); } }; deviceRowLayout.MouseUpEventHandler += deviicetypeclick; devicetypename.MouseUpEventHandler += deviicetypeclick; btnCheck.MouseUpEventHandler += deviicetypeclick; } } void devicechannelnumber (string name) { int intvalue = 0; if (Language.StringByID (MyInternationalizationString.Lights) == name) { intvalue = 64; } else if (Language.StringByID (MyInternationalizationString.Curtains) == name) { intvalue = 8; } else if (Language.StringByID (MyInternationalizationString.AC) == name) { intvalue = 8; } else if (Language.StringByID (MyInternationalizationString.MusicModel) == name) { intvalue = 8; } else if (Language.StringByID (MyInternationalizationString.FoolHeat) == name) { intvalue = 8; } else if (Language.StringByID (MyInternationalizationString.ReshAirRead) == name) { intvalue = 8; } foreach (var device in AddDevice.displaydevicelist) { if (device.channelnumber == 0) { for (int i = 1; i < intvalue; i++) { var number = AddDevice.displaydevicelist.Find ((dev) => { return (dev.channelnumber != 0 && dev.channelnumber == (byte)i); }); if (number == null) { device.channelnumber = (byte)i; break; } } } } } } }