From b7b3e92bed9c4553e30e2901a1877f088a5f8823 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期一, 04 十一月 2019 17:20:52 +0800 Subject: [PATCH] 2019.11.4 --- ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs | 2102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 2,102 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs new file mode 100755 index 0000000..7998d32 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockAddDevice.cs @@ -0,0 +1,2102 @@ +锘縰sing 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.DoorLockLogic +{ + public class LockAddDevice:FrameLayout + { + public LockAddDevice() + { + Tag = "LockLogic"; + } + Button roombjButton = new Button(); + Button roomTextButton = new Button(); + Button devicetypeButton = new Button(); + VerticalScrolViewLayout middle; + FrameLayout clickframeLayout = new FrameLayout(); + Button clickbutton = new Button(); + Button clicktextcolcrbutton = new Button(); + public void Show() + { + + UserView.HomePage.Instance.ScrollEnabled = false; + this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; + #region 鏈�涓婇潰鐨勫竷灞�浠g爜 + var topRowLayout = new RowLayout + { + BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor, + Height = Application.GetRealHeight(184), + LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor, + }; + this.AddChidren(topRowLayout); + + var titleName = new Button + { + TextSize = 16, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextAlignment = TextAlignment.CenterLeft, + X = Application.GetRealWidth(160), + Width = Application.GetRealWidth(300), + Height = Application.GetRealHeight(69), + Y = Application.GetRealHeight(92), + TextID = MyInternationalizationString.devicestate, + }; + topRowLayout.AddChidren(titleName); + + var clickBtn = new Button + { + Width = Application.GetRealWidth(81 + 51), + Height = Application.GetRealHeight(58 + 40), + Y = Application.GetRealHeight(98 - 40), + }; + topRowLayout.AddChidren(clickBtn); + clickBtn.MouseDownEventHandler += (sender, e) => + { + RemoveFromParent(); + UserView.HomePage.Instance.ScrollEnabled = true; + }; + + var back = new Button + { + Width = Application.GetRealWidth(30), + Height = Application.GetRealHeight(51), + X = Application.GetRealWidth(81), + Y = Application.GetRealHeight(98), + //Gravity = Gravity.CenterVertical; + UnSelectedImagePath = "ZigeeLogic/back.png", + }; + topRowLayout.AddChidren(back); + back.MouseDownEventHandler += (sender, e) => + { + RemoveFromParent(); + UserView.HomePage.Instance.ScrollEnabled = true; + }; + + var foolrname = new Button + { + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextAlignment = TextAlignment.CenterRight, + X = Application.GetRealWidth(1080 - 400 - 120), + Width = Application.GetRealWidth(400), + Height = Application.GetRealHeight(69), + Y = Application.GetRealHeight(92), + //TextID = MyInternationalizationString.customroom, + Text = Config.Instance.Home.GetCurrentFloorName, + }; + topRowLayout.AddChidren(foolrname); + var dropdown = new Button + { + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextAlignment = TextAlignment.CenterRight, + X = foolrname.Right, + Width = Application.GetRealWidth(72), + Height = Application.GetRealHeight(72), + Y = Application.GetRealHeight(92), + UnSelectedImagePath = "ZigeeLogic/drop-down.png", + }; + topRowLayout.AddChidren(dropdown); + #endregion + + + ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱 + if (Common.Room.Lists.Count == 0) + { + return; + } + ///鎴块棿婊戝姩鎺т欢 + var roomhorizontalScrol = new HorizontalScrolViewLayout() + { + Width = Application.GetRealWidth(1080 - 58), + Height = Application.GetRealHeight(200), + Y = topRowLayout.Bottom, + X = Application.GetRealWidth(58), + }; + this.AddChidren(roomhorizontalScrol); + + + var devicetypehorizontalScrol1 = new HorizontalScrolViewLayout() + { + Width = Application.GetRealWidth(1080 - 58 - 200), + Height = Application.GetRealHeight(280), + Y = roomhorizontalScrol.Bottom, + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + X = Application.GetRealWidth(58 + 200), + }; + this.AddChidren(devicetypehorizontalScrol1); + ///璁惧绫诲瀷婊戝姩鎺т欢 + var devicetypehorizontalScrol = new HorizontalScrolViewLayout() + { + Width = Application.GetRealWidth(1080 - 58), + Height = Application.GetRealHeight(280), + Y = roomhorizontalScrol.Bottom, + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + X = Application.GetRealWidth(58), + Radius = (uint)Application.GetRealHeight(50), + + }; + this.AddChidren(devicetypehorizontalScrol); + + middle = new VerticalScrolViewLayout(); + middle.Y = devicetypehorizontalScrol.Bottom + Application.GetRealHeight(40); + middle.Height = Application.GetRealHeight(1920) - devicetypehorizontalScrol.Y; + middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; + middle.X = Application.GetRealWidth(58); + middle.Radius = (uint)Application.GetRealHeight(50); + this.AddChidren(middle); + + ///鐩墠鏀寔鐨勮澶� + List<DeviceType> deviceTypeList = new List<DeviceType> { + DeviceType.OnOffOutput, + DeviceType.DimmableLight, + DeviceType.WindowCoveringDevice, + DeviceType.Thermostat, + DeviceType.AirSwitch, + }; + + + + ///妤煎眰鐐瑰嚮浜嬩欢 + EventHandler<MouseEventArgs> foorlclick = (sender, e) => + { + + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + flMain.MouseUpEventHandler += (sender2, e2) => + { + flMain.RemoveFromParent(); + }; + var foolrbj = new VerticalScrolViewLayout + { + + Width = Application.GetRealWidth(400), + Height = Application.GetRealHeight(600), + X = Application.GetRealWidth(1080 - 400 - 60), + Y = Application.GetRealHeight(184 + 50), + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + Radius = (uint)Application.GetRealHeight(30), + }; + flMain.AddChidren(foolrbj); + foreach (var foolr in Config.Instance.Home.FloorDics) + { + + var foolrRowLayout = new FrameLayout + { + Height = Application.GetRealHeight(150), + }; + foolrbj.AddChidren(foolrRowLayout); + + var btnfoolrname = new Button + { + Width = Application.GetRealWidth(250), + Height = Application.GetRealHeight(160), + Text = foolr.Value, + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + //SelectedTextColor=0xfffc744b, + Tag = foolr.Key, + }; + foolrRowLayout.AddChidren(btnfoolrname); + + + EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) => + { + roomhorizontalScrol.RemoveAll(); + devicetypehorizontalScrol.RemoveAll(); + middle.RemoveAll(); + foolrname.Text = btnfoolrname.Text; + flMain.RemoveFromParent(); + var list = Send.GetRoomList(btnfoolrname.Tag.ToString()); + AllRoomView(list, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol); + }; + foolrRowLayout.MouseUpEventHandler += foolrnameclick; + btnfoolrname.MouseUpEventHandler += foolrnameclick; + + + } + + }; + foolrname.MouseUpEventHandler += foorlclick; + dropdown.MouseUpEventHandler += foorlclick; + ///绗竴娆¤繘鏉� + var roomlists = new List<Common.Room>(); + roomlists.Clear(); + if (Config.Instance.Home.FloorDics.Count < 2) + { + foolrname.Visible = false; + dropdown.Visible = false; + if (Config.Instance.Home.FloorDics.Count == 0) + { + roomlists.AddRange(Common.Room.Lists); + } + else + { + roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId); + } + } + else + { + roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId); + + } + + + AllRoomView(roomlists, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol); + + + } + /// <summary> + /// 鍔犺浇鎵�鏈夋埧闂寸殑瑙嗗浘鏂规硶 + /// </summary> + void AllRoomView(List<Common.Room> roomlist, List<DeviceType> deviceTypeList, HorizontalScrolViewLayout roomhorizontalScrol, HorizontalScrolViewLayout devicetypehorizontalScrol) + { + for (int i = 0; i < roomlist.Count; i++) + { + var room = roomlist[i]; + var fra = new FrameLayout + { + Height = Application.GetRealHeight(200), + Width = Application.GetRealWidth(255), + }; + roomhorizontalScrol.AddChidren(fra); + + var roombjBtn = new Button + { + Height = Application.GetRealHeight(158), + Width = Application.GetRealWidth(255), + UnSelectedImagePath = "ZigeeLogic/iconBackgroundColor.png", + SelectedImagePath = "ZigeeLogic/iconSelectedBackgroundColor.png", + Y = Application.GetRealHeight(21), + }; + fra.AddChidren(roombjBtn); + + var roomnameBtn = new Button + { + + Height = Application.GetRealHeight(152 - 26 - 20), + Width = Application.GetRealWidth(255 - 20 - 50), + Text = room.Name, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + SelectedTextColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + Y = Application.GetRealHeight(21 + 13 + 10), + X = Application.GetRealWidth(10 + 25), + + }; + fra.AddChidren(roomnameBtn); + if (i == 0) + { + roombjButton.IsSelected = false; + roombjButton = roombjBtn; + roombjBtn.IsSelected = true; + + roomTextButton.IsSelected = false; + roomTextButton = roomnameBtn; + roomnameBtn.IsSelected = true; + var list = new List<DeviceUI>(); + foreach (var device in room.DeviceUIList) + { + if (device.CommonDevice == null) + { + continue; + } + if (!deviceTypeList.Contains(device.CommonDevice.Type)) + { + continue; + } + list.Add(device); + } + AllDeviceTypeView(list, devicetypehorizontalScrol); + + } + + + EventHandler<MouseEventArgs> roomclick = (sender, e) => + { + roombjButton.IsSelected = false; + roombjButton = roombjBtn; + roombjBtn.IsSelected = true; + + roomTextButton.IsSelected = false; + roomTextButton = roomnameBtn; + roomnameBtn.IsSelected = true; + var list = new List<DeviceUI>(); + foreach (var device in room.DeviceUIList) + { + if (device.CommonDevice == null) + { + continue; + } + if (!deviceTypeList.Contains(device.CommonDevice.Type)) + { + continue; + } + list.Add(device); + } + AllDeviceTypeView(list, devicetypehorizontalScrol); + + + }; + roomnameBtn.MouseUpEventHandler += roomclick; + roombjBtn.MouseUpEventHandler += roomclick; + + } + } + + /// <summary> + ///鍔犺浇璇ュ尯鍩熸墍鏈夎澶囩殑瑙嗗浘鏂规硶 + /// </summary> + void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol) + { + + List<string> devicetypelist = new List<string>(); + devicetypelist.Clear(); + + #region ------鎺掑垪璁惧绫诲瀷------ + var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DimmableLight || 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 ac = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.Thermostat); + if (ac != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC)); + } + var airSwitch = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.AirSwitch); + if (airSwitch != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch)); + } + + #endregion + + devicetypehorizontalScrol.RemoveAll(); + for (int i = 0; i < devicetypelist.Count; i++) + { + + var devicetype = devicetypelist[i]; + + var spaceRowLayout = new FrameLayout(); + devicetypehorizontalScrol.AddChidren(spaceRowLayout); + if (i == 0) + { + spaceRowLayout.Width = Application.GetRealWidth(37); + } + else + { + spaceRowLayout.Width = Application.GetRealWidth(80); + } + + var deviceRowLayout = new FrameLayout + { + Width = Application.GetRealWidth(156 + 20), + Height = Application.GetRealHeight(280 - 30), + Y = Application.GetRealHeight(30), + }; + devicetypehorizontalScrol.AddChidren(deviceRowLayout); + + var backgroundColor = new Button + { + Width = Application.GetRealWidth(156), + Height = Application.GetRealHeight(180), + X = Application.GetRealWidth(10), + UnSelectedImagePath = "ZigeeLogic/deviceunselectedbackgroundcolor.png", + SelectedImagePath = "ZigeeLogic/deviceselectedbackgroundcolor.png", + }; + deviceRowLayout.AddChidren(backgroundColor); + + + var devicetypeicon = new Button + { + Width = Application.GetRealWidth(84), + Height = Application.GetRealHeight(84), + X = Application.GetRealWidth(46), + Y = Application.GetRealHeight(30), + }; + deviceRowLayout.AddChidren(devicetypeicon); + + var devicetypename = new Button + { + Width = Application.GetRealWidth(176), + Height = Application.GetRealHeight(40), + Text = devicetype, + TextAlignment = TextAlignment.Center, + Y = backgroundColor.Bottom, + TextColor = ZigbeeColor.Current.LogicAddColor, + TextSize = 10, + }; + deviceRowLayout.AddChidren(devicetypename); + if (devicetype == Language.StringByID(MyInternationalizationString.Lights)) + { + devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedlight.png"; + } + else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains)) + { + devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedcurtain.png"; + } + else if (devicetype == Language.StringByID(MyInternationalizationString.AC)) + { + devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedac.png"; + } + else if (devicetype == Language.StringByID(MyInternationalizationString.Airswitch)) + { + devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedairswitch.png"; + } + EventHandler<MouseEventArgs> devicetypeclick = (sender13, e13) => + { + + devicetypeButton.IsSelected = false; + devicetypeButton = backgroundColor; + backgroundColor.IsSelected = true; + List<DeviceType> list = new List<DeviceType>(); + list.Clear(); + ///鍒嗙被鏄剧ず锛堜緥濡傜伅鍏夛細{鐏厜1锛岀伅鍏�2...}锛� + if (devicetype == Language.StringByID(MyInternationalizationString.Lights)) + { + list.Add(DeviceType.OnOffOutput);//0x0101鍗佽繘鍒�257 + list.Add(DeviceType.DimmableLight); + } + else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains)) + { + list.Add(DeviceType.WindowCoveringDevice); + } + else if (devicetype == Language.StringByID(MyInternationalizationString.AC)) + { + list.Add(DeviceType.Thermostat); + } + else if (devicetype == Language.StringByID(MyInternationalizationString.Airswitch)) + { + list.Add(DeviceType.AirSwitch); + } + + ActionDeviceView(list, devicelist); + + }; + deviceRowLayout.MouseUpEventHandler += devicetypeclick; + devicetypename.MouseUpEventHandler += devicetypeclick; + devicetypeicon.MouseUpEventHandler += devicetypeclick; + backgroundColor.MouseUpEventHandler += devicetypeclick; + + } + ///鏄剧ず鎴块棿鎵�鏈夎澶� + ActionDeviceView(new List<DeviceType>(), devicelist); + } + /// <summary> + /// 鍔犺浇璇ョ被鍨嬭澶囪鍥炬柟娉� + /// </summary> + /// <param name="devicelist">璁惧鍒楄〃</param> + void ActionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist) + { + middle.RemoveAll(); + foreach (var common in devicelist) + { + + if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type)) + { + continue; + } + + var deviceFramelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + }; + middle.AddChidren(deviceFramelayout); + + var bjFramelayout = new FrameLayout + { + Width = Application.GetRealWidth(112), + Height = Application.GetRealHeight(112), + X = Application.GetRealWidth(58), + Y = Application.GetRealHeight(30 + 9), + Radius = (uint)Application.GetRealHeight(56), + BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + }; + deviceFramelayout.AddChidren(bjFramelayout); + + var deviceIconBtn = new Button + { + Width = Application.GetRealWidth(82), + Height = Application.GetRealHeight(82), + Gravity = Gravity.Center, + + }; + bjFramelayout.AddChidren(deviceIconBtn); + + var deviceRow = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(850), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(176 + 10), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + + }; + deviceFramelayout.AddChidren(deviceRow); + + var devicename = new Button + { + Text = common.CommonDevice.DeviceEpointName, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + SelectedTextColor = ZigbeeColor.Current.LogicAddColor, + }; + deviceRow.AddChidren(devicename); + switch (common.CommonDevice.Type) + { + + case DeviceType.OnOffOutput: + { + deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/light.png"; + deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedlight.png"; + } + break; + case DeviceType.DimmableLight: + { + + deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/dimmableLight.png"; + deviceIconBtn.SelectedImagePath = "ZigeeLogic/selecteddimmableLight.png"; + } + break; + case DeviceType.WindowCoveringDevice: + { + deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/curtain.png"; + deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedcurtain.png"; + } + break; + case DeviceType.Thermostat: + { + deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/ac.png"; + deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedac.png"; + } + break; + case DeviceType.AirSwitch: + { + deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/airswitch.png"; + deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedairswitch.png"; + } + break; + } + + EventHandler<MouseEventArgs> devicclick = (sen, e) => + { + clickbutton.IsSelected = false; + clickbutton = deviceIconBtn; + deviceIconBtn.IsSelected = true; + clickframeLayout.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; + clickframeLayout = bjFramelayout; + bjFramelayout.BackgroundColor = ZigbeeColor.Current.LogicIconBackgroundColor; + clicktextcolcrbutton.IsSelected = false; + clicktextcolcrbutton = devicename; + devicename.IsSelected = true; + + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + CurrentDeviceStateView(flMain, common.CommonDevice, false); + }; + deviceFramelayout.MouseUpEventHandler += devicclick; + bjFramelayout.MouseUpEventHandler += devicclick; + deviceIconBtn.MouseUpEventHandler += devicclick; + deviceRow.MouseUpEventHandler += devicclick; + devicename.MouseUpEventHandler += devicclick; + + } + } + /// <summary> + /// 閫変腑璇ヨ澶囧姛鑳戒綔涓烘潯浠剁殑瑙嗗浘鏂规硶 + /// </summary> + /// <param name="common">Common.</param> + public static void CurrentDeviceStateView(FrameLayout flMain, CommonDevice common, bool edit) + { + //涓嶈褰撳墠鐣岄潰婊戝姩 + UserView.HomePage.Instance.ScrollEnabled = false; + Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); + List<Dictionary<string, string>> taskListInfo = new List<Dictionary<string, string>>(); + flMain.MouseUpEventHandler += (sender, e) => + { + flMain.RemoveFromParent(); + }; + var devicefra1 = new FrameLayout + { + Width = Application.GetRealWidth(1080), + Height = Application.GetRealHeight(100), + Y = Application.GetRealHeight(1920 - 100), + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + flMain.AddChidren(devicefra1); + + var devicefra = new FrameLayout + { + + Width = Application.GetRealWidth(1080), + Height = Application.GetRealHeight(530 + 160), + Y = Application.GetRealHeight(1920 - 530 - 160), + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + Radius = (uint)Application.GetRealHeight(60), + }; + flMain.AddChidren(devicefra); + + #region -------鍙栨秷 瀹屾垚 + var timetype = new RowLayout + { + Height = Application.GetRealHeight(140), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + devicefra.AddChidren(timetype); + var Btncancel = new Button + { + TextID = MyInternationalizationString.cancel, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + Height = Application.GetRealHeight(140), + Width = Application.GetRealWidth(200), + X = Application.GetRealWidth(80), + TextAlignment = TextAlignment.CenterLeft, + }; + timetype.AddChidren(Btncancel); + Btncancel.MouseUpEventHandler += (sender16, e16) => + { + flMain.RemoveFromParent(); + UserView.HomePage.Instance.ScrollEnabled = true; + }; + + var Btntitle = new Button + { + TextID = MyInternationalizationString.security, + TextColor = ZigbeeColor.Current.LogicBtnTypeColor, + Height = Application.GetRealHeight(140), + Width = Application.GetRealWidth(320), + TextAlignment = TextAlignment.Center, + X = Btncancel.Right + Application.GetRealWidth(100), + TextSize = 16, + Text = common.DeviceEpointName, + }; + timetype.AddChidren(Btntitle); + var Btncomplete = new Button + { + TextID = MyInternationalizationString.complete, + TextColor = ZigbeeColor.Current.LogicBtnCompleteColor, + Height = Application.GetRealHeight(140), + Width = Application.GetRealWidth(200), + TextAlignment = TextAlignment.CenterRight, + X = Btntitle.Right + Application.GetRealWidth(100), + + }; + timetype.AddChidren(Btncomplete); + #endregion + + + string SelectedDeviceStatusaction = "no"; + actionsInfo.Add("LinkType", 0); + actionsInfo.Add("DeviceAddr", common.DeviceAddr); + actionsInfo.Add("Epoint", common.DeviceEpoint); + actionsInfo.Add("Time", 0); + actionsInfo.Add("TaskList", taskListInfo); + + List<Dictionary<string, string>> 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<Dictionary<string, string>>; + break; + } + } + } + } + switch (common.Type) + { + + ///鐏厜 + case DeviceType.OnOffOutput: + { + + #region ----鍒濆鍖栬澶囧姛鑳芥暟鎹�---- + Dictionary<string, string> switchdictionary = new Dictionary<string, string>(); + 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 + + #region 寮� + + var openframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = timetype.Bottom + Application.GetRealHeight(20), + }; + devicefra.AddChidren(openframelayout); + + var openrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + openframelayout.AddChidren(openrowlayout); + + var btnopen = new Button + { + Width = Application.GetRealWidth(600), + TextID = MyInternationalizationString.open, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + openrowlayout.AddChidren(btnopen); + + var openBtnSelected = new SelectedButton(); + openrowlayout.AddChidren(openBtnSelected); + #endregion + #region 鍏� + var closeframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = openframelayout.Bottom, + }; + devicefra.AddChidren(closeframelayout); + var closerowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + closeframelayout.AddChidren(closerowlayout); + + var btnclose = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.close, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + closerowlayout.AddChidren(btnclose); + + var closeBtnSelected = new SelectedButton(); + closerowlayout.AddChidren(closeBtnSelected); + #endregion + #region 鍙栧弽 + var takebackframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = closeframelayout.Bottom, + }; + devicefra.AddChidren(takebackframelayout); + var takebackrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + takebackframelayout.AddChidren(takebackrowlayout); + + var btntakeback = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.onoff, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + takebackrowlayout.AddChidren(btntakeback); + + var takebackBtnSelected = new SelectedButton(); + takebackrowlayout.AddChidren(takebackBtnSelected); + + #endregion + + + #endregion + + ///纭浜嬩欢 + EventHandler<MouseEventArgs> openclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = false; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "1");//榛樿鍊� + + + }; + openrowlayout.MouseUpEventHandler += openclick; + btnopen.MouseUpEventHandler += openclick; + openBtnSelected.MouseUpEventHandler += openclick; + openframelayout.MouseUpEventHandler += openclick; + ///鍙栨秷浜嬩欢 + EventHandler<MouseEventArgs> closeclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + takebackBtnSelected.Visible = false; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "0");//榛樿鍊� + + }; + closerowlayout.MouseUpEventHandler += closeclick; + btnclose.MouseUpEventHandler += closeclick; + closeBtnSelected.MouseUpEventHandler += closeclick; + closeframelayout.MouseUpEventHandler += closeclick; + //鍙栧弽 + EventHandler<MouseEventArgs> takebackclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = true; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "2");//榛樿鍊� + + }; + takebackrowlayout.MouseUpEventHandler += takebackclick; + btntakeback.MouseUpEventHandler += takebackclick; + takebackBtnSelected.MouseUpEventHandler += takebackclick; + takebackframelayout.MouseUpEventHandler += takebackclick; + 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; + takebackBtnSelected.Visible = false; + } + else if (value["Data1"] == "0") + { + switchdictionary.Add("Data1", "0"); + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + takebackBtnSelected.Visible = false; + } + else if (value["Data1"] == "2") + { + switchdictionary.Add("Data1", "2"); + openBtnSelected.Visible = false; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = true; + } + break; + } + + } + } + + } + break; + ///璋冨厜鐏厜 + case DeviceType.DimmableLight: + { + + #region ----鍒濆鍖栬澶囧姛鑳芥暟鎹�---- + Dictionary<string, string> switchdictionary = new Dictionary<string, string>(); + if (switchdictionary.ContainsKey("Data2")) + { + switchdictionary.Remove("Data2"); + } + switchdictionary.Add("Data2", "0"); + taskListInfo.Add(switchdictionary); + + #endregion + + #region 鐏厜View + + devicefra.Y = Application.GetRealHeight(1920 - 160 * 3 - 210 - 160); + devicefra.Height = Application.GetRealHeight(160 * 3 + 210 + 160); + + #region 寮� + + var openframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160 + 160), + Y = timetype.Bottom + Application.GetRealHeight(20), + }; + devicefra.AddChidren(openframelayout); + + var openrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + openframelayout.AddChidren(openrowlayout); + + var btnopen = new Button + { + Width = Application.GetRealWidth(600), + TextID = MyInternationalizationString.open, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + openrowlayout.AddChidren(btnopen); + + var openBtnSelected = new SelectedButton(); + openrowlayout.AddChidren(openBtnSelected); + + var horizontalSeekBarRow = new RowLayout + { + Y = openrowlayout.Bottom, + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(160), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + openframelayout.AddChidren(horizontalSeekBarRow); + var horizontalSeekBarVol = new HorizontalSeekBar + { + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(80), + Radius = (uint)Application.GetRealHeight(25), + Y = Application.GetRealHeight(25), + //Gravity = Gravity.CenterVertical, + ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected, + Max = 100, + SleepTime = 1000, + ThumbRadius = 9, + IsCanMove = false + }; + horizontalSeekBarRow.AddChidren(horizontalSeekBarVol); + + #endregion + + #region 鍏� + var closeframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = openframelayout.Bottom, + }; + devicefra.AddChidren(closeframelayout); + var closerowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + closeframelayout.AddChidren(closerowlayout); + + var btnclose = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.close, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + closerowlayout.AddChidren(btnclose); + + var closeBtnSelected = new SelectedButton(); + closerowlayout.AddChidren(closeBtnSelected); + #endregion + + #region 鍙栧弽 + var takebackframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = closeframelayout.Bottom, + }; + devicefra.AddChidren(takebackframelayout); + var takebackrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + takebackframelayout.AddChidren(takebackrowlayout); + + var btntakeback = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.onoff, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + takebackrowlayout.AddChidren(btntakeback); + + var takebackBtnSelected = new SelectedButton(); + takebackrowlayout.AddChidren(takebackBtnSelected); + + #endregion + + + #endregion + + int Progressvalue = 100; + horizontalSeekBarVol.ProgressChanged += (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + Progressvalue = horizontalSeekBarVol.Progress; + if (switchdictionary.ContainsKey("TaskType")) + { + switchdictionary.Remove("TaskType"); + } + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("TaskType", "3"); + //鏈�澶т寒搴﹀�兼槸254闇�瑕佽浆鎹紱 + var lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100; + switchdictionary.Add("Data1", lightbrightnessvalue.ToString()); + + }; + ///纭浜嬩欢 + EventHandler<MouseEventArgs> openclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + horizontalSeekBarVol.IsCanMove = true; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected; + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = false; + horizontalSeekBarVol.Progress = Progressvalue; + if (switchdictionary.ContainsKey("TaskType")) + { + switchdictionary.Remove("TaskType"); + } + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("TaskType", "3"); + //鏈�澶т寒搴﹀�兼槸254闇�瑕佽浆鎹紱 + var lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100; + switchdictionary.Add("Data1", lightbrightnessvalue.ToString()); + + }; + openrowlayout.MouseUpEventHandler += openclick; + btnopen.MouseUpEventHandler += openclick; + openBtnSelected.MouseUpEventHandler += openclick; + openframelayout.MouseUpEventHandler += openclick; + ///鍙栨秷浜嬩欢 + EventHandler<MouseEventArgs> closeclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + horizontalSeekBarVol.IsCanMove = false; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + takebackBtnSelected.Visible = false; + if (switchdictionary.ContainsKey("TaskType")) + { + switchdictionary.Remove("TaskType"); + } + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("TaskType", "1"); + switchdictionary.Add("Data1", "0");//榛樿鍊� + + }; + closerowlayout.MouseUpEventHandler += closeclick; + btnclose.MouseUpEventHandler += closeclick; + closeBtnSelected.MouseUpEventHandler += closeclick; + closeframelayout.MouseUpEventHandler += closeclick; + //鍙栧弽 + EventHandler<MouseEventArgs> takebackclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + horizontalSeekBarVol.IsCanMove = false; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = true; + if (switchdictionary.ContainsKey("TaskType")) + { + switchdictionary.Remove("TaskType"); + } + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("TaskType", "1"); + switchdictionary.Add("Data1", "2");//榛樿鍊� + + }; + takebackrowlayout.MouseUpEventHandler += takebackclick; + btntakeback.MouseUpEventHandler += takebackclick; + takebackBtnSelected.MouseUpEventHandler += takebackclick; + takebackframelayout.MouseUpEventHandler += takebackclick; + + if (edit && TaskList != null) + { + foreach (var value in TaskList) + { + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + if (switchdictionary.ContainsKey("TaskType")) + { + switchdictionary.Remove("TaskType"); + } + if (value["TaskType"] == "1") + { + switchdictionary.Add("TaskType", "1"); + if (value["Data1"] == "0") + { + switchdictionary.Add("Data1", "0"); + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + takebackBtnSelected.Visible = false; + horizontalSeekBarVol.IsCanMove = false; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor; + } + else if (value["Data1"] == "2") + { + switchdictionary.Add("Data1", "2"); + openBtnSelected.Visible = false; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = true; + horizontalSeekBarVol.IsCanMove = false; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor; + } + + } + else if (value["TaskType"] == "3") + { + switchdictionary.Add("TaskType", "3"); + switchdictionary.Add("Data1", value["Data1"]); + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = false; + horizontalSeekBarVol.IsCanMove = true; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected; + horizontalSeekBarVol.Progress = int.Parse(value["Data1"]) * 100 / 254; + Progressvalue = horizontalSeekBarVol.Progress; + + } + break; + + } + } + + } + break; + ///绐楀笜 + case DeviceType.WindowCoveringDevice: + { + #region ----鍒濆鍖栬澶囧姛鑳芥暟鎹�---- + Dictionary<string, string> switchdictionary = new Dictionary<string, string>(); + if (switchdictionary.ContainsKey("TaskType")) + { + switchdictionary.Remove("TaskType"); + } + switchdictionary.Add("TaskType", "6"); + + taskListInfo.Add(switchdictionary); + + #endregion + devicefra.Y = Application.GetRealHeight(1920 - 160 * 2 - 210 - 160); + devicefra.Height = Application.GetRealHeight(160 * 2 + 210 + 160); + #region 绐楀笜View + + #region 寮� + + var openframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160 + 160), + Y = timetype.Bottom + Application.GetRealHeight(20), + }; + devicefra.AddChidren(openframelayout); + + var openrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + }; + openframelayout.AddChidren(openrowlayout); + + var btnopen = new Button + { + Width = Application.GetRealWidth(600), + TextID = MyInternationalizationString.open, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + openrowlayout.AddChidren(btnopen); + + var openBtnSelected = new SelectedButton(); + openrowlayout.AddChidren(openBtnSelected); + + + var horizontalSeekBarRow = new RowLayout + { + Y = openrowlayout.Bottom, + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(160), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + openframelayout.AddChidren(horizontalSeekBarRow); + var horizontalSeekBarVol = new HorizontalSeekBar + { + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(80), + Radius = (uint)Application.GetRealHeight(25), + Y = Application.GetRealHeight(25), + //Gravity = Gravity.CenterVertical, + ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected, + Max = 100, + SleepTime = 1000, + ThumbRadius = 9, + IsCanMove = false + }; + horizontalSeekBarRow.AddChidren(horizontalSeekBarVol); + + #endregion + + #region 鍏� + var closeframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = openframelayout.Bottom, + }; + devicefra.AddChidren(closeframelayout); + var closerowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + }; + closeframelayout.AddChidren(closerowlayout); + + var btnclose = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.close, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + closerowlayout.AddChidren(btnclose); + + var closeBtnSelected = new SelectedButton(); + closerowlayout.AddChidren(closeBtnSelected); + #endregion + + + + #endregion + int Progressvalue = 100; + horizontalSeekBarVol.ProgressChanged += (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + Progressvalue = horizontalSeekBarVol.Progress; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + if (switchdictionary.ContainsKey("Data2")) + { + switchdictionary.Remove("Data2"); + } + switchdictionary.Add("Data1", "5"); + switchdictionary.Add("Data2", horizontalSeekBarVol.Progress.ToString()); + + }; + ///纭浜嬩欢 + EventHandler<MouseEventArgs> openclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + horizontalSeekBarVol.IsCanMove = true; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected; + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + horizontalSeekBarVol.Progress = Progressvalue; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + if (switchdictionary.ContainsKey("Data2")) + { + switchdictionary.Remove("Data2"); + } + switchdictionary.Add("Data1", "5"); + switchdictionary.Add("Data2", horizontalSeekBarVol.Progress.ToString()); + + }; + openrowlayout.MouseUpEventHandler += openclick; + btnopen.MouseUpEventHandler += openclick; + openBtnSelected.MouseUpEventHandler += openclick; + openframelayout.MouseUpEventHandler += openclick; + ///鍙栨秷浜嬩欢 + EventHandler<MouseEventArgs> closeclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + horizontalSeekBarVol.IsCanMove = false; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + if (switchdictionary.ContainsKey("Data2")) + { + switchdictionary.Remove("Data2"); + } + switchdictionary.Add("Data2", "0"); + switchdictionary.Add("Data1", "1");//榛樿鍊� + + }; + closerowlayout.MouseUpEventHandler += closeclick; + btnclose.MouseUpEventHandler += closeclick; + closeBtnSelected.MouseUpEventHandler += closeclick; + closeframelayout.MouseUpEventHandler += closeclick; + + + + if (edit && TaskList != null) + { + foreach (var value in TaskList) + { + if (value["TaskType"] == "6") + { + if (value["Data1"] == "5") + { + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + if (switchdictionary.ContainsKey("Data2")) + { + switchdictionary.Remove("Data2"); + } + switchdictionary.Add("Data1", "5"); + switchdictionary.Add("Data2", value["Data2"]); + horizontalSeekBarVol.IsCanMove = true; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected; + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + horizontalSeekBarVol.Progress = int.Parse(value["Data2"]); + Progressvalue = horizontalSeekBarVol.Progress; + } + else if (value["Data1"] == "1") + { + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "1"); + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + horizontalSeekBarVol.IsCanMove = false; + horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor; + } + + } + + } + } + } + break; + ///绌烘皵寮�鍏� + case DeviceType.AirSwitch: + { + { + + #region ----鍒濆鍖栬澶囧姛鑳芥暟鎹�---- + Dictionary<string, string> switchdictionary = new Dictionary<string, string>(); + 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 + + #region 寮� + + var openframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = timetype.Bottom + Application.GetRealHeight(20), + }; + devicefra.AddChidren(openframelayout); + + var openrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + openframelayout.AddChidren(openrowlayout); + + var btnopen = new Button + { + Width = Application.GetRealWidth(600), + TextID = MyInternationalizationString.open, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + openrowlayout.AddChidren(btnopen); + + var openBtnSelected = new SelectedButton(); + openrowlayout.AddChidren(openBtnSelected); + #endregion + #region 鍏� + var closeframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = openframelayout.Bottom, + }; + devicefra.AddChidren(closeframelayout); + var closerowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + closeframelayout.AddChidren(closerowlayout); + + var btnclose = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.close, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + closerowlayout.AddChidren(btnclose); + + var closeBtnSelected = new SelectedButton(); + closerowlayout.AddChidren(closeBtnSelected); + #endregion + #region 鍙栧弽 + var takebackframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = closeframelayout.Bottom, + }; + devicefra.AddChidren(takebackframelayout); + var takebackrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + takebackframelayout.AddChidren(takebackrowlayout); + + var btntakeback = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.onoff, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + takebackrowlayout.AddChidren(btntakeback); + + var takebackBtnSelected = new SelectedButton(); + takebackrowlayout.AddChidren(takebackBtnSelected); + + #endregion + + + #endregion + + ///纭浜嬩欢 + EventHandler<MouseEventArgs> openclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = false; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "1");//榛樿鍊� + + + }; + openrowlayout.MouseUpEventHandler += openclick; + btnopen.MouseUpEventHandler += openclick; + openBtnSelected.MouseUpEventHandler += openclick; + openframelayout.MouseUpEventHandler += openclick; + ///鍙栨秷浜嬩欢 + EventHandler<MouseEventArgs> closeclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + takebackBtnSelected.Visible = false; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "0");//榛樿鍊� + + }; + closerowlayout.MouseUpEventHandler += closeclick; + btnclose.MouseUpEventHandler += closeclick; + closeBtnSelected.MouseUpEventHandler += closeclick; + closeframelayout.MouseUpEventHandler += closeclick; + //鍙栧弽 + EventHandler<MouseEventArgs> takebackclick = (sender, e) => + { + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = true; + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "2");//榛樿鍊� + + }; + takebackrowlayout.MouseUpEventHandler += takebackclick; + btntakeback.MouseUpEventHandler += takebackclick; + takebackBtnSelected.MouseUpEventHandler += takebackclick; + takebackframelayout.MouseUpEventHandler += takebackclick; + 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; + takebackBtnSelected.Visible = false; + } + else if (value["Data1"] == "0") + { + switchdictionary.Add("Data1", "0"); + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + takebackBtnSelected.Visible = false; + } + else if (value["Data1"] == "2") + { + switchdictionary.Add("Data1", "2"); + openBtnSelected.Visible = false; + closeBtnSelected.Visible = false; + takebackBtnSelected.Visible = true; + } + break; + } + + } + } + + } + } + break; + + case DeviceType.Thermostat: + { + + #region ----鍒濆鍖栬澶囧姛鑳芥暟鎹�---- + Dictionary<string, string> switchdictionary = new Dictionary<string, string>(); + Dictionary<string, string> temperaturedictionary = new Dictionary<string, string>(); + Dictionary<string, string> modedictionary = new Dictionary<string, string>(); + Dictionary<string, string> speeddictionary = new Dictionary<string, string>(); + taskListInfo.Add(switchdictionary); + taskListInfo.Add(temperaturedictionary); + taskListInfo.Add(modedictionary); + taskListInfo.Add(speeddictionary); + dictionary(switchdictionary, "TaskType", "1"); + dictionary(switchdictionary, "Data2", "0"); + dictionary(temperaturedictionary, "TaskType", "5"); + dictionary(modedictionary, "TaskType", "5"); + dictionary(modedictionary, "Data1", "3"); + dictionary(speeddictionary, "TaskType", "5"); + dictionary(speeddictionary, "Data1", "6"); + + #endregion + + #region 绌鸿皟View + + devicefra.Y = Application.GetRealHeight(1920 - 600 - 210 - 160 * 2); + devicefra.Height = Application.GetRealHeight(600 + 210 + 160 * 2); + + #region 寮� + + var openframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = timetype.Bottom + Application.GetRealHeight(20), + }; + devicefra.AddChidren(openframelayout); + + var openrowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + openframelayout.AddChidren(openrowlayout); + + var btnopen = new Button + { + Width = Application.GetRealWidth(600), + TextID = MyInternationalizationString.open, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + openrowlayout.AddChidren(btnopen); + + var openBtnSelected = new SelectedButton(); + openrowlayout.AddChidren(openBtnSelected); + #endregion + + #region 绌鸿皟鐘舵�乂iew + var PickerViewfra = new FrameLayout + { + Y = openframelayout.Bottom, + Height = Application.GetRealHeight(600), + }; + devicefra.AddChidren(PickerViewfra); + + + var pausePickerViewfra = new FrameLayout + { + Y = openframelayout.Bottom, + Height = Application.GetRealHeight(600), + }; + devicefra.AddChidren(pausePickerViewfra); + + + + var mUIPickerView = new UIPickerView + { + Height = Application.GetRealHeight(600 - 5), + }; + PickerViewfra.AddChidren(mUIPickerView); + var line = new Button + { + Y = Application.GetRealHeight(600 - 5), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(5), + X = Application.GetRealWidth(80), + BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + PickerViewfra.AddChidren(line); + + var mList1 = new List<string>(); + var mList2 = new List<string> { + Language.StringByID(MyInternationalizationString.logiccool), + Language.StringByID(MyInternationalizationString.logicheat), + Language.StringByID(MyInternationalizationString.logicauto), + Language.StringByID(MyInternationalizationString.logicdry), + Language.StringByID(MyInternationalizationString.logicfanonly), + }; + var mList3 = new List<string>{ + Language.StringByID(MyInternationalizationString.logiclow), + Language.StringByID(MyInternationalizationString.logicmedium), + Language.StringByID(MyInternationalizationString.logichigh), + }; + for (int i = 16; i < 33; i++) + { + mList1.Add(i.ToString() + " " + "鈩�"); + } + mUIPickerView.setNPicker(mList1, mList2, mList3); + ///榛樿鐘舵�� + + + #endregion + + #region 鍏� + var closeframelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + Y = PickerViewfra.Bottom, + }; + devicefra.AddChidren(closeframelayout); + var closerowlayout = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(80), + LineColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + closeframelayout.AddChidren(closerowlayout); + + var btnclose = new Button + { + //Text = "鍏�", + TextID = MyInternationalizationString.close, + Width = Application.GetRealWidth(600), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, + }; + closerowlayout.AddChidren(btnclose); + + var closeBtnSelected = new SelectedButton(); + closerowlayout.AddChidren(closeBtnSelected); + #endregion + + + + mUIPickerView.OnSelectChangeEvent += (s1, s2, s3) => + { + if (openBtnSelected.Visible) + { + SelectedDeviceStatusaction = "yes"; + var temperature = mList1[s1].Split(' ')[0]; + var modestring = mList2[s2].Split(' ')[0]; + var speedstring = mList3[s3].Split(' ')[0]; + ModeState(modestring, temperaturedictionary, modedictionary); + var a = int.Parse(temperature) * 100; + dictionary(temperaturedictionary, "Data2", a.ToString()); + + SpeedState(speedstring, speeddictionary); + + + } + }; + + #endregion + //榛樿26,鑷姩,涓 + int indextemperature = 10, indexmode = 2, indexspeed = 1; + if (edit && TaskList != null) + { + foreach (var value in TaskList) + { + if (value["TaskType"] == "1") + { + dictionary(switchdictionary, "Data1", value["Data1"]); + if (value["Data1"] == "1") + { + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + pausePickerViewfra.Height = Application.GetRealHeight(0); + } + else if (value["Data1"] == "0") + { + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + pausePickerViewfra.Height = Application.GetRealHeight(600); + } + + } + else if (value["TaskType"] == "5") + { + if (value["Data1"] == "3") + {//3---璁剧疆宸ヤ綔妯″紡(1:鑷姩;3:鍒跺喎;4:鍒剁儹;7:閫侀;8:闄ゆ箍) + dictionary(modedictionary, "Data2", value["Data2"]); + string modetext = ""; + switch (value["Data2"]) + { + case "3": + { + modetext = Language.StringByID(MyInternationalizationString.logiccool); + //indexmode = 0; + } + break; + case "4": + { + modetext = Language.StringByID(MyInternationalizationString.logicheat); + // indexmode = 1; + } + break; + case "1": + { + modetext = Language.StringByID(MyInternationalizationString.logicauto); + // indexmode = 2; + } + break; + case "8": + { + modetext = Language.StringByID(MyInternationalizationString.logicdry); + // indexmode = 3; + } + break; + case "7": + { + modetext = Language.StringByID(MyInternationalizationString.logicfanonly); + //indexmode = 4; + } + break; + } + indexmode = mList2.IndexOf(modetext); + } + else if (value["Data1"] == "6") + {//6---璁剧疆椋庢墖妯″紡(1:浣庨;2:涓;3:楂橀;) + dictionary(speeddictionary, "Data2", value["Data2"]); + string speedtext = ""; + switch (value["Data2"]) + { + case "1": + { + speedtext = Language.StringByID(MyInternationalizationString.logiclow); + //indexspeed = 0; + } + break; + + case "2": + { + speedtext = Language.StringByID(MyInternationalizationString.logicmedium); + // indexspeed = 1; + } + break; + case "3": + { + speedtext = Language.StringByID(MyInternationalizationString.logichigh); + // indexspeed = 2; + } + break; + + } + indexspeed = mList3.IndexOf(speedtext); + } + //4---璁剧疆鍔犵儹搴︽暟;5---璁剧疆鍒跺喎銆侀櫎婀垮害鏁�;7---璁剧疆鑷姩搴︽暟 + else if (value["Data1"] == "4" || value["Data1"] == "5" || value["Data1"] == "7") + { + var s = int.Parse(value["Data2"]) / 100; + indextemperature = mList1.IndexOf(s.ToString() + " " + "鈩�"); + dictionary(temperaturedictionary, "Data1", value["Data1"]); + dictionary(temperaturedictionary, "Data2", value["Data2"]); + } + + } + } + } + ///鏇存柊鏈�鏂扮┖璋冪姸鎬侊紱 + mUIPickerView.setCurrentItems(indextemperature, indexmode, indexspeed); + + ///纭浜嬩欢 + EventHandler<MouseEventArgs> openclick = (sender, e) => + { + pausePickerViewfra.Height = Application.GetRealHeight(0); + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = true; + closeBtnSelected.Visible = false; + dictionary(switchdictionary, "Data1", "1"); + var temperature = mList1[indextemperature].Split(' ')[0]; + var modestring = mList2[indexmode].Split(' ')[0]; + var speedstring = mList3[indexspeed].Split(' ')[0]; + + ModeState(modestring, temperaturedictionary, modedictionary); + var a = int.Parse(temperature) * 100; + dictionary(temperaturedictionary, "Data2", a.ToString()); + SpeedState(speedstring, speeddictionary); + + }; + openrowlayout.MouseUpEventHandler += openclick; + btnopen.MouseUpEventHandler += openclick; + openBtnSelected.MouseUpEventHandler += openclick; + openframelayout.MouseUpEventHandler += openclick; + + ///鍙栨秷浜嬩欢 + EventHandler<MouseEventArgs> closeclick = (sender, e) => + { + pausePickerViewfra.Height = Application.GetRealHeight(600); + + SelectedDeviceStatusaction = "yes"; + openBtnSelected.Visible = false; + closeBtnSelected.Visible = true; + dictionary(switchdictionary, "Data1", "0"); + }; + closerowlayout.MouseUpEventHandler += closeclick; + btnclose.MouseUpEventHandler += closeclick; + closeBtnSelected.MouseUpEventHandler += closeclick; + closeframelayout.MouseUpEventHandler += closeclick; + } + break; + + + } + + Btncomplete.MouseUpEventHandler += (sender, e) => + { + + if (SelectedDeviceStatusaction == "yes") + { + LogicIfon.AddDeviceactions(common, actionsInfo); + } + 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 lockLogicCommunalPage = new LockLogicCommunalPage(); + UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); + UserView.HomePage.Instance.PageIndex += 1; + lockLogicCommunalPage.Show(() => { }); + + }; + + } + + public static void dictionary(Dictionary<string, string> deviceactionsInfo, string Key, string Value) + { + if (deviceactionsInfo.ContainsKey(Key)) + { + deviceactionsInfo.Remove(Key); + } + deviceactionsInfo.Add(Key, Value); + } + /// <summary> + /// 绌鸿皟妯″紡鐨勭姸鎬� + /// </summary> + /// <param name="modestring"></param> + /// <param name="temperaturedictionary"></param> + /// <param name="modedictionary"></param> + public static void ModeState(string modestring, Dictionary<string, string> temperaturedictionary, Dictionary<string, string> modedictionary) + { + + if (modestring == Language.StringByID(MyInternationalizationString.logiccool)) + { + dictionary(modedictionary, "Data2", "3"); + dictionary(temperaturedictionary, "Data1", "5"); + } + else if (modestring == Language.StringByID(MyInternationalizationString.logicheat)) + { + + dictionary(modedictionary, "Data2", "4"); + dictionary(temperaturedictionary, "Data1", "4"); + } + else if (modestring == Language.StringByID(MyInternationalizationString.logicauto)) + { + + dictionary(modedictionary, "Data2", "1"); + dictionary(temperaturedictionary, "Data1", "7"); + } + else if (modestring == Language.StringByID(MyInternationalizationString.logicdry)) + { + + dictionary(modedictionary, "Data2", "8"); + dictionary(temperaturedictionary, "Data1", "5"); + } + else if (modestring == Language.StringByID(MyInternationalizationString.logicfanonly)) + { + dictionary(temperaturedictionary, "Data1", "20"); + dictionary(modedictionary, "Data2", "7"); + } + + } + /// <summary> + /// 椋庨�熺殑妯″紡 + /// </summary> + /// <param name="speedstring"></param> + /// <param name="speeddictionary"></param> + public static void SpeedState(string speedstring, Dictionary<string, string> speeddictionary) + { + + if (speedstring == Language.StringByID(MyInternationalizationString.logiclow)) + { + + dictionary(speeddictionary, "Data2", "1"); + + } + else if (speedstring == Language.StringByID(MyInternationalizationString.logicmedium)) + { + + dictionary(speeddictionary, "Data2", "2"); + + } + else if (speedstring == Language.StringByID(MyInternationalizationString.logichigh)) + { + + dictionary(speeddictionary, "Data2", "3"); + } + + } + } +} -- Gitblit v1.8.0