New file |
| | |
| | | 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.DoorLockLogic |
| | | { |
| | | public class LockLogicCommunalPage : FrameLayout |
| | | { |
| | | |
| | | public LockLogicCommunalPage() |
| | | { |
| | | UserView.HomePage.Instance.RemoveViewByTag("Logic"); |
| | | Tag = "Logic"; |
| | | } |
| | | EditText logicTextBox; |
| | | public async void Show(Action action) |
| | | { |
| | | |
| | | #region 最上面的布局代码 |
| | | UserView.HomePage.Instance.ScrollEnabled = false;//锁住左滑 |
| | | TopView view = new TopView(); |
| | | this.AddChidren(view.TopRowView()); |
| | | if (Common.Logic.CurrentLogic.LogicId != 0) |
| | | { |
| | | view.toptitleNameBtn.Text = Language.StringByID(MyInternationalizationString.editlinkageevent); |
| | | } |
| | | else |
| | | { |
| | | view.toptitleNameBtn.Text = Language.StringByID(MyInternationalizationString.addlinkageevent); |
| | | } |
| | | view.clickBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | action(); |
| | | RemoveFromParent(); |
| | | }; |
| | | var middle = new VerticalScrolViewLayout |
| | | { |
| | | Y = view.topRowLayout.Bottom, |
| | | Height = Application.GetRealHeight(Method.H - 184 - 180), |
| | | BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, |
| | | }; |
| | | this.AddChidren(middle); |
| | | |
| | | var saveBtn = new LogicView.SaveView(); |
| | | saveBtn.frameLayout.Y = middle.Bottom; |
| | | saveBtn.frameLayout.Height = Application.GetRealHeight(180); |
| | | this.AddChidren(saveBtn.Show()); |
| | | #endregion |
| | | |
| | | #region -----自动化名称 设置名称----- |
| | | var logicnamefl = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(130), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | }; |
| | | middle.AddChidren(logicnamefl); |
| | | |
| | | var text = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(60), |
| | | X = Application.GetRealWidth(58), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | //Text = "自动化名称", |
| | | TextID = MyInternationalizationString.automationname, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | Y = Application.GetRealHeight(35), |
| | | TextSize = 15, |
| | | }; |
| | | logicnamefl.AddChidren(text); |
| | | |
| | | logicTextBox = new EditText |
| | | { |
| | | Y = Application.GetRealHeight(35), |
| | | Width = Application.GetRealWidth(1080 - 58 - 300), |
| | | Height = Application.GetRealHeight(60), |
| | | X = text.Right, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCancelColor, |
| | | TextSize = 14, |
| | | Text = Common.Logic.CurrentLogic.LogicName, |
| | | //TextID=MyInternationalizationString.automation1, |
| | | }; |
| | | logicnamefl.AddChidren(logicTextBox); |
| | | |
| | | var fraline = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(30), |
| | | }; |
| | | middle.AddChidren(fraline); |
| | | #endregion |
| | | |
| | | #region -----显示逻辑条件----- |
| | | LogicView.Addview addconditionview = new LogicView.Addview(); |
| | | addconditionview.iconBtn.Visible = true; |
| | | addconditionview.titleBtn.TextID = MyInternationalizationString.ifcondition; |
| | | middle.AddChidren(addconditionview.AddDeviceView()); |
| | | ///添加条件的点击事件 |
| | | addconditionview.clickBtn.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | AddCondition(-1); |
| | | }; |
| | | |
| | | List<Dictionary<string, string>> ListConditions = new List<Dictionary<string, string>>(); |
| | | ListConditions.Clear(); |
| | | ListConditions.AddRange(Common.Logic.CurrentLogic.Conditions); |
| | | ListConditions.Add(new Dictionary<string, string>()); |
| | | for (int i = 0; i < ListConditions.Count; i++) |
| | | { |
| | | if (i == (ListConditions.Count - 1)) |
| | | { |
| | | |
| | | LogicView.AddDeviceView addflview = new LogicView.AddDeviceView(); |
| | | addflview.titleBtn.TextID = MyInternationalizationString.selectunlockingmode; |
| | | middle.AddChidren(addflview.AddFl()); |
| | | addflview.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | AddCondition(-1); |
| | | }; |
| | | |
| | | } |
| | | else |
| | | { |
| | | SelectedDeviceView selecteddevice = new SelectedDeviceView(); |
| | | selecteddevice.Show(middle); |
| | | selecteddevice.stateRow.AddRightView(selecteddevice.edit); |
| | | selecteddevice.stateRow.AddRightView(selecteddevice.del); |
| | | |
| | | var Type = int.Parse(ListConditions[i]["Type"]); |
| | | var conditions = ListConditions[i]; |
| | | switch (Type) |
| | | { |
| | | case 1: |
| | | { |
| | | var deviceinof = Method.GetCommonDevice(conditions["MacAddr"], conditions["Epoint"]); |
| | | selecteddevice.deviceNameBtn.Visible = true; |
| | | selecteddevice.deviceNameBtn.Text = LocalDevice.Current.GetDeviceEpointName(deviceinof); |
| | | selecteddevice.regionNameBtn.Visible = true; |
| | | Method.RoomNmae(selecteddevice.regionNameBtn, deviceinof); |
| | | selecteddevice.edit.Tag = i; |
| | | switch (deviceinof.Type) |
| | | { |
| | | case DeviceType.DoorLock: |
| | | { |
| | | selecteddevice.iconBtn.UnSelectedImagePath = "ZigeeLogic/doorlock.png"; |
| | | for (int a = 0; a < Common.Logic.CurrentLogic.Accounts.Count; a++) |
| | | { |
| | | if (Common.Logic.CurrentLogic.Accounts[a]["Type"] == "1") |
| | | { |
| | | if (Common.Logic.CurrentLogic.Accounts[a]["UserId"] == conditions["AttriButeData2"]) |
| | | { |
| | | selecteddevice.selecetddevicestateBtn.Text = Common.Logic.CurrentLogic.Accounts[a]["AccountName"]; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | } |
| | | |
| | | ///编辑 |
| | | selecteddevice.edit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | int intvalue = int.Parse(selecteddevice.edit.Tag.ToString()); |
| | | AddCondition(intvalue); |
| | | }; |
| | | ///删除控件 |
| | | selecteddevice.del.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm, |
| | | Language.StringByID(MyInternationalizationString.doyouwanttodelete), |
| | | Language.StringByID(MyInternationalizationString.confrim)); |
| | | alert.Show(); |
| | | alert.ConfirmClickEvent += () => |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.Remove(conditions); |
| | | selecteddevice.selecetdFrameLayout.RemoveFromParent(); |
| | | //var lockLogicCommunalPage = new LockLogicCommunalPage(); |
| | | //UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); |
| | | //UserView.HomePage.Instance.PageIndex += 1; |
| | | //lockLogicCommunalPage.Show(() => { }); |
| | | }; |
| | | }; |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region ----显示执行目标---- |
| | | LogicView.Addview addactionview = new LogicView.Addview(); |
| | | addactionview.iconBtn.Visible = true; |
| | | addactionview.titleBtn.TextID = MyInternationalizationString.execute; |
| | | middle.AddChidren(addactionview.AddDeviceView()); |
| | | |
| | | addactionview.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | Method.View(LogicView.IfString.Action_LockAction, LogicView.IfString.Action_LockScene); |
| | | }; |
| | | |
| | | List<Dictionary<string, object>> ListActions = new List<Dictionary<string, object>>(); |
| | | ListActions.Clear(); |
| | | ListActions.AddRange(Common.Logic.CurrentLogic.Actions); |
| | | ListActions.Add(new Dictionary<string, object>()); |
| | | |
| | | for (int i = 0; i < ListActions.Count; i++) |
| | | { |
| | | if (i == (ListActions.Count - 1)) |
| | | { |
| | | |
| | | LogicView.AddDeviceView addflview = new LogicView.AddDeviceView(); |
| | | addflview.titleBtn.TextID = MyInternationalizationString.addaction; |
| | | middle.AddChidren(addflview.AddFl()); |
| | | addflview.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | Method.View(LogicView.IfString.Action_LockAction, LogicView.IfString.Action_LockScene); |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | |
| | | SelectedDeviceView actiondevice = new SelectedDeviceView(); |
| | | actiondevice.Show(middle); |
| | | var linkType = int.Parse(ListActions[i]["LinkType"].ToString()); |
| | | var actions = ListActions[i]; |
| | | string name = ""; |
| | | string icon = ""; |
| | | string state = ""; |
| | | switch (linkType) |
| | | { |
| | | |
| | | case 0: |
| | | case 8: |
| | | { |
| | | |
| | | var deviceinof = Method.GetCommonDevice(actions["DeviceAddr"].ToString(), actions["Epoint"].ToString()); |
| | | name =LocalDevice.Current.GetDeviceEpointName(deviceinof); |
| | | actiondevice.regionNameBtn.Visible = true; |
| | | Method.RoomNmae(actiondevice.regionNameBtn, deviceinof); |
| | | |
| | | switch (deviceinof.Type) |
| | | { |
| | | case DeviceType.OnOffOutput: |
| | | { |
| | | icon = "ZigeeLogic/light.png"; |
| | | |
| | | var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; |
| | | if (TaskList == null) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var status in TaskList) |
| | | { |
| | | if (status["TaskType"].ToString() == "1") |
| | | { |
| | | if (status["Data1"].ToString() == "0") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.close); |
| | | |
| | | } |
| | | else if (status["Data1"].ToString() == "1") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.open); |
| | | |
| | | } |
| | | else if (status["Data1"].ToString() == "2") |
| | | { |
| | | |
| | | state = Language.StringByID(MyInternationalizationString.onoff); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case DeviceType.DimmableLight: |
| | | { |
| | | icon = "ZigeeLogic/dimmableLight.png"; |
| | | var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; |
| | | if (TaskList == null) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var status in TaskList) |
| | | { |
| | | if (status["TaskType"].ToString() == "3") |
| | | { |
| | | var intvalue = int.Parse(status["Data1"]); |
| | | var lightbrightnessvalue = (intvalue * 100) / 254; |
| | | state = lightbrightnessvalue.ToString() + "%"; |
| | | } |
| | | else if (status["TaskType"].ToString() == "1") |
| | | { |
| | | |
| | | if (status["Data1"].ToString() == "0") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.close); |
| | | } |
| | | else if (status["Data1"].ToString() == "2") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.onoff); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case DeviceType.WindowCoveringDevice: |
| | | { |
| | | icon = "ZigeeLogic/curtain.png"; |
| | | var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; |
| | | if (TaskList == null) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var status in TaskList) |
| | | { |
| | | if (status["TaskType"] == "6") |
| | | { |
| | | if (status["Data1"] == "0") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.open); |
| | | } |
| | | else if (status["Data1"] == "1") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.close); |
| | | } |
| | | else if (status["Data1"] == "5") |
| | | { |
| | | state = status["Data2"] + "%"; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | break; |
| | | case DeviceType.AirSwitch: |
| | | { |
| | | icon = "ZigeeLogic/airswitch.png"; |
| | | |
| | | var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; |
| | | if (TaskList == null) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var status in TaskList) |
| | | { |
| | | if (status["TaskType"].ToString() == "1") |
| | | { |
| | | if (status["Data1"].ToString() == "0") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.close); |
| | | |
| | | } |
| | | else if (status["Data1"].ToString() == "1") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.open); |
| | | |
| | | } |
| | | else if (status["Data1"].ToString() == "2") |
| | | { |
| | | |
| | | state = Language.StringByID(MyInternationalizationString.onoff); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case DeviceType.Thermostat: |
| | | { |
| | | icon = "ZigeeLogic/ac.png"; |
| | | |
| | | var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; |
| | | if (TaskList == null) |
| | | { |
| | | continue; |
| | | } |
| | | string modetext = "", temperaturetext = "", speedtext = ""; |
| | | bool ifclose = false; |
| | | foreach (var status in TaskList) |
| | | { |
| | | |
| | | if (TaskList.Count == 1) |
| | | { |
| | | //数组只有一个元素说明当前空调状态为关; |
| | | ifclose = false; |
| | | //如果空调状态是关;直接跳出for循坏; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | ifclose = true; |
| | | } |
| | | if (status["TaskType"].ToString() == "5") |
| | | { |
| | | if (status["Data1"] == "3") |
| | | {//3---设置工作模式(1:自动;3:制冷;4:制热;7:送风;8:除湿) |
| | | switch (status["Data2"]) |
| | | { |
| | | case "3": |
| | | { |
| | | modetext = Language.StringByID(MyInternationalizationString.logiccool); |
| | | } |
| | | break; |
| | | case "4": |
| | | { |
| | | modetext = Language.StringByID(MyInternationalizationString.logicheat); |
| | | } |
| | | break; |
| | | case "1": |
| | | { |
| | | modetext = Language.StringByID(MyInternationalizationString.logicauto); |
| | | } |
| | | break; |
| | | case "8": |
| | | { |
| | | modetext = Language.StringByID(MyInternationalizationString.logicdry); |
| | | } |
| | | break; |
| | | case "7": |
| | | { |
| | | modetext = Language.StringByID(MyInternationalizationString.logicfanonly); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | else if (status["Data1"] == "6") |
| | | {//6---设置风扇模式(1:低风;2:中风;3:高风;) |
| | | switch (status["Data2"]) |
| | | { |
| | | case "1": |
| | | { |
| | | speedtext = Language.StringByID(MyInternationalizationString.logiclow); |
| | | } |
| | | break; |
| | | |
| | | case "2": |
| | | { |
| | | speedtext = Language.StringByID(MyInternationalizationString.logicmedium); |
| | | } |
| | | break; |
| | | case "3": |
| | | { |
| | | speedtext = Language.StringByID(MyInternationalizationString.logichigh); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | //4---设置加热度数;5---设置制冷、除湿度数;7---设置自动度数 |
| | | else if (status["Data1"] == "4" || status["Data1"] == "5" || status["Data1"] == "7") |
| | | { |
| | | var s = int.Parse(status["Data2"]) / 100; |
| | | temperaturetext = s.ToString(); |
| | | } |
| | | else if (status["Data1"] == "20") |
| | | { |
| | | temperaturetext = "无"; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | if (ifclose) |
| | | { |
| | | state = modetext + ";" + temperaturetext + "℃;" + speedtext; |
| | | } |
| | | else |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.close); |
| | | |
| | | } |
| | | } |
| | | break; |
| | | case DeviceType.DoorLock: |
| | | { |
| | | //门锁特殊 |
| | | icon = "ZigeeLogic/doorlock.png"; |
| | | if (actions["PassData"].ToString() == "055704010112") |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.logicopen); |
| | | } |
| | | else |
| | | { |
| | | state = Language.StringByID(MyInternationalizationString.logicclose); |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | break; |
| | | case 2: |
| | | { |
| | | actiondevice.edit.Visible = false;//隐藏编辑按钮(场景不需要编辑)
|
| | | //在本地查找该场景;
|
| | | var sceneinof = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(Convert.ToInt32(actions["DeviceAddr"].ToString())); |
| | | //本地没有存在; |
| | | if (sceneinof == null) |
| | | { |
| | | //实现目的:显示出来让可以自己是否删除 |
| | | sceneinof = new SceneUI(); |
| | | #region -------- |
| | | ////在网关查找该场景; |
| | | ////标记问题:网络请求,存在视图加载快慢的问题; |
| | | //sceneinof = await Send.GetScene(int.Parse(actions["DeviceAddr"].ToString())); |
| | | ////网关没有存在; |
| | | //if (sceneinof == null) |
| | | //{ |
| | | // //注解:本地和网关都不存在该场景,界面将不会显示该场景; |
| | | // //sceneinof = new SceneUI(); |
| | | // //移除该场景数据; |
| | | // Common.Logic.CurrentLogic.Actions.Remove(actions); |
| | | // //移除该场景视图; |
| | | // devicesFrameLayout.RemoveFromParent(); |
| | | // continue; |
| | | //} |
| | | #endregion |
| | | } |
| | | |
| | | icon = "ZigeeLogic/scene.png"; |
| | | name = sceneinof.Name; |
| | | actiondevice.regionNameBtn.Visible = true; |
| | | /////通过设备找到区域(房间)名称 |
| | | actiondevice.regionNameBtn.Text = UserCenter.HdlRoomLogic.Current.GetRoomNameBySceneId(sceneinof.Id); |
| | | |
| | | } |
| | | break; |
| | | } |
| | | if (linkType != 2) |
| | | { |
| | | actiondevice.stateRow.AddRightView(actiondevice.edit); |
| | | } |
| | | actiondevice.stateRow.AddRightView(actiondevice.del); |
| | | //状态 |
| | | actiondevice.deviceNameBtn.Visible = true; |
| | | actiondevice.deviceNameBtn.Text = name; |
| | | actiondevice.iconBtn.UnSelectedImagePath = icon; |
| | | actiondevice.selecetddevicestateBtn.Text = state; |
| | | |
| | | ///编辑 |
| | | actiondevice.edit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | switch (linkType) |
| | | { |
| | | case 0: |
| | | case 8: |
| | | { |
| | | var deviceinof = Method.GetCommonDevice(actions["DeviceAddr"].ToString(), actions["Epoint"].ToString()); |
| | | var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | CurrentDeviceState.CurrentDeviceView(flMain, deviceinof, true, "action_lockaction"); |
| | | } |
| | | break; |
| | | |
| | | |
| | | } |
| | | }; |
| | | ///删除控件 |
| | | actiondevice.del.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm, |
| | | Language.StringByID(MyInternationalizationString.doyouwanttodelete), |
| | | Language.StringByID(MyInternationalizationString.confrim)); |
| | | alert.Show(); |
| | | |
| | | alert.ConfirmClickEvent += () => |
| | | { |
| | | Common.Logic.CurrentLogic.Actions.Remove(actions); |
| | | actiondevice.selecetdFrameLayout.RemoveFromParent(); |
| | | //var lockLogicCommunalPage = new LockLogicCommunalPage(); |
| | | //UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); |
| | | //UserView.HomePage.Instance.PageIndex += 1; |
| | | //lockLogicCommunalPage.Show(() => { }); |
| | | }; |
| | | }; |
| | | |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ----推送设置---- |
| | | Method.Push(middle); |
| | | #endregion |
| | | |
| | | saveBtn.clickviewBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var name = logicTextBox.Text.Trim(); |
| | | Method.SaveLogic(LogicView.IfString._LockLogic, name,LogicView.IfString.Tag, Common.Logic.CurrentLogic); |
| | | }; |
| | | |
| | | } |
| | | public void AddCondition(int value) |
| | | { |
| | | Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | var addCondition = new AddCondition(); |
| | | addCondition.conditionsIndex = value; |
| | | UserView.HomePage.Instance.AddChidren(addCondition); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | addCondition.Show(); |
| | | } |
| | | } |
| | | } |