From e22fdb94322e6cec38e5e4a9aec13d431a133fde Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期二, 28 四月 2020 16:32:35 +0800 Subject: [PATCH] 上传合并后的代码 --- ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs | 390 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 199 insertions(+), 191 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs index 77d8211..045ed5d 100755 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneCategoryView.cs @@ -1,29 +1,29 @@ -锘縰sing System; -using System.Collections.Generic; -using Shared.Common; -using Shared.Phone.UserCenter; - -namespace Shared.Phone.Device.CommonForm -{ - public class SceneCategoryView : RowLayout +锘縰sing System; +using System.Collections.Generic; +using Shared.Common; +using Shared.Phone.UserCenter; + +namespace Shared.Phone.Device.CommonForm +{ + public class SceneCategoryView : RowLayoutBase { - #region 鈻� 鍙橀噺澹版槑___________________________ - - /// <summary> - /// scene - /// </summary> - public SceneUI scene; - /// <summary> - /// room - /// </summary> - private Common.Room room; - /// <summary> - /// 寤舵椂鏃堕棿 - /// </summary> - private NormalViewControl btnDelayTime; - /// <summary> - /// 寤舵椂鍥炬爣 - /// </summary> + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// scene + /// </summary> + public SceneUI scene; + /// <summary> + /// room + /// </summary> + private Common.Room room; + /// <summary> + /// 寤舵椂鏃堕棿 + /// </summary> + private NormalViewControl btnDelayTime; + /// <summary> + /// 寤舵椂鍥炬爣 + /// </summary> private IconViewControl btnDelayIcon; /// <summary> /// 鍦烘櫙鍥剧墖鎺т欢 @@ -34,19 +34,19 @@ /// </summary> private bool isInitControlFinish = false; - #endregion + #endregion #region 鈻� 鍒濆鍖朹____________________________ - /// <summary> - /// SceneCategoryView - /// </summary> - public SceneCategoryView() - { - this.Width = Application.GetRealWidth(1080); - this.Height = Application.GetRealHeight(397 + 46); - this.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; - this.IsUseSameSubViewWidth = false; + /// <summary> + /// SceneCategoryView + /// </summary> + public SceneCategoryView() + { + this.Width = Application.GetRealWidth(1080); + this.Height = Application.GetRealHeight(397 + 46); + this.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; + this.IsUseSameSubViewWidth = false; } /// <summary> @@ -59,47 +59,47 @@ this.LineColor = UserCenterColor.Current.Transparent; - this.scene = i_scene; + this.scene = i_scene; this.room = i_room; - //鑷畾涔夌殑鍦烘櫙鍥剧墖鎺т欢 + //鑷畾涔夌殑鍦烘櫙鍥剧墖鎺т欢 this.sceneContr = new ScenePictrueControl(); - this.AddChidren(sceneContr); - sceneContr.InitControl(this.scene); + this.AddChidren(sceneContr); + sceneContr.InitControl(this.scene); //鍦烘櫙鐐瑰嚮 sceneContr.ButtonClickEvent += (sender, e) => { this.SceneUpHandler(); - }; - - //鏀惰棌 - sceneContr.AddCollectionControl(); + }; + + //鏀惰棌 + sceneContr.AddCollectionControl(); sceneContr.CollectEvent += (collect) => { - if (room.IsLove) - { - this.RemoveFromParent(); + if (room.IsLove) + { + this.RemoveFromParent(); } - }; - - //寤舵椂鏃堕棿 - this.btnDelayTime = new NormalViewControl(200, 58, true); - btnDelayTime.X = Application.GetRealWidth(780); - btnDelayTime.Y = Application.GetRealHeight(317); - btnDelayTime.Text = CommonFormResouce.GetTimeString(scene.SceneDelayTime); + }; + + //寤舵椂鏃堕棿 + this.btnDelayTime = new NormalViewControl(400, 58, true); + btnDelayTime.X = Application.GetRealWidth(580); + btnDelayTime.Y = Application.GetRealHeight(317); + btnDelayTime.Text = CommonFormResouce.GetTimeString(scene.SceneDelayTime); btnDelayTime.TextAlignment = TextAlignment.CenterRight; - btnDelayTime.TextColor = ZigbeeColor.Current.GXCTextSelectedColor3; - btnDelayTime.IsBold = true; - this.AddChidren(btnDelayTime); - - //寤舵椂鍥炬爣 + btnDelayTime.TextColor = ZigbeeColor.Current.GXCTextSelectedColor3; + btnDelayTime.IsBold = true; + this.AddChidren(btnDelayTime); + + //寤舵椂鍥炬爣 this.btnDelayIcon = new IconViewControl(52); btnDelayIcon.X = Application.GetRealWidth(900); - btnDelayIcon.Y = Application.GetRealHeight(30); - btnDelayIcon.Width = Application.GetMinRealAverage(52); - btnDelayIcon.Height = Application.GetMinRealAverage(52); - btnDelayIcon.UnSelectedImagePath = "Scene/Delaying.png"; + btnDelayIcon.Y = Application.GetRealHeight(30); + btnDelayIcon.Width = this.GetPictrueRealSize(52); + btnDelayIcon.Height = this.GetPictrueRealSize(52); + btnDelayIcon.UnSelectedImagePath = "Scene/Delaying.png"; this.AddChidren(btnDelayIcon); btnDelayIcon.Visible = false; @@ -116,14 +116,14 @@ this.AddLeftView(btnTemp1); //瀹氭椂 var btnDelay = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false); - btnDelay.BackgroundColor = ZigbeeColor.Current.GXCTextSelectedColor; - btnDelay.TextID = R.MyInternationalizationString.Delay; - btnDelay.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; - btnDelay.TextAlignment = TextAlignment.Center; - btnDelay.Tag = scene.SceneDelayTime; - btnDelay.Radius = (uint)Application.GetRealHeight(17); - btnDelay.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight | - HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); + btnDelay.BackgroundColor = ZigbeeColor.Current.GXCTextSelectedColor; + btnDelay.TextID = R.MyInternationalizationString.Delay; + btnDelay.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; + btnDelay.TextAlignment = TextAlignment.Center; + btnDelay.Tag = scene.SceneDelayTime; + btnDelay.Radius = (uint)Application.GetRealHeight(17); + btnDelay.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight | + HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); this.AddLeftView(btnDelay); //鍙樻洿鎸夐挳鐨勯珮搴� btnDelay.Height = sceneContr.btnScenePic.Height; @@ -131,23 +131,23 @@ //缂栬緫 var btnEditor = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false); - btnEditor.BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor; - btnEditor.TextID = R.MyInternationalizationString.Edit; - btnEditor.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; - btnEditor.TextAlignment = TextAlignment.Center; + btnEditor.BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor; + btnEditor.TextID = R.MyInternationalizationString.Edit; + btnEditor.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; + btnEditor.TextAlignment = TextAlignment.Center; btnEditor.Tag = scene.SceneDelayTime; btnEditor.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerTopLeft); //鍒犻櫎 - var btnDelete = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false); - btnDelete.Tag = scene; - btnDelete.BackgroundColor = ZigbeeColor.Current.GXCRedColor; - btnDelete.TextID = R.MyInternationalizationString.Delete; - btnDelete.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; - btnDelete.TextAlignment = TextAlignment.Center; + var btnDelete = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false); + btnDelete.Tag = scene; + btnDelete.BackgroundColor = ZigbeeColor.Current.GXCRedColor; + btnDelete.TextID = R.MyInternationalizationString.Delete; + btnDelete.TextColor = ZigbeeColor.Current.GXCTextWhiteColor; + btnDelete.TextAlignment = TextAlignment.Center; btnDelete.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight); - if (room.IsSharedRoom == false && room.IsLove == false) + if (room.IsSharedRoom == false && room.IsLove == false) { //涓嶆槸鍒嗕韩,骞朵笖涓嶆槸鏀惰棌 this.AddRightView(btnEditor); @@ -155,20 +155,28 @@ //鍙樻洿鎸夐挳鐨勯珮搴� btnEditor.Height = sceneContr.btnScenePic.Height; btnEditor.Y = 0; - btnDelete.Height = sceneContr.btnScenePic.Height; - btnDelete.Y = 0; - //娣诲姞鍙宠竟绌虹櫧鍖哄煙 + btnDelete.Height = sceneContr.btnScenePic.Height; + btnDelete.Y = 0; + //娣诲姞鍙宠竟绌虹櫧鍖哄煙 var btnTemp2 = new NormalViewControl(Application.GetRealWidth(58), sceneContr.btnScenePic.Height, false); - this.AddRightView(btnTemp2); - } - - //鍒犻櫎鍦烘櫙 + this.AddRightView(btnTemp2); + } + + //鍒犻櫎鍦烘櫙 btnDelete.ButtonClickEvent += (sender, e) => { var alert = new ShowMsgControl(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.ConfirmDelete)); alert.Show(); alert.ConfirmClickEvent += async () => { + //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + //绉婚櫎缂撳瓨 + HdlSceneLogic.Current.DeleteLocalScene(scene); + RemoveFromParent(); + return; + } //0 绉婚櫎澶辫触 1 绉婚櫎鎴愬姛 2 娌℃湁璇ュ満鏅� var removeSceneAllData = await ZigBee.Device.Scene.DeleteSceneAsync(scene.Id); if (removeSceneAllData == null || removeSceneAllData.removeSceneData == null) @@ -179,7 +187,7 @@ //1鎴愬姛 if (removeSceneAllData.removeSceneData.Result == 1) { - HdlSceneLogic.Current.RemoveScene(scene); + HdlSceneLogic.Current.DeleteLocalScene(scene); RemoveFromParent(); } //0 绉婚櫎澶辫触 @@ -191,128 +199,128 @@ //2 娌℃湁璇ュ満鏅� else if (removeSceneAllData.removeSceneData.Result == 2) { - HdlSceneLogic.Current.RemoveScene(scene); + HdlSceneLogic.Current.DeleteLocalScene(scene); RemoveFromParent(); return; } }; - }; - - //缂栬緫鍦烘櫙 - btnEditor.ButtonClickEvent += (sender, e) => - { - //鍏抽棴宸︽粦鑿滃崟 - this.HideMenu(); - //缂栬緫鍦烘櫙 - var form = new Phone.Category.AddOrEditorSceneForm(); - form.AddForm(i_scene); - form.SceneChangedEvent = (myScene, roomId) => - { - if (roomId != room.Id) - { - //瀹冨彉鏇翠簡鎴块棿 - this.RemoveFromParent(); - } - else - { - this.InitControl(myScene, room); - } - }; - }; - //缂栬緫寤舵椂 - btnDelay.ButtonClickEvent += (sender, e) => - { - if (scene.RemainTime > 0) - { - CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying)); - return; - } - var timeSelect = new SelectTime(); - CommonPage.Instance.AddChidren(timeSelect); - timeSelect.TempTime = scene.SceneDelayTime; - timeSelect.Init(); - timeSelect.TimeAction = (t) => - { - //闅愯棌鍙冲垝鑿滃崟 - this.HideMenu(); - scene.SceneDelayTime = t; - btnDelayTime.Text = CommonFormResouce.GetTimeString(t); - }; + }; + + //缂栬緫鍦烘櫙 + btnEditor.ButtonClickEvent += (sender, e) => + { + //鍏抽棴宸︽粦鑿滃崟 + this.HideMenu(); + //缂栬緫鍦烘櫙 + var form = new Phone.Category.AddOrEditorSceneForm(); + form.AddForm(i_scene); + form.SceneChangedEvent = (myScene, roomId) => + { + if (roomId != room.Id) + { + //瀹冨彉鏇翠簡鎴块棿 + this.RemoveFromParent(); + } + else + { + this.InitControl(myScene, room); + } + }; + }; + //缂栬緫寤舵椂 + btnDelay.ButtonClickEvent += (sender, e) => + { + if (scene.RemainTime > 0) + { + CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying)); + return; + } + var timeSelect = new SelectTime(); + CommonPage.Instance.AddChidren(timeSelect); + timeSelect.TempTime = scene.SceneDelayTime; + timeSelect.Init(); + timeSelect.TimeAction = (t) => + { + //闅愯棌鍙冲垝鑿滃崟 + this.HideMenu(); + scene.SceneDelayTime = t; + btnDelayTime.Text = CommonFormResouce.GetTimeString(t); + }; }; } - #endregion - + #endregion + /// <summary> /// /// </summary> /// <param name="btnScenePic"></param> - /// <param name="btnSceneName"></param> - private async void SceneUpHandler() - { + /// <param name="btnSceneName"></param> + private async void SceneUpHandler() + { if (scene.SceneDelayTime <= 0 && scene.RemainTime <= 0) { //濡傛灉娌℃湁寤惰繜鐨勮瘽,鐩存帴寮�鍚疞oading鐗规晥 this.StartLoadingApreal(); - } - //璋冪敤鍦烘櫙 - var result = await HdlSceneLogic.Current.ControlScene(scene); - if (result == false) - { - return; - } - - scene.RemainTime = scene.SceneDelayTime; - scene.SceneDelayTime = 0; + } + //璋冪敤鍦烘櫙 + var result = await HdlSceneLogic.Current.ControlScene(scene); + if (result == false) + { + return; + } + + scene.RemainTime = scene.SceneDelayTime; + scene.SceneDelayTime = 0; if (scene.RemainTime <= 0) { return; - } + } int myRemainTime = scene.RemainTime; //寮�鍚唴閮ㄥ欢鏃舵椂闂寸嚎绋�(鏃ㄥ湪鍏ㄩ儴鍦版柟鐨勫悓涓�鍦烘櫙鏃堕棿鍚屾) - HdlSceneLogic.Current.StartDelayTimeThread(scene); - - new System.Threading.Thread(() => - { - while (myRemainTime > 0 && this.Parent != null) - { - System.Threading.Thread.Sleep(1000); - Application.RunOnMainThread(() => - { - SetTimeText(CommonFormResouce.GetTimeString(scene.RemainTime)); - }); - myRemainTime--; - } - Application.RunOnMainThread(() => - { + HdlSceneLogic.Current.StartDelayTimeThread(scene); + + new System.Threading.Thread(() => + { + while (myRemainTime > 0 && this.Parent != null) + { + System.Threading.Thread.Sleep(1000); + Application.RunOnMainThread(() => + { + SetTimeText(CommonFormResouce.GetTimeString(scene.RemainTime)); + }); + myRemainTime--; + } + Application.RunOnMainThread(() => + { if (this.Parent != null) { SetTimeImage(); //鐩存帴寮�鍚疞oading鐗规晥 this.StartLoadingApreal(); - } - }); - }) - { IsBackground = true }.Start(); - } - - /// <summary> - /// SetTimeText - /// </summary> - /// <param name="name"></param> - public void SetTimeText(string name) - { - btnDelayIcon.Visible = true; - btnDelayTime.Text = name; - } - - /// <summary> - /// SetTimeImage - /// </summary> - public void SetTimeImage() - { - btnDelayIcon.Visible = false; - btnDelayTime.Text = string.Empty; + } + }); + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// SetTimeText + /// </summary> + /// <param name="name"></param> + public void SetTimeText(string name) + { + btnDelayIcon.Visible = true; + btnDelayTime.Text = name; + } + + /// <summary> + /// SetTimeImage + /// </summary> + public void SetTimeImage() + { + btnDelayIcon.Visible = false; + btnDelayTime.Text = string.Empty; } /// <summary> @@ -349,8 +357,8 @@ frameBack1.RemoveFromParent(); frameBack2.RemoveFromParent(); }; - } - + } + /// <summary> /// 鑷畾涔夋帶浠�(闇�瑕佺殑瀹冪Щ闄や簨浠�) /// </summary> @@ -370,6 +378,6 @@ this.DisponeEvent?.Invoke(); this.DisponeEvent = null; } - } - } -} + } + } +} -- Gitblit v1.8.0