From 5da99fed2eb0d08b6338064da5f998891252c7b8 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 18 五月 2020 16:39:59 +0800 Subject: [PATCH] 2020-05-18-2 --- ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs | 330 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 251 insertions(+), 79 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs index bfbff84..6e7edf2 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicList.cs @@ -3,130 +3,192 @@ using Shared.Common; using Shared.R; -namespace Shared.Phone.Logic.DoorLockLogic +namespace Shared.Phone.Device.Logic.DoorLockLogic { public class LockLogicList : FrameLayout { - public async void Show() + public LockLogicList() + { + Tag = "LockListView"; + } + VerticalRefreshLayout middle; + public void Show() { - #region 鏈�涓婇潰鐨勫竷灞�浠g爜 - var topRowLayout = new RowLayout + #region 涓婇潰鐨勫竷灞�浠g爜 + TopView view = new TopView(); + this.AddChidren(view.TopRowView()); + view.toptitleNameBtn.TextID = MyInternationalizationString.linkageevent; + view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); }; + //鍔犲ぇ鐐瑰嚮鐑敭 + var addiocnclick = new Button { - BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor, - Height = Application.GetRealHeight(184), - LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor, + Width = Application.GetRealWidth(108+58), + Height = Application.GetRealHeight(72+20), + X = Application.GetRealWidth(1080 - 108 - 58), + Y = Application.GetRealHeight(184 - 72), }; - this.AddChidren(topRowLayout); - - var titleName = new Button - { - TextSize = 16, - TextColor = ZigbeeColor.Current.LogicTextBlackColor, - TextAlignment = TextAlignment.CenterLeft, - X = Application.GetRealWidth(176), - Width = Application.GetRealWidth(400), - Height = Application.GetRealHeight(69), - Y = Application.GetRealHeight(92), - TextID = MyInternationalizationString.selection, - }; - 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(); - }; - - 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(); - }; + view.topRowLayout.AddChidren(addiocnclick); var addiocn = new Button { - Width = Application.GetRealWidth(72), - Height = Application.GetRealHeight(72), + Width = Application.GetMinRealAverage(72), + Height = Application.GetMinRealAverage(72), X = Application.GetRealWidth(1080 - 108 - 58), UnSelectedImagePath = "ZigeeLogic/lockadd.png", Y = Application.GetRealHeight(184 - 72 - 20), }; - topRowLayout.AddChidren(addiocn); - addiocn.MouseUpEventHandler += (sender, e) => + view.topRowLayout.AddChidren(addiocn); + + EventHandler<MouseEventArgs> addclick = (sender, e) => { //new涓�涓柊閫昏緫瀵硅薄锛� Common.Logic.CurrentLogic = new Common.Logic(); Common.Logic.CurrentLogic.IsEnable = 1;//榛樿涓哄紑 - Common.Logic.CurrentLogic.LogicType = 1; - //Config.Instance.Guid鐢ㄦ潵璇嗗埆璐﹀彿韬唤锛� - var accounts = new System.Collections.Generic.Dictionary<string, string>(); - accounts.Add("Account", Config.Instance.Guid); - Common.Logic.CurrentLogic.Accounts.Add(accounts); - Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.automation1); + Common.Logic.CurrentLogic.LogicType = 1;//鏍囪鑷姩鍖栫被鍨� + Common.Logic.CurrentLogic.Relationship = 1; + Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.linkageevent); var lockLogicCommunalPage = new LockLogicCommunalPage(); UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); UserView.HomePage.Instance.PageIndex += 1; lockLogicCommunalPage.Show(() => { }); }; - #endregion - var middle = new VerticalScrolViewLayout + addiocnclick.MouseUpEventHandler += addclick; + addiocn.MouseUpEventHandler += addclick; + + #endregion + middle = new VerticalRefreshLayout { - Y = topRowLayout.Bottom, - Height = Application.GetRealHeight(1920 - 184), + Y = view.topRowLayout.Bottom, + Height = Application.GetRealHeight(Method.H - 184), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); + middle.BeginHeaderRefreshingAction += () => + { + //閲嶆柊鍒锋柊logic鍒楄〃 + Common.Logic.LockLogicList.Clear(); + Read(); + //鍏抽棴鍒锋柊View锛� + middle.EndHeaderRefreshing(); + }; + Read(); + } + + /// <summary> + /// 璇诲彇鑷姩鍖栨暟鎹� + /// </summary> + public async void Read() + { CommonPage.Loading.Start(); - if (Common.Logic.LockLogicList.Count == 0) + if (!BoolExist()) { - var Idlist = await Device.Logic.Send.GetLogicId(); + var Idlist = await Send.GetLogicId(1); if (Idlist.Count != 0) { - var listlogic = await Device.Logic.Send.ReadList(Idlist.Count); - for (int i = 0; i < Idlist.Count; i++) + var listlogic = await Send.ReadList(Idlist.Count, 1); + //foreach鍙兘闆嗗悎宸茶淇敼,鏋氫妇鎿嶄綔鍙兘涓嶄細鎵ц,鍙兘鍑虹幇宕╂簝(寤鸿for)銆� + for (int j = 0; j < listlogic.Count; j++) { - var LogicId = Idlist[i]; - //foreach鍙兘闆嗗悎宸茶淇敼,鏋氫妇鎿嶄綔鍙兘涓嶄細鎵ц,鍙兘鍑虹幇宕╂簝(寤鸿for)銆� - for (int j = 0; j < listlogic.Count; j++) + var logic = listlogic[j]; + if (logic.LogicType != 1) { - var logic = listlogic[j]; - if (logic.LogicId == LogicId) - { - Common.Logic.LockLogicList.Add(logic); - } + continue; } + Common.Logic.LockLogicList.Add(logic); + //bool yes = false; + //for (int a = 0; a < logic.Accounts.Count; a++) + //{ + // //Option4鏄澶噈ac锛汷ption2鏄澶囩鍙o紱 + // if (logic.Accounts[a]["Option4"].ToString() != Send.CurrentDoorLock.DeviceAddr) + // { + // //鏌ユ壘鏄惁鏄偅涓棬閿侊紱 + // //濡傛灉涓嶆槸璇ラ棬閿佽仈鍔ㄤ簨浠朵笉鏄剧ず鍑烘潵; + // yes = false; + // } + // else + // { + // yes = true; + // } + // //if (logic.Accounts[a]["Account"].ToString() == Config.Instance.Guid) + // //{ + // // //鏌ユ壘鑷繁璐﹀彿涓嬬殑鍒涘缓鑱斿姩浜嬩欢锛� + // // yes = true; + // // break; + // //} + //} + //if (yes) + //{ + // Common.Logic.LockLogicList.Add(listlogic[j]); + //} } } } - //鑷姩鍖� + Automationview(); + CommonPage.Loading.Hide(); + } + /// <summary> + /// 鍔犺浇鑷姩鍖栧垪琛ㄧ殑鐣岄潰 + /// </summary> + public void Automationview() + { + middle.RemoveAll(); + + //if (Common.Logic.LockLogicList.Count == 0) + if (!BoolExist()) + { + //灏辨槸涓轰簡鏄剧ず寮曞娣诲姞鍥炬爣; + var noFrameLayout = new FrameLayout + { + Height = Application.GetRealHeight(434 + 200 + 32 + 320), + //BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + }; + middle.AddChidren(noFrameLayout); + + + var noIconBtn = new Button + { + Y = Application.GetRealHeight(320), + Width = Application.GetMinRealAverage(756), + Height = Application.GetMinRealAverage(434), + UnSelectedImagePath = "Item/NoFunction.png", + X = Application.GetRealWidth(162), + }; + noFrameLayout.AddChidren(noIconBtn); + + var noTextBtn = new Button() + { + Y = noIconBtn.Bottom, + Height = Application.GetRealHeight(200) + Application.GetRealHeight(32), + Width = Application.GetRealWidth(700), + //Gravity = Gravity.CenterHorizontal, + Text = Language.StringByID(MyInternationalizationString.tiplocktextnull).Replace("{\\r\\n}", "\r\n"), + TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, + TextAlignment = TextAlignment.Center, + IsMoreLines = true, + X = Application.GetRealWidth(190), + }; + noFrameLayout.AddChidren(noTextBtn); + + } for (int i = 0; i < Common.Logic.LockLogicList.Count; i++) { var logic = Common.Logic.LockLogicList[i]; + if (!Exist(logic)) + { + continue; + } + var logicRowlayout = new RowLayout { Width = Application.GetRealWidth(1080), Height = Application.GetRealHeight(190), - LineColor = ZigbeeColor.Current.LogicBackgroundColor, + LineColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + SubViewWidth = Application.GetRealWidth(184),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� }; middle.AddChidren(logicRowlayout); @@ -140,14 +202,15 @@ TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, Gravity = Gravity.CenterVertical, + TextSize = 15, }; logicRowlayout.AddChidren(logicnameBtn); var logicswitchBtn = new Button { - Width = Application.GetMinRealAverage(104), - Height = Application.GetMinRealAverage(63), + Width = Application.GetRealWidth(104), + Height = Application.GetRealHeight(63), UnSelectedImagePath = "ZigeeLogic/logicclose.png", SelectedImagePath = "ZigeeLogic/logicopen.png", X = logicRowlayout.Width - Application.GetRealWidth(104 + 58), @@ -155,8 +218,117 @@ }; logicRowlayout.AddChidren(logicswitchBtn); + logicswitchBtn.MouseUpEventHandler += (sender, e) => + { + logicswitchBtn.IsSelected = !logicswitchBtn.IsSelected; + if (logicswitchBtn.IsSelected) + { + //閫昏緫寮� + logic.IsEnable = 1; + } + else + { + //閫昏緫鍏� + logic.IsEnable = 0; + } + Send.LogicControlSwitch(logic); + + }; + if (logic.IsEnable == 1) + { + logicswitchBtn.IsSelected = true; + } + else if (logic.IsEnable == 0) + { + logicswitchBtn.IsSelected = false; + } + ///缂栬緫 + var edit = new Button + { + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor1, + Text = Language.StringByID(MyInternationalizationString.edit), + TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor, + }; + logicRowlayout.AddRightView(edit); + edit.MouseUpEventHandler += (sender, e) => + { + Common.Logic.CurrentLogic = logic; + var lockLogicCommunalPage = new LockLogicCommunalPage(); + UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); + UserView.HomePage.Instance.PageIndex += 1; + lockLogicCommunalPage.Show(() => { logicnameBtn.Text = logic.LogicName; Automationview(); }); + + }; + + ///鍒犻櫎 + var del = new Button + { + BackgroundColor = ZigbeeColor.Current.LogicDelBlackColor1, + Text = Language.StringByID(MyInternationalizationString.del), + TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor, + }; + logicRowlayout.AddRightView(del); + 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.LockLogicList.Remove(logic); + Automationview(); + Send.DelLogic(logic.LogicId); + }; + + }; } - CommonPage.Loading.Hide(); + + } + + + /// <summary> + /// 鏌ユ壘璇ラ棬閿佹槸鍚﹀瓨鍦ㄨ嚜鍔ㄥ寲 + /// </summary> + /// <returns></returns> + private bool BoolExist() + { + bool yes = false; + for (int i = 0; i < Common.Logic.LockLogicList.Count; i++) + { + var logic = Common.Logic.LockLogicList[i]; + if (logic.LogicType != 1) + { + continue; + } + + if (Exist(logic)) + { + yes = true; + //瀛樺湪灏遍��鍑� + break; + } + } + return yes; + } + + /// <summary> + /// 鏌ユ壘杩欎竴鏉¤嚜鍔ㄥ寲鏄惁灞炰簬璇ラ棬閿� + /// </summary> + /// <returns></returns> + private bool Exist(Common.Logic logic) + { + for (int j = 0; j < logic.Accounts.Count; j++) + { + //Option4鏄澶噈ac锛汷ption2鏄澶囩鍙o紱 + if (logic.Accounts[j]["Option4"].ToString() == Send.CurrentDoorLock.DeviceAddr) + { + //鏌ユ壘鏄惁鏄偅涓棬閿侊紱 + //濡傛灉涓嶆槸璇ラ棬閿佽仈鍔ㄤ簨浠朵笉鏄剧ず鍑烘潵; + return true; + } + } + return false; } } } -- Gitblit v1.8.0