From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期五, 10 七月 2020 10:52:13 +0800 Subject: [PATCH] 2020-07-10-01 --- ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs | 681 ++++++++++++++++++++++++++++++++------------------------ 1 files changed, 385 insertions(+), 296 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs index fe50a89..bb545c2 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedContentForm.cs @@ -1,7 +1,6 @@ 锘縰sing System; using System.Collections.Generic; using System.Text; -using System.Threading.Tasks; using ZigBee.Device; namespace Shared.Phone.UserCenter.SharedContent @@ -14,29 +13,42 @@ #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> - /// 璁惧鍒楄〃鎺т欢 + /// 鏌ョ湅鐨勬埧闂村璞� /// </summary> - private VerticalScrolViewLayout listDeviceView = null; - /// <summary> - /// 鍦烘櫙鍒楄〃鎺т欢 - /// </summary> - private VerticalScrolViewLayout listSceneView = null; - /// <summary> - /// 鎴愬憳淇℃伅 - /// </summary> - private MemberInfoRes memberResult = null; + private Common.Room lookRoom = null; /// <summary> /// 鎴愬憳鐨勫垎浜暟鎹� /// </summary> private MemberShardInfoData memberShardInfo = null; /// <summary> - /// 鎴块棿瀵硅薄 + /// 璁惧妗屽竷鎺т欢 /// </summary> - private Common.Room room = null; + private FrameLayout frameDeviceTable = null; /// <summary> - /// Tab鐨勯�夋嫨銆�1锛氬姛鑳絋ab 2锛氬満鏅疶ab + /// 璁惧妗屽竷鎺т欢 /// </summary> - private int TabSelectIndex = 1; + private FrameLayout frameSceneTable = null; + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + private BottomClickButton btnDelete = null; + /// <summary> + /// 閫夋嫨鐨勫満鏅� + /// </summary> + private Dictionary<int, Common.SceneUI> dicSelectScene = new Dictionary<int, Common.SceneUI>(); + /// <summary> + /// 閫夋嫨鐨勮澶� + /// </summary> + private Dictionary<string, CommonDevice> dicSelectDevice = new Dictionary<string, CommonDevice>(); + /// <summary> + /// 褰撳墠閫夋嫨鐨勫垎鏀� 0锛氬満鏅� 1锛氬姛鑳� + /// </summary> + private int nowSwitchIndex = 0; + /// <summary> + /// 褰撳墠閫夋嫨鐨勮澶囩储寮� + /// </summary> + private string nowDeviceIndex = string.Empty; + #endregion #region 鈻� 鍒濆鍖朹____________________________ @@ -44,332 +56,409 @@ /// <summary> /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) /// </summary> - /// <param name="i_room">鎴块棿淇℃伅</param> - /// <param name="i_memberResult">鎴愬憳淇℃伅</param> + /// <param name="i_room">鏌ョ湅鐨勬埧闂村璞�</param> /// <param name="i_memberShardInfo">鎴愬憳鐨勫垎浜暟鎹�</param> - public void ShowForm(Common.Room i_room, MemberInfoRes i_memberResult, MemberShardInfoData i_memberShardInfo) + public void ShowForm(Common.Room i_room, MemberShardInfoData i_memberShardInfo) { - this.memberResult = i_memberResult; - this.room = i_room; + this.lookRoom = i_room; this.memberShardInfo = i_memberShardInfo; //璁剧疆澶撮儴淇℃伅 base.SetTitleText(i_room.Name); //鍒濆鍖栦腑閮ㄤ俊鎭� - //this.InitMiddleFrame(); + this.InitMiddleFrame(); } - ///// <summary> - ///// 鍒濆鍖栦腑閮ㄤ俊鎭� - ///// </summary> - //private void InitMiddleFrame() - //{ - // //娓呯┖bodyFrame - // this.ClearBodyFrame(); + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + this.dicSelectDevice = new Dictionary<string, CommonDevice>(); + this.dicSelectScene = new Dictionary<int, Common.SceneUI>(); - // //鍒濆鍖朤ab鎺т欢 - // var frame = this.InitTabControl(); + //鍒濆鍖栨甯冩帶浠� + this.frameSceneTable = new FrameLayout(); + frameSceneTable.Y = Application.GetRealHeight(132); + frameSceneTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(132); + bodyFrameLayout.AddChidren(frameSceneTable); - // this.listDeviceView = new VerticalScrolViewLayout(); - // listDeviceView.Y = frame.Bottom; - // listDeviceView.Height = bodyFrameLayout.Height - frame.Bottom; - // listDeviceView.Visible = this.TabSelectIndex == 1; - // bodyFrameLayout.AddChidren(listDeviceView); + this.frameDeviceTable = new FrameLayout(); + frameDeviceTable.Y = frameSceneTable.Y; + frameDeviceTable.Height = frameSceneTable.Height; + bodyFrameLayout.AddChidren(frameDeviceTable); + frameDeviceTable.Visible = false; - // this.listSceneView = new VerticalScrolViewLayout(); - // listSceneView.Y = frame.Bottom; - // listSceneView.Height = bodyFrameLayout.Height - frame.Bottom; - // listSceneView.Visible = this.TabSelectIndex == 2; - // bodyFrameLayout.AddChidren(listSceneView); + //鍒濆鍖栧垎鏀帶浠� + this.InitSwitchControl(); - // HdlThreadLogic.Current.Run(() => - // { - // //鍒濆鍖栧姛鑳絋ab鍒楄〃 - // this.InitFunctionTabList(); - // //鍒濆鍖栧満鏅疶ab鍒楄〃 - // this.InitSceneTabList(); - // }); - //} + //鍒犻櫎鎸夐挳 + this.btnDelete = new BottomClickButton(); + btnDelete.BackgroundColor = 0xfff75858; + btnDelete.TextID = R.MyInternationalizationString.uDelete; + bodyFrameLayout.AddChidren(btnDelete); + btnDelete.Visible = false; + btnDelete.ButtonClickEvent += (sender, e) => + { + //鍒犻櫎鍒嗕韩 + this.DeleteShardData(); + }; + + //鍒濆鍖栧満鏅垪琛� + this.InitSceneList(); + //鍒濆鍔熻兘鍒楄〃 + this.InitFunctionList(); + } + + /// <summary> + /// 鍒濆鍖栧垎鏀帶浠� + /// </summary> + private void InitSwitchControl() + { + var tabControl = new SceneFunctionSwitchControl(); + tabControl.Y = Application.GetRealHeight(40); + bodyFrameLayout.AddChidren(tabControl); + //璁剧疆鍒濆鍖栧�� + tabControl.SetDefultIndex(nowSwitchIndex); + tabControl.SelectTabEvent += (tabIndex) => + { + this.nowSwitchIndex = tabIndex; + if (tabIndex == 0) + { + //鏄剧ず鍦烘櫙鍒楄〃 + this.frameSceneTable.Visible = true; + this.frameDeviceTable.Visible = false; + } + else + { + //鏄剧ず鍔熻兘鍒楄〃 + this.frameSceneTable.Visible = false; + this.frameDeviceTable.Visible = true; + } + }; + //寮�濮嬪垵濮嬪寲鍦烘櫙鍔熻兘鍒囨崲鎺т欢 + var listTitle = new List<string>(); + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence)); + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction)); + tabControl.InitControl(listTitle); + } #endregion - //#region 鈻� 鍒濆鍖朤ab鎺т欢______________________ + #region 鈻� 鍦烘櫙鏄剧ず___________________________ - ///// <summary> - ///// 鍒濆鍖朤ab鎺т欢 - ///// </summary> - ///// <returns></returns> - //private FrameLayout InitTabControl() - //{ - // //Tab鍒囨崲鎺т欢 - // var frameSwich = new FrameLayout(); - // frameSwich.Height = Application.GetRealHeight(150); - // frameSwich.BackgroundColor = UserCenterColor.Current.TopFrameLayout; - // bodyFrameLayout.AddChidren(frameSwich); + /// <summary> + /// 鍒濆鍖栧満鏅垪琛� + /// </summary> + private void InitSceneList() + { + //娓呯┖妗屽竷 + this.frameSceneTable.RemoveAll(); - // //鍔熻兘 - // var btnFunction = new NormalViewControl(frameSwich.Width / 2, Application.GetRealHeight(100)); - // btnFunction.Gravity = Gravity.CenterVertical; - // btnFunction.TextID = R.MyInternationalizationString.uFunction; - // btnFunction.TextAlignment = TextAlignment.Center; - // btnFunction.TextColor = UserCenterColor.Current.SelectTextColor; - // btnFunction.TextAlignment = TextAlignment.Center; - // frameSwich.AddChidren(btnFunction); + var listScene = new List<Common.SceneUI>(); + for (int i = 0; i < lookRoom.ListSceneId.Count; i++) + { + var byteData = HdlShardLogic.Current.GetShardFileContent($"Scene_{lookRoom.ListSceneId[i]}.json"); + if (byteData == null) + { + continue; + } + var sceneUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(System.Text.Encoding.UTF8.GetString(byteData)); + listScene.Add(sceneUi); + } + if (listScene.Count == 0) + { + //鏃犲彲鍙栨秷鍏变韩鐨勫満鏅� + this.ShowNotDataImage(frameSceneTable, Language.StringByID(R.MyInternationalizationString.uNotCanCancelShardSceneMsg), "Item/NotShardPic.png", 383, 279); + return; + } - // //鍦烘櫙 - // var btnScene = new NormalViewControl(frameSwich.Width / 2, Application.GetRealHeight(100)); - // btnScene.Gravity = Gravity.CenterVertical; - // btnScene.X = frameSwich.Width / 2; - // btnScene.TextID = R.MyInternationalizationString.uScence; - // btnScene.TextAlignment = TextAlignment.Center; - // frameSwich.AddChidren(btnScene); + HdlThreadLogic.Current.RunMainInThread(() => + { + var listView = new VerticalFrameControl(3); + listView.Y = Application.GetRealHeight(53); + listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187); + frameSceneTable.AddChidren(listView); - // //绾� - // var btnLine = new ProgressLine(); - // btnLine.Gravity = Gravity.BottomLeft; - // frameSwich.AddChidren(btnLine); - // btnLine.SetValue(50, true); + foreach (var data in listScene) + { + //鍦烘櫙鎺т欢 + var frameContr = new ScenePictrueControl(); + listView.AddChidren(frameContr); + frameContr.InitControl(data); - // if (this.TabSelectIndex == 2) - // { - // btnScene.TextColor = UserCenterColor.Current.SelectTextColor; - // btnFunction.TextColor = Common.ZigbeeColor.Current.TextColor; - // btnLine.SetValue(50, false); - // } + var btnSelect = new IconViewControl(58); + btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png"; + btnSelect.SelectedImagePath = "Item/ItemSelected.png"; + btnSelect.X = Application.GetRealWidth(887); + btnSelect.Y = Application.GetRealHeight(35); + frameContr.AddChidren(btnSelect, ChidrenBindMode.BindEvent); + if (dicSelectScene.ContainsKey(data.Id) == true) + { + btnSelect.IsSelected = true; + } + frameContr.ButtonClickEvent += (sender, e) => + { + //閫夋嫨 + btnSelect.IsSelected = !btnSelect.IsSelected; + if (btnSelect.IsSelected == true) + { + dicSelectScene[data.Id] = data; + if (this.btnDelete.Visible == false) + { + this.btnDelete.Visible = true; + } + } + else + { + dicSelectScene.Remove(data.Id); + if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0) + { + this.btnDelete.Visible = false; + } + } + }; + } + //璋冩暣涓�涓嬮珮搴� + listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(185)); + }); + } - // //鍔熻兘Tab - // btnFunction.MouseUpEventHandler += (sender, e) => - // { - // if (this.TabSelectIndex == 1) - // { - // return; - // } - // btnScene.TextColor = Common.ZigbeeColor.Current.TextColor; - // btnFunction.TextColor = UserCenterColor.Current.SelectTextColor; - // btnLine.SetValue(50); - // this.TabSelectIndex = 1; + #endregion - // //闅愯棌鍦烘櫙鍒楄〃鎺т欢,鏄剧ず璁惧鍒楄〃鎺т欢 - // this.listSceneView.Visible = false; - // this.listDeviceView.Visible = true; - // }; + #region 鈻� 鍔熻兘鏄剧ず___________________________ - // //鍦烘櫙Tab - // btnScene.MouseUpEventHandler += (sender, e) => - // { - // if (this.TabSelectIndex == 2) - // { - // return; - // } - // btnScene.TextColor = UserCenterColor.Current.SelectTextColor; - // btnFunction.TextColor = Common.ZigbeeColor.Current.TextColor; - // btnLine.SetValue(50, false); - // this.TabSelectIndex = 2; + /// <summary> + /// 鍒濆鍖栧姛鑳藉垪琛� + /// </summary> + private void InitFunctionList() + { + //娓呯┖妗屽竷 + this.frameDeviceTable.RemoveAll(); - // //闅愯棌璁惧鍒楄〃鎺т欢,鏄剧ず鍦烘櫙鍒楄〃鎺т欢 - // this.listDeviceView.Visible = false; - // this.listSceneView.Visible = true; - // }; + HdlThreadLogic.Current.RunMainInThread(() => + { + //鑾峰彇鍒嗙粍鍚庣殑璁惧鍒楄〃 + var dicGroupDevice = this.GetAllGroupDevice(); + if (dicGroupDevice.Count == 0) + { + //鏃犲彲鍙栨秷鍏变韩鐨勮澶� + this.ShowNotDataImage(frameDeviceTable, Language.StringByID(R.MyInternationalizationString.uNotCanCancelDeviceMsg), "Item/NotShardPic.png", 383, 279); + } + else + { + var frameBack = new FrameLayout(); + frameBack.X = ControlCommonResourse.XXLeft; + frameBack.Y = Application.GetRealHeight(178); + frameBack.BackgroundColor = UserCenterColor.Current.White; + frameBack.Width = bodyFrameLayout.Width; + frameBack.Height = Application.GetRealHeight(1650); + frameBack.Radius = (uint)Application.GetRealHeight(58); + frameDeviceTable.AddChidren(frameBack); - // return frameSwich; - //} + var listView = new VerticalListControl(23); + listView.Y = Application.GetRealHeight(23); + listView.Height = Application.GetRealHeight(1437 - 23); + frameBack.AddChidren(listView); + //鍒濆鍖栬澶囩被鍨嬭 + this.InitDeviceObjectRow(dicGroupDevice, listView); + } + }); + } - //#endregion + #endregion - //#region 鈻� 鏄剧ず鍔熻兘Tab鍒楄〃____________________ + #region 鈻� 鍒濆鍖栬澶囩被鍨嬭___________________ - ///// <summary> - ///// 鍒濆鍖栧姛鑳絋ab鍒楄〃 - ///// </summary> - //private void InitFunctionTabList() - //{ - // //鑾峰彇鍒嗕韩鐨勮澶� - // var listDevice = this.GetShardListDevice(); + /// <summary> + /// 鍒濆鍖栬澶囩被鍨嬭 + /// </summary> + /// <param name="dicData"></param> + /// <param name="listView"></param> + private void InitDeviceObjectRow(Dictionary<int, List<CommonDevice>> dicData, VerticalListControl listView) + { + var scrolContr = new RoomDeviceGroupMenuControl(dicData); + this.frameDeviceTable.AddChidren(scrolContr); + //璁剧疆鍒濆鍊� + scrolContr.SetDefultIndex(nowDeviceIndex); + scrolContr.SelectDeviceEvent += (listdevice) => + { + this.nowDeviceIndex = scrolContr.nowSelectKeys; + //娣诲姞璁惧琛� + this.AddDeviceRow(listdevice, listView); + }; + scrolContr.InitControl(); + } - // foreach (var device in listDevice) - // { - // Application.RunOnMainThread(() => - // { - // if (this.Parent != null) - // { - // //娣诲姞璁惧鐨勬槑缁嗚 - // this.AddDeviceDetailRow(device); - // } - // }); - // } - //} + #endregion - ///// <summary> - ///// 娣诲姞璁惧鐨勬槑缁嗚 - ///// </summary> - ///// <param name="device">璁惧瀵硅薄</param> - //private void AddDeviceDetailRow(CommonDevice device) - //{ - // var row = new StatuRowLayout(listDeviceView); + #region 鈻� 娣诲姞璁惧琛宊________________________ - // //鍥剧墖 - // var btnIcon = new RowLeftIconView(); - // Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device); - // row.AddChidren(btnIcon, ChidrenBindMode.NotBind); + /// <summary> + /// 娣诲姞璁惧琛� + /// </summary> + /// <param name="listDevice"></param> + /// <param name="listView"></param> + private void AddDeviceRow(List<CommonDevice> listDevice, VerticalListControl listView) + { + listView.RemoveAll(); + //杩樺師楂樺害 + listView.RecoverHeight(); - // //璁惧绫诲瀷鐨勭炕璇戝悕瀛� - // var btnName = new RowCenterView(); - // btnName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device); - // row.AddChidren(btnName, ChidrenBindMode.NotBind); + foreach (var device in listDevice) + { + var frameRow = new FrameRowControl(listView.rowSpace / 2); + frameRow.LeftOffset = Application.GetRealWidth(46) - ControlCommonResourse.XXLeft; + frameRow.RightOffset = -ControlCommonResourse.XXLeft; + listView.AddChidren(frameRow); + //鍥炬爣 + var btnIcon = frameRow.AddLeftIcon(81); + Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device); + //鍚嶇О + var btnView = frameRow.AddLeftCaption(string.Empty, 600); + btnView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device); + btnView.TextSize = 15; + //搴曠嚎 + frameRow.AddBottomLine(); + //閫夋嫨 + var btnSelect = frameRow.AddMostRightEmptyIcon(69, 69); + btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png"; + btnSelect.SelectedImagePath = "Item/ItemSelected.png"; - // //绉婚櫎 - // var btnDelete = new RowDeleteButton(); - // btnDelete.TextID = R.MyInternationalizationString.RemoveBotton; - // row.AddRightView(btnDelete); - // btnDelete.MouseUpEventHandler += (sender, e) => - // { - // //纭畾绉婚櫎閫変腑鐨勮澶囷紵 - // string msg = Language.StringByID(R.MyInternationalizationString.uConfirmRemoveSelectDeviceMsg); - // this.ShowConfirmMsg(msg, "DeleteShardDevice", row, device); - // }; - //} + string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); + if (dicSelectDevice.ContainsKey(mainKeys) == true) + { + btnSelect.IsSelected = true; + } + frameRow.ButtonClickEvent += (sender, e) => + { + //閫夋嫨 + btnSelect.IsSelected = !btnSelect.IsSelected; + if (btnSelect.IsSelected == true) + { + dicSelectDevice[mainKeys] = device; + if (this.btnDelete.Visible == false) + { + this.btnDelete.Visible = true; + } + } + else + { + dicSelectDevice.Remove(mainKeys); + if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0) + { + this.btnDelete.Visible = false; + } + } + }; + } + //鍒楄〃鑷繁鏈変釜23鐨刌杞村潗鏍� + listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23), Application.GetRealHeight(300 - 23)); + } - ///// <summary> - ///// 鍒犻櫎鍏变韩璁惧 - ///// </summary> - ///// <param name="row"></param> - ///// <param name="device"></param> - //public async void DeleteShardDevice(StatuRowLayout row, CommonDevice device) - //{ - // var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, this.room, new List<CommonDevice>() { device }, new List<Common.SceneUI>()); - // if (result == true) - // { - // Application.RunOnMainThread(() => - // { - // row?.RemoveFromParent(); - // if (this.listDeviceView != null && this.listDeviceView.ChildrenCount == 0 && this.listSceneView.ChildrenCount == 0) - // { - // //浠�涔堥兘娌℃湁浜�,鍒欏叧闂晫闈� - // this.CloseForm(); - // } - // }); - // } - //} + #endregion - //#endregion + #region 鈻� 鏁村悎璁惧___________________________ - //#region 鈻� 鏄剧ず鍦烘櫙Tab鍒楄〃____________________ + /// <summary> + /// 鑾峰彇鍒嗙粍鍚庣殑璁惧 + /// </summary> + /// <returns></returns> + private Dictionary<int, List<CommonDevice>> GetAllGroupDevice() + { + //鍏ㄩ儴鐨勮澶� + var listDevice = this.GetShardListDevice(); + var dic = new Dictionary<int, List<CommonDevice>>(); + foreach (var device in listDevice) + { + var typeInfo = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device); + if (dic.ContainsKey(typeInfo.BeloneTextId) == false) + { + dic[typeInfo.BeloneTextId] = new List<CommonDevice>(); + } + dic[typeInfo.BeloneTextId].Add(device); + } + return dic; + } - ///// <summary> - ///// 鍒濆鍖栧満鏅疶ab鍒楄〃 - ///// </summary> - //private void InitSceneTabList() - //{ - // foreach (var sceneUi in this.room.SceneUIList) - // { - // if (sceneUi == null || memberShardInfo.dicAllMemberShard[this.room.FileName].Contains(sceneUi.FileName) == false) - // { - // //寮傚父锛屾垨鑰呬笉瀛樺湪,鍒欎笉鏄剧ず - // continue; - // } - // Application.RunOnMainThread(() => - // { - // if (this.Parent != null) - // { - // //娣诲姞鍦烘櫙琛� - // this.AddSceneDetailRow(sceneUi); - // } - // }); - // } - //} + #endregion - ///// <summary> - ///// 娣诲姞鍦烘櫙鐨勬槑缁嗚 - ///// </summary> - ///// <param name="sceneUI">鍦烘櫙瀵硅薄</param> - //private void AddSceneDetailRow(Common.SceneUI sceneUI) - //{ - // var sceneRow = new SceneViewRow(this.listSceneView, sceneUI); + #region 鈻� 鍒犻櫎鍒嗕韩___________________________ - // //绉婚櫎 - // var btnDelete = new RowDeleteButton(); - // btnDelete.TextID = R.MyInternationalizationString.RemoveBotton; - // sceneRow.AddRightView(btnDelete); - // btnDelete.MouseUpEventHandler += (sender, e) => - // { - // //纭畾绉婚櫎閫変腑鐨勫満鏅紵 - // string msg = Language.StringByID(R.MyInternationalizationString.uConfirmRemoveSelectSceneMsg); - // this.ShowConfirmMsg(msg, "DeleteShardScene", sceneRow, sceneUI); - // }; - //} + /// <summary> + /// 鍒犻櫎鍒嗕韩 + /// </summary> + private void DeleteShardData() + { + //閫夋嫨鐨勮澶� + var listDevice = new List<CommonDevice>(); + foreach (var device in dicSelectDevice.Values) + { + listDevice.Add(device); + } + //閫夋嫨鐨勫満鏅� + var listScene = new List<Common.SceneUI>(); + foreach (var scene in dicSelectScene.Values) + { + listScene.Add(scene); + } - ///// <summary> - ///// 鍒犻櫎鍏变韩鍦烘櫙 - ///// </summary> - ///// <param name="row"></param> - ///// <param name="sceneUI"></param> - //public async void DeleteShardScene(SceneViewRow row, Common.SceneUI sceneUI) - //{ - // var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, this.room, new List<CommonDevice>(), new List<Common.SceneUI>() { sceneUI }); - // if (result == true) - // { - // Application.RunOnMainThread(() => - // { - // row?.RemoveFromParent(); - // if (this.listDeviceView != null && this.listDeviceView.ChildrenCount == 0 && this.listSceneView.ChildrenCount == 0) - // { - // //浠�涔堥兘娌℃湁浜�,鍒欏叧闂晫闈� - // this.CloseForm(); - // } - // }); - // } - //} + //纭鍒犻櫎閫夋嫨鐨勫叡浜満鏅拰鍔熻兘锛� + this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteShardContentMsg), () => + { + HdlThreadLogic.Current.RunThread(async () => + { + //涓婁紶鏂囦欢 + var result = await HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, this.lookRoom, listDevice, listScene); + if (result == true) + { + HdlThreadLogic.Current.RunMain(() => + { + //閲嶆柊鍒濆鍖栫晫闈� + this.InitMiddleFrame(); + }); + } + }); + }); + } - //#endregion + #endregion - //#region 鈻� 鑾峰彇鍙互鍒嗕韩鐨勮澶嘷________________ + #region 鈻� 涓�鑸柟娉昣__________________________ - ///// <summary> - ///// 鑾峰彇鍒嗕韩鐨勮澶� - ///// </summary> - ///// <returns></returns> - //private List<CommonDevice> GetShardListDevice() - //{ - // //鑾峰彇杩欎釜鎴块棿閲岄潰鐨勫垎浜澶囩殑璺緞 - // var listDeviceFile = new List<string>(); - // foreach (var ui in this.room.DeviceUIList) - // { - // if (ui.CommonDevice != null && memberShardInfo.dicAllMemberShard[this.room.FileName].Contains(ui.CommonDevice.FilePath) == true) - // { - // listDeviceFile.Add(ui.CommonDevice.FilePath); - // } - // } + /// <summary> + /// 鑾峰彇鍒嗕韩鐨勮澶� + /// </summary> + /// <returns></returns> + private List<CommonDevice> GetShardListDevice() + { + //鑾峰彇杩欎釜鎴块棿閲岄潰鐨勫垎浜澶� + var listDevice = new List<CommonDevice>(); + foreach (var deviceKeys in this.lookRoom.ListDevice) + { + string deviceFile = HdlShardLogic.Current.GetShardDeviceFileName(deviceKeys); + if (memberShardInfo.dicAllShardKeys.ContainsKey(deviceFile) == true) + { + var strArry = deviceFile.Split('_'); + if (strArry.Length < 3) + { + continue; + } + //浠庡垎浜枃浠朵腑搴忓垪鍖栧洖鏉� + var deviceData = HdlShardLogic.Current.GetShardFileContent(deviceFile); + var device = ZigBee.Device.CommonDevice.CommonDeviceByByteString(strArry[1], System.Text.Encoding.UTF8.GetString(deviceData)); + if (device != null) + { + listDevice.Add(device); + } + } + } + return listDevice; + } - // var listFile = HdlShardLogic.Current.GetLocalAllShardFile(); - // var listDevice = new List<CommonDevice>(); - // foreach (string file in listFile) - // { - // //濡傛灉涓嶆槸璁惧鏂囦欢锛屾垨鑰呰繖涓埧闂撮噷闈㈡病鏈夎繖涓澶� - // if (file.StartsWith(Common.LocalDevice.deviceFirstName) == false || listDeviceFile.Contains(file) == false) - // { - // continue; - // } - // var strArry = file.Split('_'); - // if (strArry.Length < 3) - // { - // continue; - // } - // //浠庡垎浜枃浠朵腑搴忓垪鍖栧洖鏉� - // var deviceData = HdlShardLogic.Current.GetShardFileContent(file); - // var device = ZigBee.Device.CommonDevice.CommonDeviceByByteString(strArry[1], System.Text.Encoding.UTF8.GetString(deviceData)); - // if (device != null) - // { - // listDevice.Add(device); - // } - // } - // return listDevice; - //} - - //#endregion - - //#region 鈻� 涓�鑸柟娉昣__________________________ - - //#endregion + #endregion } } -- Gitblit v1.8.0