From d0396d3f30d46810f8453bf21f86bd93fe5dbdec Mon Sep 17 00:00:00 2001 From: lss <316519258@qq.com> Date: 星期三, 10 六月 2020 15:54:37 +0800 Subject: [PATCH] test --- ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs | 220 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 162 insertions(+), 58 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs index dc3d1db..c242403 100644 --- a/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundControlContentForm.cs @@ -1,6 +1,9 @@ 锘縰sing System; using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; using Shared.Common; +using Shared.Phone.UserCenter.SmartSound.Util; using ZigBee.Device; namespace Shared.Phone.UserCenter.SmartSound.Forms @@ -11,7 +14,8 @@ /// 涓存椂鏁版嵁 /// </summary> private List<SmartSound.Layer> TempDatas = new List<SmartSound.Layer>(); - + + private SmartSoundInfo.SoundInfo mSoundInfo; /// <summary> /// 鍒楄〃鎺т欢 /// </summary> @@ -21,9 +25,9 @@ public int CurrentIndex = 0; private BottomClickButton bottomClickButton = null; - public SmartSoundControlContentForm() + public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo) { - // + this.mSoundInfo = soundInfo; } /// <summary> @@ -41,15 +45,14 @@ this.bodyFrameLayout.AddChidren(contentLayout); IniAllDataView(); - } - + #region 鍔犺浇鏈湴鎵�鏈夋暟鎹紝鐢熸垚渚涚敤鎴烽�夋嫨鎴块棿鐨勭晫闈� private void IniAllDataView() { contentLayout.RemoveAll(); - + var pullLayout = new MyPullControl(this, SmartSound.LocaData); contentLayout.AddChidren(pullLayout); pullLayout.InitControl(); @@ -61,13 +64,27 @@ bottomClickButton.Text = "纭"; bottomClickButton.ButtonClickEvent += (sender, e) => { - //淇濆瓨鏁版嵁 - if (SmartSound.CurretnData == null) - SmartSound.CurretnData = new List<SmartSound.Layer>(); + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + //淇濆瓨鏁版嵁 + if (SmartSound.getInstantiate().LayerList == null) + SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>(); - SmartSound.CurretnData.Clear(); - SmartSound.CurretnData = TempDatas; - this.CloseForm(); + SmartSound.getInstantiate().LayerList.Clear(); + SmartSound.getInstantiate().LayerList = CollateData(); + SmartSound.getInstantiate().TokenID = mSoundInfo.Id; + SmartSound.getInstantiate().UserID = mSoundInfo.UserID; + + //涓婁紶鏁版嵁鍒版湇鍔″櫒 + string str = await postBatchEdit(); + CloseProgressBar(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + CloseForm(); + }); + }); }; bottomClickButton.Visible = false; @@ -76,7 +93,7 @@ private void LoadAllRoomListView() { try - { + { if (SmartSound.LocaData == null || SmartSound.LocaData.Count < 1) return; @@ -84,13 +101,11 @@ // 鍔犺浇褰撳墠妤煎眰鐨勬墍鏈夋埧闂� ListView SmartSound.Layer layer = SmartSound.LocaData[CurrentIndex]; if (listView == null) - { - + { listView = new VerticalListControl(); contentLayout.AddChidren(listView); listView.Y = Application.GetRealHeight(173); - listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173); - + listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173); } listView.RemoveAll(); @@ -101,47 +116,34 @@ listView.AddChidren(roomRowLayout); roomRowLayout.InitControl(); } - + + //澶氫釜鐨勬椂鍊欙紝纭鎸夐挳浼氶伄鎸′竴閮ㄥ垎銆傝拷鍔犱笁涓┖鐨勮鐨勯珮搴︼紝鎶婂畠椤朵笂鏉� + if (listView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + listView.AddChidren(textView); + } } catch { } } + private async Task<string> postBatchEdit() + { + // The remote server returned an error: (400) Bad Request. + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit"; + string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate()); + string response_str = await MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); + return response_str; + } + #endregion + /// <summary> /// 灏嗘暟鎹浆鎹负鏅鸿兘闊崇浣跨敤鐨勬暟鎹� /// </summary> private void IniFloorData() { - #region//1.浠庢湇鍔″櫒鑾峰彇鐨勬暟鎹紝json鍙嶅簭鍒楀寲寰楁潵 - //2.鐐瑰嚮"+"灏嗙綉鍏崇殑鏁版嵁杞崲涓� 鏅鸿兘闊崇浣跨敤鐨勬暟鎹� - /*{ - - Dictionary<string, string> ss = Config.Instance.Home.FloorDics;//妤煎眰鍒楄〃 - string currentFloor = Config.Instance.Home.CurrentFloorId;//褰撳墠妤煎眰鐨勯敭 - - var listRoom = HdlRoomLogic.Current.GetFloorSortRoom("妤煎眰鐨勪富閿�");//鑾峰彇褰撳墠妤煎眰鐨勬墍鏈夋埧闂� - var room = listRoom[0]; - for (int i=0;i<room.ListDevice.Count;i++) - {//璁惧鏁版嵁 - var device = LocalDevice.Current.GetDevice(room.ListDevice[i]); - var myType = LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device }); - - if (myType.BeloneType == DeviceBeloneType.A鐏厜) - { - //杩欓噷闈㈢殑灏辨槸鐏厜浜� - var light = device; - // light.DeviceAddr; 璁惧鐨勫湴鍧� - // light.DeviceEpoint;//璁惧鐨勭鍙� - } - } - - for (int i = 0; i < room.ListSceneId.Count; i++) - { //鍦烘櫙鏁版嵁 - var device = HdlSceneLogic.Current.GetSceneUIBySceneId(room.ListSceneId[i]); - // device.Id;鍦烘櫙 id - } - }*/ - #endregion if (SmartSound.LocaData == null) SmartSound.LocaData = new List<SmartSound.Layer>(); @@ -155,7 +157,7 @@ { //娌℃湁妤煎眰,妯℃嫙涓�涓� SmartSound.Layer layer = new SmartSound.Layer(); - layer.LayerID = "0000"; + layer.LayerID = DateTime.Now.ToString("yyyyMMddHHmmssms"); layer.LayerName = "涓�妤�"; layer.RoomList.Clear(); SmartSound.LocaData.Add(layer); @@ -205,15 +207,17 @@ continue; SmartSound.Device smartDevice = new SmartSound.Device(); - smartDevice.Id = device.DeviceID.ToString();//璁惧 Id + //smartDevice.Id = device.DeviceID.ToString();//璁惧 Id smartDevice.DeviceAddress = device.DeviceAddr;//璁惧 MAC smartDevice.Epoint = device.DeviceEpoint;//璁惧绔彛 - smartDevice.ClusterID = 0; + //smartDevice.ClusterID = 0; smartDevice.DeviceName = device.DeviceName;//璁惧鍚嶇О smartDevice.NicksName = ""; smartDevice.DeviceType = GetDeviceType(device);//璁惧绫诲瀷 smartDevice.GatewayID = device.CurrentGateWayId;//缃戝叧 Id - smartDevice.RoomID = room.Id;//鎴块棿 Id + //smartDevice.RoomID = room.Id;//鎴块棿 Id + if (smartDevice.DeviceName == "" || smartDevice.DeviceName == string.Empty) + continue; smartRoom.DeviceList.Add(smartDevice); @@ -226,15 +230,20 @@ for (int k = 0; k < sceneList.Count; k++) { SceneUI scene = sceneList[k]; + if (scene == null) continue; SmartSound.Scene smartScene = new SmartSound.Scene(); - smartScene.Id = scene.DeviceID.ToString(); + //smartScene.Id = scene.DeviceID.ToString(); smartScene.SceneName = scene.Name; smartScene.SceneID = scene.Id; smartScene.DelayTime = scene.DelayTime; - smartScene.ClusterID = 0; + //smartScene.ClusterID = 0; smartScene.NicksName = ""; - smartScene.RoomID = room.Id; + //smartScene.RoomID = room.Id; + smartScene.GatewayID = ZbGateway.MainGateWay.CurrentGateWayId; + + if (smartScene.SceneName == "" || smartScene.SceneName == string.Empty) + continue; smartRoom.SceneList.Add(smartScene); } @@ -304,6 +313,8 @@ SmartSound.Layer tempLayer = SmartSound.LocaData[CurrentIndex]; if (tempLayer == null) return; + + #region 娣诲姞妤煎眰 bool floor_exists = false; @@ -347,6 +358,7 @@ if (!room_exists) { TempDatas[i].RoomList.Add(room); + CheckedAll(room);//娣诲姞鎴块棿鎴愬姛锛岄粯璁ら�変腑鎵�鏈夎澶� break; } } @@ -372,6 +384,89 @@ } } catch { } + } + + /// <summary> + /// 榛樿閫夋嫨鎵�鏈夎澶� + /// </summary> + /// <param name="room"></param> + private void CheckedAll(SmartSound.Room room) + { + // 鏍囪鎵�鏈夊満鏅� + for (int n = 0; n < room.SceneList.Count; n++) + { + SmartSound.Scene _scene = room.SceneList[n]; + _scene.Checked = true; + } + + //鏍囪鎵�鏈夎澶� + for (int k = 0; k < room.DeviceList.Count; k++) + { + + SmartSound.Device _device = room.DeviceList[k]; + _device.Checked = true; + } + } + + /// <summary> + /// 閲嶆柊鏁寸悊鏁版嵁锛屾妸娌℃湁閫変腑鐨勬暟鎹兘鍓旈櫎鎺� + /// </summary> + private List<SmartSound.Layer> CollateData() + { + try + { + //绉诲嚭鏈�変腑鐨勮澶囥�佸満鏅� + for (int i = 0; i < TempDatas.Count; i++) + { + SmartSound.Layer _layer = TempDatas[i]; + + for (int j = 0; j < _layer.RoomList.Count; j++) + { + SmartSound.Room _room = _layer.RoomList[j]; + if (_room.Checked) + { + #region 娓呴櫎鏈�変腑鐨勮澶� + for (int k = 0; k < _room.DeviceList.Count; k++) + { + SmartSound.Device _device = _room.DeviceList[k]; + if (!_device.Checked) + { + _room.DeviceList.Remove(_device); + } + } + #endregion + + #region 娓呴櫎鏈�変腑鐨勫満鏅� + for (int n = 0; n < _room.SceneList.Count; n++) + { + SmartSound.Scene _scene = _room.SceneList[n]; + if (!_scene.Checked) + { + _room.SceneList.Remove(_scene); + } + } + #endregion + } + else + { + _layer.RoomList.Remove(_room); + } + } + } + + //绉诲嚭娌℃湁璁惧鐨勬埧闂� + for (int j = 0; j < TempDatas.Count; j++) + { + SmartSound.Layer _layer = TempDatas[j]; + if (_layer.RoomList.Count < 1) + { + TempDatas.Remove(_layer); + } + } + } + catch { } + + return TempDatas; } #region 鈻� 鑷畾涔夋ゼ灞傞�夋嫨鎺т欢_____________________ @@ -426,7 +521,13 @@ layout.ButtonClickEvent += (sender, e) => { ShowPullList(); - }; + }; + + if (Layers.Count == 1) + { + right_icon.Visible = false; + layout.Visible = false; + } } @@ -458,6 +559,7 @@ private class RoomRowLayout : FrameRowControl { private SmartSoundControlContentForm smartSoundControlContentForm = null; + private SmartSound.Room mRoom = null; /// <summary> /// 鎴块棿鍚嶇О @@ -477,14 +579,14 @@ this.BackgroundColor = UserCenterColor.Current.White; this.Height = Application.GetRealHeight(170); } - + /// <summary> /// 鍒濆鍖栨帶浠� /// </summary> public void InitControl() { //鏄剧ず鏂囨湰 - btnName = this.AddLeftCaption(string.Empty, 700); + btnName = this.AddLeftCaption(string.Empty, 2000); btnName.Height = Application.GetRealHeight(60); btnName.TextSize = 17; btnName.Y = Application.GetRealHeight(57); @@ -497,6 +599,8 @@ btnName.ButtonClickEvent += (sender, e) => { + mRoom.Checked = true; + RefreshRightIconState(mRoom.Checked); SmartSoundContentForDevice deviceForm = new SmartSoundContentForDevice(mRoom); deviceForm.AddForm(); }; -- Gitblit v1.8.0