using System; using Shared; using Shared.R; using System.Collections.Generic; using Newtonsoft.Json.Linq; using ZigBee.Device; using Shared.Common; namespace Shared.Phone.Device.Logic { public class DeviceStateCondition :FrameLayout { public DeviceStateCondition() { 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.ColorDimmableLight, // DeviceType.OnOffOutput, // DeviceType.WindowCoveringDevice, // 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)) { continue; } list.Add(device); } AllDeviceTypeView(list); }; rowLayout.MouseUpEventHandler += roomclick; btnroomname.MouseUpEventHandler += roomclick; } }; Common.Room room1= new Common.Room(); foreach (var device in Common.Logic.LogicDviceList) { if (!deviceTypeList.Contains(device.Type)) { continue; } var deviceui = room1.GetDeviceUI(device); if (deviceui != null) { room1.DeviceUIList.Add(deviceui); } } AllDeviceTypeView(room1.DeviceUIList); } /// /// 加载该区域所有设备视图方法 /// 0 /// Devicelist. 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)); } var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone); if (iASZonejosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor)); } var onOffSwitchjson = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.OnOffSwitch); if (onOffSwitchjson != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch)); } #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"; } else if (devicetype == Language.StringByID(MyInternationalizationString.OnOffSwitch)) { devicetypeicon.UnSelectedImagePath = "ZigeeLogic/OnOffSwitch.png"; devicetypeicon.SelectedImagePath = "ZigeeLogic/OnOffSwitchSelected.png"; } else if (devicetype == Language.StringByID(MyInternationalizationString.sensor)) { devicetypeicon.UnSelectedImagePath = "ZigeeLogic/Sensor.png"; devicetypeicon.SelectedImagePath = "ZigeeLogic/SensorSelected.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); } else if (devicetype == Language.StringByID(MyInternationalizationString.OnOffSwitch)) { list.Add(DeviceType.OnOffSwitch); } else if (devicetype == Language.StringByID(MyInternationalizationString.sensor)) { list.Add(DeviceType.IASZone); } ConditionDeviceView(list, devicelist); }; deviceRowLayout.MouseUpEventHandler += devicetypeclick; devicetypename.MouseUpEventHandler += devicetypeclick; devicetypeicon.MouseUpEventHandler += devicetypeclick; } ///显示房间所有设备 ConditionDeviceView(new List(), devicelist); } /// /// 加载该类型设备视图方法 /// /// Device typelist. /// 设备列表 void ConditionDeviceView(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); CurrentDeviceView(flMain, common.CommonDevice, false); }; row.MouseUpEventHandler += devicclick; devicename.MouseUpEventHandler += devicclick; btndeviceback.MouseUpEventHandler += devicclick; } } /// /// 选中该设备功能作为条件的视图方法 /// /// Common. public static void CurrentDeviceView(FrameLayout flMain,CommonDevice common,bool edit) { //不让当前界面滑动 UserView.HomePage.Instance.ScrollEnabled = false; Dictionary deviceConditionsInfo = new Dictionary(); //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); string SelectedDeviceStatuscondition = "no"; if (deviceConditionsInfo.ContainsKey("Type")) { deviceConditionsInfo.Remove("Type"); } if (deviceConditionsInfo.ContainsKey("IsValid")) { deviceConditionsInfo.Remove("IsValid"); } if (deviceConditionsInfo.ContainsKey("MacAddr")) { deviceConditionsInfo.Remove("MacAddr"); } if (deviceConditionsInfo.ContainsKey("Epoint")) { deviceConditionsInfo.Remove("Epoint"); } deviceConditionsInfo.Add("Type", "1"); deviceConditionsInfo.Add("IsValid", "1"); deviceConditionsInfo.Add("MacAddr", common.DeviceAddr); deviceConditionsInfo.Add("Epoint",common.DeviceEpoint.ToString()); Dictionary devices = null; if (edit) { foreach (var deviceinfo in Common.Logic.CurrentLogic.Conditions) { if (deviceinfo["Type"] == "1") { if (common.DeviceAddr == deviceinfo["MacAddr"] && common.DeviceEpoint.ToString() == deviceinfo["Epoint"]) { devices = deviceinfo; break; } } } } switch (common.Type) { ///灯光 case DeviceType.OnOffOutput: { if (deviceConditionsInfo.ContainsKey("Cluster_ID")) { deviceConditionsInfo.Remove("Cluster_ID"); } if (deviceConditionsInfo.ContainsKey("AttriButeId")) { deviceConditionsInfo.Remove("AttriButeId"); } if (deviceConditionsInfo.ContainsKey("Range")) { deviceConditionsInfo.Remove("Range"); } if (deviceConditionsInfo.ContainsKey("AttriButeData2")) { deviceConditionsInfo.Remove("AttriButeData2"); } deviceConditionsInfo.Add("Cluster_ID", "6"); deviceConditionsInfo.Add("AttriButeId", "0"); deviceConditionsInfo.Add("Range", "1"); deviceConditionsInfo.Add("AttriButeData2", "0"); #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(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), }; OnOffOutputfra.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); #endregion ///点击确认事件 EventHandler openclick = (sender, e) => { openBtnSelected.Visible = true; closeBtnSelected.Visible = false; SelectedDeviceStatuscondition = "yes"; if (deviceConditionsInfo.ContainsKey("AttriButeData1")) { deviceConditionsInfo.Remove("AttriButeData1"); } deviceConditionsInfo.Add("AttriButeData1", "1");//默认值 }; openrowlayout.MouseUpEventHandler += openclick; btnopen.MouseUpEventHandler += openclick; openBtnSelected.MouseUpEventHandler += openclick; ///点击取消事件 EventHandler closeclick = (sender, e) => { openBtnSelected.Visible = false; closeBtnSelected.Visible = true; SelectedDeviceStatuscondition = "yes"; if (deviceConditionsInfo.ContainsKey("AttriButeData1")) { deviceConditionsInfo.Remove("AttriButeData1"); } deviceConditionsInfo.Add("AttriButeData1", "0");//默认值 }; closerowlayout.MouseUpEventHandler += closeclick; btnclose.MouseUpEventHandler += closeclick; closeBtnSelected.MouseUpEventHandler += openclick; if (edit && devices != null) { if (devices["AttriButeId"] == "0") { if (devices["AttriButeData1"] == "1") { openBtnSelected.Visible = true; closeBtnSelected.Visible = false; } else { openBtnSelected.Visible = false; closeBtnSelected.Visible = true; } } } } break; case DeviceType.WindowCoveringDevice: { if (deviceConditionsInfo.ContainsKey("Cluster_ID")) { deviceConditionsInfo.Remove("Cluster_ID"); } if (deviceConditionsInfo.ContainsKey("AttriButeId")) { deviceConditionsInfo.Remove("AttriButeId"); } if (deviceConditionsInfo.ContainsKey("Range")) { deviceConditionsInfo.Remove("Range"); } if (deviceConditionsInfo.ContainsKey("AttriButeData2")) { deviceConditionsInfo.Remove("AttriButeData2"); } deviceConditionsInfo.Add("Cluster_ID", "258"); deviceConditionsInfo.Add("AttriButeId", "8"); deviceConditionsInfo.Add("Range", "0"); deviceConditionsInfo.Add("AttriButeData2", "0"); #region 窗帘View devicefra.Y = Application.GetRealHeight(1920 - 30 - 720); devicefra.Height = Application.GetRealHeight(720); var windowCoveringfra = new FrameLayout { Y = Application.GetRealHeight(180), Height = Application.GetRealHeight(180 * 2 + 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); #endregion ///点击确认事件 EventHandler openclick = (sender, e) => { SelectedDeviceStatuscondition = "yes"; openBtnSelected.Visible = true; closeBtnSelected.Visible = false; if (deviceConditionsInfo.ContainsKey("AttriButeData1")) { deviceConditionsInfo.Remove("AttriButeData1"); } deviceConditionsInfo.Add("AttriButeData1", "95");//默认值 }; openrowlayout.MouseUpEventHandler += openclick; btnopen.MouseUpEventHandler += openclick; openBtnSelected.MouseUpEventHandler += openclick; ///点击取消事件 EventHandler closeclick = (sender, e) => { SelectedDeviceStatuscondition = "yes"; openBtnSelected.Visible = false; closeBtnSelected.Visible = true; if (deviceConditionsInfo.ContainsKey("AttriButeData1")) { deviceConditionsInfo.Remove("AttriButeData1"); } deviceConditionsInfo.Add("AttriButeData1", "5");//默认值 }; closerowlayout.MouseUpEventHandler += closeclick; btnclose.MouseUpEventHandler += closeclick; closeBtnSelected.MouseUpEventHandler += closeclick; if (edit && devices != null) { if (devices["AttriButeId"] == "8") { if (int.Parse(devices["AttriButeData1"]) > 5) { openBtnSelected.Visible = true; closeBtnSelected.Visible = false; } else { openBtnSelected.Visible = false; closeBtnSelected.Visible = true; } } } } break; case DeviceType.IASZone: { var iASZonedevice = common as IASZone; if (iASZonedevice.DeviceID != 1026) { break; } if (deviceConditionsInfo.ContainsKey("Cluster_ID")) { deviceConditionsInfo.Remove("Cluster_ID"); } if (deviceConditionsInfo.ContainsKey("AttriButeId")) { deviceConditionsInfo.Remove("AttriButeId"); } if (deviceConditionsInfo.ContainsKey("AttriButeData2")) { deviceConditionsInfo.Remove("AttriButeData2"); } deviceConditionsInfo.Add("Cluster_ID", "1280"); deviceConditionsInfo.Add("AttriButeId", "1281"); deviceConditionsInfo.Add("AttriButeData2", "0"); #region 安防设备View devicefra.Y = Application.GetRealHeight(1920 - 30 - 720); devicefra.Height = Application.GetRealHeight(720); var iASZonedevicefra = new FrameLayout { Y = Application.GetRealHeight(180), Height = Application.GetRealHeight(180 * 2 + 30), }; devicefra.AddChidren(iASZonedevicefra); var openrowlayout = new RowLayout { Height = Application.GetRealHeight(180), }; var btnopen = new Button { //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 { Height = Application.GetRealHeight(180), Y = openrowlayout.Bottom, }; /// var btnclose = new Button { //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); #endregion ///点击确认事件 EventHandler openclick = (sender, e) => { SelectedDeviceStatuscondition = "yes"; openBtnSelected.Visible = true; closeBtnSelected.Visible = false; if (deviceConditionsInfo.ContainsKey("Range")) { deviceConditionsInfo.Remove("Range"); } deviceConditionsInfo.Add("Range", "5"); if (deviceConditionsInfo.ContainsKey("AttriButeData1")) { deviceConditionsInfo.Remove("AttriButeData1"); } deviceConditionsInfo.Add("AttriButeData1", "1");//默认值 }; openrowlayout.MouseUpEventHandler += openclick; btnopen.MouseUpEventHandler += openclick; openBtnSelected.MouseUpEventHandler += openclick; ///点击取消事件 EventHandler closeclick = (sender, e) => { SelectedDeviceStatuscondition = "yes"; openBtnSelected.Visible = false; closeBtnSelected.Visible = true; if (deviceConditionsInfo.ContainsKey("Range")) { deviceConditionsInfo.Remove("Range"); } deviceConditionsInfo.Add("Range", "1"); if (deviceConditionsInfo.ContainsKey("AttriButeData1")) { deviceConditionsInfo.Remove("AttriButeData1"); } deviceConditionsInfo.Add("AttriButeData1", "0");//默认值 }; closerowlayout.MouseUpEventHandler += closeclick; btnclose.MouseUpEventHandler += closeclick; closeBtnSelected.MouseUpEventHandler += closeclick; switch (iASZonedevice.IasDeviceType) { case 13: { btnopen.TextID = MyInternationalizationString.someone; //btnclose.TextID = MyInternationalizationString.unmanned; iASZonedevicefra.AddChidren(openrowlayout); //iASZonedevicefra.AddChidren(closerowlayout); } break; case 21: { btnopen.TextID = MyInternationalizationString.logicopen; btnclose.TextID = MyInternationalizationString.logicclose; iASZonedevicefra.AddChidren(openrowlayout); iASZonedevicefra.AddChidren(closerowlayout); } break; case 22: { btnopen.TextID = MyInternationalizationString.logicopen; btnclose.TextID = MyInternationalizationString.logicclose; iASZonedevicefra.AddChidren(openrowlayout); iASZonedevicefra.AddChidren(closerowlayout); } break; case 40: { btnopen.TextID = MyInternationalizationString.smokescreen; //btnclose.TextID = MyInternationalizationString.nosmokescreen; iASZonedevicefra.AddChidren(openrowlayout); } break; case 42: { btnopen.TextID = MyInternationalizationString.waterleakage; btnclose.TextID = MyInternationalizationString.noleakage; iASZonedevicefra.AddChidren(openrowlayout); iASZonedevicefra.AddChidren(closerowlayout); } break; case 43: { btnopen.TextID = MyInternationalizationString.gas; //btnclose.TextID = MyInternationalizationString.nogas; iASZonedevicefra.AddChidren(openrowlayout); } break; case 44: { btnopen.TextID = MyInternationalizationString.emergencybutton; //btnclose.TextID = MyInternationalizationString.nosmokescreen; iASZonedevicefra.AddChidren(openrowlayout); } break; case 277: { btnopen.TextID = MyInternationalizationString.callthepolice; //btnclose.TextID = MyInternationalizationString.nosmokescreen; iASZonedevicefra.AddChidren(openrowlayout); } break; default: { btnopen.TextID = MyInternationalizationString.callthepolice; iASZonedevicefra.AddChidren(openrowlayout); } break; } if (edit && devices != null) { if (devices["AttriButeId"] == "1281") { if (devices["AttriButeData1"] == "1") { openBtnSelected.Visible = true; closeBtnSelected.Visible = false; } else { openBtnSelected.Visible = false; closeBtnSelected.Visible = true; } } } } break; case DeviceType.OnOffSwitch: { if (deviceConditionsInfo.ContainsKey("Cluster_ID")) { deviceConditionsInfo.Remove("Cluster_ID"); } if (deviceConditionsInfo.ContainsKey("AttriButeId")) { deviceConditionsInfo.Remove("AttriButeId"); } if (deviceConditionsInfo.ContainsKey("Range")) { deviceConditionsInfo.Remove("Range"); } if (deviceConditionsInfo.ContainsKey("AttriButeData1")) { deviceConditionsInfo.Remove("AttriButeData1"); } if (deviceConditionsInfo.ContainsKey("AttriButeData2")) { deviceConditionsInfo.Remove("AttriButeData2"); } deviceConditionsInfo.Add("Cluster_ID", "1282"); deviceConditionsInfo.Add("AttriButeId", "1283"); deviceConditionsInfo.Add("Range", "0");//按键特殊 deviceConditionsInfo.Add("AttriButeData1", "0"); deviceConditionsInfo.Add("AttriButeData2", "0"); 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 buttonRow = new RowLayout { Height = Application.GetRealHeight(180), }; OnOffOutputfra.AddChidren(buttonRow); var button = new Button { //TextID = MyInternationalizationString.button1, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(40), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(180), Text=Language.StringByID(MyInternationalizationString.OnOffSwitch)+common.DeviceEpoint.ToString(), //SelectedBackgroundColor = 0xfffe5e00, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; buttonRow.AddChidren(button); var buttonSelected = new Button { X = Application.GetRealWidth(1000 - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/YesSelected.png", Visible = false, Gravity = Gravity.CenterVertical }; buttonRow.AddChidren(buttonSelected); EventHandler buttonclick = (sender, e) => { buttonSelected.Visible = true; SelectedDeviceStatuscondition = "yes"; }; buttonRow.MouseUpEventHandler += buttonclick; button.MouseUpEventHandler += buttonclick; buttonSelected.MouseUpEventHandler += buttonclick; if (edit && devices != null) { buttonSelected.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; }; var btnSave = new Button { Y = Application.GetRealHeight(20), Width = Application.GetRealWidth(200), Height = Application.GetRealHeight(150), Text = Language.StringByID(MyInternationalizationString.complete), TextColor = ZigbeeColor.Current.LogicTextBlueColor, X = Application.GetRealWidth(1000 - 200), }; devicefra.AddChidren(btnSave); btnSave.MouseUpEventHandler += (sender2, e2) => { //UserView.HomePage.Instance.ScrollEnabled = true; if (SelectedDeviceStatuscondition == "yes") { LogicIfon.AddDeviceconditions(common, deviceConditionsInfo); } else { if (!edit) { var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt), Language.StringByID(MyInternationalizationString.selectdevicestatuscondition), Language.StringByID(MyInternationalizationString.complete)); alert.Show(); return; } } flMain.RemoveFromParent(); var logicCommunalPage = new LogicCommunalPage(); UserView.HomePage.Instance.AddChidren(logicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; logicCommunalPage.Show(() => { }); }; } } }