| | |
| | | using 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 |
| | |
| | | /// 临时数据 |
| | | /// </summary> |
| | | private List<SmartSound.Layer> TempDatas = new List<SmartSound.Layer>(); |
| | | |
| | | |
| | | private SmartSoundInfo.SoundInfo mSoundInfo; |
| | | /// <summary> |
| | | /// 列表控件 |
| | | /// </summary> |
| | |
| | | public int CurrentIndex = 0; |
| | | private BottomClickButton bottomClickButton = null; |
| | | |
| | | public SmartSoundControlContentForm() |
| | | public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo) |
| | | { |
| | | // |
| | | this.mSoundInfo = soundInfo; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | this.bodyFrameLayout.AddChidren(contentLayout); |
| | | |
| | | IniAllDataView(); |
| | | |
| | | } |
| | | |
| | | |
| | | #region 加载本地所有数据,生成供用户选择房间的界面 |
| | | |
| | | private void IniAllDataView() |
| | | { |
| | | contentLayout.RemoveAll(); |
| | | |
| | | |
| | | var pullLayout = new MyPullControl(this, SmartSound.LocaData); |
| | | contentLayout.AddChidren(pullLayout); |
| | | pullLayout.InitControl(); |
| | |
| | | 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 = CollateData(); |
| | | 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; |
| | |
| | | private void LoadAllRoomListView() |
| | | { |
| | | try |
| | | { |
| | | { |
| | | |
| | | if (SmartSound.LocaData == null || SmartSound.LocaData.Count < 1) |
| | | return; |
| | |
| | | // 加载当前楼层的所有房间 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(); |
| | |
| | | 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> |
| | | 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>(); |
| | |
| | | { |
| | | //没有楼层,模拟一个 |
| | | SmartSound.Layer layer = new SmartSound.Layer(); |
| | | layer.LayerID = "0000"; |
| | | layer.LayerID = DateTime.Now.ToString("yyyyMMddHHmmssms"); |
| | | layer.LayerName = "一楼"; |
| | | layer.RoomList.Clear(); |
| | | SmartSound.LocaData.Add(layer); |
| | |
| | | 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); |
| | | |
| | |
| | | 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); |
| | | } |
| | |
| | | layout.ButtonClickEvent += (sender, e) =>
|
| | | { |
| | | ShowPullList(); |
| | | }; |
| | | };
|
| | |
|
| | | if (Layers.Count == 1) |
| | | {
|
| | | right_icon.Visible = false;
|
| | | layout.Visible = false;
|
| | | }
|
| | |
|
| | | }
|
| | |
|