From c1de48884fa145a16a0f8bcee93274dcfaa0ff82 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 07 五月 2020 10:40:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-2020xm
---
ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs | 625 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 625 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs
new file mode 100755
index 0000000..711f0b1
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs
@@ -0,0 +1,625 @@
+锘縰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 LockLogicCommunalPage : FrameLayout
+ {
+
+ public LockLogicCommunalPage()
+ {
+ UserView.HomePage.Instance.RemoveViewByTag("Logic");
+ Tag = "Logic";
+ }
+ EditText logicTextBox;
+ public async void Show(Action action)
+ {
+
+ #region 鏈�涓婇潰鐨勫竷灞�浠g爜
+ 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();
+ }
+ }
+}
--
Gitblit v1.8.0