using System; namespace Shared.SimpleControl.Phone { public class UserUniversalPage : FrameLayout { /// /// 当前打开的灯光界面 /// static UserUniversalPage curView; VerticalScrolViewLayout lightListView; Room room; /// /// 显示当前房间灯光设备 /// /// Room. public UserUniversalPage (Room Room) { curView = this; room = Room; BackgroundColor = SkinStyle.Current.ViewColor; } /// /// 房间模式进入的灯光界面 /// /// The lights room. public void ShowUniversalRoom () { #region 标题 var topView = new FrameLayout () { Y = Application.GetRealHeight (36), Height = Application.GetRealHeight (90), BackgroundColor = SkinStyle.Current.MainColor, }; AddChidren (topView); var title = new Button () { TextAlignment = TextAlignment.Center, Text = room.Name, TextColor = SkinStyle.Current.TextColor1, TextSize = 19, }; topView.AddChidren (title); var logo = new Button () { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (486), UnSelectedImagePath = MainPage.LogoString, }; topView.AddChidren (logo); var back = new Button () { Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (85), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", }; topView.AddChidren (back); back.MouseUpEventHandler += (sender, e) => { (Parent as PageLayout).PageIndex -= 1; curView = null; }; #endregion VerticalScrolViewLayout bodyMainView = new VerticalScrolViewLayout () { Height = Application.GetRealHeight (Application.DesignHeight) - topView.Bottom, Y = topView.Bottom, }; AddChidren (bodyMainView); var roomBackgroundImage = new FrameLayout () { Height = Application.GetRealHeight (360), }; bodyMainView.AddChidren (roomBackgroundImage); roomBackgroundImage.BackgroundImagePath = room.BackGroundImage; roomBackgroundImage.MouseLongEventHandler += (sender, e) => { Camera.SelectPicture ((obj) => { if (obj != null) { room.BackGroundImage = obj; roomBackgroundImage.BackgroundImagePath = obj; room.Save (typeof (Room).Name + "_" + room.Name); } }, room.Name, false); }; lightListView = new VerticalScrolViewLayout () { BackgroundColor = SkinStyle.Current.ViewColor, Y = roomBackgroundImage.Bottom, Height = Application.GetRealHeight (Application.DesignHeight) - topView.Bottom, }; lightListView.Y = roomBackgroundImage.Bottom; bodyMainView.AddChidren (lightListView); var universalDeviceList = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.UniversalDevice; }); // foreach (var common in universalDeviceList) { UniversalDevice udDevice = common as UniversalDevice; FrameLayout lightView = new FrameLayout () { Height = Application.GetRealHeight (130), Radius = 1, BorderColor = SkinStyle.Current.Transparent, BorderWidth = (uint)Application.GetMinRealAverage (5), }; lightView.AddTag ("UpdataKey", udDevice.CommonLoopID); lightListView.AddChidren (lightView); Button BtnLightViewNull = new Button () { Y = Application.GetRealHeight (127), Height = Application.GetRealHeight (3), BackgroundColor = SkinStyle.Current.MainColor, SelectedBackgroundColor = SkinStyle.Current.MainColor, }; lightView.AddChidren (BtnLightViewNull); // var tempLightName = new Button () { X = Application.GetRealWidth (20), TextAlignment = TextAlignment.CenterLeft, Text = udDevice.Name, Enable = false, TextColor = SkinStyle.Current.TextColor1, SelectedTextColor = SkinStyle.Current.TextColor1, //TextSize = 15, }; lightView.AddChidren (tempLightName); var tempSiwtch = new Button () { Width = Application.GetRealWidth (110), Height = Application.GetRealHeight (70), X = Application.GetRealWidth (640 - 110 - 20), Gravity = Gravity.CenterVertical, Radius = 2, BorderColor = SkinStyle.Current.BorderColor, TextColor = SkinStyle.Current.TextColor1, SelectedTextColor = SkinStyle.Current.TextColor1, BorderWidth = 2, }; lightView.AddChidren (tempSiwtch); if (udDevice.ActionType == 0) { tempSiwtch.Text = udDevice.ON_Text; } else if (udDevice.ActionType == 1) { tempSiwtch.Text = udDevice.OFF_Text; } else if (udDevice.ActionType == 2) { tempSiwtch.Text = udDevice.OFF_Text; Button tempON = new Button () { Width = Application.GetRealWidth (110), Height = Application.GetRealHeight (70), X = Application.GetRealWidth (640 - 250 - 20), Gravity = Gravity.CenterVertical, Radius = 2, BorderColor = SkinStyle.Current.BorderColor, TextColor = SkinStyle.Current.TextColor1, SelectedTextColor = SkinStyle.Current.TextColor1, BorderWidth = 2, Text = udDevice.ON_Text }; lightView.AddChidren (tempON); tempON.MouseUpEventHandler += (sender3, e3) => { if (udDevice.UniversalType == 0xE01C) { Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 },SendCount.Zero); } tempON.BorderColor = SkinStyle.Current.Transparent; lightView.BorderColor = SkinStyle.Current.Transparent; }; tempON.MouseDownEventHandler += (sende3r, e3) => { tempON.BorderColor = SkinStyle.Current.SelectedColor; lightView.BorderColor = SkinStyle.Current.SelectedColor; }; } tempSiwtch.MouseUpEventHandler += (sender3, e3) => { if (udDevice.UniversalType == 0xE01C) { if (udDevice.ActionType == 0) { Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 },SendCount.Zero); } else if (udDevice.ActionType == 1) { Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 },SendCount.Zero); } else if (udDevice.ActionType == 2) { Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 },SendCount.Zero); } } tempSiwtch.BorderColor = SkinStyle.Current.Transparent; lightView.BorderColor = SkinStyle.Current.Transparent; }; tempSiwtch.MouseDownEventHandler += (sende3r, e3) => { tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor; lightView.BorderColor = SkinStyle.Current.SelectedColor; }; } } } }