| | |
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalScrolViewLayout listView = null;
|
| | | private VerticalFrameControl listView = null;
|
| | | /// <summary>
|
| | | /// 成员信息
|
| | | /// </summary>
|
| | |
| | | this.memberShardInfo.SubAccountDistributedMark = this.memberResult.SubAccountDistributedMark;
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uHadSharedContent));
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uShared2));
|
| | |
|
| | | //添加图标
|
| | | var btnAdd = new MostRightIconControl(69, 69);
|
| | |
| | | btnAdd.InitControl();
|
| | |
|
| | | //初始化中部信息
|
| | | //this.InitMiddleFrame();
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化中部信息
|
| | | ///// </summary>
|
| | | //private void InitMiddleFrame()
|
| | | //{
|
| | | // //清空bodyFrame
|
| | | // this.ClearBodyFrame();
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | // //区域列表
|
| | | // var btnTitle = new NormalViewControl(1000, true);
|
| | | // btnTitle.X = ControlCommonResourse.XXLeft;
|
| | | // btnTitle.TextID = R.MyInternationalizationString.uAreaList;
|
| | | // btnTitle.Y = Application.GetRealHeight(30);
|
| | | // bodyFrameLayout.AddChidren(btnTitle);
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //获取成员的共享列表
|
| | | var result = await this.GetMemberShardContentListAndSetToLocation();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //从本地获取成员的分享列表
|
| | | this.GetMemberShardContentListFromLocal();
|
| | | //初始化区域列表
|
| | | this.InitAreaListRow();
|
| | |
|
| | | // this.listView = new VerticalScrolViewLayout();
|
| | | // listView.Y = btnTitle.Bottom + Application.GetRealHeight(30);
|
| | | // listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(30) - btnTitle.Bottom;
|
| | | // bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | // HdlThreadLogic.Current.Run(async () =>
|
| | | // {
|
| | | // //获取成员的共享列表(返回文件的名字和主键)
|
| | | // var result = await this.GetMemberShardContentListAndSetToLocation();
|
| | | // if (result == false)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // //从本地获取成员的分享列表
|
| | | // this.GetMemberShardContentListFromLocal();
|
| | | // //初始化区域列表
|
| | | // this.InitAreaListRow();
|
| | |
|
| | | // });
|
| | | //}
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | //#region ■ 区域列表___________________________
|
| | | #region ■ 区域列表___________________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化区域列表
|
| | | ///// </summary>
|
| | | //private void InitAreaListRow()
|
| | | //{
|
| | | // if (memberShardInfo.dicShardRoom.Count == 0)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (bodyFrameLayout != null)
|
| | | // {
|
| | | // bodyFrameLayout.RemoveAll();
|
| | | // //请配置共享设备
|
| | | // var btnMsg = new MsgViewControl(bodyFrameLayout.Width, false);
|
| | | // btnMsg.Gravity = Gravity.CenterVertical;
|
| | | // btnMsg.TextID = R.MyInternationalizationString.uPleaseConfigureShardDeviceMsg;
|
| | | // bodyFrameLayout.AddChidren(btnMsg);
|
| | | // }
|
| | | // });
|
| | | // return;
|
| | | // }
|
| | | // foreach (var room in memberShardInfo.dicShardRoom.Values)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (bodyFrameLayout != null)
|
| | | // {
|
| | | // this.AddRoomRow(room);
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | | /// <summary>
|
| | | /// 初始化区域列表
|
| | | /// </summary>
|
| | | private void InitAreaListRow()
|
| | | {
|
| | | if (memberShardInfo.dicShardRoom.Count == 0)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //显示没有分享数据模式
|
| | | this.ShowNotShardMode();
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | //合并同一楼层的房间
|
| | | var dicGroup = new Dictionary<string, List<Common.Room>>();
|
| | | foreach (var room in memberShardInfo.dicShardRoom.Values)
|
| | | {
|
| | | if (dicGroup.ContainsKey(room.FloorId) == false)
|
| | | {
|
| | | dicGroup[room.FloorId] = new List<Common.Room>();
|
| | | }
|
| | | dicGroup[room.FloorId].Add(room);
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 添加房间行
|
| | | ///// </summary>
|
| | | ///// <param name="room"></param>
|
| | | //private void AddRoomRow(Common.Room room)
|
| | | //{
|
| | | // var row = new StatuRowLayout(listView);
|
| | | // //房间名
|
| | | // var btnName = new RowCenterView(false);
|
| | | // btnName.Text = room.Name;
|
| | | // row.AddChidren(btnName);
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | bodyFrameLayout.RemoveAll();
|
| | |
|
| | | // var btnDelete = new RowDeleteButton();
|
| | | // row.AddRightView(btnDelete);
|
| | | // btnDelete.MouseUpEventHandler += (sender, e) =>
|
| | | // {
|
| | | // //确定移除该共享区域?
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uDeleteShardAreaMsg);
|
| | | // this.ShowConfirmMsg(msg, "DoDeleteShardContentByRoom", room);
|
| | | // };
|
| | | this.listView = new VerticalFrameControl(29);
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | // row.AddRightArrow();
|
| | | //添加各自楼层的房间列表
|
| | | foreach (var floorId in dicGroup.Keys)
|
| | | {
|
| | | this.AddRoomListRow(floorId, dicGroup[floorId]);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | // row.MouseUpEvent += (sender, e) =>
|
| | | // {
|
| | | // var form = new SearchConfigureSharedMainForm();
|
| | | // form.AddForm(room, memberResult, memberShardInfo);
|
| | | // };
|
| | | //}
|
| | | //#endregion
|
| | | /// <summary>
|
| | | /// 添加房间列表行
|
| | | /// </summary>
|
| | | /// <param name="listRoom"></param>
|
| | | private void AddRoomListRow(string floorId, List<Common.Room> listRoom)
|
| | | {
|
| | | var frameBack = new FrameListControl(29);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.Height = 10;
|
| | | this.listView.AddChidrenFrame(frameBack);
|
| | |
|
| | | //#region ■ 删除共享区域_______________________
|
| | | //楼层
|
| | | if (string.IsNullOrEmpty(floorId) == false)
|
| | | {
|
| | | var btnFloor = new NormalViewControl(800, 60, true);
|
| | | btnFloor.X = ControlCommonResourse.XXLeft;
|
| | | btnFloor.Y = Application.GetRealHeight(52);
|
| | | btnFloor.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnFloor.TextSize = 15;
|
| | | frameBack.AddChidren(btnFloor);
|
| | | if (memberShardInfo.dicShardFloor.ContainsKey(floorId) == true)
|
| | | {
|
| | | btnFloor.Text = memberShardInfo.dicShardFloor[floorId];
|
| | | }
|
| | | else
|
| | | {
|
| | | btnFloor.Text = "UnKnown";
|
| | | }
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 删除共享区域
|
| | | ///// </summary>
|
| | | ///// <param name="room">指定要删除的共享区域</param>
|
| | | //public void DoDeleteShardContentByRoom(Common.Room room)
|
| | | //{
|
| | | // //获取全部设备
|
| | | // var listDevice = new List<CommonDevice>();
|
| | | // foreach (var deviceUi in room.DeviceUIList)
|
| | | // {
|
| | | // var device = deviceUi.CommonDevice;
|
| | | // if (device == null)
|
| | | // {
|
| | | // var byteData = HdlShardLogic.Current.GetShardFileContent(deviceUi.DeviceFileName);
|
| | | // if (byteData == null)
|
| | | // {
|
| | | // continue;
|
| | | // }
|
| | | // device = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | // }
|
| | | // listDevice.Add(device);
|
| | | // }
|
| | | // //获取全部场景
|
| | | // var listScene = new List<Common.SceneUI>();
|
| | | // foreach (var sceneUi in room.SceneUIList)
|
| | | // {
|
| | | // listScene.Add(sceneUi);
|
| | | // }
|
| | | for (int i = 0; i < listRoom.Count; i++)
|
| | | {
|
| | | var room = listRoom[i];
|
| | | var frameRow = new RowLayoutControl(frameBack.rowSpace / 2);
|
| | | frameBack.AddChidren(frameRow);
|
| | | //图标
|
| | | var btnIcon = frameRow.frameTable.AddLeftIcon(81);
|
| | | btnIcon.UnSelectedImagePath = "Item/RoomIcon.png";
|
| | | //名称
|
| | | var btnName = frameRow.frameTable.AddLeftCaption(room.Name, 600);
|
| | | btnName.TextSize = 15;
|
| | | //右箭头
|
| | | frameRow.frameTable.AddRightArrow();
|
| | | if (i != listRoom.Count - 1)
|
| | | {
|
| | | //底线
|
| | | frameRow.frameTable.AddBottomLine();
|
| | | }
|
| | | frameRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | };
|
| | |
|
| | | // HdlThreadLogic.Current.Run(async () =>
|
| | | // {
|
| | | // //执行删除
|
| | | // var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, room, listDevice, listScene);
|
| | | // if (result == true)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // //重新刷新界面
|
| | | // this.InitMiddleFrame();
|
| | | // });
|
| | | // }
|
| | | // });
|
| | | //}
|
| | | //删除
|
| | | var btnDelete = new NormalViewControl(Application.GetRealWidth(184), frameRow.Height, false);
|
| | | btnDelete.BackgroundColor = 0xfff75858;
|
| | | btnDelete.TextSize = 12;
|
| | | btnDelete.TextColor = UserCenterColor.Current.White;
|
| | | btnDelete.TextAlignment = TextAlignment.Center;
|
| | | btnDelete.TextID = R.MyInternationalizationString.uDelete;
|
| | | frameRow.AddRightView(btnDelete);
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //确认删除共享房间?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteShardRoomMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //删除共享区域
|
| | | this.DoDeleteShardContentByRoom(room);
|
| | | });
|
| | | };
|
| | | }
|
| | | //调整子控件Frame高度
|
| | | this.listView.AdjustChidrenFrameHeight(frameBack, Application.GetRealHeight(29));
|
| | | }
|
| | | #endregion
|
| | |
|
| | | //#endregion
|
| | | #region ■ 删除共享区域_______________________
|
| | |
|
| | | //#region ■ 获取成员共享列表___________________
|
| | | /// <summary>
|
| | | /// 删除共享区域
|
| | | /// </summary>
|
| | | /// <param name="room">指定要删除的共享区域</param>
|
| | | public void DoDeleteShardContentByRoom(Common.Room room)
|
| | | {
|
| | | //获取全部设备
|
| | | var listDevice = new List<CommonDevice>();
|
| | | foreach (var deviceUi in room.DeviceUIList)
|
| | | {
|
| | | var device = deviceUi.CommonDevice;
|
| | | if (device == null)
|
| | | {
|
| | | string deviceFile = deviceUi.FileName.Replace("DeviceUI_", string.Empty);
|
| | | var byteData = HdlShardLogic.Current.GetShardFileContent(deviceFile);
|
| | | if (byteData == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | device = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | }
|
| | | listDevice.Add(device);
|
| | | }
|
| | | //获取全部场景
|
| | | var listScene = new List<Common.SceneUI>();
|
| | | foreach (var sceneUi in room.SceneUIList)
|
| | | {
|
| | | listScene.Add(sceneUi);
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 获取成员共享列表然后保存到本地
|
| | | ///// </summary>
|
| | | ///// <returns></returns>
|
| | | //private async Task<bool> GetMemberShardContentListAndSetToLocation()
|
| | | //{
|
| | | // if (this.memberShardInfo.Refresh == false)
|
| | | // {
|
| | | // return true;
|
| | | // }
|
| | | // this.memberShardInfo.Refresh = false;
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //执行删除
|
| | | var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, room, listDevice, listScene);
|
| | | if (result == true)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //重新刷新界面
|
| | | this.InitMiddleFrame();
|
| | | });
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | // //开启进度条
|
| | | // this.ShowProgressBar();
|
| | | #endregion
|
| | |
|
| | | // var infoPra = new
|
| | | // {
|
| | | // DistributedMark = memberResult.SubAccountDistributedMark,
|
| | | // HouseDistributedMark = Shared.Common.Config.Instance.HomeId,
|
| | | // IsOtherAccountControl = Common.Config.Instance.isAdministrator
|
| | | // };
|
| | | // var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra);
|
| | | // if (result == null)
|
| | | // {
|
| | | // //关闭进度条
|
| | | // this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | // return false;
|
| | | // }
|
| | | // var listData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ReceiveShardInfoResult>>(result);
|
| | | // //先清空共享文件夹
|
| | | // HdlShardLogic.Current.ClearShardDirectory();
|
| | | #region ■ 获取成员共享列表___________________
|
| | |
|
| | | // var listMark = new List<string>();
|
| | | // foreach (var data in listData)
|
| | | // {
|
| | | // //性能优化:如果本地拥有这个文件的话,直接使用那个文件
|
| | | // string fileName = data.ShareName;
|
| | | // //记录起它的主键
|
| | | // memberShardInfo.dicAllShardKeys[fileName] = data.DistributedMark;
|
| | | /// <summary>
|
| | | /// 获取成员共享列表然后保存到本地
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async Task<bool> GetMemberShardContentListAndSetToLocation()
|
| | | {
|
| | | if (this.memberShardInfo.Refresh == false)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | this.memberShardInfo.Refresh = false;
|
| | |
|
| | | // if (fileName.StartsWith("Room_") == true || fileName.StartsWith("Scene_") == true)
|
| | | // {
|
| | | // //房间文件和场景文件需要重新反序列化
|
| | | // listMark.Add(data.DistributedMark);
|
| | | // continue;
|
| | | // }
|
| | | // if (Shared.Common.Global.IsExistsByHomeId(fileName) == true)
|
| | | // {
|
| | | // //其他文件的话,如果本地存在,则以本地文件为准
|
| | | // HdlShardLogic.Current.AddShardFile(fileName);
|
| | | // continue;
|
| | | // }
|
| | | // listMark.Add(data.DistributedMark);
|
| | | // }
|
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | // //将分享的数据存入本地,返回的是文件名字(异常时返回null)
|
| | | // var listFile = await HdlShardLogic.Current.SetShardFileToLocation(listMark);
|
| | | // if (listFile == null)
|
| | | // {
|
| | | // //关闭进度条
|
| | | // this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | // return false;
|
| | | // }
|
| | | // //关闭进度条
|
| | | // this.CloseProgressBar();
|
| | | var infoPra = new
|
| | | {
|
| | | DistributedMark = memberResult.SubAccountDistributedMark,
|
| | | HouseDistributedMark = Shared.Common.Config.Instance.HomeId,
|
| | | IsOtherAccountControl = Common.Config.Instance.isAdministrator
|
| | | };
|
| | | var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra);
|
| | | if (result == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | var listData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ReceiveShardInfoResult>>(result);
|
| | | //先清空共享文件夹
|
| | | HdlShardLogic.Current.ClearShardDirectory();
|
| | |
|
| | | // return true;
|
| | | //}
|
| | | var listMark = new List<string>();
|
| | | foreach (var data in listData)
|
| | | {
|
| | | //性能优化:如果本地拥有这个文件的话,直接使用那个文件
|
| | | string fileName = data.ShareName;
|
| | | //记录起它的主键
|
| | | memberShardInfo.dicAllShardKeys[fileName] = data.DistributedMark;
|
| | |
|
| | | ///// <summary>
|
| | | ///// 从本地获取成员的分享列表
|
| | | ///// </summary>
|
| | | //private void GetMemberShardContentListFromLocal()
|
| | | //{
|
| | | // memberShardInfo.dicShardRoom = new Dictionary<string, Common.Room>();
|
| | | if (fileName.StartsWith("Room_") == true || fileName.StartsWith("Scene_") == true)
|
| | | {
|
| | | //房间文件和场景文件需要重新反序列化
|
| | | listMark.Add(data.DistributedMark);
|
| | | continue;
|
| | | }
|
| | | if (Shared.Common.Global.IsExistsByHomeId(fileName) == true)
|
| | | {
|
| | | //其他文件的话,如果本地存在,则以本地文件为准
|
| | | HdlShardLogic.Current.AddShardFile(fileName);
|
| | | continue;
|
| | | }
|
| | | listMark.Add(data.DistributedMark);
|
| | | }
|
| | |
|
| | | // var listFile = HdlShardLogic.Current.GetLocalAllShardFile();
|
| | | // foreach (string fileName in listFile)
|
| | | // {
|
| | | // if (fileName.StartsWith("Room_") == true)
|
| | | // {
|
| | | // var byteData = HdlShardLogic.Current.GetShardFileContent(fileName);
|
| | | // if (byteData == null)
|
| | | // {
|
| | | // continue;
|
| | | // }
|
| | | // string valueData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | // var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.Room>(valueData);
|
| | | // memberShardInfo.dicShardRoom[fileName] = roomTemp;
|
| | | //将分享的数据存入本地,返回的是文件名字(异常时返回null)
|
| | | var listFile = await HdlShardLogic.Current.SetShardFileToLocation(listMark);
|
| | | if (listFile == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return false;
|
| | | }
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | | // if (memberShardInfo.dicAllMemberShard.ContainsKey(fileName) == false)
|
| | | // {
|
| | | // //先初始化房间
|
| | | // memberShardInfo.dicAllMemberShard[fileName] = new HashSet<string>();
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | // //设置房间里面设备的UI对象(因为这个东西是反序列化出来的,设备UI对象是不序列化对象)
|
| | | // this.InitRoomAttributeData();
|
| | | //}
|
| | | return true;
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 初始化房间的属性对象全部的本地文件
|
| | | ///// </summary>
|
| | | //private void InitRoomAttributeData()
|
| | | //{
|
| | | // //设置房间里面设备的UI对象(因为这个东西是反序列化出来的,设备UI对象是不序列化对象)
|
| | | // foreach (var tempRoom in memberShardInfo.dicShardRoom.Values)
|
| | | // {
|
| | | // var listShard = memberShardInfo.dicAllMemberShard[tempRoom.FileName];
|
| | | // listShard.Clear();
|
| | | // //添加房间
|
| | | // listShard.Add(tempRoom.FileName);
|
| | | /// <summary>
|
| | | /// 从本地获取成员的分享列表
|
| | | /// </summary>
|
| | | private void GetMemberShardContentListFromLocal()
|
| | | {
|
| | | memberShardInfo.dicShardRoom = new Dictionary<string, Common.Room>();
|
| | |
|
| | | // //还原UI设备对象
|
| | | // tempRoom.DeviceUIList.Clear();
|
| | | // foreach (string uiPath in tempRoom.DeviceUIFilePathList)
|
| | | // {
|
| | | // var byteData = HdlShardLogic.Current.GetShardFileContent(uiPath);
|
| | | // if (byteData == null)
|
| | | // {
|
| | | // continue;
|
| | | // }
|
| | | // string valueData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | // var tempUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.DeviceUI>(valueData);
|
| | | // tempRoom.DeviceUIList.Add(tempUi);
|
| | | var listFile = HdlShardLogic.Current.GetLocalAllShardFile();
|
| | | //设备文件(分享的,而不是本地的)
|
| | | var dicDeviceFile = new Dictionary<string, string>();
|
| | | //先初始化房间
|
| | | foreach (string fileName in listFile)
|
| | | {
|
| | | if (fileName.StartsWith("Room_") == true)
|
| | | {
|
| | | var byteData = HdlShardLogic.Current.GetShardFileContent(fileName);
|
| | | if (byteData == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | string valueData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.Room>(valueData);
|
| | | memberShardInfo.dicShardRoom[fileName] = roomTemp;
|
| | |
|
| | | // //设备UI
|
| | | // listShard.Add(tempUi.FileName);
|
| | | // //设备
|
| | | // listShard.Add(tempUi.DeviceFileName);
|
| | | // }
|
| | | // //还原场景对象
|
| | | // tempRoom.SceneUIList.Clear();
|
| | | // foreach (string uiPath in tempRoom.SceneUIFilePathList)
|
| | | // {
|
| | | // var byteData = HdlShardLogic.Current.GetShardFileContent(uiPath);
|
| | | // if (byteData == null)
|
| | | // {
|
| | | // continue;
|
| | | // }
|
| | | // string valueData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | // var tempUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData);
|
| | | // tempRoom.SceneUIList.Add(tempUi);
|
| | | if (memberShardInfo.dicAllMemberShard.ContainsKey(fileName) == false)
|
| | | {
|
| | | memberShardInfo.dicAllMemberShard[fileName] = new HashSet<string>();
|
| | | }
|
| | | }
|
| | | else if (fileName.StartsWith("Device_") == true)
|
| | | {
|
| | | //设备文件
|
| | | string[] MyArry = fileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (MyArry.Length == 4)
|
| | | {
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(MyArry[2], Convert.ToInt32(MyArry[3]));
|
| | | dicDeviceFile[mainKeys] = fileName;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // //场景的主键
|
| | | // listShard.Add(tempUi.FileName);
|
| | | // //从场景对象里面获取全部的绑定目标的文件名字
|
| | | // this.GetSceneBindFileName(tempUi, ref listShard);
|
| | | // }
|
| | | // }
|
| | | //}
|
| | | //设置房间里面设备的UI对象(因为这个东西是反序列化出来的,设备UI对象是不序列化对象)
|
| | | foreach (var tempRoom in memberShardInfo.dicShardRoom.Values)
|
| | | {
|
| | | var listShard = memberShardInfo.dicAllMemberShard[tempRoom.FileName];
|
| | | listShard.Clear();
|
| | | //添加房间
|
| | | listShard.Add(tempRoom.FileName);
|
| | |
|
| | | //#endregion
|
| | | //还原设备对象
|
| | | tempRoom.DeviceUIList.Clear();
|
| | | foreach (string uiPath in tempRoom.DeviceUIFilePathList)
|
| | | {
|
| | | string deviceFile = uiPath.Replace("DeviceUI_", string.Empty);
|
| | | if (HdlShardLogic.Current.IsFileExists(deviceFile) == false)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | tempRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(uiPath));
|
| | | //设备
|
| | | listShard.Add(deviceFile);
|
| | | }
|
| | | //还原场景对象
|
| | | tempRoom.SceneUIList.Clear();
|
| | | foreach (string uiPath in tempRoom.SceneUIFilePathList)
|
| | | {
|
| | | var byteData = HdlShardLogic.Current.GetShardFileContent(uiPath);
|
| | | if (byteData == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | string valueData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | | var tempUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData);
|
| | | tempRoom.SceneUIList.Add(tempUi);
|
| | |
|
| | | //#region ■ 界面重新激活事件___________________
|
| | | //场景的主键
|
| | | listShard.Add(tempUi.FileName);
|
| | | //从场景对象里面获取全部的绑定目标的文件名字
|
| | | this.GetSceneBindFileName(tempUi, dicDeviceFile, ref listShard);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | ///// <summary>
|
| | | ///// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
|
| | | ///// </summary>
|
| | | //public override void FormActionAgainEvent()
|
| | | //{
|
| | | // //不要删除这个函数
|
| | | // base.FormActionAgainEvent();
|
| | | // //重新刷新界面
|
| | | // this.InitMiddleFrame();
|
| | | //}
|
| | | /// <summary>
|
| | | /// 从场景对象里面获取全部的绑定目标的文件名字
|
| | | /// </summary>
|
| | | /// <param name="scene">场景</param>
|
| | | /// <param name="dicDeviceFile">分享的设备文件</param>
|
| | | /// <param name="listFile">文件列表(里面存的是设备UI文件和设备文件和场景文件)</param>
|
| | | private void GetSceneBindFileName(Common.SceneUI scene, Dictionary<string, string> dicDeviceFile, ref HashSet<string> listFile)
|
| | | {
|
| | | foreach (var data in scene.AddSceneMemberDataList)
|
| | | {
|
| | | //设备
|
| | | if (data.Type == 0)
|
| | | {
|
| | | var mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
|
| | | if (dicDeviceFile.ContainsKey(mainKeys) == true && listFile.Contains(dicDeviceFile[mainKeys]) == false)
|
| | | {
|
| | | listFile.Add(dicDeviceFile[mainKeys]);
|
| | | }
|
| | | }
|
| | | if (data.Type == 1)
|
| | | {
|
| | | var sceneTemp = new Common.SceneUI();
|
| | | sceneTemp.Id = data.ElseScenesId;
|
| | | if (listFile.Contains(sceneTemp.FileName))
|
| | | {
|
| | | listFile.Add(sceneTemp.FileName);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | //#endregion
|
| | | #endregion
|
| | |
|
| | | //#region ■ 一般方法___________________________
|
| | | #region ■ 界面重新激活事件___________________
|
| | |
|
| | | ///// <summary>
|
| | | ///// 从场景对象里面获取全部的绑定目标的文件名字
|
| | | ///// </summary>
|
| | | ///// <param name="scene">场景</param>
|
| | | ///// <param name="listFile">文件列表(里面存的是设备UI文件和设备文件和场景文件)</param>
|
| | | //private void GetSceneBindFileName(Common.SceneUI scene, ref HashSet<string> listFile)
|
| | | //{
|
| | | // foreach (var data in scene.AddSceneMemberDataList)
|
| | | // {
|
| | | // //设备
|
| | | // if (data.Type == 0)
|
| | | // {
|
| | | // var device = Common.LocalDevice.Current.GetDevice(data.DeviceAddr, data.Epoint);
|
| | | // if (device != null)
|
| | | // {
|
| | | // string uiName = "DeviceUI_" + device.FilePath;
|
| | | // if (listFile.Contains(uiName) == false)
|
| | | // {
|
| | | // listFile.Add(uiName);
|
| | | // listFile.Add(device.FilePath);
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | // if (data.Type == 1)
|
| | | // {
|
| | | // var sceneTemp = Common.Room.CurrentRoom.GetSceneUIBySceneId(data.ElseScenesId);
|
| | | // if (sceneTemp != null && listFile.Contains(sceneTemp.FileName))
|
| | | // {
|
| | | // listFile.Add(sceneTemp.FileName);
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | //}
|
| | | //#endregion
|
| | | /// <summary>
|
| | | /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
|
| | | /// </summary>
|
| | | public override int FormActionAgainEvent()
|
| | | {
|
| | | //重新刷新界面
|
| | | this.InitMiddleFrame();
|
| | | return 1;
|
| | | }
|
| | |
|
| | | //#region ■ 结构体_____________________________
|
| | | #endregion
|
| | |
|
| | | ///// <summary>
|
| | | ///// 接收分享数据
|
| | | ///// </summary>
|
| | | //private class ReceiveShardInfoResult
|
| | | //{
|
| | | // /// <summary>
|
| | | // /// 文件名字
|
| | | // /// </summary>
|
| | | // public string ShareName = string.Empty;
|
| | | // /// <summary>
|
| | | // /// 主键
|
| | | // /// </summary>
|
| | | // public string DistributedMark = string.Empty;
|
| | | //}
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | //#endregion
|
| | | /// <summary>
|
| | | /// 显示没有分享数据模式
|
| | | /// </summary>
|
| | | private void ShowNotShardMode()
|
| | | {
|
| | | bodyFrameLayout.RemoveAll();
|
| | | //图片
|
| | | var btnPic = new PicViewControl(383, 279);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | btnPic.Y = Application.GetRealHeight(498);
|
| | | btnPic.UnSelectedImagePath = "Item/NotShardPic.png";
|
| | | bodyFrameLayout.AddChidren(btnPic);
|
| | |
|
| | | //还没有共享区域给成员{0}可点击右上角“+”添加
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uNotShardComtentMsg);
|
| | | string[] Arry = msg.Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | var btnMsg1 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false);
|
| | | btnMsg1.Y = Application.GetRealHeight(962);
|
| | | btnMsg1.TextAlignment = TextAlignment.Center;
|
| | | btnMsg1.TextSize = 12;
|
| | | btnMsg1.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnMsg1.Text = Arry[0];
|
| | | bodyFrameLayout.AddChidren(btnMsg1);
|
| | | if (Arry.Length > 1)
|
| | | {
|
| | | var btnMsg2 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false);
|
| | | btnMsg2.Y = btnMsg1.Bottom;
|
| | | btnMsg2.TextAlignment = TextAlignment.Center;
|
| | | btnMsg2.TextSize = 12;
|
| | | btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnMsg2.Text = Arry[1];
|
| | | bodyFrameLayout.AddChidren(btnMsg2);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 结构体_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 接收分享数据
|
| | | /// </summary>
|
| | | private class ReceiveShardInfoResult
|
| | | {
|
| | | /// <summary>
|
| | | /// 文件名字
|
| | | /// </summary>
|
| | | public string ShareName = string.Empty;
|
| | | /// <summary>
|
| | | /// 主键
|
| | | /// </summary>
|
| | | public string DistributedMark = string.Empty;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|