From c7df85937f73fb347ee0b19e9c052d2d00a6df6c Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 18 九月 2020 13:58:19 +0800 Subject: [PATCH] 新版本 --- ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs | 180 +++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 118 insertions(+), 62 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs old mode 100755 new mode 100644 index 02c58fe..9ccdd57 --- a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs +++ b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Shared.Common; using Shared.Phone.UserCenter.SmartSound.Util; +using Shared.Phone.UserCenter.SmartSound.Widget; using ZigBee.Device; namespace Shared.Phone.UserCenter.SmartSound.Forms @@ -22,8 +23,15 @@ private VerticalListControl listView = null; private FrameLayout contentLayout = null; - public int CurrentIndex = 0; + /// <summary> + /// 褰撳墠妤煎眰鐨勭储寮� + /// </summary> + public int CurrentIndex = 0; private BottomClickButton bottomClickButton = null; + /// <summary> + /// 褰撳墠妤煎眰鐨勫悕绉� + /// </summary> + private static NormalViewControl pullLayoutText = null; public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo) { @@ -64,30 +72,57 @@ bottomClickButton.Text = "纭"; bottomClickButton.ButtonClickEvent += (sender, e) => { - HdlThreadLogic.Current.RunThread(async () => + if (SmartSound.getInstantiate().LayerList != null && SmartSound.getInstantiate().LayerList.Count > 0) { - this.ShowProgressBar(); - //淇濆瓨鏁版嵁 - if (SmartSound.getInstantiate().LayerList == null) - SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>(); + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new TextDialog("纭鍒犻櫎鐜版湁鎴块棿鍒楄〃鐨勬墍鏈夋帶鍒跺唴瀹癸紝娣诲姞鍏ㄦ柊鐨勫満鏅拰鍔熻兘锛�", "纭"); + dialogForm.SetTitleText("鎻愮ず"); - 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(() => + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += () => { - CloseForm(); - }); - }); + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + uploadData(); + }; + } + else + { + uploadData(); + } + }; bottomClickButton.Visible = false; + } + + /// <summary> + /// 鎻愪氦鏁版嵁鍒版湇鍔″櫒 + /// </summary> + private void uploadData() + { + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + //淇濆瓨鏁版嵁 + if (SmartSound.getInstantiate().LayerList == null) + SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>(); + + SmartSound.getInstantiate().LayerList.Clear(); + SmartSound.getInstantiate().LayerList = CollateData(); + SmartSound.getInstantiate().TokenID = mSoundInfo.Id; + SmartSound.getInstantiate().UserID = mSoundInfo.UserID; + SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID; + + //涓婁紶鏁版嵁鍒版湇鍔″櫒 + string str = await postBatchEdit(); + CloseProgressBar(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + CloseForm(); + }); + }); } private void LoadAllRoomListView() @@ -108,6 +143,7 @@ listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173); } + pullLayoutText.Text = layer.LayerName; listView.RemoveAll(); foreach(SmartSound.Room room in layer.RoomList) @@ -133,7 +169,7 @@ // 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); + string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); return response_str; } @@ -181,7 +217,6 @@ for (int n = 0; n < SmartSound.LocaData.Count; n++) { SmartSound.Layer layer = SmartSound.LocaData[n]; - foreach (Room room in roomList) { try @@ -207,20 +242,27 @@ continue; SmartSound.Device smartDevice = new SmartSound.Device(); - //smartDevice.Id = device.DeviceID.ToString();//璁惧 Id smartDevice.DeviceAddress = device.DeviceAddr;//璁惧 MAC smartDevice.Epoint = device.DeviceEpoint;//璁惧绔彛 - //smartDevice.ClusterID = 0; - smartDevice.DeviceName = device.DeviceName;//璁惧鍚嶇О + smartDevice.DeviceName = Common.LocalDevice.Current.GetDeviceEpointName(device);//璁惧鍚嶇О smartDevice.NicksName = ""; smartDevice.DeviceType = GetDeviceType(device);//璁惧绫诲瀷 - smartDevice.GatewayID = device.CurrentGateWayId;//缃戝叧 Id - //smartDevice.RoomID = room.Id;//鎴块棿 Id + if (smartDevice.DeviceType == 0) + continue; + + if(ZbGateway.GateWayBaseInfomations.ContainsKey(device.CurrentGateWayId) ==true) + { + smartDevice.GatewayID = ZbGateway.GateWayBaseInfomations[device.CurrentGateWayId].MacMark;//缃戝叧 Id + } + else + { + smartDevice.GatewayID = device.CurrentGateWayId;//缃戝叧 Id + } + if (smartDevice.DeviceName == "" || smartDevice.DeviceName == string.Empty) continue; smartRoom.DeviceList.Add(smartDevice); - } #endregion @@ -229,25 +271,36 @@ #region //娣诲姞鍦烘櫙 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.SceneName = scene.Name; - smartScene.SceneID = scene.Id; - smartScene.DelayTime = scene.DelayTime; - //smartScene.ClusterID = 0; - smartScene.NicksName = ""; - //smartScene.RoomID = room.Id; - smartScene.GatewayID = ZbGateway.MainGateWay.GwId; + try + { + SceneUI scene = sceneList[k]; - if (smartScene.SceneName == "" || smartScene.SceneName == string.Empty) - continue; + if (scene == null) continue; + SmartSound.Scene smartScene = new SmartSound.Scene(); + smartScene.SceneName = scene.Name; + smartScene.SceneID = scene.Id; + smartScene.DelayTime = scene.DelayTime; + smartScene.NicksName = ""; + if (ZbGateway.GateWayBaseInfomations.ContainsKey(ZbGateway.MainGateWay.GwId) == true) + { + smartScene.GatewayID = ZbGateway.GateWayBaseInfomations[ZbGateway.MainGateWay.GwId].MacMark;//缃戝叧 Id + } + else + { + smartScene.GatewayID = ZbGateway.MainGateWay.GwId;//缃戝叧 Id + } - smartRoom.SceneList.Add(smartScene); + if (smartScene.SceneName == "" || smartScene.SceneName == string.Empty) + continue; + + smartRoom.SceneList.Add(smartScene); + } + catch (Exception e) { } } #endregion + + if (smartRoom.DeviceList.Count == 0 && sceneList.Count == 0) + layer.RoomList.Remove(smartRoom); } catch (Exception e) @@ -314,7 +367,6 @@ if (tempLayer == null) return; - #region 娣诲姞妤煎眰 bool floor_exists = false; @@ -432,6 +484,7 @@ if (!_device.Checked) { _room.DeviceList.Remove(_device); + k--; } } #endregion @@ -443,6 +496,7 @@ if (!_scene.Checked) { _room.SceneList.Remove(_scene); + n--; } } #endregion @@ -450,6 +504,7 @@ else { _layer.RoomList.Remove(_room); + j--; } } } @@ -461,6 +516,7 @@ if (_layer.RoomList.Count < 1) { TempDatas.Remove(_layer); + j--; } } } @@ -514,21 +570,21 @@ right_icon.ButtonClickEvent += (sender, e) => { ShowPullList(); - }; - - var layout = this.AddMostRightView(Layers[smartSoundDataAdd.CurrentIndex].LayerName, 300, false); - layout.Name = "pullLayout"; - layout.ButtonClickEvent += (sender, e) => + }; + + pullLayoutText = this.AddMostRightView(Layers[smartSoundDataAdd.CurrentIndex].LayerName, 300, false); + pullLayoutText.Name = "pullLayout"; + pullLayoutText.ButtonClickEvent += (sender, e) => { ShowPullList(); }; + pullLayoutText.Text = Layers[smartSoundDataAdd.CurrentIndex].LayerName; if (Layers.Count == 1) { right_icon.Visible = false; - layout.Visible = false; - } - + pullLayoutText.Visible = false; + } } private void ShowPullList() @@ -536,14 +592,16 @@ //鎴块棿鍒楄〃琛寋鎴块棿鍒楄〃 textView锛屾ゼ灞備笅鎷夌獥} //鏄剧ず鎴块棿{甯﹂�夋嫨妗嗙殑锛涘綋閫変腑浜嗘埧闂村悗闇�瑕佸湪搴曢儴寮瑰嚭纭鎸夐挳锛岀偣鍑荤‘璁よ烦杞埌鏂扮殑鐣岄潰} var pull_frame = new TopRightMenuControl(Layers.Count, 2); + pull_frame.Y = this.Height; for (int i = 0; i < Layers.Count; i++) { + int index = i; //鍒涘缓妤煎眰 pull_frame.AddRowMenu(Layers[i].LayerName, "Item/CreatFloor.png", "Item/CreatFloorSelected.png", () => { - smartSoundDataAdd.CurrentIndex = i; + smartSoundDataAdd.CurrentIndex = index; smartSoundDataAdd.LoadAllRoomListView(); }); } @@ -566,7 +624,7 @@ /// </summary> private NormalViewControl btnName = null; - private IconViewControl Right_icon = null; + private MostRightIconControl Right_icon = null; /// <summary> /// 鎴块棿鍒楄〃琛� @@ -588,14 +646,12 @@ //鏄剧ず鏂囨湰 btnName = this.AddLeftCaption(string.Empty, 2000); btnName.Height = Application.GetRealHeight(60); - btnName.TextSize = 17; + btnName.TextSize = 14; btnName.Y = Application.GetRealHeight(57); btnName.Text = mRoom.RoomName; - Right_icon = this.AddRightArrow(); - Right_icon.Width = Application.GetRealWidth(115); - Right_icon.Height = Application.GetRealHeight(115); + + Right_icon = this.AddMostRightEmptyIcon(58, 58); Right_icon.Gravity = Gravity.CenterVertical; - Right_icon.X = Right_icon.X - Application.GetRealWidth(60); btnName.ButtonClickEvent += (sender, e) => { @@ -622,15 +678,15 @@ { if (bol) { - Right_icon.SelectedImagePath = "SmartSound/CheckBoxSel.png"; - Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxSel.png"; + Right_icon.SelectedImagePath = "Item/ItemSelected.png"; + Right_icon.UnSelectedImagePath = "Item/ItemSelected.png"; smartSoundControlContentForm.AddData(mRoom); } else { - Right_icon.SelectedImagePath = "SmartSound/CheckBoxDef.png"; - Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxDef.png"; + Right_icon.SelectedImagePath = "Item/ItemUnSelected.png"; + Right_icon.UnSelectedImagePath = "Item/ItemUnSelected.png"; smartSoundControlContentForm.RemoveData(mRoom); } -- Gitblit v1.8.0