From a4924de3136289d10cabbf2f61a228387d44ded7 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期四, 07 十一月 2019 13:48:36 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC --- ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 280 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs new file mode 100755 index 0000000..1ad2d94 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/GarrisonAreaExistSensorForm.cs @@ -0,0 +1,280 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.Safety +{ + /// <summary> + /// 宸茬粡璁剧疆浜嗙殑浼犳劅鍣ㄧ殑涓�瑙堢敾闈� + /// </summary> + public class GarrisonAreaExistSensorForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + /// <summary> + /// 闃插尯ID + /// </summary> + private int zoonID = 0; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="SectorsName">闃插尯鍚嶅瓧</param> + /// <param name="i_zoonID">闃插尯ID</param> + public void ShowForm(string SectorsName, int i_zoonID) + { + this.zoonID = i_zoonID; + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(SectorsName + Language.StringByID(R.MyInternationalizationString.uSettion)); + + //鍙充笂瑙掔殑鈥滐紜鈥濆浘鏍� + var btnTopIcon = new MostRightIconControl(69, 69); + btnTopIcon.UnSelectedImagePath = "Item/Add.png"; + topFrameLayout.AddChidren(btnTopIcon); + btnTopIcon.InitControl(); + btnTopIcon.ButtonClickEvent += (sender, e) => + { + //娣诲姞鏂扮殑浼犳劅鍣� + this.AddNewSensorDevice(); + }; + + //鍒濆鍖栦紶鎰熷櫒鍒楄〃淇℃伅 + this.InitSensorDevicesListInfo(); + } + + /// <summary> + /// 鍒濆鍖栦紶鎰熷櫒鍒楄〃淇℃伅 + /// </summary> + private void InitSensorDevicesListInfo() + { + //娓呯┖bodyFrameLayout + this.ClearBodyFrame(); + + //鑾峰彇鎸囧畾闃插尯鍏ㄩ儴鐨勪紶鎰熷櫒璁惧鐨勪俊鎭� + var listInfo = HdlSafeguardLogic.Current.GetSensorDevicesInfoByZoonID(this.zoonID); + if (listInfo.Count == 0) + { + //杩樻病鏈夎缃紶鎰熷櫒鍝� + this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDoNotHadSettionSensorMsg)); + this.listView = null; + return; + } + + listView = new VerticalListControl(29); + listView.Y = Application.GetRealHeight(-6); + listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6); + listView.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(listView); + + HdlThreadLogic.Current.RunMainInThread(() => + { + int count = listInfo.Count - 1; + for (int i = 0; i < listInfo.Count; i++) + { + this.AddRowLayout(listInfo[i], i != count); + } + //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� + this.listView.AdjustRealHeight(Application.GetRealHeight(23)); + }); + } + + #endregion + + #region 鈻� 娣诲姞浼犳劅鍣ㄨ_______________________ + + /// <summary> + /// 娣诲姞琛� + /// </summary> + /// <param name="sensorInfo">浼犳劅鍣ㄤ俊鎭�</param> + /// <param name="addLine">鏄惁娣诲姞搴曠嚎</param> + private void AddRowLayout(Safeguard.ZoneDeviceListData sensorInfo, bool addLine) + { + CommonDevice device = Common.LocalDevice.Current.GetDevice(sensorInfo.MacAddr, sensorInfo.Epoint); + if (device == null) + { + return; + } + //鑷畾涔夋帶浠� + var rowLayout = new DeviceRoomControl(device, listView.rowSpace / 2); + listView.AddChidren(rowLayout); + rowLayout.InitControl(); + rowLayout.frameTable.UseClickStatu = false; + if (addLine == true) + { + //搴曠嚎 + rowLayout.frameTable.AddBottomLine(); + } + //鏃佽矾鐘舵�� + var txtStatu = rowLayout.frameTable.AddMostRightView("", 350); + txtStatu.TextColor = UserCenterColor.Current.TextGrayColor1; + + //鏃佽矾璁剧疆 + var btnBypass = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false); + btnBypass.TextID = R.MyInternationalizationString.uBypass; + btnBypass.BackgroundColor = 0xff4a4a4a; + btnBypass.TextColor = UserCenterColor.Current.TextColor3; + btnBypass.TextAlignment = TextAlignment.Center; + btnBypass.TextSize = 12; + if (sensorInfo.IsBypass == 1) + { + //宸茶缃梺璺� + txtStatu.TextID = R.MyInternationalizationString.uHadSetBypass; + //鍙栨秷鏃佽矾 + btnBypass.TextID = R.MyInternationalizationString.uCancelBypass; + } + rowLayout.AddLeftView(btnBypass); + btnBypass.ButtonClickEvent += (sender, e) => + { + //璁剧疆鏃佽矾鐘舵�� + this.SetBypassStatu(sensorInfo, device); + }; + + //鍒犻櫎 + var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false); + btnDelete.TextID = R.MyInternationalizationString.uDelete; + btnDelete.BackgroundColor = 0xfff75858; + btnDelete.TextColor = UserCenterColor.Current.TextColor3; + btnDelete.TextAlignment = TextAlignment.Center; + btnDelete.TextSize = 12; + rowLayout.AddRightView(btnDelete); + btnDelete.ButtonClickEvent += (sender, e) => + { + //纭鏄惁瑕佸垹闄�? + string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg); + this.ShowMassage(ShowMsgType.Confirm, msg, () => + { + //鍒犻櫎浼犳劅鍣ㄨ + this.DeleteRow(rowLayout, device); + }); + }; + } + + #endregion + + #region 鈻� 鍒犻櫎浼犳劅鍣ㄨ_______________________ + + /// <summary> + /// 鍒犻櫎琛� + /// </summary> + /// <param name="rowLayout"></param> + /// <param name="device"></param> + private async void DeleteRow(DeviceRoomControl rowLayout, CommonDevice device) + { + bool result = await HdlSafeguardLogic.Current.DeleteSensorDevice(this.zoonID, new List<CommonDevice>() { device }); + + if (result == false) + { + return; + } + //浠庣敾闈腑绉婚櫎 + rowLayout?.RemoveFromParent(); + //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� + this.listView.AdjustRealHeight(Application.GetRealHeight(23)); + if (this.listView.ChildrenCount == 0) + { + //鍒濆鍖栦紶鎰熷櫒鍒楄〃淇℃伅 + this.InitSensorDevicesListInfo(); + } + } + + #endregion + + #region 鈻� 鏃佽矾璁剧疆___________________________ + + /// <summary> + /// 璁剧疆鏃佽矾鐘舵�� + /// </summary> + /// <param name="sensorInfo">浼犳劅鍣ㄤ俊鎭�</param> + /// <param name="device">浼犳劅鍣ㄨ澶�</param> + private async void SetBypassStatu(Safeguard.ZoneDeviceListData sensorInfo, CommonDevice device) + { + //鍙樻洿鐘舵�� + int statu = sensorInfo.IsBypass == 1 ? 0 : 1; + + bool result = await HdlSafeguardLogic.Current.SetByPassStatuToSafety(this.zoonID, device, statu); + if (result == false) + { + return; + } + //鍙樻洿鐘舵�� + sensorInfo.IsBypass = statu; + + this.InitSensorDevicesListInfo(); + } + + #endregion + + #region 鈻� 娣诲姞鏂扮殑浼犳劅鍣╛____________________ + + /// <summary> + /// 娣诲姞鏂扮殑浼犳劅鍣� + /// </summary> + private void AddNewSensorDevice() + { + //鑾峰彇鑳藉娣诲姞鐨勪紶鎰熷櫒 + var list = this.GetCanAddSensorDevice(); + + //鏄剧ず閫夋嫨鐣岄潰 + var form = new SelectDeviceForm(); + form.AddForm(list, new List<string>(), true); + form.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddSensor)); + + //璁惧閫夋嫨纭畾 + form.ActionSelectDeviceEx += (async (listDevice) => + { + if (listDevice.Count == 0) + { + //鍏抽棴鐣岄潰 + form.CloseForm(); + return; + } + //娣诲姞璁惧鍒板畨闃� + bool success = await HdlSafeguardLogic.Current.AddSensorDevice(this.zoonID, listDevice); + if (success == true) + { + //鍏抽棴鐣岄潰 + form.CloseForm(); + //鍒锋柊鍒楄〃 + this.InitSensorDevicesListInfo(); + } + }); + } + + /// <summary> + /// 鑾峰彇鑳藉娣诲姞鐨勪紶鎰熷櫒 + /// </summary> + /// <returns></returns> + private List<CommonDevice> GetCanAddSensorDevice() + { + List<CommonDevice> listNew = new List<CommonDevice>(); + List<CommonDevice> listDevices = Common.LocalDevice.Current.listAllDevice; + foreach (CommonDevice device in listDevices) + { + //鍙浼犳劅鍣� + if (device.Type != DeviceType.IASZone) + { + continue; + } + //濡傛灉閭d釜璁惧宸茬粡娣诲姞浜嗭紝鍒欎笉鍐嶆樉绀� + if (HdlSafeguardLogic.Current.IsSensorDeviceExist(device) == true) + { + continue; + } + listNew.Add(device); + } + return listNew; + } + + #endregion + } +} -- Gitblit v1.8.0