| | |
| | | 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 |
| | |
| | | private VerticalListControl listView = null; |
| | | |
| | | private FrameLayout contentLayout = null; |
| | | /// <summary> |
| | | /// 当前楼层的索引 |
| | | /// </summary> |
| | | public int CurrentIndex = 0; |
| | | private BottomClickButton bottomClickButton = null; |
| | | /// <summary> |
| | | /// 当前楼层的名称 |
| | | /// </summary> |
| | | private static NormalViewControl pullLayoutText = null; |
| | | |
| | | public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo) |
| | | { |
| | |
| | | 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() |
| | |
| | | listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173); |
| | | } |
| | | |
| | | pullLayoutText.Text = layer.LayerName; |
| | | listView.RemoveAll(); |
| | | |
| | | foreach(SmartSound.Room room in layer.RoomList) |
| | |
| | | // 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; |
| | | } |
| | | |
| | |
| | | for (int n = 0; n < SmartSound.LocaData.Count; n++) |
| | | { |
| | | SmartSound.Layer layer = SmartSound.LocaData[n]; |
| | | |
| | | foreach (Room room in roomList) |
| | | { |
| | | try |
| | |
| | | for (int j = 0; j < room.ListDevice.Count; j++) |
| | | { |
| | | string key = room.ListDevice[j].ToString(); |
| | | var device = LocalDevice.Current.GetDevice(key); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(key); |
| | | if (device == null) |
| | | 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 = HdlDeviceCommonLogic.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.DicGatewayBaseInfo.ContainsKey(device.CurrentGateWayId) ==true) |
| | | { |
| | | smartDevice.GatewayID = ZbGateway.DicGatewayBaseInfo[device.CurrentGateWayId].Id;//网关 Id |
| | | } |
| | | else |
| | | { |
| | | smartDevice.GatewayID = device.CurrentGateWayId;//网关 Id |
| | | } |
| | | |
| | | if (smartDevice.DeviceName == "" || smartDevice.DeviceName == string.Empty) |
| | | continue; |
| | | |
| | | smartRoom.DeviceList.Add(smartDevice); |
| | | |
| | | } |
| | | #endregion |
| | | |
| | |
| | | #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.DicGatewayBaseInfo.ContainsKey(ZbGateway.MainGateWay.GwId) == true) |
| | | { |
| | | smartScene.GatewayID = ZbGateway.DicGatewayBaseInfo[ZbGateway.MainGateWay.GwId].Id;//网关 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) |
| | |
| | | if (tempLayer == null) return; |
| | | |
| | | |
| | | |
| | | #region 添加楼层 |
| | | |
| | | bool floor_exists = false; |
| | |
| | | if (!_device.Checked) |
| | | { |
| | | _room.DeviceList.Remove(_device); |
| | | k--; |
| | | } |
| | | } |
| | | #endregion |
| | |
| | | if (!_scene.Checked) |
| | | { |
| | | _room.SceneList.Remove(_scene); |
| | | n--; |
| | | } |
| | | } |
| | | #endregion |
| | |
| | | else |
| | | { |
| | | _layer.RoomList.Remove(_room); |
| | | j--; |
| | | } |
| | | } |
| | | } |
| | |
| | | if (_layer.RoomList.Count < 1) |
| | | { |
| | | TempDatas.Remove(_layer); |
| | | j--; |
| | | } |
| | | } |
| | | } |
| | |
| | | return TempDatas; |
| | | } |
| | | |
| | | #region ■ 自定义楼层选择控件_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 房间列表行
|
| | | /// </summary>
|
| | | private class MyPullControl : FrameRowControl
|
| | | #region ■ 自定义楼层选择控件_____________________ |
| | | |
| | | /// <summary> |
| | | /// 房间列表行 |
| | | /// </summary> |
| | | private class MyPullControl : FrameRowControl |
| | | { |
| | | |
| | | private SmartSoundControlContentForm smartSoundDataAdd = null; |
| | | private List<SmartSound.Layer> Layers = null; |
| | | /// <summary>
|
| | | /// 房间列表
|
| | | /// </summary>
|
| | | private NormalViewControl btnName = null;
|
| | |
|
| | | /// <summary>
|
| | | /// 房间列表行
|
| | | /// </summary>
|
| | | public MyPullControl(SmartSoundControlContentForm _SmartSoundDataAdd,List<SmartSound.Layer> _layers)
|
| | | {
|
| | | this.smartSoundDataAdd = _SmartSoundDataAdd;
|
| | | this.Layers = _layers;
|
| | | /// <summary> |
| | | /// 房间列表 |
| | | /// </summary> |
| | | private NormalViewControl btnName = null; |
| | | |
| | | /// <summary> |
| | | /// 房间列表行 |
| | | /// </summary> |
| | | public MyPullControl(SmartSoundControlContentForm _SmartSoundDataAdd,List<SmartSound.Layer> _layers) |
| | | { |
| | | this.smartSoundDataAdd = _SmartSoundDataAdd; |
| | | this.Layers = _layers; |
| | | this.UseClickStatu = false; |
| | | this.BackgroundColor = UserCenterColor.Current.White;
|
| | | this.Height = Application.GetRealHeight(173);
|
| | | this.BackgroundColor = UserCenterColor.Current.White; |
| | | this.Height = Application.GetRealHeight(173); |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 初始化控件
|
| | | /// </summary>
|
| | | public void InitControl()
|
| | | /// <summary> |
| | | /// 初始化控件 |
| | | /// </summary> |
| | | public void InitControl() |
| | | { |
| | | //显示文本 |
| | | btnName = this.AddLeftCaption(string.Empty, 700);
|
| | | btnName.Height = Application.GetRealHeight(60);
|
| | | btnName.TextSize = 17;
|
| | | btnName.Y = Application.GetRealHeight(57);
|
| | | btnName = this.AddLeftCaption(string.Empty, 700); |
| | | btnName.Height = Application.GetRealHeight(60); |
| | | btnName.TextSize = 17; |
| | | btnName.Y = Application.GetRealHeight(57); |
| | | btnName.Text = "房间列表"; |
| | | |
| | | var right_icon=this.AddRightArrow();
|
| | | right_icon.SelectedImagePath = "SmartSound/PullDown.png";
|
| | | right_icon.UnSelectedImagePath = "SmartSound/PullDown.png";
|
| | | right_icon.ButtonClickEvent += (sender, e) =>
|
| | | var right_icon=this.AddRightArrow(); |
| | | right_icon.SelectedImagePath = "SmartSound/PullDown.png"; |
| | | right_icon.UnSelectedImagePath = "SmartSound/PullDown.png"; |
| | | 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;
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | { |
| | | right_icon.Visible = false; |
| | | pullLayoutText.Visible = false; |
| | | } |
| | | } |
| | | |
| | | private void ShowPullList() |
| | | { |
| | | //房间列表行{房间列表 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(); |
| | | }); |
| | | } |
| | | }
|
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ■ 自定义房间选择控件_____________________
|
| | | #region ■ 自定义房间选择控件_____________________ |
| | | |
| | | /// <summary>
|
| | | /// 房间列表行
|
| | | /// </summary>
|
| | | private class RoomRowLayout : FrameRowControl
|
| | | /// <summary> |
| | | /// 房间列表行 |
| | | /// </summary> |
| | | private class RoomRowLayout : FrameRowControl |
| | | { |
| | | private SmartSoundControlContentForm smartSoundControlContentForm = null; |
| | | |
| | | private SmartSound.Room mRoom = null; |
| | | /// <summary>
|
| | | /// 房间名称
|
| | | /// </summary>
|
| | | private NormalViewControl btnName = null;
|
| | |
|
| | | private IconViewControl Right_icon = null; |
| | |
|
| | | /// <summary>
|
| | | /// 房间列表行
|
| | | /// </summary>
|
| | | public RoomRowLayout(SmartSoundControlContentForm _smartSoundControlContentForm,SmartSound.Room _room)
|
| | | {
|
| | | this.smartSoundControlContentForm = _smartSoundControlContentForm;
|
| | | this.mRoom = _room;
|
| | | /// <summary> |
| | | /// 房间名称 |
| | | /// </summary> |
| | | private NormalViewControl btnName = null; |
| | | |
| | | private MostRightIconControl Right_icon = null; |
| | | |
| | | /// <summary> |
| | | /// 房间列表行 |
| | | /// </summary> |
| | | public RoomRowLayout(SmartSoundControlContentForm _smartSoundControlContentForm,SmartSound.Room _room) |
| | | { |
| | | this.smartSoundControlContentForm = _smartSoundControlContentForm; |
| | | this.mRoom = _room; |
| | | this.UseClickStatu = false; |
| | | this.BackgroundColor = UserCenterColor.Current.White;
|
| | | this.Height = Application.GetRealHeight(170);
|
| | | this.BackgroundColor = UserCenterColor.Current.White; |
| | | this.Height = Application.GetRealHeight(170); |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 初始化控件
|
| | | /// </summary>
|
| | | public void InitControl()
|
| | | /// <summary> |
| | | /// 初始化控件 |
| | | /// </summary> |
| | | public void InitControl() |
| | | { |
| | | //显示文本 |
| | | btnName = this.AddLeftCaption(string.Empty, 2000);
|
| | | btnName.Height = Application.GetRealHeight(60);
|
| | | btnName.TextSize = 17;
|
| | | btnName.Y = Application.GetRealHeight(57);
|
| | | btnName = this.AddLeftCaption(string.Empty, 2000); |
| | | btnName.Height = Application.GetRealHeight(60); |
| | | 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.Gravity = Gravity.CenterVertical; |
| | | Right_icon.X = Right_icon.X - Application.GetRealWidth(60); |
| | | |
| | | btnName.ButtonClickEvent += (sender, e) =>
|
| | | Right_icon = this.AddMostRightEmptyIcon(58, 58); |
| | | Right_icon.Gravity = Gravity.CenterVertical; |
| | | |
| | | btnName.ButtonClickEvent += (sender, e) => |
| | | { |
| | | mRoom.Checked = true; |
| | | RefreshRightIconState(mRoom.Checked); |
| | |
| | | RefreshRightIconState(mRoom.Checked); |
| | | AddBottomLine(); |
| | | |
| | | }
|
| | |
|
| | | } |
| | | |
| | | private void RefreshRightIconState(bool bol = false) |
| | | {
|
| | | { |
| | | try |
| | | { |
| | | 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); |
| | | } |
| | |
| | | { |
| | | string error = e.Message; |
| | | } |
| | | }
|
| | |
|
| | | }
|
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | } |