using System; using System.Collections.Generic; using Newtonsoft.Json.Linq; using Shared; using Shared.Common; using Shared.Phone; using Shared.R; using ZigBee.Device; namespace Shared.Phone.Device.Logic { public class LogicDevicePage : FrameLayout { public LogicDevicePage() { Tag = "Logic"; } Button SelectedButton = new Button(); HorizontalScrolViewLayout horizontalScrol; VerticalScrolViewLayout middle; public void Show() { UserView.HomePage.Instance.ScrollEnabled = false; this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor; var topFrameLayout = new RowLayout { Height = Application.GetRealHeight(220), Y = Application.GetRealHeight(80), BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, }; AddChidren(topFrameLayout); var titleName = new Button { TextID = MyInternationalizationString.devicestate, TextSize = 17, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(150), }; topFrameLayout.AddChidren(titleName); var back = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), X = Application.GetRealWidth(20), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "ZigeeLogic/Back.png", }; topFrameLayout.AddChidren(back); back.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); UserView.HomePage.Instance.ScrollEnabled = true; }; var roomname = new Button { Width = Application.GetMinRealAverage(300 + 300-30), Height = Application.GetMinRealAverage(80), X = Application.GetRealWidth(1080 - 300 - 30 - 300), Y = Application.GetRealHeight(120), TextAlignment = TextAlignment.CenterRight, //Text = "自定义房间", TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextID=MyInternationalizationString.customroom, }; topFrameLayout.AddChidren(roomname); var horizontalScrolfl = new FrameLayout { Height = Application.GetRealHeight(220 + 30), Y = topFrameLayout.Bottom, BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, }; AddChidren(horizontalScrolfl); horizontalScrol = new HorizontalScrolViewLayout() { Width = Application.GetRealWidth(1080 - 40), Height = Application.GetRealHeight(180 + 30), Y = Application.GetRealHeight(40), X = Application.GetRealWidth(40), Radius = (uint)Application.GetRealHeight(30), }; horizontalScrolfl.AddChidren(horizontalScrol); middle = new VerticalScrolViewLayout(); middle.Y = horizontalScrolfl.Bottom; middle.Height = Application.GetRealHeight(1920 - 300 - 250); middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; this.AddChidren(middle); ///过滤掉的设备 List deviceTypeList = new List { DeviceType.IASZone, DeviceType.OnOffSwitch, DeviceType.AirSwitch, }; ///房间点击事件 roomname.MouseUpEventHandler += (sender, e) => { var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); flMain.MouseUpEventHandler += (sender2, e2) => { flMain.RemoveFromParent(); }; var roombj = new VerticalScrolViewLayout { Width = Application.GetRealWidth(400), Height = Application.GetRealHeight(600), X = Application.GetRealWidth(1080 - 400 - 60), Y = Application.GetRealHeight(220 + 30 + 80), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, Radius = (uint)Application.GetRealHeight(30), }; flMain.AddChidren(roombj); List roomlist = new List(); roomlist.Clear(); Common.Room customroom = new Common.Room(); customroom.Name = Language.StringByID(MyInternationalizationString.customroom); foreach (var device in Common.Logic.LogicDviceList) { var deviceui = customroom.GetDeviceUI(device); if (deviceui != null) { customroom.DeviceUIList.Add(deviceui); } } roomlist.Add(customroom); roomlist.AddRange(Common.Room.Lists); foreach (var room in roomlist) { var rowLayout = new RowLayout { Height = Application.GetRealHeight(150), }; roombj.AddChidren(rowLayout); var btnroomname = new Button { Width = Application.GetRealWidth(300), Text = room.Name, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(30), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; rowLayout.AddChidren(btnroomname); EventHandler roomclick = (sender1, e1) => { flMain.RemoveFromParent(); roomname.Text = room.Name; var list = new List(); foreach (var device in room.DeviceUIList) { if (!deviceTypeList.Contains(device.CommonDevice.Type)) { list.Add(device); } } AllDeviceTypeView(list); }; rowLayout.MouseUpEventHandler += roomclick; btnroomname.MouseUpEventHandler += roomclick; } }; Common.Room customroom1 = new Common.Room(); foreach (var device in Common.Logic.LogicDviceList) { //过滤掉没有用到设备; if (deviceTypeList.Contains(device.Type)) { continue; } var deviceui = customroom1.GetDeviceUI(device); if (deviceui != null) { customroom1.DeviceUIList.Add(deviceui); } } AllDeviceTypeView(customroom1.DeviceUIList); } /// ///加载该区域所有设备的视图方法 /// void AllDeviceTypeView(List devicelist) { List devicetypelist = new List(); devicetypelist.Clear(); #region ------排列设备类型------ var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.ColorDimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } #endregion horizontalScrol.RemoveAll(); foreach (var devicetype in devicetypelist) { var deviceRowLayout = new FrameLayout { Height = Application.GetRealHeight(180 + 30), Width = Application.GetRealWidth(250), }; horizontalScrol.AddChidren(deviceRowLayout); var devicetypeicon = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), X = Application.GetRealWidth(70), }; deviceRowLayout.AddChidren(devicetypeicon); if (devicetype == Language.StringByID(MyInternationalizationString.Lights)) { devicetypeicon.UnSelectedImagePath = "ZigeeLogic/Light.png"; devicetypeicon.SelectedImagePath = "ZigeeLogic/LightSelected.png"; } else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains)) { devicetypeicon.UnSelectedImagePath = "ZigeeLogic/Curtain.png"; devicetypeicon.SelectedImagePath = "ZigeeLogic/CurtainSelected.png"; } var devicetypename = new Button { Width = Application.GetRealWidth(250), Height = Application.GetRealHeight(50), Text = devicetype, TextAlignment = TextAlignment.Center, Y = devicetypeicon.Bottom + Application.GetRealHeight(20), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; deviceRowLayout.AddChidren(devicetypename); EventHandler devicetypeclick = (sender13, e13) => { List list = new List(); list.Clear(); SelectedButton.IsSelected = false; SelectedButton = devicetypeicon; SelectedButton.IsSelected = true; ///分类显示(例如灯光:{灯光1,灯光2...}) if (devicetype == Language.StringByID(MyInternationalizationString.Lights)) { list.Add(DeviceType.OnOffOutput);//0x0101十进制257 } else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains)) { list.Add(DeviceType.WindowCoveringDevice); } ActionDeviceView(list, devicelist); }; deviceRowLayout.MouseUpEventHandler += devicetypeclick; devicetypename.MouseUpEventHandler += devicetypeclick; devicetypeicon.MouseUpEventHandler += devicetypeclick; } ///显示房间所有设备 ActionDeviceView( new List(), devicelist); } /// /// 加载该类型设备视图方法 /// /// 设备列表 void ActionDeviceView( List deviceTypelist, List devicelist) { middle.RemoveAll(); foreach (var common in devicelist) { if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type)) { continue; } var row = new RowLayout { Height = Application.GetRealHeight(180), }; middle.AddChidren(row); var devicename = new Button { Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(600), //SelectedBackgroundColor = 0xFFE9652D, Text = common.CommonDevice.DeviceEpointName, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; row.AddChidren(devicename); var btndeviceback = new Button { Width = Application.GetRealWidth(110), Height = Application.GetRealHeight(110), UnSelectedImagePath = "ZigeeLogic/Next.png", X = Application.GetRealWidth(1080 - 140), Gravity = Gravity.CenterVertical, }; row.AddChidren(btndeviceback); EventHandler devicclick = (sen, e) => { var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); CurrentDeviceStateView(flMain, common.CommonDevice, false); }; row.MouseUpEventHandler += devicclick; devicename.MouseUpEventHandler += devicclick; btndeviceback.MouseUpEventHandler += devicclick; } } /// /// 选中该设备功能作为条件的视图方法 /// /// Common. public static void CurrentDeviceStateView(FrameLayout flMain, CommonDevice common, bool edit) { //不让当前界面滑动 UserView.HomePage.Instance.ScrollEnabled = false; Dictionary actionsInfo = new Dictionary(); List> taskListInfo = new List>(); //var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; //this.AddChidren(flMain); flMain.MouseUpEventHandler += (sender, e) => { flMain.RemoveFromParent(); }; var devicefra = new FrameLayout { Width = Application.GetRealWidth(1080 - 80), X = Application.GetRealWidth(40), BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, Radius = (uint)Application.GetRealHeight(50), }; flMain.AddChidren(devicefra); var devicename = new Button { Y = Application.GetRealHeight(20), Text = common.DeviceEpointName, TextColor = ZigbeeColor.Current.LogicTextBlackColor, Height = Application.GetRealHeight(150), Width = Application.GetRealWidth(1080 - 80), }; devicefra.AddChidren(devicename); if (actionsInfo.ContainsKey("LinkType")) { actionsInfo.Remove("LinkType"); } if (actionsInfo.ContainsKey("DeviceAddr")) { actionsInfo.Remove("DeviceAddr"); } if (actionsInfo.ContainsKey("Epoint")) { actionsInfo.Remove("Epoint"); } if (actionsInfo.ContainsKey("Time")) { actionsInfo.Remove("Time"); } if (actionsInfo.ContainsKey("TaskList")) { actionsInfo.Remove("TaskList"); } actionsInfo.Add("LinkType", 0); actionsInfo.Add("DeviceAddr", common.DeviceAddr); actionsInfo.Add("Epoint", common.DeviceEpoint); actionsInfo.Add("Time", 0); actionsInfo.Add("TaskList", taskListInfo); List> TaskList = null; if (edit) { foreach (var deviceinfo in Common.Logic.CurrentLogic.Actions) { if (deviceinfo["LinkType"].ToString() == "0") { if (deviceinfo["DeviceAddr"].ToString() == common.DeviceAddr && deviceinfo["Epoint"].ToString() == common.DeviceEpoint.ToString()) { TaskList = deviceinfo["TaskList"] as List>; break; } } } } switch (common.Type) { ///灯光 case DeviceType.OnOffOutput: { #region ----初始化设备功能数据---- Dictionary switchdictionary = new Dictionary(); if (switchdictionary.ContainsKey("TaskType")) { switchdictionary.Remove("TaskType"); } if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } if (switchdictionary.ContainsKey("Data2")) { switchdictionary.Remove("Data2"); } switchdictionary.Add("TaskType", "1"); switchdictionary.Add("Data1", "0"); switchdictionary.Add("Data2", "0"); taskListInfo.Add(switchdictionary); #endregion #region 灯光View devicefra.Y = Application.GetRealHeight(1920 - 30 - 720); devicefra.Height = Application.GetRealHeight(720); var OnOffOutputfra = new FrameLayout { Y = Application.GetRealHeight(180), Height = Application.GetRealHeight(180 * 2+ 30), }; devicefra.AddChidren(OnOffOutputfra); var openrowlayout = new RowLayout { Height = Application.GetRealHeight(180), }; OnOffOutputfra.AddChidren(openrowlayout); var btnopen = new Button { //Text = "开", TextID = MyInternationalizationString.open, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(180), //SelectedBackgroundColor = 0xfffe5e00, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; openrowlayout.AddChidren(btnopen); var openBtnSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; openrowlayout.AddChidren(openBtnSelected); var closerowlayout = new RowLayout { Y = openrowlayout.Bottom, Height = Application.GetRealHeight(180), }; OnOffOutputfra.AddChidren(closerowlayout); var btnclose = new Button { //Text = "关", TextID = MyInternationalizationString.close, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(180), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; closerowlayout.AddChidren(btnclose); var closeBtnSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical, }; closerowlayout.AddChidren(closeBtnSelected); #endregion ///确认事件 EventHandler openclick = (sender, e) => { openBtnSelected.Visible = true; closeBtnSelected.Visible = false; if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "1");//默认值 LogicIfon.AddDeviceactions(common,actionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; openrowlayout.MouseUpEventHandler += openclick; btnopen.MouseUpEventHandler += openclick; openBtnSelected.MouseUpEventHandler += openclick; ///取消事件 EventHandler closeclick = (sender, e) => { openBtnSelected.Visible = false; closeBtnSelected.Visible = true; if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "0");//默认值 LogicIfon.AddDeviceactions(common, actionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; closerowlayout.MouseUpEventHandler += closeclick; btnclose.MouseUpEventHandler += closeclick; closeBtnSelected.MouseUpEventHandler += closeclick; if (edit && TaskList != null) { foreach (var value in TaskList) { if (value["TaskType"] == "1") { if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } if (value["Data1"] == "1") { switchdictionary.Add("Data1", "1"); openBtnSelected.Visible = true; closeBtnSelected.Visible = false; } else { switchdictionary.Add("Data1", "0"); openBtnSelected.Visible = false; closeBtnSelected.Visible = true; } break; } } } } break; ///调光灯光 case DeviceType.ColorDimmableLight: { #region ----初始化设备功能数据---- Dictionary switchdictionary = new Dictionary(); if (switchdictionary.ContainsKey("TaskType")) { switchdictionary.Remove("TaskType"); } if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } if (switchdictionary.ContainsKey("Data2")) { switchdictionary.Remove("Data2"); } switchdictionary.Add("TaskType", "1"); switchdictionary.Add("Data1", "0"); switchdictionary.Add("Data2", "0"); taskListInfo.Add(switchdictionary); //Dictionary brightnessdictionary = new Dictionary(); //if (brightnessdictionary.ContainsKey("TaskType")) //{ // switchdictionary.Remove("TaskType"); //} //if (brightnessdictionary.ContainsKey("Data1")) //{ // brightnessdictionary.Remove("Data1"); //} //if (brightnessdictionary.ContainsKey("Data2")) //{ // switchdictionary.Remove("Data2"); //} //brightnessdictionary.Add("TaskType", "3"); //brightnessdictionary.Add("Data1", "0"); //brightnessdictionary.Add("Data2", "0"); //taskListInfo.Add(brightnessdictionary); #endregion #region 灯光View devicefra.Y = Application.GetRealHeight(1920 - 30 - 900); devicefra.Height = Application.GetRealHeight(900); var OnOffOutputfra = new FrameLayout { Y = Application.GetRealHeight(180), Height = Application.GetRealHeight(180 * 3 + 30), }; devicefra.AddChidren(OnOffOutputfra); var openrowlayout = new RowLayout { Height = Application.GetRealHeight(180), }; OnOffOutputfra.AddChidren(openrowlayout); var btnopen = new Button { //Text = "开", TextID = MyInternationalizationString.open, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(180), //SelectedBackgroundColor = 0xfffe5e00, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; openrowlayout.AddChidren(btnopen); var openBtnSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; openrowlayout.AddChidren(openBtnSelected); var closerowlayout = new RowLayout { Y = openrowlayout.Bottom, Height = Application.GetRealHeight(180), }; OnOffOutputfra.AddChidren(closerowlayout); var btnclose = new Button { //Text = "关", TextID = MyInternationalizationString.close, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(180), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; closerowlayout.AddChidren(btnclose); var closeBtnSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical, }; closerowlayout.AddChidren(closeBtnSelected); var customrowlayout = new RowLayout { Height = Application.GetRealHeight(180), Y = closerowlayout.Bottom, }; OnOffOutputfra.AddChidren(customrowlayout); var Btncustom = new Button { //Text = "自定义亮度", TextID = MyInternationalizationString.custombrightness, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(180), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; customrowlayout.AddChidren(Btncustom); #endregion ///确认事件 EventHandler openclick = (sender, e) => { openBtnSelected.Visible = true; closeBtnSelected.Visible = false; if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "1");//默认值 LogicIfon.AddDeviceactions(common, actionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; openrowlayout.MouseUpEventHandler += openclick; btnopen.MouseUpEventHandler += openclick; openBtnSelected.MouseUpEventHandler += openclick; ///取消事件 EventHandler closeclick = (sender, e) => { openBtnSelected.Visible = false; closeBtnSelected.Visible = true; if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "0");//默认值 LogicIfon.AddDeviceactions(common, actionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; closerowlayout.MouseUpEventHandler += closeclick; btnclose.MouseUpEventHandler += closeclick; closeBtnSelected.MouseUpEventHandler += closeclick; ///自定义亮度事件 EventHandler customclick = (sender, e) => { var setDeviceState = new SetDeviceState(); UserView.HomePage.Instance.AddChidren(setDeviceState); UserView.HomePage.Instance.PageIndex += 1; setDeviceState.Show(common, Btncustom.Text, edit); }; customrowlayout.MouseUpEventHandler += customclick; Btncustom.MouseUpEventHandler += customclick; if (edit && TaskList != null) { foreach (var value in TaskList) { if (value["TaskType"] == "1") { if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } if (value["Data1"] == "1") { switchdictionary.Add("Data1", "1"); openBtnSelected.Visible = true; closeBtnSelected.Visible = false; } else { switchdictionary.Add("Data1", "0"); openBtnSelected.Visible = false; closeBtnSelected.Visible = true; } break; } } } } break; ///窗帘 case DeviceType.WindowCoveringDevice: { #region ----初始化设备功能数据---- Dictionary switchdictionary = new Dictionary(); if (switchdictionary.ContainsKey("TaskType")) { switchdictionary.Remove("TaskType"); } if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } if (switchdictionary.ContainsKey("Data2")) { switchdictionary.Remove("Data2"); } switchdictionary.Add("TaskType", "6"); switchdictionary.Add("Data1", "1"); switchdictionary.Add("Data2", "0"); taskListInfo.Add(switchdictionary); //Dictionary brightnessdictionary = new Dictionary(); //if (brightnessdictionary.ContainsKey("TaskType")) //{ // brightnessdictionary.Remove("TaskType"); //} //if (brightnessdictionary.ContainsKey("Data2")) //{ // brightnessdictionary.Remove("Data2"); //} //if (brightnessdictionary.ContainsKey("Data1")) //{ // brightnessdictionary.Remove("Data1"); //} //brightnessdictionary.Add("TaskType", "6"); //brightnessdictionary.Add("Data1", "5"); //brightnessdictionary.Add("Data2", "0"); //taskListInfo.Add(brightnessdictionary); #endregion #region 窗帘View devicefra.Y = Application.GetRealHeight(1920 - 30 - 900); devicefra.Height = Application.GetRealHeight(900); var windowCoveringfra = new FrameLayout { Y = Application.GetRealHeight(180), Height = Application.GetRealHeight(180 * 3 + 30), }; devicefra.AddChidren(windowCoveringfra); var openrowlayout = new RowLayout { Height = Application.GetRealHeight(180), }; windowCoveringfra.AddChidren(openrowlayout); var btnopen = new Button { //Text = "开", TextID = MyInternationalizationString.open, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(180), //SelectedBackgroundColor = 0xfffe5e00, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; openrowlayout.AddChidren(btnopen); var openBtnSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; openrowlayout.AddChidren(openBtnSelected); var closerowlayout = new RowLayout { Y = openrowlayout.Bottom, Height = Application.GetRealHeight(180), }; windowCoveringfra.AddChidren(closerowlayout); var btnclose = new Button { //Text = "关", TextID = MyInternationalizationString.close, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(180), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; closerowlayout.AddChidren(btnclose); var closeBtnSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; closerowlayout.AddChidren(closeBtnSelected); var customrowlayout = new RowLayout { Height = Application.GetRealHeight(180), Y = closerowlayout.Bottom, }; windowCoveringfra.AddChidren(customrowlayout); var Btncustom = new Button { //Text = "自定义百分比", TextID = MyInternationalizationString.custompercentage, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(180), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; customrowlayout.AddChidren(Btncustom); #endregion ///点击确认事件 EventHandler openclick = (sender, e) => { openBtnSelected.Visible = true; closeBtnSelected.Visible = false; if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "0"); LogicIfon.AddDeviceactions(common, actionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; openrowlayout.MouseUpEventHandler += openclick; btnopen.MouseUpEventHandler += openclick; openBtnSelected.MouseUpEventHandler += openclick; ///点击取消事件 EventHandler closeclick = (sender, e) => { openBtnSelected.Visible = false; closeBtnSelected.Visible = true; if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "1"); LogicIfon.AddDeviceactions(common, actionsInfo); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; closerowlayout.MouseUpEventHandler += closeclick; btnclose.MouseUpEventHandler += closeclick; closeBtnSelected.MouseUpEventHandler += closeclick; ///自定义亮度事件 EventHandler customclick = (sender, e) => { var setDeviceState = new SetDeviceState(); UserView.HomePage.Instance.AddChidren(setDeviceState); UserView.HomePage.Instance.PageIndex += 1; setDeviceState.Show(common, Btncustom.Text, edit); }; customrowlayout.MouseUpEventHandler += customclick; Btncustom.MouseUpEventHandler += customclick; if (edit && TaskList != null) { foreach (var value in TaskList) { if (value["TaskType"] == "6") { if (value["Data1"] == "0") { if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "0"); openBtnSelected.Visible = true; closeBtnSelected.Visible = false; } else if (value["Data1"] == "1") { if (switchdictionary.ContainsKey("Data1")) { switchdictionary.Remove("Data1"); } switchdictionary.Add("Data1", "1"); openBtnSelected.Visible = false; closeBtnSelected.Visible = true; } } } } } break; } var cancel = new Button { Height = Application.GetRealHeight(160), TextID = MyInternationalizationString.cancel, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextSize = 16, BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, Y = devicefra.Height - Application.GetRealHeight(160), }; devicefra.AddChidren(cancel); cancel.MouseUpEventHandler += (sender, e) => { flMain.RemoveFromParent(); UserView.HomePage.Instance.ScrollEnabled = true; }; } } }