From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs | 779 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 779 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs b/ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs new file mode 100755 index 0000000..5cee0ea --- /dev/null +++ b/ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs @@ -0,0 +1,779 @@ +锘縰sing System; +using System.Collections.Generic; +using Shared.Common; +using Shared.Phone.Device.CommonForm; +using Shared.Phone.UserCenter; +using Shared.Phone.UserView; +using ZigBee.Device; + +namespace Shared.Phone.MainPage +{ + /// <summary> + /// 鏈垎閰嶇殑绠$悊鐣岄潰 + /// </summary> + public class UnallocatedRoomForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴浜嬩欢 + /// </summary> + public Action FormCloseEvent = null; + /// <summary> + /// 娣诲姞鍒� 鐨勮儗鏅浘鎺т欢 + /// </summary> + private FrameLayoutStatuControl frameAddBackGroud = null; + /// <summary> + /// 鍔熻兘鐨勬甯冩帶浠� + /// </summary> + private NormalFrameLayout DeviceBodyTableControl = null; + /// <summary> + /// 鍦烘櫙鐨勫垪琛ㄦ帶浠� + /// </summary> + private VerticalFrameControl listSceneView = null; + /// <summary> + /// 璁惧鐨勫垪琛ㄦ帶浠� + /// </summary> + private VerticalListControl listDeviceView = null; + /// <summary> + /// 鍦烘櫙鐨勬甯冩帶浠� + /// </summary> + private NormalFrameLayout SceneBodyTableControl = null; + /// <summary> + /// 鍏ㄩ�夋帶浠� + /// </summary> + private NormalViewControl btnAllSelect = null; + /// <summary> + /// 閫夋嫨鐨勫満鏅� + /// </summary> + private Dictionary<int, SceneUI> dicSelectScene = new Dictionary<int, SceneUI>(); + /// <summary> + /// 閫夋嫨鐨勮澶� + /// </summary> + private Dictionary<string, CommonDevice> dicSelectDevice = new Dictionary<string, CommonDevice>(); + /// <summary> + /// 褰撳墠閫夋嫨鐨勮澶囩被鍨嬩俊鎭�(涓轰簡澶勭悊閫熷害浣跨敤) + /// </summary> + private DeviceRowInfo nowSelectDeviceInfo = null; + /// <summary> + /// 鍏ㄩ儴鍒嗙粍鐨勮澶囦俊鎭� + /// </summary> + private Dictionary<string, DeviceRowInfo> dicGroupDevice = null; + /// <summary> + /// 鏄惁宸茬粡鏀瑰彉浜嗘暟鎹� + /// </summary> + private bool dataHadChanged = false; + /// <summary> + /// 鑳藉惁鍏ㄩ�夌殑鐘舵�� + /// </summary> + private bool canSelectAll = true; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //鍒濆鍖栧ご閮ㄦ帶浠� + this.InitTopFrameLayout(); + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitBodyFrameLayout(); + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.Unallocated)); + + //鍒濆鍖栧叏閫夋帶浠� + this.InitAllSelectControl(); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + var tabControl = new SceneFunctionSwitchControl(); + tabControl.Y = Application.GetRealHeight(40); + bodyFrameLayout.AddChidren(tabControl); + + //鍒濆鍖栧満鏅甯� + this.SceneBodyTableControl = new NormalFrameLayout(); + SceneBodyTableControl.Y = tabControl.Bottom; + SceneBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom; + bodyFrameLayout.AddChidren(SceneBodyTableControl); + //鍒濆鍖栬澶囨甯� + this.DeviceBodyTableControl = new NormalFrameLayout(); + DeviceBodyTableControl.Y = tabControl.Bottom; + DeviceBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom; + bodyFrameLayout.AddChidren(DeviceBodyTableControl); + + tabControl.SelectTabEvent += (index) => + { + //鍦烘櫙 + if (index == 0) + { + //鍒濆鍖栧満鏅垎鏀殑鎺т欢 + this.InitSceneCaseControl(); + //妫�娴嬪悇鎺т欢鐘舵�� + this.CheckControlsStatu(null); + } + //鍔熻兘 + else + { + //鍒濆鍖栧姛鑳藉垎鏀殑鎺т欢 + this.InitDeviceCaseControl(); + //妫�娴嬪悇鎺т欢鐘舵�� + this.CheckControlsStatu(this.nowSelectDeviceInfo); + } + }; + + //寮�濮嬪垵濮嬪寲鍦烘櫙鍔熻兘鍒囨崲鎺т欢 + var listTitle = new List<string>(); + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence)); + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction)); + //浠栦細鑷姩鍥炶皟浜嬩欢 + tabControl.InitControl(listTitle); + } + + #endregion + + #region 鈻� 鍦烘櫙鍒嗘敮___________________________ + + /// <summary> + /// 鍒濆鍖栧満鏅垎鏀殑鎺т欢 + /// </summary> + private void InitSceneCaseControl() + { + //闅愯棌璁惧鍒楄〃 + this.DeviceBodyTableControl.Visible = false; + //鏄剧ず鍦烘櫙 + this.SceneBodyTableControl.Visible = true; + if (this.SceneBodyTableControl.Name == "Scene") + { + //宸茬粡鍒濆鍖栬繃 + return; + } + //鎵撲釜鏍囪瘑鑰屽凡 + this.SceneBodyTableControl.Name = "Scene"; + //寮�濮嬫墽琛屽垵濮嬪寲鍦烘櫙鍒嗘敮鐨勬帶浠� + this.DoInitSceneCaseControl(); + } + + /// <summary> + /// 寮�濮嬫墽琛屽垵濮嬪寲鍦烘櫙鍒嗘敮鐨勬帶浠� + /// </summary> + private void DoInitSceneCaseControl() + { + HdlThreadLogic.Current.RunMainInThread(() => + { + //娓呯┖妗屽竷 + this.SceneBodyTableControl.RemoveAll(); + + this.listSceneView = new VerticalFrameControl(3); + listSceneView.Y = Application.GetRealHeight(53); + listSceneView.Height = SceneBodyTableControl.Height; + SceneBodyTableControl.AddChidren(listSceneView); + + var listScene = HdlSceneLogic.Current.GetUnalloctedScenes(); + if (listScene.Count == 0) { return; } + + foreach (var data in listScene) + { + //鍦烘櫙鍥剧墖 + var frameContr = new ScenePictrueControl(); + listSceneView.AddChidren(frameContr); + frameContr.InitControl(data); + + //娣诲姞閫夋嫨鎺т欢 + frameContr.AddSelectControl(); + + //鏀惰棌 + frameContr.AddCollectionControl(); + frameContr.CollectEvent += (collect) => + { + //濡傛灉褰撳墠鏄敹钘忔埧闂�,鍒欓渶瑕佸埛鏂颁富椤� + if (HdlRoomLogic.Current.NowMainPageRoom.IsLove == true) + { + this.dataHadChanged = true; + } + }; + + frameContr.ButtonClickEvent += (sender, e) => + { + //閫夋嫨 + frameContr.IsSelected = !frameContr.IsSelected; + if (frameContr.IsSelected == true) + { + dicSelectScene[data.Id] = data; + } + else + { + dicSelectScene.Remove(data.Id); + } + //妫�娴嬪悇鎺т欢鐘舵�� + this.CheckControlsStatu(null); + }; + } + //淇冧娇瀹冭秴杩囨椂,鑳藉寰�涓婃粦 + var frameTemp = new FrameLayout(); + frameTemp.Height = Application.GetRealHeight(202 + 23); + listSceneView.AddChidren(frameTemp); + }); + } + + #endregion + + #region 鈻� 鍔熻兘鍒嗘敮___________________________ + + /// <summary> + /// 鍒濆鍖栧姛鑳藉垎鏀殑鎺т欢 + /// </summary> + private void InitDeviceCaseControl() + { + //闅愯棌鍦烘櫙鍒楄〃 + this.SceneBodyTableControl.Visible = false; + //鏄剧ず鍔熻兘 + this.DeviceBodyTableControl.Visible = true; + if (this.DeviceBodyTableControl.Name == "Function") + { + //宸茬粡鍒濆鍖栬繃 + return; + } + //鎵撲釜鏍囪瘑鑰屽凡 + this.DeviceBodyTableControl.Name = "Function"; + //寮�濮嬫墽琛屽垵濮嬪寲鍔熻兘鍒嗘敮鐨勬帶浠� + this.DoInitDeviceCaseControl(); + } + + /// <summary> + /// 寮�濮嬫墽琛屽垵濮嬪寲鍔熻兘鍒嗘敮鐨勬帶浠� + /// </summary> + private void DoInitDeviceCaseControl() + { + HdlThreadLogic.Current.RunMainInThread(() => + { + //娓呯┖妗屽竷,涓嶆竻绌鸿繖涓殑璇�,瀹冮噷闈㈣繕鏈変笂涓�娆$殑涓滆タ + this.listDeviceView?.RemoveAll(); + this.DeviceBodyTableControl.RemoveAll(); + + //鑾峰彇鍒嗙粍鍚庣殑璁惧鍒楄〃 + this.dicGroupDevice = this.GetAllGroupDevice(); + if (dicGroupDevice.Count == 0) + { + this.listDeviceView = null; + return; + } + + //璁惧鐨勮儗鏅鍣� + var frameDeviceBack = new FrameLayout(); + frameDeviceBack.X = ControlCommonResourse.XXLeft; + frameDeviceBack.Y = Application.GetRealHeight(369); + frameDeviceBack.BackgroundColor = UserCenterColor.Current.White; + frameDeviceBack.Width = bodyFrameLayout.Width; + frameDeviceBack.Height = Application.GetRealHeight(1236); + frameDeviceBack.Radius = (uint)Application.GetRealHeight(58); + DeviceBodyTableControl.AddChidren(frameDeviceBack); + //璁惧鍒楄〃鎺т欢 + this.listDeviceView = new VerticalListControl(35); + listDeviceView.Y = Application.GetRealHeight(14); + listDeviceView.Height = Application.GetRealHeight(1236 - 14); + frameDeviceBack.AddChidren(listDeviceView); + + //鍒濆鍖栬澶囩被鍨嬭彍鍗� + this.InitDeviceObjectMenu(); + }); + } + + #endregion + + #region 鈻� 鍒濆鍖栬澶囩被鍨嬭彍鍗昣________________ + + /// <summary> + /// 鍒濆鍖栬澶囩被鍨嬭彍鍗� + /// </summary> + private void InitDeviceObjectMenu() + { + //澶撮儴鐨勭櫧鑹茶儗鏅� + var functionBack1 = new FrameLayout(); + functionBack1.X = ControlCommonResourse.XXLeft; + functionBack1.Y = Application.GetRealHeight(55); + functionBack1.Height = Application.GetRealHeight(160); + functionBack1.Width = Application.GetRealWidth(1028); + functionBack1.BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; + DeviceBodyTableControl.AddChidren(functionBack1); + functionBack1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft); + var functionBack2 = new FrameLayout(); + functionBack2.X = ControlCommonResourse.XXLeft; + functionBack2.Y = functionBack1.Bottom - Application.GetRealHeight(50); + functionBack2.Height = Application.GetRealHeight(279 - 160 + 50); + functionBack2.Width = Application.GetRealWidth(1028); + functionBack2.BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; + DeviceBodyTableControl.AddChidren(functionBack2); + functionBack2.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft); + + //宸﹀彸婊戝姩鐨勬帶浠� + var HorizontalView = new HorizontalScrolViewLayout(); + HorizontalView.X = Application.GetRealWidth(CommonFormResouce.X_Left); + HorizontalView.Y = Application.GetRealHeight(55); + HorizontalView.Height = Application.GetRealHeight(279); + HorizontalView.Width = Application.GetRealWidth(1028); + DeviceBodyTableControl.AddChidren(HorizontalView); + + //涓婁竴娆¢�夋嫨鐨勮彍鍗� + Controls.DeviceFunctionMenuControl oldSelectContr = null; + foreach (string strText in this.dicGroupDevice.Keys) + { + var rowInfo = dicGroupDevice[strText]; + + //璁惧绫诲瀷鐨勫鍣� + var devieFrame = new FrameLayout(); + devieFrame.Width = Application.GetRealWidth(220); + HorizontalView.AddChidren(devieFrame); + + //鑿滃崟鍥剧墖鎺т欢 + var deviceObjContr = new Controls.DeviceFunctionMenuControl(); + devieFrame.AddChidren(deviceObjContr); + deviceObjContr.InitControl(strText, rowInfo.IconPath, rowInfo.IconPathSelected); + deviceObjContr.ButtonClickEvent += (sender, e) => + { + //閫夋嫨鐨勬槸鍚屼竴涓笢瑗跨殑璇�,涓嶅鐞� + if (this.nowSelectDeviceInfo.Text != rowInfo.Text) + { + //涓婁竴娆$殑鑿滃崟鍙栨秷,鏈鑿滃崟閫夋嫨 + oldSelectContr.SetSelectStatu(false); + deviceObjContr.SetSelectStatu(true); + oldSelectContr = deviceObjContr; + + this.nowSelectDeviceInfo = rowInfo; + HdlThreadLogic.Current.RunMainInThread(() => + { + //鍒濆鍖栬澶囧垪琛ㄦ帶浠� + this.InitListDeviceControls(rowInfo); + //妫�娴嬪悇鎺т欢鐘舵�� + this.CheckControlsStatu(this.nowSelectDeviceInfo); + }); + } + }; + + if (this.nowSelectDeviceInfo == null) + { + //璁剧疆鍒濆閫夋嫨 + this.nowSelectDeviceInfo = rowInfo; + //璁板綍鍒濆閫夋嫨鐨勮彍鍗曟帶浠� + oldSelectContr = deviceObjContr; + deviceObjContr.SetSelectStatu(true); + } + } + if (this.nowSelectDeviceInfo != null) + { + //鍒濆鍖栭粯璁ょ殑璁惧鍒楄〃鎺т欢 + this.InitListDeviceControls(nowSelectDeviceInfo); + } + } + + #endregion + + #region 鈻� 鍒濆鍖栬澶囧垪琛ㄦ帶浠禵________________ + + /// <summary> + /// 鍒濆鍖栬澶囧垪琛ㄦ帶浠� + /// </summary> + /// <param name="rowInfo"></param> + /// <param name="listView"></param> + private void InitListDeviceControls(DeviceRowInfo rowInfo) + { + this.listDeviceView.RemoveAll(); + //鍒濆鍖栬澶囧垪琛ㄦ帶浠� + foreach (var deviceKey in rowInfo.listDeviceKeys) + { + var device = LocalDevice.Current.GetDevice(deviceKey); + var deviceRow = new Controls.DeviceSelectUnallocatedControl(listDeviceView.rowSpace / 2); + listDeviceView.AddChidren(deviceRow); + deviceRow.InitControl(device); + + if (this.dicSelectDevice.ContainsKey(deviceKey) == true) + { + //濡傛灉瀹冧箣鍓嶉�夋嫨浜嗙殑璇� + deviceRow.IsSelected = true; + } + deviceRow.ButtonClickEvent += (sender, e) => + { + deviceRow.IsSelected = !deviceRow.IsSelected; + //璁板綍缂撳瓨 + if (deviceRow.IsSelected == true) + { + this.dicSelectDevice[deviceKey] = device; + } + else + { + this.dicSelectDevice.Remove(deviceKey); + } + //妫�娴嬪悇鎺т欢鐘舵�� + this.CheckControlsStatu(rowInfo); + }; + } + //淇冧娇瀹冭秴杩囨椂,鑳藉寰�涓婃粦 + var frameTemp = new FrameLayout(); + frameTemp.Height = Application.GetRealHeight(202 + 23); + listDeviceView.AddChidren(frameTemp); + } + + #endregion + + #region 鈻� 鍏ㄩ�夋帶浠禵__________________________ + + /// <summary> + /// 鍒濆鍖栧叏閫夋帶浠� + /// </summary> + private void InitAllSelectControl() + { + this.btnAllSelect = new NormalViewControl(150, 70, true); + btnAllSelect.TextAlignment = TextAlignment.CenterRight; + btnAllSelect.X = topFrameLayout.Width - Application.GetRealWidth(150 + 115); + btnAllSelect.Gravity = Gravity.CenterVertical; + btnAllSelect.TextID = R.MyInternationalizationString.AllSelect; + btnAllSelect.IsBold = true; + topFrameLayout.AddChidren(btnAllSelect); + btnAllSelect.ButtonClickEvent += (sender, e) => + { + //鍦烘櫙鍒嗘敮 + if (SceneBodyTableControl.Visible == true) + { + if (listSceneView == null) { return; } + for (int i = 0; ; i++) + { + var myContr = listSceneView.frameTable.GetChildren(i); + if (myContr == null) + { + break; + } + if (myContr is ScenePictrueControl) + { + ((ScenePictrueControl)myContr).IsSelected = this.canSelectAll; + var scene = ((ScenePictrueControl)myContr).scene; + if (this.canSelectAll == true) + { + //娣诲姞缂撳瓨 + dicSelectScene[scene.Id] = scene; + } + else + { + //绉婚櫎缂撳瓨 + dicSelectScene.Remove(scene.Id); + } + } + } + //妫�娴嬪悇鎺т欢鐘舵�� + this.CheckControlsStatu(null); + } + //鍔熻兘鍒嗘敮 + else + { + if (listDeviceView == null) { return; } + for (int i = 0; ; i++) + { + var myContr = listDeviceView.GetChildren(i); + if (myContr == null) + { + break; + } + if (myContr is Controls.DeviceSelectUnallocatedControl) + { + ((Controls.DeviceSelectUnallocatedControl)myContr).IsSelected = this.canSelectAll; + var device = ((Controls.DeviceSelectUnallocatedControl)myContr).device; + if (this.canSelectAll == true) + { + //娣诲姞缂撳瓨 + dicSelectDevice[LocalDevice.Current.GetDeviceMainKeys(device)] = device; + } + else + { + //绉婚櫎缂撳瓨 + dicSelectDevice.Remove(LocalDevice.Current.GetDeviceMainKeys(device)); + } + } + } + //妫�娴嬪悇鎺т欢鐘舵�� + this.CheckControlsStatu(this.nowSelectDeviceInfo); + } + }; + } + + #endregion + + #region 鈻� [娣诲姞鍒癩鎺т欢_______________________ + + /// <summary> + /// 鍒濆鍖栨坊鍔犲埌鎺т欢 + /// </summary> + private void InitAddToControl() + { + //娣诲姞鍒� 鐨勮儗鏅浘鎺т欢 + this.frameAddBackGroud = new FrameLayoutStatuControl(); + frameAddBackGroud.UseClickStatu = false; + frameAddBackGroud.Height = Application.GetRealHeight(202); + frameAddBackGroud.Gravity = Gravity.BottomCenter; + frameAddBackGroud.BackgroundImagePath = "Room/AddBackground.png"; + bodyFrameLayout.AddChidren(frameAddBackGroud); + frameAddBackGroud.Visible = false; + + //娣诲姞鍒� 鎸夐挳 + var btnAdd = new NormalViewControl(1034, 156, true); + btnAdd.Gravity = Gravity.Center; + btnAdd.BackgroundColor = UserCenterColor.Current.White; + btnAdd.TextColor = ZigbeeColor.Current.GXCTextSelectedColor4; + btnAdd.TextAlignment = TextAlignment.Center; + btnAdd.TextID = R.MyInternationalizationString.AddTo; + btnAdd.TextSize = 17; + btnAdd.Radius = (uint)Application.GetRealHeight(35); + frameAddBackGroud.AddChidren(btnAdd, ChidrenBindMode.BindEvent); + frameAddBackGroud.ButtonClickEvent += (sender, e) => + { + HdlControlLogic.Current.ShowBottomListRoomView(string.Empty, Language.StringByID(R.MyInternationalizationString.AddTo), (selectId, selectName) => + { + if (selectId == string.Empty) + { + //閫夋嫨鐨勬槸鏈垎閰� + return; + } + //鍙樻洿浜嗗綋鍓嶆埧闂寸殑涓滆タ,涓婚〉闇�瑕佸埛鏂� + if (HdlRoomLogic.Current.NowMainPageRoom.Id == selectId) + { + this.dataHadChanged = true; + } + //淇濆瓨閫夋嫨鐨勮澶囧拰鍦烘櫙 + var room = HdlRoomLogic.Current.GetRoomById(selectId); + this.SaveSelectDeviceAndScene(room); + //鍒嗙被鐣岄潰闇�瑕佸埛鏂� + UserPage.Instance.RefreshCategoryForm = true; + //涓婁紶绌洪棿鍖哄煙淇℃伅 + HdlRoomLogic.Current.SetRoomInfoToGateway(); + }); + }; + } + + /// <summary> + /// 淇濆瓨閫夋嫨鐨勮澶囧拰鍦烘櫙 + /// </summary> + /// <param name="room"></param> + private void SaveSelectDeviceAndScene(Room room) + { + foreach (var deviceKey in this.dicSelectDevice.Keys) + { + //娣诲姞璁惧 + HdlRoomLogic.Current.AddDevice(room, dicSelectDevice[deviceKey], true); + foreach (var rowInf in dicGroupDevice.Values) + { + //绉婚櫎缂撳瓨 + if (rowInf.listDeviceKeys.Contains(deviceKey) == true) + { + rowInf.listDeviceKeys.Remove(deviceKey); + } + } + } + foreach (var scene in this.dicSelectScene.Values) + { + //娣诲姞鍦烘櫙 + HdlSceneLogic.Current.AddSceneToRoom(room, scene); + } + //娓呯┖缂撳瓨 + this.dicSelectScene.Clear(); + this.dicSelectDevice.Clear(); + //鍙充笂瑙掔殑鏂囧瓧鍒囨崲涓� 鍏ㄩ�� + btnAllSelect.TextID = R.MyInternationalizationString.AllSelect; + this.canSelectAll = true; + + //鍦烘櫙鍒嗘敮闇�瑕侀噸鏂板垵濮嬪寲 + this.DoInitSceneCaseControl(); + + if (this.nowSelectDeviceInfo != null) + { + + bool allHadDevice = true; + foreach (var data in this.dicGroupDevice.Values) + { + if (data.listDeviceKeys.Count == 0) + { + //鏈夊垎鏀凡缁忔病鏈夎澶囦簡 + allHadDevice = false; + break; + } + } + //濡傛灉鎵�鏈夊垎鏀兘杩樻湁璁惧鐨勮瘽,灏卞埛鏂板綋鍓嶇殑鍒楄〃鍗冲彲 + if (allHadDevice == true) + { + //鍒濆鍖栬澶囧垪琛ㄦ帶浠� + this.InitListDeviceControls(this.nowSelectDeviceInfo); + } + else + { + //濡傛灉瀛樺湪鍒嗘敮宸茬粡娌℃湁璁惧浜嗙殑璇�,閭d箞瀹冪殑鑿滃崟涔熼渶瑕佸垹闄ゆ帀,鎵�浠ラ渶瑕侀噸鏂板垵濮嬪寲 + this.nowSelectDeviceInfo = null; + this.DoInitDeviceCaseControl(); + } + } + //闅愯棌 娣诲姞鍒� 鎸夐挳 + this.frameAddBackGroud.Visible = false; + } + + #endregion + + #region 鈻� 鏁村悎璁惧___________________________ + + /// <summary> + /// 鑾峰彇鍒嗙粍鍚庣殑璁惧 + /// </summary> + /// <returns></returns> + private Dictionary<string, DeviceRowInfo> GetAllGroupDevice() + { + //鍏ㄩ儴鐨勮澶� + var listDevice = HdlRoomLogic.Current.GetUnalloctedDevice(); + //鏍规嵁璁惧鎵�灞炵被鍨嬫帓搴� + listDevice = LocalDevice.Current.SortDeviceByBelongType(listDevice); + var dic = new Dictionary<string, DeviceRowInfo>(); + foreach (var device in listDevice) + { + var typeInfo = LocalDevice.Current.GetDeviceBelongEnumInfo(device); + //鎸夋墍灞濱D鍒嗙粍 + if (dic.ContainsKey(typeInfo.BeloneText) == false) + { + dic[typeInfo.BeloneText] = new DeviceRowInfo(); + string path1 = string.Empty; + string path2 = string.Empty; + //鑾峰彇鍥剧墖 + Common.LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo, ref path1, ref path2); + dic[typeInfo.BeloneText].IconPath = path1; + dic[typeInfo.BeloneText].IconPathSelected = path2; + dic[typeInfo.BeloneText].Text = typeInfo.BeloneText; + } + dic[typeInfo.BeloneText].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device)); + } + return dic; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + //璋冪敤鍥炶皟浜嬩欢 + this.FormCloseEvent?.Invoke(); + this.FormCloseEvent = null; + + if (this.dataHadChanged == true) + { + HdlThreadLogic.Current.RunMainInThread(() => + { + //鍒锋柊涓婚〉 + HomeMainPageForm.Instance?.RefreshBodyView(); + }); + } + base.CloseFormBefore(); + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 妫�娴嬪悇鎺т欢鐘舵�� + /// </summary> + private void CheckControlsStatu(DeviceRowInfo rowInfo) + { + if (this.frameAddBackGroud == null) + { + //鍒濆鍖栨坊鍔犲埌鎺т欢 + this.InitAddToControl(); + } + + if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0) + { + //闅愯棌 娣诲姞鍒� 鎺т欢 + if (frameAddBackGroud.Visible == true) + { + frameAddBackGroud.Visible = false; + } + } + else + { + //鏄剧ず 娣诲姞鍒� 鎺т欢 + if (frameAddBackGroud.Visible == false) + { + frameAddBackGroud.Visible = true; + } + } + //褰撳墠閫夋嫨鐨勬槸鍦烘櫙鍒嗘敮 + if (rowInfo == null) + { + if (this.dicSelectScene.Count > 0) + { + //鍙充笂瑙掔殑鏂囧瓧鍒囨崲涓� 鍙栨秷 + btnAllSelect.TextID = R.MyInternationalizationString.Cancel; + this.canSelectAll = false; + } + else + { + //鍙充笂瑙掔殑鏂囧瓧鍒囨崲涓� 鍏ㄩ�� + btnAllSelect.TextID = R.MyInternationalizationString.AllSelect; + this.canSelectAll = true; + } + } + //褰撳墠閫夋嫨鐨勬槸鍔熻兘鍒嗘敮 + else + { + foreach (var deviceKey in rowInfo.listDeviceKeys) + { + //濡傛灉褰撳墠鐨勮澶囩被鍨嬮�夋嫨鍒嗘敮涓嬶紝瀛樺湪涔嬪墠閫夋嫨鐨勮澶囩殑璇� + if (this.dicSelectDevice.ContainsKey(deviceKey) == true) + { + //鍙充笂瑙掔殑鏂囧瓧鍒囨崲涓� 鍙栨秷 + btnAllSelect.TextID = R.MyInternationalizationString.Cancel; + this.canSelectAll = false; + return; + } + } + //濡傛灉涓嶅瓨鍦ㄧ殑璇�,鍙充笂瑙掔殑鏂囧瓧鍒囨崲涓� 鍏ㄩ�� + btnAllSelect.TextID = R.MyInternationalizationString.AllSelect; + this.canSelectAll = true; + } + } + + #endregion + + #region 鈻� 缁撴瀯浣揰____________________________ + + /// <summary> + /// 璁惧琛屼俊鎭� + /// </summary> + private class DeviceRowInfo + { + /// <summary> + /// 鏂囨湰,鐩墠鐢ㄦ潵鍋氫富閿� + /// </summary> + public string Text = string.Empty; + /// <summary> + /// 鍥炬爣 + /// </summary> + public string IconPath = string.Empty; + /// <summary> + /// 鍥炬爣 + /// </summary> + public string IconPathSelected = string.Empty; + /// <summary> + /// 璁惧鍥炶矾涓婚敭 + /// </summary> + public List<string> listDeviceKeys = new List<string>(); + } + + #endregion + } +} -- Gitblit v1.8.0