From c2348ebb81ca12b72eee6fbe9eee47925c1a5b07 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 06 九月 2023 12:02:54 +0800 Subject: [PATCH] Merge branch 'wxr-2.1' into wxr-2.0 --- HDL-ON_Android/Properties/AndroidManifest.xml | 2 HDL_ON/UI/UI2/1-HomePage/HomePage.cs | 84 +-- HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs | 208 ++++++--- HDL-ON_iOS/HDL-ON_iOS.csproj | 1 HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs | 8 HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs | 120 ++++- HDL_ON/DAL/Mqtt/MqttClient.cs | 2 HDL-ON_Android/HDL-ON_Android.csproj | 7 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs | 18 HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs | 82 ++++ HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs | 165 +++++-- HDL_ON/Entity/Function/Function.cs | 5 HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png | 0 HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs | 179 +++++--- HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs | 3 HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs | 172 +++++--- HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs | 14 HDL_ON/DAL/Server/HttpServerRequest.cs | 1 HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs | 74 +++ HDL_ON/DAL/DriverLayer/Control.cs | 30 HDL_ON/UI/MainPage.cs | 3 HDL_ON/UI/UI1-Login/LoginPage.cs | 4 HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png | 0 23 files changed, 784 insertions(+), 398 deletions(-) diff --git a/HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png b/HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png new file mode 100644 index 0000000..ecfcb33 --- /dev/null +++ b/HDL-ON_Android/Assets/Phone/Collection/GatewayOnlineTipIcon.png Binary files differ diff --git a/HDL-ON_Android/HDL-ON_Android.csproj b/HDL-ON_Android/HDL-ON_Android.csproj index f71fe68..9a632bf 100644 --- a/HDL-ON_Android/HDL-ON_Android.csproj +++ b/HDL-ON_Android/HDL-ON_Android.csproj @@ -598,6 +598,13 @@ <AndroidAsset Include="Assets\Phone\HisenseTv\yingliangjiaSelected.png" /> <AndroidAsset Include="Assets\Phone\FunctionIcon\EnvirSensor\IlluminationBg.png" /> <AndroidAsset Include="Assets\Phone\FunctionIcon\EnvirSensor\IlluminationIcon.png" /> + <AndroidAsset Include="Assets\h5\static\js\pages-index-index~pages-inverter-index.0253e8cd.js" /> + <AndroidAsset Include="Assets\h5\static\img\inverter-center.18b181f4.png" /> + <AndroidAsset Include="Assets\h5\static\img\co2-reduction-ic.9c75228c.png" /> + <AndroidAsset Include="Assets\h5\static\img\equal-plant-ic.7ef6befa.png" /> + <AndroidAsset Include="Assets\h5\static\img\coal-save-ic.6c5fd125.png" /> + <AndroidAsset Include="Assets\h5\static\font\SourceHanSansCN-Normal.otf" /> + <AndroidAsset Include="Assets\Phone\Collection\GatewayOnlineTipIcon.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\colors.xml" /> diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml index eac25b1..340f490 100644 --- a/HDL-ON_Android/Properties/AndroidManifest.xml +++ b/HDL-ON_Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@ 锘�<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.1.2" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202308171"> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.1.2" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202308281"> <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="29" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <!--鍙嬬洘--> diff --git a/HDL-ON_iOS/HDL-ON_iOS.csproj b/HDL-ON_iOS/HDL-ON_iOS.csproj index 0ddf75d..2f43e76 100644 --- a/HDL-ON_iOS/HDL-ON_iOS.csproj +++ b/HDL-ON_iOS/HDL-ON_iOS.csproj @@ -1752,6 +1752,7 @@ <BundleResource Include="Resources\Phone\HisenseTv\yingliangjiaSelected.png" /> <BundleResource Include="Resources\Phone\FunctionIcon\EnvirSensor\IlluminationBg.png" /> <BundleResource Include="Resources\Phone\FunctionIcon\EnvirSensor\IlluminationIcon.png" /> + <BundleResource Include="Resources\Phone\Collection\GatewayOnlineTipIcon.png" /> </ItemGroup> <ItemGroup> <ITunesArtwork Include="iTunesArtwork" /> diff --git a/HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png b/HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png new file mode 100644 index 0000000..ecfcb33 --- /dev/null +++ b/HDL-ON_iOS/Resources/Phone/Collection/GatewayOnlineTipIcon.png Binary files differ diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index 85737d2..6955fab 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -732,8 +732,18 @@ } else { - var pm = new DAL.Server.HttpServerRequest(); - var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); + var pm = new HttpServerRequest(); + try + { + pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); + }catch(Exception ex) + { + MainPage.Log($"杩滅▼璇诲彇璁惧鐘舵�佸紓甯�:{ex.Message}"); + } + finally + { + pm = null; + } } } } @@ -1312,16 +1322,6 @@ } MainPage.Log(localFunction.name); - if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞� - { - if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains(localFunction.spk)) - { - //MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�........"); - - return; - } - } - //if (SPK.MusicSpkList().Contains(localFunction.spk)) //{ // if (updateTemp.status.Count < 3) @@ -1342,6 +1342,11 @@ { localFunction.online = updateTemp.online; } + if (SPK.LightSpkList().Contains(localFunction.spk)) + { + localFunction.updateTime = DateTime.Now; + } + //鏇存柊鐣岄潰鐘舵�� switch (localFunction.spk) @@ -1606,6 +1611,7 @@ break; } + HomePage.UpdataFunctionStates(localFunction); RoomPage.UpdataStates(localFunction); FunctionPage.UpdataStates(localFunction); diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index 3b1d20a..9c11563 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -553,7 +553,7 @@ { var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); var revString = Encoding.UTF8.GetString(bytes); - MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}"); + //MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}"); Control.Ins.UpdataFunctionStatus(revString, null, true); //Control.Ins.MsgInfoList.Add($"mqtt 鐘舵�佹洿鏂�:{revString}"); //Control.Ins.MsgInfoList.Add(revString + "\r\n"); diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs index 25c2273..a3038f6 100644 --- a/HDL_ON/DAL/Server/HttpServerRequest.cs +++ b/HDL_ON/DAL/Server/HttpServerRequest.cs @@ -3649,7 +3649,6 @@ var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetGroupControlInfos, requestJson); return pack; } - /// <summary> /// 鑾峰彇缇ゆ帶璇︽儏 /// </summary> diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index afb0f09..b8a2894 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -1060,6 +1060,11 @@ /// 鏇存柊鏃堕棿 /// </summary> public DateTime refreshTime = DateTime.MinValue; + /// <summary> + /// 鏈�鍚庢洿鏂扮姸鎬佺殑鏃堕棿 + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public DateTime updateTime = DateTime.MinValue; /// <summary> /// 鑾峰彇鏈湴鎺у埗鏁版嵁 diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs index e704e17..ddf24dc 100644 --- a/HDL_ON/UI/MainPage.cs +++ b/HDL_ON/UI/MainPage.cs @@ -634,7 +634,8 @@ || msg.Contains("鍙戦��") || msg.Contains("鎺ユ敹鍒版帹閫�") || msg.Contains("api") - + || msg.Contains("璇诲彇鍔熻兘鐘舵��") + //|| true ) Console.WriteLine(msg); #endif diff --git a/HDL_ON/UI/UI1-Login/LoginPage.cs b/HDL_ON/UI/UI1-Login/LoginPage.cs index ebf1170..5662f9d 100644 --- a/HDL_ON/UI/UI1-Login/LoginPage.cs +++ b/HDL_ON/UI/UI1-Login/LoginPage.cs @@ -311,7 +311,6 @@ //etAccount.Text = "18244942707"; //etAccount.Text = "13143792049"; etAccount.Text = "18688414428";//澶╂渤3妤� - //etAccount.Text = "18244942707"; //etAccount.Text = "13418062953"; etAccount.Text = "13138683659"; //etAccount.Text = "15217626103"; @@ -326,6 +325,7 @@ etAccount.Text = "pjh@hdlchina.com.cn"; //etAccount.Text = "12345678904";//2.0 娴嬭瘯 钀ょ煶 etAccount.Text = "18316672920"; + etAccount.Text = "18244942707"; } else { @@ -386,7 +386,7 @@ }; #endif -#region 鐧诲綍鏂瑰紡閫夋嫨 + #region 鐧诲綍鏂瑰紡閫夋嫨 btnPhoneLogin = new Button() { X = Application.GetRealWidth(28), diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs index eb216d9..2257bfa 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs @@ -30,7 +30,7 @@ /// <summary> /// 杩炴帴鐘舵�佹彁绀� /// </summary> - Button btnLinkStateTip; + FrameLayout divLinkStateTip; /// <summary> /// 瀹夐槻鐘舵�佸浘鏍� /// </summary> @@ -213,69 +213,35 @@ IsBold = true }; topView.AddChidren(btnResidenceName); - btnLinkStateTip = new Button() + + divLinkStateTip = new FrameLayout() { - //X = Application.GetRealWidth(16), - Y = btnResidenceName.Bottom, - Height = Application.GetRealWidth(14), - //BackgroundColor = CSS_Color.LinkTipFail, - TextAlignment = TextAlignment.Center, + Y = Application.GetRealHeight(113) - Application.GetRealWidth(24), + Height = Application.GetRealWidth(24), + BackgroundColor = 0xFFFF4747, + Visible = false, + }; + topView.AddChidren(divLinkStateTip); + Button btnLinkStateIcon = new Button() + { + X = Application.GetRealWidth(16), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth(20), + Height = Application.GetRealWidth(20), + UnSelectedImagePath = "Collection/GatewayOnlineTipIcon.png" + }; + divLinkStateTip.AddChidren(btnLinkStateIcon); + + var btnLinkStateTip = new Button() + { + X = btnLinkStateIcon.Right + Application.GetRealWidth(4), + TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextColor = CSS_Color.MainBackgroundColor, + TextID = StringId.NetworkAnomaly, }; - topView.AddChidren(btnLinkStateTip); - //btnLinkStateTip.Width = btnLinkStateTip.GetTextWidth(); + divLinkStateTip.AddChidren(btnLinkStateTip); //鏇存柊閾炬帴鐘舵�乮con棰滆壊 - - -#if DEBUG - int ddd = 0; - btnResidenceName.MouseUpEventHandler = (sender, e) => - { - //827a98c98da7469b8bc19bb6a3c7651906 - //St_00009073b431d8b2490c9df0c5cb0e73 - //Com.Hdl.HdlToLc.InitData(Shared.Application.Activity,false, "827a98c98da7469b8bc19bb6a3c7651906"); - //Com.Hdl.HdlToLc.OpenActivity(); - //new System.Threading.Thread(() => - //{ - // var http = new HttpServerRequest(); - // var pack = http.GetLcSubAccountToken(); - // if (pack.Code == StateCode.SUCCESS) - // { - // if(pack.Data == null || string.IsNullOrEmpty(pack.Data.ToString())) - // { - // Application.RunOnMainThread(() => - // { - // new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), Language.StringByID(StringId.huoqushujushibao)); - // }); - // } - // Com.Utils.HdlToLcUtils.Instance.HomeId = DB_ResidenceData.Instance.CurrentRegion.id; - // Com.Utils.HdlToLcUtils.Instance.Token = UserInfo.Current.AccessToken; - // Com.Utils.HdlToLcUtils.Instance.SubAccessToken = pack.Data.ToString(); - // Application.RunOnMainThread(() => - // { - // //Com.Utils.HdlToLcUtils.Instance.OpenActivity(); - // //Com.Utils.HdlToLcUtils.Instance.Play() - // var backTemp = new AddLcCam(); - // backTemp.backAction = () => - // { - // //Load3tyBrandDeviceList(); - // }; - // Com.Utils.HdlToLcUtils.Instance.AddCamera(backTemp); - // }); - // } - // else - // { - // Application.RunOnMainThread(() => - // { - // new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), Language.StringByID(StringId.huoqushujushibao) + $"({pack.Code})"); - // }); - // } - //}) - //{ IsBackground = true }.Start(); - }; -#endif - environmentalView = new FrameLayout() { Y = Application.GetRealHeight(1) + btnResidenceName.Bottom, diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs index fa26fd2..34599ea 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs @@ -269,15 +269,15 @@ if (!Control.Ins.GatewayOnline_Local && !Control.Ins.GatewayOnline_Cloud) { - bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.LinkTipFail; - bodyView.btnLinkStateTip.TextID = StringId.NetworkAnomaly; - bodyView.environmentalView.Y = Application.GetRealHeight(8) + btnResidenceName.Bottom; + bodyView.divLinkStateTip.Visible = true; } + //else if () + //{ + // bodyView.divLinkStateTip.Visible = true; + //} else { - bodyView.btnLinkStateTip.BackgroundColor = 0x00000000; - bodyView.btnLinkStateTip.Text = ""; - bodyView.environmentalView.Y = Application.GetRealHeight(1) + btnResidenceName.Bottom; + bodyView.divLinkStateTip.Visible = false; } } @@ -351,11 +351,17 @@ } } + object lockObj = new object(); + /// <summary> /// 鏇存柊鏄剧ず鐘舵�� /// </summary> public static void UpdataFunctionStates(Function function) { + if(bodyView == null) + { + return; + } Application.RunOnMainThread(() => { try diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs index 8e87e01..0069a00 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs @@ -4,13 +4,85 @@ { public partial class FunctionPage { + System.Threading.Thread updateUiThread; + object lockObj = new object(); /// <summary> /// 鏇存柊鍔熻兘鍒楄〃鐣岄潰鍔熻兘鐘舵�� /// </summary> /// <param name="function"></param> public static void UpdataStates(Function function) { - new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView); + try + { + if (bodyView == null) + { + return; + } + //if (SPK.LightSpkList().Contains(function.spk)) + //{ + + // { + // var localFunction = FunctionList.List.GetLightList().Find((obj) => obj.sid == function.sid); + // { + // if (localFunction != null) + // { + // if (bodyView.updateUiThread == null) + // { + // bodyView.updateUiThread = new System.Threading.Thread(() => + // { + // lock (bodyView.lockObj) + // { + // if (bodyView.updateUiThread == null) + // { + // MainPage.Log("绾跨▼琚疆绌轰簡锛侊紒"); + // return; + // } + // try + // { + // while (true) + // { + // System.Threading.Thread.Sleep(1500); + // if (bodyView == null) + // { + // return; + // } + // if (DateTime.Now.AddMilliseconds(-1500) > localFunction.updateTime) + // { + // MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI"); + // break; + // } + // else + // { + // MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�"); + // } + // } + // new ClassificaitionPublicBLL().UpdataStates(localFunction, bodyView, functionListView); + // } + // catch (Exception ex) + // { + // MainPage.Log("FunctionPage UpdateStates error 2 :" + ex.Message); + // } + // finally + // { + // //bodyView.updateUiThread = null; + // } + // } + // }); + // bodyView.updateUiThread.IsBackground = true; + // bodyView.updateUiThread.Start(); + // } + // } + // } + // } + //} + //else + { + new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView); + } + }catch(Exception ex) + { + MainPage.Log("FunctionPage UpdateStates error " + ex.Message); + } } public static void UpdataOnline(Function function) diff --git a/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs index 5323666..5435079 100644 --- a/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs @@ -6,13 +6,93 @@ { public partial class RoomPage { + System.Threading.Thread updateUiThread; + object lockObj = new object(); /// <summary> /// 鏇存柊鍔熻兘鐘舵�� /// </summary> /// <param name="function"></param> public static void UpdataStates(Function function) { - new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room); + + try + { + if (bodyView == null) + { + return; + } + //if (SPK.LightSpkList().Contains(function.spk)) + //{ + // { + // var localFunction = FunctionList.List.GetLightList().Find((obj) => obj.sid == function.sid); + // { + // if (localFunction != null) + // { + // if (bodyView.updateUiThread == null) + // { + // bodyView.updateUiThread = new System.Threading.Thread(() => + // { + // lock (bodyView.lockObj) + // { + // try + // { + // while (true) + // { + // try + // { + // System.Threading.Thread.Sleep(1500); + // if (bodyView == null) + // { + // return; + // } + // if (bodyView.updateUiThread == null) + // { + // return; + // } + // if (DateTime.Now.AddMilliseconds(-1500) > localFunction.updateTime) + // { + // MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI"); + // break; + // } + // else + // { + // MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�"); + // } + // } + // catch (Exception ex) + // { + // MainPage.Log("绾跨▼寮傚父:" + ex.Message); + // } + // } + // new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView, room); + // } + // catch (Exception ex) + // { + // MainPage.Log("FunctionPage UpdateStates error 2 :" + ex.Message); + // } + // finally + // { + // //bodyView.updateUiThread = null; + // } + // } + // }); + // bodyView.updateUiThread.IsBackground = true; + // bodyView.updateUiThread.Start(); + // } + // } + // } + // } + //} + //else + { + new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room); + } + } + catch (Exception ex) + { + MainPage.Log("FunctionPage UpdateStates error " + ex.Message); + } + } public static void UpdataOnline(Function function) { diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs index f75ceef..62dc7d0 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs @@ -79,13 +79,13 @@ if (sceneFunction.localFunction.spk == SPK.LightRGB || sceneFunction.localFunction.spk == SPK.GroupControl) { - //var colorfulStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful); - //if (colorfulStatus != null) - //{ - // isColorful = true; - // LoadColorfulRow(colorfulStatus); - // isColorful = colorfulStatus.value == "on"; - //} + var colorfulStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Colorful); + if (colorfulStatus != null) + { + isColorful = true; + LoadColorfulRow(colorfulStatus); + isColorful = colorfulStatus.value == "on"; + } } foreach (var attr in sceneFunction.status) { diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs index b5f70fd..1066e2f 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs @@ -441,92 +441,137 @@ MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}"); } } - try + var waitPage = new Loading(); + bodyView.AddChidren(waitPage); + waitPage.Start(""); + new Thread(() => { - groupControl.type = groupControlType.type; - groupControl.sid = groupControl.NewGroupControlSid(); - var pack = Common.ApiUtlis.Ins.HttpRequest.AddGroupControl(new List<GroupControl>() { groupControl }); - if (pack != null) + try { - if (pack.Code == StateCode.SUCCESS) + groupControl.type = groupControlType.type; + groupControl.sid = groupControl.NewGroupControlSid(); + var pack = ApiUtlis.Ins.HttpRequest.AddGroupControl(new List<GroupControl>() { groupControl }); + if (pack != null) { + if (pack.Code == StateCode.SUCCESS) + { + try + { + var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString()); + if (addTemp != null && addTemp.Count > 0) + groupControl.userDeviceGroupControlId = addTemp[0].userDeviceGroupControlId; + FunctionList.List.groupControls.Add(groupControl); + } + catch (Exception ex) + { + MainPage.Log($"娣诲姞缇ゆ帶寮傚父锛岃浆璇戣繑鍥炴暟鎹け璐�:{ex.Message}"); + } + Application.RunOnMainThread(() => + { + addActon?.Invoke(groupControl); + this.RemoveFromParent(); + }); + } + else + { + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + } + } + + } + catch (Exception ex) + { + MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}"); + } + finally + { + Application.RunOnMainThread(() => { try { - var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString()); - if (addTemp != null && addTemp.Count > 0) - groupControl.userDeviceGroupControlId = addTemp[0].userDeviceGroupControlId; - FunctionList.List.groupControls.Add(groupControl); + waitPage.Hide(); + waitPage = null; } - catch (Exception ex) - { - MainPage.Log($"娣诲姞缇ゆ帶寮傚父锛岃浆璇戣繑鍥炴暟鎹け璐�:{ex.Message}"); - } - addActon?.Invoke(groupControl); - this.RemoveFromParent(); - } - else - { - IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); - } + catch { } + }); } - } - catch (Exception ex) - { - MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}"); - } + }) + { IsBackground = true }.Start(); } else { - try + var waitPage = new Loading(); + bodyView.AddChidren(waitPage); + waitPage.Start(""); + new Thread(() => { - //var newEditDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl); - //var newEditDataString1 = Newtonsoft.Json.JsonConvert.SerializeObject(groupControlLightList); - //var newEditDataString2 = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl.sids); - ////娌℃湁鏇存柊鏁版嵁鍒欑洿鎺ラ��鍑� - //if (newEditDataString == editDataString && newEditDataString1 == newEditDataString2) - //{ - // this.RemoveFromParent(); - // return; - //} - groupControl.sids.Clear(); - foreach (var light in groupControlLightList) + try { - try + //var newEditDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl); + //var newEditDataString1 = Newtonsoft.Json.JsonConvert.SerializeObject(groupControlLightList); + //var newEditDataString2 = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl.sids); + ////娌℃湁鏇存柊鏁版嵁鍒欑洿鎺ラ��鍑� + //if (newEditDataString == editDataString && newEditDataString1 == newEditDataString2) + //{ + // this.RemoveFromParent(); + // return; + //} + groupControl.sids.Clear(); + foreach (var light in groupControlLightList) { - var gc = new GroupControlFunction(); - gc.sid = light.sid; - gc.spk = light.spk; - groupControl.sids.Add(gc); - } - catch (Exception ex) - { - MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}"); - } - } - - var pack = Common.ApiUtlis.Ins.HttpRequest.EditGroupControl(new List<GroupControl>() { groupControl }); - if (pack != null) - { - if (pack.Code == StateCode.SUCCESS) - { - var temp = FunctionList.List.groupControls.Find((obj) => obj.userDeviceGroupControlId == groupControl.userDeviceGroupControlId); - if(temp!= null) + try { - temp = groupControl; + var gc = new GroupControlFunction(); + gc.sid = light.sid; + gc.spk = light.spk; + groupControl.sids.Add(gc); } - addActon?.Invoke(temp); - this.RemoveFromParent(); + catch (Exception ex) + { + MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}"); + } } - else + + var pack = ApiUtlis.Ins.HttpRequest.EditGroupControl(new List<GroupControl>() { groupControl }); + if (pack != null) { - IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + if (pack.Code == StateCode.SUCCESS) + { + var temp = FunctionList.List.groupControls.Find((obj) => obj.userDeviceGroupControlId == groupControl.userDeviceGroupControlId); + if (temp != null) + { + temp = groupControl; + } + Application.RunOnMainThread(() => + { + addActon?.Invoke(temp); + this.RemoveFromParent(); + }); + } + else + { + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + } } } - } - catch (Exception ex) - { - MainPage.Log($"缂栬緫缇ゆ帶寮傚父:{ex.Message}"); - } + catch (Exception ex) + { + MainPage.Log($"缂栬緫缇ゆ帶寮傚父:{ex.Message}"); + } + finally + { + Application.RunOnMainThread(() => + { + try + { + waitPage.Hide(); + waitPage = null; + } + catch { } + }); + + } + }) + { IsBackground = true }.Start(); } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs index ad7b605..c9d675a 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs @@ -6,52 +6,99 @@ namespace HDL_ON.UI { public partial class ColorTureLampPage - { + { + /// <summary> + /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂� + /// </summary> + DateTime notiyUpdateTime = DateTime.MinValue; + System.Threading.Thread updateUiThread; + object lockObj = new object(); /// <summary> /// 鏇存柊鍔熻兘鐘舵�� /// </summary> public static void UpdataStatus(Function updataTemp) - { - Application.RunOnMainThread(() => - { - try - { - if (bodyView == null) - return; - if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid) - { - if (updataTemp.trait_on_off.curValue.ToString() == "on") - { - bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); - if (!bodyView.onDimmerBar) - { - bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness)); - } - if (updataTemp.GetAttrState(FunctionAttributeKey.Brightness) != "0") - { - bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%"; - bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); - } - } - else - { - bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor); - } - bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on"; - bodyView.barColorTemplatrue.Enable = updataTemp.trait_on_off.curValue.ToString() == "on"; - var cct = 27; - int.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CCT), out cct); - bodyView.barColorTemplatrue.Progress = cct / 100; - //璁剧疆鍒濆鍊� - bodyView.barColorTemplatrue.SetCustomText(bodyView.barColorTemplatrue.Progress * 100 + "K"); - - } - } - catch (Exception ex) - { - MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}"); - } - }); + { + if(bodyView == null) + { + return; + } + lock (bodyView.lockObj) + { + MainPage.Log($"鏀跺埌鏇存柊" + DateTime.Now.Ticks); + bodyView.notiyUpdateTime = DateTime.Now; + if (bodyView.updateUiThread == null) + { + bodyView.updateUiThread = new System.Threading.Thread(() => + { + while (true) + { + System.Threading.Thread.Sleep(1500); + if (bodyView == null) + { + return; + } + if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime) + { + MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI"); + break; + } + else + { + MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�"); + } + } + + Application.RunOnMainThread(() => + { + try + { + if (bodyView == null) + return; + if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid) + { + if (updataTemp.trait_on_off.curValue.ToString() == "on") + { + bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); + if (!bodyView.onDimmerBar) + { + bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness)); + } + if (updataTemp.GetAttrState(FunctionAttributeKey.Brightness) != "0") + { + bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%"; + bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); + } + } + else + { + bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor); + } + bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on"; + bodyView.barColorTemplatrue.Enable = updataTemp.trait_on_off.curValue.ToString() == "on"; + var cct = 27; + int.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CCT), out cct); + bodyView.barColorTemplatrue.Progress = cct / 100; + //璁剧疆鍒濆鍊� + bodyView.barColorTemplatrue.SetCustomText(bodyView.barColorTemplatrue.Progress * 100 + "K"); + + } + } + catch (Exception ex) + { + MainPage.Log($"{bodyView.GetType().Name} UpdataStates error : {ex.Message}"); + } + finally + { + bodyView.updateUiThread = null; + } + + }); + + bodyView.updateUiThread.IsBackground = true; + bodyView.updateUiThread.Start(); + }); + } + } } void LoadEventList() @@ -181,9 +228,9 @@ curDimmerStatus = onDimmerBar = true; }; dimmerBar.OnProgressChangedEvent = (sender, e) => - { - //dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); - if (!btnSwitch.IsSelected) + { + //dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); + if (!btnSwitch.IsSelected) { dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); } @@ -196,20 +243,20 @@ d.Add(FunctionAttributeKey.Brightness, e.ToString()); Control.Ins.SendWriteCommand(function, d); } - else - { - if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) - { - function.refreshTime = DateTime.Now; - new System.Threading.Thread(() => - { - System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); - d.Add(FunctionAttributeKey.Brightness, e.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - } - } + //else + //{ + // if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) + // { + // function.refreshTime = DateTime.Now; + // new System.Threading.Thread(() => + // { + // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + // d.Add(FunctionAttributeKey.Brightness, e.ToString()); + // Control.Ins.SendWriteCommand(function, d); + // }) + // { IsBackground = true }.Start(); + // } + //} btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs index 4a6cf52..765396b 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs @@ -8,40 +8,87 @@ public partial class DimmerPage { /// <summary> + /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂� + /// </summary> + DateTime notiyUpdateTime = DateTime.MinValue; + System.Threading.Thread updateUiThread; + object lockObj = new object(); + + /// <summary> /// 鏇存柊鍔熻兘鐘舵�� /// </summary> public static void UpdataStates(Function updataTemp) { - Application.RunOnMainThread((() => + if (bodyView == null) { - try + return; + } + lock (bodyView.lockObj) + { + MainPage.Log($"鏀跺埌鏇存柊" + DateTime.Now.Ticks); + bodyView.notiyUpdateTime = DateTime.Now; + if (bodyView.updateUiThread == null) { - if (bodyView == null) - return; - if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid) + bodyView.updateUiThread = new System.Threading.Thread(() => { - bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%"; - if (updataTemp.trait_on_off.curValue.ToString() == "on") + while (true) { - bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); - if (!bodyView.onDimmerBar) + System.Threading.Thread.Sleep(1500); + if (bodyView == null) { - bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness)); - bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40); + return; + } + if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime) + { + MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI"); + break; + } + else + { + MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�"); } } - else - { - bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor); - } - bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on"; - } + + Application.RunOnMainThread(() =>{ + try + { + if (bodyView == null) + return; + if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid) + { + bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%"; + if (updataTemp.trait_on_off.curValue.ToString() == "on") + { + bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); + if (!bodyView.onDimmerBar) + { + bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness)); + bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40); + } + } + else + { + bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor); + } + bodyView.btnSwitch.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on"; + } + } + catch (Exception ex) + { + MainPage.Log($"{bodyView.GetType().Name} UpdataStates error : {ex.Message}"); + } + finally + { + bodyView.updateUiThread = null; + } + }); + + + bodyView.updateUiThread.IsBackground = true; + bodyView.updateUiThread.Start(); + }); } - catch (Exception ex) - { - MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}"); - } - })); + } } void LoadEventList() @@ -117,7 +164,6 @@ //20201223 鍒犻櫎婊戝姩鍙戦�佸懡浠わ紝闃叉鎺т欢璺冲姩 dimmerBar.OnProgressChangedEvent = (sender, e) => { - if (!btnSwitch.IsSelected) { dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); @@ -132,20 +178,20 @@ d.Add(FunctionAttributeKey.Brightness, e.ToString()); Control.Ins.SendWriteCommand(function, d); } - else - { - if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) - { - function.refreshTime = DateTime.Now; - new System.Threading.Thread(() => - { - System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>(); - dic.Add(FunctionAttributeKey.Brightness, e.ToString()); - Control.Ins.SendWriteCommand(function, dic); - }) - { IsBackground = true }.Start(); - } - } + //else + //{ + // if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) + // { + // function.refreshTime = DateTime.Now; + // new System.Threading.Thread(() => + // { + // System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>(); + // dic.Add(FunctionAttributeKey.Brightness, e.ToString()); + // Control.Ins.SendWriteCommand(function, dic); + // }) + // { IsBackground = true }.Start(); + // } + //} btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40); btnBrightnessText.Text = dimmerBar.Progress + "%"; }; diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs index 8269b50..c48a8d5 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs @@ -349,6 +349,7 @@ dimmerBar.OnProgressChangedEvent = (sender, e) => { + return; if (e == 0 && lastBrightness != 0) { lastBrightness = 0; @@ -443,6 +444,7 @@ dimmerBar.OnProgressChangedEvent = (sender, e) => { + return; if (e == 0 && lastBrightness != 0) { lastBrightness = 0; @@ -764,6 +766,7 @@ dimmerBar.OnProgressChangedEvent = (sender, e) => { + return; if (e == 0 && lastBrightness != 0) { lastBrightness = 0; diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs index 51f0282..4560904 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs @@ -455,11 +455,12 @@ new TopViewDiv(bodyView, Language.StringByID(StringId.Lights)).LoadTopView_FunctionTop(function, actionRefresh); new System.Threading.Thread(() => { - DriverLayer.Control.Ins.SendReadCommand(function); + Control.Ins.SendReadCommand(function); }) { IsBackground = true }.Start(); - new System.Threading.Thread(() => { + new System.Threading.Thread(() => + { while (true) { System.Threading.Thread.Sleep(1000); @@ -473,7 +474,8 @@ } else { - DriverLayer.Control.Ins.SendReadCommand(function); + System.Threading.Thread.Sleep(1000); + Control.Ins.SendReadCommand(function); curDimmerStatus = true; } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs index 124ed5f..e60c686 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs @@ -7,78 +7,132 @@ public partial class RGBPage { /// <summary> + /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂� + /// </summary> + DateTime notiyUpdateTime = DateTime.MinValue; + System.Threading.Thread updateUiThread; + object lockObj = new object(); + + public override void RemoveFromParent() + { + bodyView = null; + base.RemoveFromParent(); + } + /// <summary> /// 鏇存柊鍔熻兘鐘舵�� /// </summary> public static void UpdataStates(Function updateTemp) { - Application.RunOnMainThread((() => + if(bodyView == null) { - try + return; + } + lock (bodyView.lockObj) + { + MainPage.Log($"鏀跺埌鏇存柊"+ DateTime.Now.Ticks); + bodyView.notiyUpdateTime = DateTime.Now; + if (bodyView.updateUiThread == null) { - if (bodyView == null) - return; - if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid) + bodyView.updateUiThread = new System.Threading.Thread(() => { + while (true) + { + System.Threading.Thread.Sleep(1500); + if(bodyView == null) + { + return; + } + if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime) + { + MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI"); + break; + } + else + { + MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�"); + } + } - if (updateTemp.trait_on_off.curValue.ToString() == "on") + Application.RunOnMainThread((() => { - //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� - if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png") + try { - bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; - } - bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1; - bodyView.btnSwitch.IsSelected = true; - if (!bodyView.onDimmerBar) - { - bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness)); - } - } - //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘 - else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true) - { - //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� - if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png") - { - bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; - } - //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; - bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2; - bodyView.btnSwitch.IsSelected = false; - //鑹茬洏鐨勫渾鐐归殣钘� - bodyView.btnWhiteRound.Visible = false; - } - bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB))); - bodyView.lastColor = bodyView.lightTemp.GetRGBbytes(updateTemp); - if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000) - { - bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2; - } - else - { - bodyView.btnCurColor.BorderColor = 0x00000000; - } - try - { - var colorfulState = updateTemp.GetAttribute(FunctionAttributeKey.Colorful); - if (colorfulState != null) - { - if(bodyView.btnColorfulSwitch!= null) + if (bodyView == null) + return; + if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid) { - bodyView.btnColorfulSwitch.IsSelected = colorfulState.curValue.ToString() == "on"; + + if (updateTemp.trait_on_off.curValue.ToString() == "on") + { + //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� + if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png") + { + bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; + } + bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1; + bodyView.btnSwitch.IsSelected = true; + if (!bodyView.onDimmerBar) + { + bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness)); + } + } + //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘 + else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true) + { + //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� + if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png") + { + bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; + } + //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; + bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2; + bodyView.btnSwitch.IsSelected = false; + //鑹茬洏鐨勫渾鐐归殣钘� + bodyView.btnWhiteRound.Visible = false; + } + bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB))); + bodyView.lastColor = bodyView.lightTemp.GetRGBbytes(updateTemp); + if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGB)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000) + { + bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2; + } + else + { + bodyView.btnCurColor.BorderColor = 0x00000000; + } + try + { + var colorfulState = updateTemp.GetAttribute(FunctionAttributeKey.Colorful); + if (colorfulState != null) + { + if (bodyView.btnColorfulSwitch != null) + { + bodyView.btnColorfulSwitch.IsSelected = colorfulState.curValue.ToString() == "on"; + } + } + } + catch (Exception ex) + { + MainPage.Log($"鏇存柊RGB 鐐僵寮�鍏崇姸鎬佸紓甯�:{ex.Message}"); + } } } - }catch(Exception ex) - { - MainPage.Log($"鏇存柊RGB 鐐僵寮�鍏崇姸鎬佸紓甯�:{ex.Message}"); - } - } + catch (Exception ex) + { + MainPage.Log($"{bodyView.GetType().Name} UpdataStates error : {ex.Message}"); + } + finally + { + bodyView.updateUiThread = null; + } + })); + + }); + bodyView.updateUiThread.IsBackground = true; + bodyView.updateUiThread.Start(); } - catch (Exception ex) - { - MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}"); - } - })); + } + } @@ -263,25 +317,25 @@ d.Add(FunctionAttributeKey.Brightness, e.ToString()); Control.Ins.SendWriteCommand(function, d); } - else - { - if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) - { - function.refreshTime = DateTime.Now; - new System.Threading.Thread(() => - { - //Control.Send(CommandType_A.write, function); - System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); - d.Add(FunctionAttributeKey.Brightness, e.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - } - else - { - MainPage.Log("skip dimmer control!!"); - } - } + //else + //{ + // if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) + // { + // function.refreshTime = DateTime.Now; + // new System.Threading.Thread(() => + // { + // //Control.Send(CommandType_A.write, function); + // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + // d.Add(FunctionAttributeKey.Brightness, e.ToString()); + // Control.Ins.SendWriteCommand(function, d); + // }) + // { IsBackground = true }.Start(); + // } + // else + // { + // MainPage.Log("skip dimmer control!!"); + // } + //} }; } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs index c2bd28a..369d3b9 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/RGBWPageBLL.cs @@ -7,64 +7,110 @@ public partial class RGBWPage { /// <summary> + /// 閫氱煡鏇存柊鐣岄潰鐨勬椂闂� + /// </summary> + DateTime notiyUpdateTime = DateTime.MinValue; + System.Threading.Thread updateUiThread; + object lockObj = new object(); + /// <summary> /// 鏇存柊鍔熻兘鐘舵�� /// </summary> public static void UpdataStates(Function updateTemp) { - Application.RunOnMainThread((() => + if (bodyView == null) { - try + return; + } + lock (bodyView.lockObj) + { + MainPage.Log($"鏀跺埌鏇存柊" + DateTime.Now.Ticks); + bodyView.notiyUpdateTime = DateTime.Now; + if (bodyView.updateUiThread == null) { - if (bodyView == null) - return; - if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid) + bodyView.updateUiThread = new System.Threading.Thread(() => { + while (true) + { + System.Threading.Thread.Sleep(1500); + if (bodyView == null) + { + return; + } + if (DateTime.Now.AddMilliseconds(-1500) > bodyView.notiyUpdateTime) + { + MainPage.Log("娌℃湁鏂版暟鎹紝鏇存柊UI"); + break; + } + else + { + MainPage.Log("鏈夋柊鏁版嵁锛岀户缁瓑寰�"); + } + } + Application.RunOnMainThread(() => + { + try + { + if (bodyView == null) + return; + if (updateTemp.spk == bodyView.function.spk && updateTemp.sid == bodyView.function.sid) + { - if (updateTemp.trait_on_off.curValue.ToString() == "on") - { - //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� - if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png") - { - bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; + if (updateTemp.trait_on_off.curValue.ToString() == "on") + { + //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� + if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png") + { + bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; + } + bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1; + bodyView.btnSwitch.IsSelected = true; + if (!bodyView.onDimmerBar) + { + bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness)); + } + } + //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘 + else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true) + { + //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� + if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png") + { + bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; + } + //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; + bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2; + bodyView.btnSwitch.IsSelected = false; + //鑹茬洏鐨勫渾鐐归殣钘� + bodyView.btnWhiteRound.Visible = false; + } + bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW))); + bodyView.lastColor = bodyView.lightTemp.GetRGBWbytes(updateTemp); + if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000) + { + bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2; + } + else + { + bodyView.btnCurColor.BorderColor = 0x00000000; + } + } } - bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1; - bodyView.btnSwitch.IsSelected = true; - if (!bodyView.onDimmerBar) + catch (Exception ex) { - bodyView.dimmerBar.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.Brightness)); + MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}"); } - } - //鐘舵�佷竴鏍锋椂,涓嶅啀鍒锋柊瑙嗗浘 - else if (updateTemp.trait_on_off.curValue.ToString() == "off" && bodyView.btnSwitch.IsSelected == true) - { - //瑙e喅閮ㄥ垎瀹夊崜鎵嬫満锛屽埛鏂板浘鐗囨椂浼氬彉灏忛棶棰� - if (bodyView.colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png") + finally { - bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; + bodyView.updateUiThread = null; } - //bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; - bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2; - bodyView.btnSwitch.IsSelected = false; - //鑹茬洏鐨勫渾鐐归殣钘� - bodyView.btnWhiteRound.Visible = false; - } - bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW))); - bodyView.lastColor = bodyView.lightTemp.GetRGBWbytes(updateTemp); - if (bodyView.lightTemp.GetRGBcolor(updateTemp.GetAttrState(FunctionAttributeKey.RGBW)) == 16777215 && bodyView.btnCurColor.BorderColor != 0x00000000) - { - bodyView.btnCurColor.BorderColor = CSS.CSS_Color.PromptingColor2; - } - else - { - bodyView.btnCurColor.BorderColor = 0x00000000; - } - } + }); + + + bodyView.updateUiThread.IsBackground = true; + bodyView.updateUiThread.Start(); + }); } - catch (Exception ex) - { - MainPage.Log($"{bodyView.GetType().Name } UpdataStates error : {ex.Message}"); - } - })); + } } @@ -256,25 +302,25 @@ d.Add(FunctionAttributeKey.Brightness, e.ToString()); Control.Ins.SendWriteCommand(function, d); } - else - { - if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) - { - function.refreshTime = DateTime.Now; - new System.Threading.Thread(() => - { - //Control.Send(CommandType_A.write, function); - System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); - d.Add(FunctionAttributeKey.Brightness, e.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - } - else - { - MainPage.Log("skip dimmer control!!"); - } - } + //else + //{ + // if (350 < (DateTime.Now - function.refreshTime).TotalMilliseconds) + // { + // function.refreshTime = DateTime.Now; + // new System.Threading.Thread(() => + // { + // //Control.Send(CommandType_A.write, function); + // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + // d.Add(FunctionAttributeKey.Brightness, e.ToString()); + // Control.Ins.SendWriteCommand(function, d); + // }) + // { IsBackground = true }.Start(); + // } + // else + // { + // MainPage.Log("skip dimmer control!!"); + // } + //} }; } } -- Gitblit v1.8.0