From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期二, 21 七月 2020 09:46:53 +0800 Subject: [PATCH] 请合并最新多功能面板代码 --- ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs | 345 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 345 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs new file mode 100755 index 0000000..2aadc19 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/LookRoomSettionForm.cs @@ -0,0 +1,345 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.Residence +{ + /// <summary> + /// 鏌ョ湅鎴块棿閰嶇疆鐨勭晫闈� + /// </summary> + public class LookRoomSettionForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鏌ョ湅鐨勬埧闂村璞� + /// </summary> + private Common.Room lookRoom = null; + /// <summary> + /// 妗屽竷鎺т欢 + /// </summary> + private NormalFrameLayout frameTable = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_room">鏌ョ湅鐨勬埧闂村璞�</param> + public void ShowForm(Common.Room i_room) + { + this.lookRoom = i_room; + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(lookRoom.Name); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //鍒濆鍖栨甯冩帶浠� + this.frameTable = new NormalFrameLayout(); + frameTable.Y = Application.GetRealHeight(187); + frameTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(187); + bodyFrameLayout.AddChidren(frameTable); + + //鍒濆鍖栧垎鏀帶浠� + this.InitSwitchControl(); + } + + /// <summary> + /// 鍒濆鍖栧垎鏀帶浠� + /// </summary> + private void InitSwitchControl() + { + var tabControl = new SceneFunctionSwitchControl(); + tabControl.Y = Application.GetRealHeight(40); + bodyFrameLayout.AddChidren(tabControl); + tabControl.SelectTabEvent += (tabIndex) => + { + if (tabIndex == 0) + { + //鏄剧ず鍦烘櫙鍒楄〃 + this.ShowSceneList(); + } + else + { + //鏄剧ず鍔熻兘鍒楄〃 + this.ShowFunctionList(); + } + }; + var listTitle = new List<string>(); + //鍦烘櫙,鍔熻兘 + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence)); + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction)); + tabControl.InitControl(listTitle); + } + + #endregion + + #region 鈻� 鍦烘櫙鏄剧ず___________________________ + + /// <summary> + /// 鏄剧ず鍦烘櫙鍒楄〃 + /// </summary> + private void ShowSceneList() + { + //娓呯┖妗屽竷 + this.frameTable.RemoveAll(); + HdlThreadLogic.Current.RunMainInThread(() => + { + if (lookRoom.ListSceneId.Count == 0) + { + //杩樻病鏈夋坊鍔犲満鏅摝 + this.ShowNotDataImage(frameTable, Language.StringByID(R.MyInternationalizationString.uDoNotHadAddScenceMsg)); + return; + } + var listView = new VerticalFrameControl(3); + listView.Height = frameTable.Height; + frameTable.AddChidren(listView); + + foreach (var dataId in lookRoom.ListSceneId) + { + var data = HdlSceneLogic.Current.GetSceneUIBySceneId(dataId); + if (data == null) + { + continue; + } + //鍦烘櫙鎺т欢 + var frameContr = new ScenePictrueControl(); + listView.AddChidren(frameContr); + frameContr.InitControl(data); + } + }); + } + + #endregion + + #region 鈻� 鍔熻兘鏄剧ず___________________________ + + /// <summary> + /// 鏄剧ず鍔熻兘鍒楄〃 + /// </summary> + private void ShowFunctionList() + { + //娓呯┖妗屽竷 + this.frameTable.RemoveAll(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + //鑾峰彇鍒嗙粍鍚庣殑璁惧鍒楄〃 + var dicGroupDevice = this.GetAllGroupDevice(); + if (dicGroupDevice.Count == 0) + { + //杩樻病鏈夋坊鍔犺澶囧摝 + this.ShowNotDataImage(frameTable, Language.StringByID(R.MyInternationalizationString.uDoNotHadAddDeviceMsg)); + return; + } + + var frameBack = new FrameLayout(); + frameBack.X = ControlCommonResourse.XXLeft; + frameBack.BackgroundColor = UserCenterColor.Current.White; + frameBack.Width = bodyFrameLayout.Width; + frameBack.Height = Application.GetRealHeight(1650); + frameBack.Radius = (uint)Application.GetRealHeight(58); + frameTable.AddChidren(frameBack); + + var listView = new VerticalListControl(23); + listView.Y = Application.GetRealHeight(23); + listView.Height = Application.GetRealHeight(1549 - 23); + frameBack.AddChidren(listView); + + var dicData = new Dictionary<string, DeviceRowInfo>(); + var listGwId = new List<string>(); + foreach (var textId in dicGroupDevice.Keys) + { + //娣诲姞璁惧琛� + this.AddDeviceRow(dicGroupDevice[textId], textId, listView); + foreach (var deviceKey in dicGroupDevice[textId].listDeviceKeys) + { + var device = Common.LocalDevice.Current.GetDevice(deviceKey); + if (listGwId.Contains(device.CurrentGateWayId) == false) + { + //缃戝叧ID + listGwId.Add(device.CurrentGateWayId); + } + //浠ュ洖璺綔涓虹储寮曞幓鎸囧畾瀵硅薄 + dicData[deviceKey] = dicGroupDevice[textId]; + } + } + listView.AdjustRealHeight(Application.GetRealHeight(23)); + //濡傛灉涓嶆槸铏氭嫙浣忓畢 + if (Common.Config.Instance.Home.IsVirtually == false) + { + //寮�鍚澶囧湪绾跨洃娴� + this.StartCheckDeviceOnline(listView, listGwId, dicData); + } + }); + } + + #endregion + + #region 鈻� 娣诲姞璁惧琛宊________________________ + + /// <summary> + /// 娣诲姞璁惧琛� + /// </summary> + /// <param name="rowInfo"></param> + /// <param name="TextId"></param> + /// <param name="listView"></param> + private void AddDeviceRow(DeviceRowInfo rowInfo, int TextId, VerticalListControl listView) + { + var frameRow = new FrameRowControl(listView.rowSpace / 2); + frameRow.LeftOffset = Application.GetRealWidth(46) - ControlCommonResourse.XXLeft; + frameRow.RightOffset = -ControlCommonResourse.XXLeft; + listView.AddChidren(frameRow); + //鍥炬爣 + var btnIcon = frameRow.AddLeftIcon(81); + btnIcon.UnSelectedImagePath = rowInfo.IconPath; + //鍚嶇О + var btnView = frameRow.AddLeftCaption(string.Empty, 600); + btnView.TextID = TextId; + btnView.TextSize = 15; + //鍙崇澶� + frameRow.AddRightArrow(); + //鍦ㄧ嚎鏁� + var btnOnline = frameRow.AddMostRightView(rowInfo.OnlineCount + "/" + rowInfo.listDeviceKeys.Count, 300); + rowInfo.btnOnline = btnOnline; + //搴曠嚎 + frameRow.AddBottomLine(); + frameRow.ButtonClickEvent += (sender, e) => + { + var form = new LookRoomDeviceListForm(); + form.AddForm(lookRoom.Name, Language.StringByID(TextId), rowInfo.listDeviceKeys); + }; + } + + #endregion + + #region 鈻� 鏁村悎璁惧___________________________ + + /// <summary> + /// 鑾峰彇鍒嗙粍鍚庣殑璁惧 + /// </summary> + /// <returns></returns> + private Dictionary<int, DeviceRowInfo> GetAllGroupDevice() + { + //鍏ㄩ儴鐨勮澶� + var listDevice = HdlRoomLogic.Current.GetRoomListDevice(lookRoom); + var dic = new Dictionary<int, DeviceRowInfo>(); + foreach (var device in listDevice) + { + var typeInfo = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device); + //鎸夋墍灞濱D鍒嗙粍 + if (dic.ContainsKey(typeInfo.BeloneTextId) == false) + { + dic[typeInfo.BeloneTextId] = new DeviceRowInfo(); + string path1 = string.Empty; + string path2 = string.Empty; + //鑾峰彇鍥剧墖 + Common.LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo.ConcreteType, ref path1, ref path2); + dic[typeInfo.BeloneTextId].IconPath = path1; + } + dic[typeInfo.BeloneTextId].listDeviceKeys.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device)); + } + return dic; + } + + #endregion + + #region 鈻� 璁惧鍦ㄧ嚎___________________________ + + /// <summary> + /// 寮�鍚澶囧湪绾跨洃娴� + /// </summary> + /// <param name="listView">鍒ゆ柇閫�鍑烘椂浣跨敤</param> + /// <param name="listGwId">缃戝叧ID</param> + /// <param name="dicData">浠ュ洖璺綔涓虹储寮曞幓鎸囧畾瀵硅薄</param> + private void StartCheckDeviceOnline(VerticalListControl listView, List<string> listGwId, Dictionary<string, DeviceRowInfo> dicData) + { + HdlThreadLogic.Current.RunThread(() => + { + var listCheck = new HashSet<string>(); + for (int i = 0; i < listGwId.Count; i++) + { + if (listView.Parent == null) + { + return; + } + //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵�� + var zbway = HdlGatewayLogic.Current.GetLocalGateway(listGwId[i]); + int statu = 0; + var list = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO); + if (statu != -1) + { + HdlThreadLogic.Current.RunMain(() => + { + for (int j = 0; j < list.Count; j++) + { + string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(list[j]); + if (listView.Parent == null || dicData.ContainsKey(mainkeys) == false || listCheck.Contains(mainkeys) == true) + { + return; + } + listCheck.Add(mainkeys); + + var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys); + if (localDevice != null && localDevice.IsOnline != list[j].IsOnline) + { + //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂� + localDevice.IsOnline = list[j].IsOnline; + localDevice.ReSave(); + } + if (Common.LocalDevice.Current.CheckDeviceIsOnline(list[j]) == true) + { + dicData[mainkeys].OnlineCount += 1; + dicData[mainkeys].btnOnline.Text = dicData[mainkeys].OnlineCount + "/" + dicData[mainkeys].listDeviceKeys.Count; + } + } + }); + } + } + }); + } + + #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 璁惧琛屼俊鎭� + /// </summary> + private class DeviceRowInfo + { + /// <summary> + /// 鍥炬爣 + /// </summary> + public string IconPath = string.Empty; + /// <summary> + /// 璁惧鍥炶矾涓婚敭 + /// </summary> + public List<string> listDeviceKeys = new List<string>(); + /// <summary> + /// 璁惧鍦ㄧ嚎鏁� + /// </summary> + public int OnlineCount = 0; + /// <summary> + /// 鍦ㄧ嚎鎺т欢 + /// </summary> + public NormalViewControl btnOnline = null; + } + + #endregion + } +} -- Gitblit v1.8.0