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/UserCenter/SharedContent/AddNewSharedContentForm.cs | 448 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 448 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs
new file mode 100755
index 0000000..84b790a
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs
@@ -0,0 +1,448 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.SharedContent
+{
+ /// <summary>
+ /// 閰嶇疆鏂板叡浜唴瀹圭殑涓荤晫闈�
+ /// </summary>
+ public class AddNewSharedContentForm : EditorCommonForm
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 鏌ョ湅鐨勬埧闂村璞�
+ /// </summary>
+ private Common.Room lookRoom = null;
+ /// <summary>
+ /// 鎴愬憳鐨勫垎浜暟鎹�
+ /// </summary>
+ private MemberShardInfoData memberShardInfo = null;
+ /// <summary>
+ /// 璁惧妗屽竷鎺т欢
+ /// </summary>
+ private NormalFrameLayout frameDeviceTable = null;
+ /// <summary>
+ /// 璁惧妗屽竷鎺т欢
+ /// </summary>
+ private NormalFrameLayout frameSceneTable = null;
+ /// <summary>
+ /// 鍔熻兘鎸夐挳
+ /// </summary>
+ private BottomClickButton btnShard = 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 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+ /// </summary>
+ /// <param name="i_room">鏌ョ湅鐨勬埧闂村璞�</param>
+ /// <param name="i_memberShardInfo">鎴愬憳鐨勫垎浜暟鎹�</param>
+ public void ShowForm(Common.Room i_room, MemberShardInfoData i_memberShardInfo)
+ {
+ this.lookRoom = i_room;
+ this.memberShardInfo = i_memberShardInfo;
+
+ //璁剧疆澶撮儴淇℃伅
+ base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddShared));
+
+ //鍒濆鍖栦腑閮ㄤ俊鎭�
+ this.InitMiddleFrame();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+ /// </summary>
+ private void InitMiddleFrame()
+ {
+ //娓呯┖bodyFrame
+ this.ClearBodyFrame();
+ this.dicSelectDevice = new Dictionary<string, CommonDevice>();
+ this.dicSelectScene = new Dictionary<int, Common.SceneUI>();
+
+ //鍒濆鍖栨甯冩帶浠�
+ this.frameSceneTable = new NormalFrameLayout();
+ frameSceneTable.Y = Application.GetRealHeight(132);
+ frameSceneTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(132);
+ bodyFrameLayout.AddChidren(frameSceneTable);
+
+ this.frameDeviceTable = new NormalFrameLayout();
+ frameDeviceTable.Y = frameSceneTable.Y;
+ frameDeviceTable.Height = frameSceneTable.Height;
+ bodyFrameLayout.AddChidren(frameDeviceTable);
+ frameDeviceTable.Visible = false;
+
+ //鍒濆鍖栧垎鏀帶浠�
+ this.InitSwitchControl();
+
+ //鎴块棿
+ var btnRoom = new NormalViewControl(400, 63, true);
+ btnRoom.Y = Application.GetRealHeight(40);
+ btnRoom.X = bodyFrameLayout.Width - Application.GetRealWidth(58 + 400);
+ btnRoom.Text = this.lookRoom.Name;
+ btnRoom.TextAlignment = TextAlignment.CenterRight;
+ bodyFrameLayout.AddChidren(btnRoom);
+
+ //鍒嗕韩鎸夐挳
+ this.btnShard = new BottomClickButton();
+ btnShard.TextID = R.MyInternationalizationString.uShared2;
+ bodyFrameLayout.AddChidren(btnShard);
+ btnShard.Visible = false;
+ btnShard.ButtonClickEvent += (sender, e) =>
+ {
+ //淇濆瓨鍒嗕韩
+ this.SaveShardData();
+ };
+
+ //鍒濆鍖栧満鏅垪琛�
+ 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 鈻� 鍦烘櫙鏄剧ず___________________________
+
+ /// <summary>
+ /// 鍒濆鍖栧満鏅垪琛�
+ /// </summary>
+ private void InitSceneList()
+ {
+ //娓呯┖妗屽竷
+ this.frameSceneTable.RemoveAll();
+
+ //鍦烘櫙鏈夌偣鐗规畩,濡傛灉鍚屼竴涓埧闂村唴,宸茬粡鍒嗕韩浜�,鍒欎笉鍐嶆樉绀�
+ //濡傛灉杩欎釜鍦烘櫙鏄敱宓屽鑰屽垎浜殑,杩欎釜鏃跺��,瀹冨彲浠ユ樉绀哄嚭鏉�
+ var listScene = new List<int>();
+ if (memberShardInfo.dicShardRoom.ContainsKey(lookRoom.FileName) == false)
+ {
+ listScene.AddRange(lookRoom.ListSceneId);
+ }
+ else
+ {
+ var tempRoom = memberShardInfo.dicShardRoom[lookRoom.FileName];
+ foreach (var dataId in lookRoom.ListSceneId)
+ {
+ if (tempRoom.ListSceneId.Contains(dataId) == false)
+ {
+ listScene.Add(dataId);
+ }
+ }
+ }
+ if (listScene.Count == 0)
+ {
+ //鏃犲彲鍏变韩鐨勫満鏅�
+ this.ShowNotDataImage(frameSceneTable, Language.StringByID(R.MyInternationalizationString.uNotCanShardSceneMsg), "Item/NotShardPic.png", 383, 279);
+ return;
+ }
+
+ HdlThreadLogic.Current.RunMainInThread(() =>
+ {
+ var listView = new VerticalFrameControl(3);
+ listView.Y = Application.GetRealHeight(53);
+ listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
+ frameSceneTable.AddChidren(listView);
+
+ foreach (var dataId in listScene)
+ {
+ var data = HdlSceneLogic.Current.GetSceneUIBySceneId(dataId);
+ if (data == null)
+ {
+ continue;
+ }
+ //鍦烘櫙鍥剧墖
+ var frameContr = new ScenePictrueControl();
+ listView.AddChidren(frameContr);
+ frameContr.InitControl(data);
+
+ 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.btnShard.Visible == false)
+ {
+ this.btnShard.Visible = true;
+ }
+ }
+ else
+ {
+ dicSelectScene.Remove(data.Id);
+ if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
+ {
+ this.btnShard.Visible = false;
+ }
+ }
+ };
+ }
+ //璋冩暣涓�涓嬮珮搴�
+ listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(185));
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 鍔熻兘鏄剧ず___________________________
+
+ /// <summary>
+ /// 鍒濆鍖栧姛鑳藉垪琛�
+ /// </summary>
+ private void InitFunctionList()
+ {
+ //娓呯┖妗屽竷
+ this.frameDeviceTable.RemoveAll();
+
+ HdlThreadLogic.Current.RunMainInThread(() =>
+ {
+ //鑾峰彇鍒嗙粍鍚庣殑璁惧鍒楄〃
+ var dicGroupDevice = this.GetAllGroupDevice();
+ if (dicGroupDevice.Count == 0)
+ {
+ //鏃犲彲鍏变韩鐨勮澶�
+ this.ShowNotDataImage(frameDeviceTable, Language.StringByID(R.MyInternationalizationString.uNotCanShardDeviceMsg), "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);
+
+ var listView = new VerticalListControl(23);
+ listView.Y = Application.GetRealHeight(23);
+ listView.Height = Application.GetRealHeight(1437 - 23);
+ frameBack.AddChidren(listView);
+ //鍒濆鍖栬澶囩被鍨嬭
+ this.InitDeviceObjectRow(dicGroupDevice, listView);
+ }
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栬澶囩被鍨嬭___________________
+
+ /// <summary>
+ /// 鍒濆鍖栬澶囩被鍨嬭
+ /// </summary>
+ /// <param name="dicData"></param>
+ /// <param name="listView"></param>
+ private void InitDeviceObjectRow(Dictionary<string, 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();
+ }
+
+ #endregion
+
+ #region 鈻� 娣诲姞璁惧琛宊________________________
+
+ /// <summary>
+ /// 娣诲姞璁惧琛�
+ /// </summary>
+ /// <param name="listDevice"></param>
+ /// <param name="listView"></param>
+ private void AddDeviceRow(List<CommonDevice> listDevice, VerticalListControl listView)
+ {
+ listView.RemoveAll();
+
+ 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";
+
+ 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.btnShard.Visible == false)
+ {
+ this.btnShard.Visible = true;
+ }
+ }
+ else
+ {
+ dicSelectDevice.Remove(mainKeys);
+ if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
+ {
+ this.btnShard.Visible = false;
+ }
+ }
+ };
+ }
+
+ //鍒楄〃鑷繁鏈変釜23鐨刌杞村潗鏍�
+ listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23), Application.GetRealHeight(300 - 23));
+ }
+
+ #endregion
+
+ #region 鈻� 鏁村悎璁惧___________________________
+
+ /// <summary>
+ /// 鑾峰彇鍒嗙粍鍚庣殑璁惧
+ /// </summary>
+ /// <returns></returns>
+ private Dictionary<string, List<CommonDevice>> GetAllGroupDevice()
+ {
+ //鍏ㄩ儴鐨勮澶�
+ var listDevice = HdlRoomLogic.Current.GetRoomListDevice(lookRoom);
+ var dic = new Dictionary<string, List<CommonDevice>>();
+ foreach (var device in listDevice)
+ {
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(device.FilePath) == true)
+ {
+ //濡傛灉宸茬粡鍒嗕韩浜�,鍒欎笉鏄剧ず
+ continue;
+ }
+ var typeInfo = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device);
+ if (dic.ContainsKey(typeInfo.BeloneText) == false)
+ {
+ dic[typeInfo.BeloneText] = new List<CommonDevice>();
+ }
+ dic[typeInfo.BeloneText].Add(device);
+ }
+ return dic;
+ }
+
+ #endregion
+
+ #region 鈻� 淇濆瓨鍒嗕韩___________________________
+
+ /// <summary>
+ /// 淇濆瓨鍒嗕韩
+ /// </summary>
+ private void SaveShardData()
+ {
+ //閫夋嫨鐨勮澶�
+ 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);
+ }
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ //涓婁紶鏂囦欢
+ var result = HdlShardLogic.Current.DoUploadSharedContent(memberShardInfo, this.lookRoom, listDevice, listScene);
+ if (result == true)
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //閲嶆柊鍒濆鍖栫晫闈�
+ this.InitMiddleFrame();
+ });
+ }
+ });
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0