From 7467a843644aee00e5a4d91dd967cdb9e30f1985 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期二, 15 十二月 2020 17:20:06 +0800 Subject: [PATCH] 20201215-3 --- HDL_ON/Entity/Function/Scene.cs | 35 + HDL-ON_Android/Properties/AndroidManifest.xml | 2 HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs | 1 HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs | 229 ++++++---- HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs | 171 +++++-- HDL_ON/Entity/DB_ResidenceData.cs | 5 HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs | 4 HDL_ON/DAL/DriverLayer/Control_Udp.cs | 4 HDL_ON/Entity/FunctionList.cs | 171 +++++++ HDL_ON/Entity/Function/Function.cs | 268 ------------ HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs | 4 HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs | 6 HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs | 264 ++++++------ HDL_ON/DAL/Server/HttpServerRequest.cs | 8 .vs/HDL_APP_Project/xs/UserPrefs.xml | 51 +- 15 files changed, 614 insertions(+), 609 deletions(-) diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml index 0af4d57..32bec03 100644 --- a/.vs/HDL_APP_Project/xs/UserPrefs.xml +++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml @@ -1,21 +1,16 @@ 锘�<Properties StartupConfiguration="{D998E133-F0DD-4760-BE3C-461632F54DA4}|Default"> <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.6242be7109c740c6cb8999a8904b6e0ea8d45192" /> - <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs"> <Files> - <File FileName="HDL_ON/Entity/Function/Scene.cs" Line="262" Column="29" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" Line="383" Column="25" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs" Line="107" Column="29" /> - <File FileName="HDL_ON/Entity/FunctionList.cs" Line="504" Column="47" /> - <File FileName="HDL_ON/DAL/Server/HttpServerRequest.cs" Line="1957" Column="10" /> - <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" Line="172" Column="1" /> - <File FileName="HDL_ON/DAL/Server/NewAPI.cs" Line="372" Column="84" /> - <File FileName="HDL_ON/DAL/DriverLayer/Control_Udp.cs" Line="829" Column="45" /> - <File FileName="HDL_ON/DAL/DriverLayer/Control.cs" Line="376" Column="1" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs" Line="100" Column="1" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs" Line="528" Column="27" /> - <File FileName="HDL_ON/UI/UI2/1-HomePage/HomePage.cs" Line="909" Column="66" /> - <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs" Line="170" Column="43" /> - <File FileName="HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs" Line="34" Column="30" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs" Line="385" Column="43" /> + <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" /> + <File FileName="HDL_ON/DAL/DriverLayer/Control.cs" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs" Line="133" Column="1" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs" Line="888" Column="16" /> + <File FileName="HDL_ON/UI/UI2/1-HomePage/HomePage.cs" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs" /> + <File FileName="HDL_ON/Entity/Function/Function.cs" /> + <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneFunctionListEditPage.cs" Line="475" Column="32" /> </Files> <Pads> <Pad Id="ProjectPad"> @@ -23,31 +18,22 @@ <Node name="HDL_APP_Project" expanded="True"> <Node name="HDL_ON" expanded="True"> <Node name="DAL" expanded="True"> - <Node name="DriverLayer" expanded="True" /> <Node name="Server" expanded="True" /> </Node> <Node name="Entity" expanded="True"> <Node name="Function" expanded="True" /> </Node> <Node name="UI" expanded="True"> - <Node name="UI0-Public" expanded="True" /> <Node name="UI2" expanded="True"> - <Node name="1-HomePage" expanded="True" /> - <Node name="2-Classification" expanded="True"> - <Node name="ClassificationPage.cs" selected="True" /> - </Node> <Node name="3-Intelligence" expanded="True"> - <Node name="Scene" expanded="True" /> + <Node name="Scene" expanded="True"> + <Node name="SceneEditPage.cs" selected="True" /> + </Node> </Node> <Node name="4-PersonalCenter" expanded="True"> <Node name="RoomListManage" expanded="True"> <Node name="AddRoom" expanded="True" /> </Node> - </Node> - <Node name="FuntionControlView" expanded="True"> - <Node name="AC" expanded="True" /> - <Node name="Electrical" expanded="True" /> - <Node name="FoolHeating" expanded="True" /> </Node> </Node> </Node> @@ -58,6 +44,11 @@ </Node> </Node> </Node> + </State> + </Pad> + <Pad Id="MonoDevelop.Debugger.WatchPad"> + <State> + <Value>sceneFunctionInfo</Value> </State> </Pad> </Pads> @@ -71,8 +62,10 @@ <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhone" /> <MonoDevelop.Ide.DebuggingService.Breakpoints> <BreakpointStore> - <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/Entity/Function/Scene.cs" relfile="HDL_ON/Entity/Function/Scene.cs" line="292" column="1" /> - <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/Entity/Function/Scene.cs" relfile="HDL_ON/Entity/Function/Scene.cs" line="266" column="1" /> + <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/Entity/Function/Scene.cs" relfile="HDL_ON/Entity/Function/Scene.cs" line="285" column="1" /> + <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs" line="133" column="1" /> + <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs" line="540" column="1" /> + <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs" line="386" column="1" /> </BreakpointStore> </MonoDevelop.Ide.DebuggingService.Breakpoints> <MultiItemStartupConfigurations /> diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml index 44c5909..8e73faa 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:versionCode="202012141" android:versionName="1.0.202012141" package="com.hdl.onplus"> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="202012141" android:versionName="1.0.202012141" package="com.hdl.onpro"> <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" /> <!-- 瀹氫綅鏉冮檺--> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> diff --git a/HDL_ON/DAL/DriverLayer/Control_Udp.cs b/HDL_ON/DAL/DriverLayer/Control_Udp.cs index 478de5c..e4e770b 100644 --- a/HDL_ON/DAL/DriverLayer/Control_Udp.cs +++ b/HDL_ON/DAL/DriverLayer/Control_Udp.cs @@ -196,7 +196,7 @@ case FunctionAttributeKey.FanSpeed: tempAc.trait_fan.curValue = attr.value; break; - case FunctionAttributeKey.Temp: + case FunctionAttributeKey.SetTemp: tempAc.trait_temp.curValue = attr.value; switch (tempAc.curModeIndex) { @@ -261,7 +261,7 @@ case FunctionAttributeKey.OnOff: tempFh.trait_on_off.curValue = attr.value; break; - case FunctionAttributeKey.Temp: + case FunctionAttributeKey.SetTemp: tempFh.trait_temp.curValue = attr.value; break; case FunctionAttributeKey.Mode: diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs index a3de321..71bfe0f 100644 --- a/HDL_ON/DAL/Server/HttpServerRequest.cs +++ b/HDL_ON/DAL/Server/HttpServerRequest.cs @@ -585,8 +585,12 @@ DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0]; if(mHomeGatewayRes[0].gatewayStatus == "ON_LINE") { - DriverLayer.Control.Ins.IsRemote = true; + //DriverLayer.Control.Ins.IsRemote = true; DriverLayer.Control.Ins.GatewayOnline = true; + } + else + { + DriverLayer.Control.Ins.GatewayOnline = false; } DB_ResidenceData.Instance.SaveResidenceData(); return; @@ -1913,7 +1917,7 @@ d.Add("userSceneIds",new List<string>() { seceneId }); var requestJson = HttpUtil.GetSignRequestJson(d); - return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneList, requestJson); + return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson); } /// <summary> /// 娣诲姞鍦烘櫙 diff --git a/HDL_ON/Entity/DB_ResidenceData.cs b/HDL_ON/Entity/DB_ResidenceData.cs index 1478f42..04ffcb9 100644 --- a/HDL_ON/Entity/DB_ResidenceData.cs +++ b/HDL_ON/Entity/DB_ResidenceData.cs @@ -157,7 +157,10 @@ } } } - + /// <summary> + /// 璁板綍绐楀笜鍏ㄥ紑鍏ㄥ叧鐘舵�� + /// </summary> + public bool GlobalCurtainStatus = false; /// <summary> /// 妫�娴嬩綇瀹呮槸鍚︾粦瀹氫簡缃戝叧 /// gatewayId 鍒ょ┖ diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index 578e86f..0fb021f 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -469,270 +469,6 @@ /// </summary> public object curValue = new object(); - //----app鑷畾涔� - /// <summary> - /// 灞炴�у�煎崟浣� - /// </summary> - string _uintString; - [Newtonsoft.Json.JsonIgnore] - public string uintString - { - get - { - if (!string.IsNullOrEmpty(_uintString)) - { - return _uintString; - } - var us = ""; - switch (key) - { - case "temperature": - case "set_temp": - us = "掳C"; - break; - case "percent": - case "brightness": - us = "%"; - break; - } - return us; - } - } - - /// <summary> - /// 灞炴�у悕绉版樉绀烘枃鏈� - /// 涓嫳鏂囨樉绀� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public string name_text - { - get - { - string text = ""; - switch (key) - { - case "on_off": - text = Language.StringByID(StringId.OnOff); - break; - case "brightness": - text = Language.StringByID(StringId.Brightness); - break; - case "color": - text = Language.StringByID(StringId.ColorValue); - break; - case "mode": - text = Language.StringByID(StringId.Mode); - break; - case "fan": - text = Language.StringByID(StringId.FanSpeed); - break; - case "temperature": - case "set_temp": - text = Language.StringByID(StringId.Temp); - break; - case "delay": - text = Language.StringByID(StringId.Delay); - break; - case "cct": - text = "CCT"; - break; - //case "fade_time": - case "percent": - text = Language.StringByID(StringId.PercentAdjustment); - break; - //case "lock": - //case "ico": - //case "swing": - //case "set_point": - //case "pm25": - //case "volume": - //case "vol_step": - //case "source": - //case "treble": - //case "bass": - //case "playlist": - //case "song_name": - //case "current_status": - //case "enable": - //case "lux": - //case "adjust_value": - //case "range": - //case "humidity": - //case "type": - //case "state": - //case "sensitivity": - //case "pm25value": - } - return text; - } - } - - /// <summary> - /// 鑾峰彇褰撳墠灞炴�х殑鏄剧ず鏂囨湰 - /// 涓嫳鏂囨樉绀� - /// </summary> - public string GetCurValueText() - { - return GetValueText(curValue.ToString()); - } - - /// <summary> - /// 鑾峰彇鎸囧畾灞炴�х殑鏄剧ず鏂囨湰 - /// 涓嫳鏂囨樉绀� - /// </summary> - public string GetValueText(string value) - { - string text = ""; - value = value.Replace("{}", ""); - switch (key) - { - case "on_off": - text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF); - break; - case "temperature": - case "set_temp": - case "brightness": - case "percent": - if (value == "") - { - this.curValue = this.min; - text = this.min.ToString(); - } - else - { - text = value; - } - break; - //case "color": - case "mode": - switch (value) - { - //----绌鸿皟 - case "auto": - text = Language.StringByID(StringId.Auto); - break; - case "cool": - text = Language.StringByID(StringId.Cool); - break; - case "heat": - text = Language.StringByID(StringId.Heat); - break; - case "dry": - text = Language.StringByID(StringId.Dry); - break; - case "fan": - text = Language.StringByID(StringId.AirSupply); - break; - //-----鍦扮儹 - case "day": - text = Language.StringByID(StringId.Day); - break; - case "night": - text = Language.StringByID(StringId.Night); - break; - case "away": - text = Language.StringByID(StringId.Away); - break; - case "normal": - text = Language.StringByID(StringId.Normal); - break; - case "timer": - text = Language.StringByID(StringId.Timer); - break; - default: - if (this.value.Contains("cool")) - { - this.curValue = "cool"; - text = Language.StringByID(StringId.Cool); - } - else if (this.value.Contains("day")) - { - this.curValue = "day"; - text = Language.StringByID(StringId.Day); - } - else - { - foreach (var v in this.value) - { - this.curValue = v; - text = GetCurValueText(); - } - } - break; - } - break; - case "fan": - switch (value) - { - case "high": - text = Language.StringByID(StringId.HighWindSpeed); - break; - case "medium": - text = Language.StringByID(StringId.MiddleWindSpeed); - break; - case "low": - text = Language.StringByID(StringId.LowWindSpeed); - break; - case "auto": - text = Language.StringByID(StringId.Auto); - break; - default: - if (this.value.Contains("low")) - { - this.curValue = "low"; - text = Language.StringByID(StringId.LowWindSpeed); - } - else - { - foreach (var v in this.value) - { - this.curValue = v; - text = GetCurValueText(); - } - } - break; - } - break; - //case "delay": - //case "cct": - //case "fade_time": - //case "lock": - //case "ico": - //case "swing": - //case "set_point": - //case "pm25": - //case "volume": - //case "vol_step": - //case "source": - //case "treble": - //case "bass": - //case "playlist": - //case "song_name": - //case "current_status": - //case "enable": - //case "lux": - //case "adjust_value": - //case "range": - //case "humidity": - //case "type": - //case "state": - //case "sensitivity": - //case "pm25value": - case "high": - text = Language.StringByID(StringId.HighWindSpeed); - break; - case "medium": - text = Language.StringByID(StringId.MiddleWindSpeed); - break; - case "low": - text = Language.StringByID(StringId.LowWindSpeed); - break; - case "auto": - text = Language.StringByID(StringId.Auto); - break; - } - return text; - } } /// <summary> /// 鍔熻兘灞炴�ч敭鍚嶅垪琛� @@ -760,9 +496,9 @@ /// </summary> public const string FanSpeed = "fan"; /// <summary> - /// 娓╁害 + /// 璁剧疆娓╁害 /// </summary> - public const string Temp = "temperature"; + public const string SetTemp = "set_temp"; /// <summary> /// 寤舵椂 /// </summary> diff --git a/HDL_ON/Entity/Function/Scene.cs b/HDL_ON/Entity/Function/Scene.cs index 3983d39..b1ace2a 100644 --- a/HDL_ON/Entity/Function/Scene.cs +++ b/HDL_ON/Entity/Function/Scene.cs @@ -256,10 +256,31 @@ MainPage.Log($"Save Scene Data : {savePath}"); } } + + /// <summary> + /// 淇敼鍦烘櫙 + /// </summary> + public string UpdateScene() + { + var pm = new HttpServerRequest(); + var revPack = pm.EditScene(this); + if (revPack.Code == StateCode.SUCCESS) + { + var scenes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(revPack.Data.ToString()); + var tempScene = scenes.Find((obj) => obj.sid == sid); + if (tempScene != null) + { + var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(tempScene)); + Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); + } + } + return revPack.Code; + } + /// <summary> /// 娣诲姞鍦烘櫙 /// </summary> - public void AddScene() + public string AddScene() { var pm = new HttpServerRequest(); var revPack = pm.AddScene(this); @@ -268,6 +289,7 @@ var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); } + return revPack.Code; } /// <summary> @@ -329,10 +351,11 @@ /// 鏈湴瀵瑰簲鐨勫姛鑳� /// </summary> [Newtonsoft.Json.JsonIgnore] - public Function localFunction { + public Function localFunction + { get { - if(_localFunction == null) + if (_localFunction == null) { _localFunction = ConvertFunctionObject(); } @@ -347,13 +370,9 @@ Function ConvertFunctionObject() { var localFunction = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.sid == sid); - foreach (var s in status) - { - localFunction.attributes.Add(new FunctionAttributes() { key = s.key, curValue = s.value, value = new List<string>() { s.value } }); - } return localFunction; } - + } /// <summary> diff --git a/HDL_ON/Entity/FunctionList.cs b/HDL_ON/Entity/FunctionList.cs index 8a38fa0..0cbae44 100644 --- a/HDL_ON/Entity/FunctionList.cs +++ b/HDL_ON/Entity/FunctionList.cs @@ -4,6 +4,7 @@ using System.Threading; using HDL_ON.DAL; using HDL_ON.DAL.Server; +using Shared; namespace HDL_ON.Entity { @@ -437,15 +438,7 @@ var sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString()); if (sceneList != null) { - ////灏嗕笅杞藉埌鍒版暟鎹叏閮ㄤ繚瀛� - //new Thread(() => { - // foreach (var temp in sceneList) - // { - // temp.SaveSceneData(); - // } - //}) - //{ IsBackground = true }.Start(); - for(int i=0;i<List.scenes.Count;) + for (int i=0;i<List.scenes.Count;) { var localScene = List.scenes[i]; if (localScene == null) @@ -626,6 +619,166 @@ { IsBackground = true }.Start(); } + + #region 鍔熻兘鏂囨湰鐩稿叧 + /// <summary> + /// 灞炴�у悕绉版樉绀烘枃鏈� + /// 涓嫳鏂囨樉绀� + /// </summary> + public string GetNameText(string key) + { + string text = ""; + switch (key) + { + case FunctionAttributeKey.OnOff: + text = Language.StringByID(StringId.OnOff); + break; + case FunctionAttributeKey.Brightness: + text = Language.StringByID(StringId.Brightness); + break; + case FunctionAttributeKey.Color: + text = Language.StringByID(StringId.ColorValue); + break; + case FunctionAttributeKey.Mode: + text = Language.StringByID(StringId.Mode); + break; + case FunctionAttributeKey.FanSpeed: + text = Language.StringByID(StringId.FanSpeed); + break; + case FunctionAttributeKey.SetTemp: + text = Language.StringByID(StringId.Temp); + break; + case FunctionAttributeKey.IndoorTemp: + text = Language.StringByID(StringId.IndoorTemp); + break; + case FunctionAttributeKey.Delay: + text = Language.StringByID(StringId.Delay); + break; + case FunctionAttributeKey.CCT: + text = "CCT"; + break; + case FunctionAttributeKey.Percent: + text = Language.StringByID(StringId.PercentAdjustment); + break; + } + return text; + } + + /// <summary> + /// 灞炴�у�煎崟浣� + /// </summary> + public string GetUintString(string key) + { + var us = ""; + switch (key) + { + case FunctionAttributeKey.SetTemp: + case FunctionAttributeKey.IndoorTemp: + us = "掳C"; + break; + case FunctionAttributeKey.Percent: + case FunctionAttributeKey.Brightness: + us = "%"; + break; + } + return us; + } + + /// <summary> + /// 鑾峰彇鎸囧畾灞炴�х殑鏄剧ず鏂囨湰 + /// 涓嫳鏂囨樉绀� + /// </summary> + public string GetValueText(string key, string value) + { + string text = ""; + switch (key) + { + case FunctionAttributeKey.OnOff: + text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF); + break; + case FunctionAttributeKey.SetTemp: + case FunctionAttributeKey.IndoorTemp: + case FunctionAttributeKey.Brightness: + case FunctionAttributeKey.Percent: + if (value == "") + { + value = "0"; + } + text = value; + break; + case FunctionAttributeKey.Mode: + switch (value) + { + //----绌鸿皟 + case "auto": + text = Language.StringByID(StringId.Auto); + break; + case "cool": + text = Language.StringByID(StringId.Cool); + break; + case "heat": + text = Language.StringByID(StringId.Heat); + break; + case "dry": + text = Language.StringByID(StringId.Dry); + break; + case "fan": + text = Language.StringByID(StringId.AirSupply); + break; + //-----鍦扮儹 + case "day": + text = Language.StringByID(StringId.Day); + break; + case "night": + text = Language.StringByID(StringId.Night); + break; + case "away": + text = Language.StringByID(StringId.Away); + break; + case "normal": + text = Language.StringByID(StringId.Normal); + break; + case "timer": + text = Language.StringByID(StringId.Timer); + break; + } + break; + case FunctionAttributeKey.FanSpeed: + switch (value) + { + case "high": + text = Language.StringByID(StringId.HighWindSpeed); + break; + case "medium": + text = Language.StringByID(StringId.MiddleWindSpeed); + break; + case "low": + text = Language.StringByID(StringId.LowWindSpeed); + break; + case "auto": + text = Language.StringByID(StringId.Auto); + break; + default: + text = "low"; + break; + } + break; + case "high": + text = Language.StringByID(StringId.HighWindSpeed); + break; + case "medium": + text = Language.StringByID(StringId.MiddleWindSpeed); + break; + case "low": + text = Language.StringByID(StringId.LowWindSpeed); + break; + case "auto": + text = Language.StringByID(StringId.Auto); + break; + } + return text; + } + #endregion } } diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs index d29fe3f..1e9ab60 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs @@ -615,7 +615,7 @@ UnSelectedImagePath = "FunctionIcon/Curtain/CurtainCloseIcon.png", SelectedImagePath = "FunctionIcon/Curtain/CurtainCloseOnIcon.png", //Tag = item + "_AllControl", - IsSelected = false + IsSelected = !DB_ResidenceData.Instance.GlobalCurtainStatus, }; functionView.AddChidren(btnClose); @@ -628,7 +628,7 @@ Height = Application.GetRealWidth(32), UnSelectedImagePath = "FunctionIcon/Curtain/CurtainOpenIcon.png", SelectedImagePath = "FunctionIcon/Curtain/CurtainOpenOnIcon.png", - IsSelected = true, + IsSelected = DB_ResidenceData.Instance.GlobalCurtainStatus, }; functionView.AddChidren(btnOpen); LoadEvent_CurtainSwitch(btnClose, btnOpen); diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs index 73ab724..6b0a1c4 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs @@ -356,6 +356,9 @@ { btnOpen.MouseUpEventHandler = (sender, e) => { + DB_ResidenceData.Instance.GlobalCurtainStatus = true; + btnOpen.IsSelected = true; + btnClose.IsSelected = false; foreach (var f in FunctionList.List.curtains) { f.trait_on_off.curValue = "on"; @@ -368,6 +371,9 @@ btnClose.MouseUpEventHandler = (sender, e) => { + DB_ResidenceData.Instance.GlobalCurtainStatus = false; + btnClose.IsSelected = true; + btnOpen.IsSelected = false; foreach (var f in FunctionList.List.curtains) { f.trait_on_off.curValue = "off"; diff --git a/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs b/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs index 25511ec..4cc12db 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs @@ -374,7 +374,6 @@ Action refreshAction = () => { btnName.Text = scene.name; btnZone.Text = scene.GetRoomListName(); - //view.BackgroundImagePath = scene.ImagePath; //2020-12-03 淇敼鍥剧墖鍔犺浇鏂规硶 ImageUtlis.Current.LoadLocalOrNetworkImages((scene as Scene).ImagePath, view); }; diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs index 2da30d5..fb7bb19 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/NewSceneMenuListPage.cs @@ -164,9 +164,9 @@ this.RemoveFromParent(); action(); }; - var scene = new Entity.Scene() { roomIds = new System.Collections.Generic.List<string>() { "" } }; + var scene = new Scene() { roomIds = new System.Collections.Generic.List<string>() { "" } }; scene.NewSid(); - scene.name = Language.StringByID(StringId.Scene) + " " + (1 + Entity.FunctionList.List.scenes.Count).ToString(); + scene.name = Language.StringByID(StringId.Scene) + " " + (1 + FunctionList.List.scenes.Count).ToString(); var aep = new SceneAddPage(scene,backAction); MainPage.BasePageView.AddChidren(aep); aep.LoadPage(); diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs index 99b4656..8651933 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneAddPage.cs @@ -90,23 +90,18 @@ scene = s; backAction = act; - refreshFunctionRowAction = () => { LoadFunctionRow(functionListView); }; } - public void LoadPage( Action backRefresh) + public void LoadPage() { - new TopViewDiv(bodyView, Language.StringByID(StringId.NewScene)).LoadTopView(backRefresh); - initPage(); - } - - void initPage() - { + new TopViewDiv(bodyView, Language.StringByID(StringId.NewScene)).LoadTopView(); + bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; - VerticalScrolViewLayout contentView = new VerticalScrolViewLayout() + var contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(603 - 50), @@ -114,7 +109,7 @@ bodyView.AddChidren(contentView); contentView.AddChidren(new Button() { Height = Application.GetRealWidth(12) }); - FrameLayout sceneBgView = new FrameLayout() + var sceneBgView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(252), @@ -135,7 +130,6 @@ //2020-12-03 淇敼鍥剧墖鍔犺浇鏂规硶 ImageUtlis.Current.LoadLocalOrNetworkImages(scene.ImagePath, addSceneImageView); - #region 鍦烘櫙鍚嶇Оrow sceneNameView = new FrameLayout() @@ -401,8 +395,6 @@ }; row.AddChidren(btnRight); - - var btnFunctionInfo = new Button() { Width = Application.GetRealWidth(327), @@ -472,7 +464,6 @@ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; - Button btnDelSceneFunction = new Button() { BackgroundColor = CSS_Color.WarningColor, @@ -485,10 +476,7 @@ scene.SaveSceneData(true); row.RemoveFromParent(); functionListView.Height = Application.GetRealWidth(65 * scene.functions.Count); - //LoadFunctionRow(functionListView); }; - - } } @@ -506,66 +494,115 @@ if (sfs.value == "off") return Language.StringByID(StringId.Close); } - if (sfs.key == FunctionAttributeKey.Mode) - { - - } } - FunctionAttributes perTrait; - switch (sceneFunction.localFunction.functionType) + if (sceneFunction.status.Count == 0) { - case FunctionType.AC: - sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); - sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + - sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; - sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan").GetCurValueText(); - break; - case FunctionType.FloorHeating: - sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); - sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + - sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; - break; - case FunctionType.Dimmer: - perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"); - if (perTrait != null) - { - sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; - } - else - { - sceneFunctionInfo += Language.StringByID(StringId.Open); - } - break; - case FunctionType.Relay: - sceneFunctionInfo += Language.StringByID(StringId.Open); - break; - case FunctionType.RGB: - perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); - if (perTrait != null) - { - sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; - } - else - { - sceneFunctionInfo += Language.StringByID(StringId.Open); - } - break; - case FunctionType.Curtain: - sceneFunctionInfo += Language.StringByID(StringId.Open); - break; - case FunctionType.MotorCurtain: - perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); - if (perTrait != null) - { - sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%"; - } - else - { - sceneFunctionInfo += Language.StringByID(StringId.Open); - } - break; + return sceneFunctionInfo += Language.StringByID(StringId.Open); } + + var modeState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode); + var tempState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp); + var fanState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); + if (modeState != null) + { + sceneFunctionInfo += FunctionList.List.GetValueText(modeState.key, modeState.value); + } + if (tempState != null) + { + sceneFunctionInfo += FunctionList.List.GetValueText(tempState.key, tempState.value); + sceneFunctionInfo += FunctionList.List.GetUintString(tempState.key); + } + if (fanState != null) + { + sceneFunctionInfo += FunctionList.List.GetValueText(fanState.key, fanState.value); + } + var briState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness); + if (briState != null) + { + sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; + } + else + { + sceneFunctionInfo += Language.StringByID(StringId.Open); + } + var perState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent); + if (perState != null) + { + sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; + } + else + { + sceneFunctionInfo += Language.StringByID(StringId.Open); + } + + //FunctionAttributes perTrait; + + //switch (sceneFunction.localFunction.functionType) + //{ + //case FunctionType.AC: + //var acMode = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode); + //var acTemp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp); + //var acFan = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); + //if (acMode != null) + //{ + // sceneFunctionInfo += FunctionList.List.GetValueText(acMode.key, acMode.value); + //} + //if (acTemp != null) + //{ + // sceneFunctionInfo += FunctionList.List.GetValueText(acTemp.key, acTemp.value); + // sceneFunctionInfo += FunctionList.List.GetUintString(acTemp.key); + //} + //if (acFan!=null) + //{ + // sceneFunctionInfo += FunctionList.List.GetValueText(acFan.key, acFan.value); + //} + // break; + //case FunctionType.FloorHeating: + //sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); + //sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + + // sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; + //break; + //case FunctionType.Dimmer: + //perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"); + //if (perTrait != null) + //{ + // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; + //} + //else + //{ + // sceneFunctionInfo += Language.StringByID(StringId.Open); + //} + //break; + //case FunctionType.Relay: + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // break; + //case FunctionType.RGB: + // perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); + // if (perTrait != null) + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; + // } + // else + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // } + // break; + //case FunctionType.Curtain: + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // break; + //case FunctionType.MotorCurtain: + // perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); + // if (perTrait != null) + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%"; + // } + // else + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // } + // break; + //} return sceneFunctionInfo; } @@ -843,41 +880,35 @@ { btnComplete.MouseUpEventHandler += (sender, e) => { - if (btnComplete.TextID == StringId.Complete) + if (string.IsNullOrEmpty(scene.name)) { - if (string.IsNullOrEmpty(scene.name)) + new Tip() { - new Tip() - { - CloseTime = 1, - Text = Language.StringByID(StringId.SceneNameCannotBeEmpty), - Direction = AMPopTipDirection.None, - }.Show(bodyView); + CloseTime = 1, + Text = Language.StringByID(StringId.SceneNameCannotBeEmpty), + Direction = AMPopTipDirection.None, + }.Show(bodyView); + return; + } + foreach (var tempRoom in FunctionList.List.scenes) + { + if (scene.name == tempRoom.name) + { + new PublicAssmebly().TipMsg(StringId.Tip, StringId.SceneNameAlreadyExists); return; } - foreach (var tempRoom in FunctionList.List.scenes) - { - if (scene.name == tempRoom.name) - { - new PublicAssmebly().TipMsg(StringId.Tip, StringId.SceneNameAlreadyExists); - return; - } - } - scene.SaveSceneData(true); + } + var result = scene.AddScene(); + if (result == StateCode.SUCCESS) + { FunctionList.List.scenes.Add(scene); backAction(); this.RemoveFromParent(); } - if (btnComplete.TextID == StringId.Del) + else { - Action action = () => - { - FunctionList.List.DeleteScene(scene, true); - backAction(); - this.RemoveFromParent(); - }; - new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DeleteSceneTip, action); - }; + IMessageCommon.Current.ShowErrorInfoAlter(result); + } }; } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs index cb146e7..049a185 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs @@ -374,6 +374,37 @@ bodyView.AddChidren(btnComplete); LoadEventList(); + + var waitPage = new Loading(); + new Thread(() => { + Application.RunOnMainThread(() => { + bodyView.AddChidren(waitPage); + waitPage.Start(Language.StringByID(StringId.PleaseWait)); + }); + var pm = new HttpServerRequest(); + var pack = pm.GetSceneInfo(scene.userSceneId); + if (pack.Code == StateCode.SUCCESS) + { + var sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString()); + var tempScene = sceneList.Find((obj) => obj.userSceneId == scene.userSceneId); + if(tempScene!= null) + { + scene.functions = tempScene.functions; + } + Application.RunOnMainThread(() => + { + waitPage.Hide(); + }); + } + else + { + Application.RunOnMainThread(() => + { + waitPage.Hide(); + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + }); + } + }).Start(); } /// <summary> /// 鍔犺浇鍔熻兘鍒楄〃 @@ -513,66 +544,94 @@ if (sfs.value == "off") return Language.StringByID(StringId.Close); } - if (sfs.key == FunctionAttributeKey.Mode) - { - - } } - FunctionAttributes perTrait; - switch (sceneFunction.localFunction.functionType) + if (sceneFunction.status.Count == 0) { - case FunctionType.AC: - sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); - sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + - sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; - sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan").GetCurValueText(); - break; - case FunctionType.FloorHeating: - sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); - sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + - sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; - break; - case FunctionType.Dimmer: - perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"); - if (perTrait != null) - { - sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; - } - else - { - sceneFunctionInfo += Language.StringByID(StringId.Open); - } - break; - case FunctionType.Relay: - sceneFunctionInfo += Language.StringByID(StringId.Open); - break; - case FunctionType.RGB: - perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); - if (perTrait != null) - { - sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; - } - else - { - sceneFunctionInfo += Language.StringByID(StringId.Open); - } - break; - case FunctionType.Curtain: - sceneFunctionInfo += Language.StringByID(StringId.Open); - break; - case FunctionType.MotorCurtain: - perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); - if (perTrait != null) - { - sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%"; - } - else - { - sceneFunctionInfo += Language.StringByID(StringId.Open); - } - break; + return sceneFunctionInfo += Language.StringByID(StringId.Open); } + + var modeState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode); + var tempState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp); + var fanState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); + if (modeState != null) + { + sceneFunctionInfo += FunctionList.List.GetValueText(modeState.key, modeState.value); + } + if (tempState != null) + { + sceneFunctionInfo += FunctionList.List.GetValueText(tempState.key, tempState.value); + sceneFunctionInfo += FunctionList.List.GetUintString(tempState.key); + } + if (fanState != null) + { + sceneFunctionInfo += FunctionList.List.GetValueText(fanState.key, fanState.value); + } + var briState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness); + if (briState != null) + { + sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + briState.value + "%"; + } + var perState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent); + if (perState != null) + { + sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + perState.value + "%"; + } + //FunctionAttributes perTrait; + + //switch (sceneFunction.localFunction.functionType) + //{ + // case FunctionType.AC: + // sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); + // sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + + // sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; + // sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan").GetCurValueText(); + // break; + // case FunctionType.FloorHeating: + // sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText(); + // sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() + + // sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString; + // break; + // case FunctionType.Dimmer: + // perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"); + // if (perTrait != null) + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; + // } + // else + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // } + // break; + // case FunctionType.Relay: + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // break; + // case FunctionType.RGB: + // perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); + // if (perTrait != null) + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%"; + // } + // else + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // } + // break; + // case FunctionType.Curtain: + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // break; + // case FunctionType.MotorCurtain: + // perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"); + // if (perTrait != null) + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%"; + // } + // else + // { + // sceneFunctionInfo += Language.StringByID(StringId.Open); + // } + // break; + //} return sceneFunctionInfo; } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs index d562d05..e1695e9 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs @@ -10,21 +10,19 @@ { FrameLayout bodyView; VerticalScrolViewLayout contentView; + Button btnOnText; Scene scene; Action refreshAction; SceneFunction sceneFunction; - //Function localFunction; public SceneFunctionInfoEditPage(Scene s, SceneFunction fc,Action action) { bodyView = this; scene = s; - //localFunction = fc; sceneFunction = fc; refreshAction = action; } - public void LoadPage() { @@ -40,35 +38,58 @@ }; bodyView.AddChidren(contentView); - //鍔犺浇寮�鍏砇ow - LoadFunctionRow(sceneFunction.localFunction.trait_on_off); + LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff)); - switch (sceneFunction.localFunction.functionType) + foreach (var attr in sceneFunction.status) { - case FunctionType.AC: - LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp")); - LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode")); - LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan")); - break; - case FunctionType.FloorHeating: - LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp")); - LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode")); - break; - case FunctionType.Curtain: - //鏃犳搷浣� - break; - case FunctionType.MotorCurtain: - case FunctionType.RollingShutter: - LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent")); - break; - case FunctionType.Relay: - //鏃犳搷浣� - break; - case FunctionType.Dimmer: - case FunctionType.RGB: - LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness")); - break; + switch (attr.key) + { + case FunctionAttributeKey.SetTemp: + LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp)); + break; + case FunctionAttributeKey.Mode: + LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode)); + break; + case FunctionAttributeKey.FanSpeed: + LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed)); + break; + case FunctionAttributeKey.Percent: + LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent)); + break; + case FunctionAttributeKey.Brightness: + LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness)); + break; + } } + + //鍔犺浇寮�鍏砇ow + //LoadFunctionRow(sceneFunction.localFunction.trait_on_off); + //switch (sceneFunction.localFunction.functionType) + //{ + // case FunctionType.AC: + // LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp")); + // LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode")); + // LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan")); + // break; + // case FunctionType.FloorHeating: + // LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp")); + // LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode")); + // break; + // case FunctionType.Curtain: + // //鏃犳搷浣� + // break; + // case FunctionType.MotorCurtain: + // case FunctionType.RollingShutter: + // LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent")); + // break; + // case FunctionType.Relay: + // //鏃犳搷浣� + // break; + // case FunctionType.Dimmer: + // case FunctionType.RGB: + // LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness")); + // break; + //} //鍔犺浇寤舵椂Row LoadDelayRow(); @@ -100,7 +121,6 @@ btnConfrim.MouseUpEventHandler = (sender, e) => { - //var temp = localFunction.ConvertSceneFunction(); var temp = scene.functions.Find((obj) => obj.sid == sceneFunction.sid); if (temp != null) { @@ -110,9 +130,19 @@ { scene.functions.Add(sceneFunction); } - scene.SaveSceneData(true); - refreshAction(); - this.RemoveFromParent(); + if (!string.IsNullOrEmpty(scene.userSceneId)) + { + var result = scene.UpdateScene(); + if (result == DAL.Server.StateCode.SUCCESS) + { + refreshAction(); + this.RemoveFromParent(); + } + else + { + DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(result); + } + } }; } @@ -120,9 +150,9 @@ /// <summary> /// 鍔犺浇鍔熻兘Row /// </summary> - void LoadFunctionRow(FunctionAttributes trait) + void LoadFunctionRow(SceneFunctionStatus sceneStatus) { - if (trait == null) + if (sceneStatus == null) return; #region Row code var row = new FrameLayout() @@ -131,7 +161,7 @@ BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(row); - if (trait.key != "on_off") + if (sceneStatus.key != FunctionAttributeKey.OnOff) { row.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor }); } @@ -151,9 +181,11 @@ TextAlignment = TextAlignment.CenterRight, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, - Text = trait.GetCurValueText() + trait.uintString + Text = FunctionList.List.GetValueText(sceneStatus.key,sceneStatus.value) + FunctionList.List.GetUintString(sceneStatus.key) }; row.AddChidren(btnFunctionText); + if (sceneStatus.key == FunctionAttributeKey.OnOff) + btnOnText = btnFunctionText; var btnFunctionName = new Button() { @@ -161,62 +193,48 @@ TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, - Text = trait.name_text + Text = FunctionList.List.GetNameText(sceneStatus.key) }; row.AddChidren(btnFunctionName); btnFunctionName.MouseUpEventHandler = (sender, e) => { - switch (trait.key) + switch (sceneStatus.key) { - case "on_off": - LoadEditDialog_OnOff(trait, btnFunctionText); + case FunctionAttributeKey.OnOff: + LoadEditDialog_OnOff(sceneStatus, btnFunctionText); break; - case "brightness": - LoadEditDialog_Percent(trait, btnFunctionText); + case FunctionAttributeKey.Brightness: + LoadEditDialog_Percent(sceneStatus, btnFunctionText); break; - //case "color": - // break; - case "mode": - LoadEditDialog_FunctionPar(trait, btnFunctionText); + case FunctionAttributeKey.Mode: + var statusList = new List<string>(); + var tr = sceneFunction.localFunction.attributes.Find((obj) => obj.key == FunctionAttributeKey.Mode); + foreach(var t in tr.value) + { + statusList.Add(t); + } + LoadEditDialog_FunctionPar(sceneStatus, btnFunctionText,statusList); break; - case "fan": - LoadEditDialog_FunctionPar(trait, btnFunctionText); + case FunctionAttributeKey.FanSpeed: + var fanStatusList = new List<string>(); + var tr1 = sceneFunction.localFunction.attributes.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); + foreach (var t in tr1.value) + { + fanStatusList.Add(t); + } + LoadEditDialog_FunctionPar(sceneStatus, btnFunctionText, fanStatusList); break; - case "set_temp": - LoadEditDialog_Temp(trait, btnFunctionText); + case FunctionAttributeKey.SetTemp: + LoadEditDialog_Temp(sceneStatus, btnFunctionText); break; case "delay": break; case "cct": break; - //case "fade_time": - case "percent": - LoadEditDialog_Percent(trait, btnFunctionText); + case FunctionAttributeKey.Percent: + LoadEditDialog_Percent(sceneStatus, btnFunctionText); break; - //case "lock": - //case "ico": - //case "swing": - //case "set_ point": - //case "pm25": - //case "volume": - //case "vol_step": - //case "source": - //case "treble": - //case "bass": - //case "playlist": - //case "song_name": - //case "current_status": - //case "enable": - //case "lux": - //case "adjust_value": - //case "range": - //case "humidity": - //case "type": - //case "state": - //case "sensitivity": - //case "pm25value": } - //LoadEditDialog_Temp(trait, btnFunctionText); }; #endregion @@ -286,7 +304,7 @@ /// </summary> /// <param name="function"></param> /// <param name="btn"></param> - void LoadEditDialog_OnOff(FunctionAttributes trait, Button btn) + void LoadEditDialog_OnOff(SceneFunctionStatus trait, Button btn) { Dialog dialog = new Dialog(); @@ -324,7 +342,7 @@ SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.On, - IsSelected = trait.curValue.ToString() == "on" + IsSelected = trait.value.ToString() == "on" }; optionView.AddChidren(btnOn); @@ -338,7 +356,7 @@ SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.OFF, - IsSelected = trait.curValue.ToString() == "off" + IsSelected = trait.value.ToString() == "off" }; optionView.AddChidren(btnOff); @@ -367,15 +385,15 @@ }; btnOn.MouseUpEventHandler = (sender, e) => { dialog.Close(); - trait.curValue = "on"; + trait.value = "on"; sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = "on"; - btn.Text = trait.GetCurValueText() + trait.uintString; + btn.Text = FunctionList.List.GetValueText(trait.key, trait.value) + FunctionList.List.GetUintString(trait.key); }; btnOff.MouseUpEventHandler = (sender,e) =>{ dialog.Close(); - trait.curValue = "off"; + trait.value = "off"; sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = "off"; - btn.Text= trait.GetCurValueText() + trait.uintString; + btn.Text= FunctionList.List.GetValueText(trait.key,trait.value) + FunctionList.List.GetUintString(trait.key); }; } @@ -385,7 +403,7 @@ /// </summary> /// <param name="function"></param> /// <param name="btn"></param> - void LoadEditDialog_Temp(FunctionAttributes trait, Button btn) + void LoadEditDialog_Temp(SceneFunctionStatus trait, Button btn) { List<string> pickerItems = new List<string>(); if(trait == null) @@ -452,33 +470,14 @@ Height = Application.GetRealHeight(210), Radius = (uint)Application.GetRealWidth(12), }; - if(trait!=null) + for (int i = 16; i <= 32; i += 1) { - if (trait.data_type == "float") - { - for (double i = trait.min; i <= trait.max; i += 0.5) - { - pickerItems.Add(i.ToString() + trait.uintString); - } - } - else - { - for (int i = trait.min; i <= trait.max; i += 1) - { - pickerItems.Add(i.ToString() + trait.uintString); - } - } - }else - { - for (int i = 16; i <= 32; i += 1) - { - pickerItems.Add(i.ToString() + trait.uintString); - } + pickerItems.Add(i.ToString() + FunctionList.List.GetUintString(trait.key)); } uIPickerView.setNPicker(pickerItems, null, null); optionBaseView.AddChidren(uIPickerView); - uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.curValue.ToString()), 4, 5); - string selectItem = trait.curValue.ToString() + trait.uintString; + uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.value.ToString()), 4, 5); + string selectItem = trait.value.ToString() + FunctionList.List.GetUintString(trait.key); dialog.Show(); @@ -495,19 +494,18 @@ btnConfrim.MouseUpEventHandler = (sender, e) => { dialog.Close(); btn.Text = selectItem; - sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ; - trait.curValue = selectItem.Replace(trait.uintString,""); + //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ; + trait.value = selectItem.Replace(FunctionList.List.GetUintString(trait.key),""); }; } - /// <summary> /// 鍔犺浇浜害閫夋嫨寮圭獥 /// </summary> /// <param name="function"></param> /// <param name="btn"></param> - void LoadEditDialog_Percent(FunctionAttributes trait, Button btn) + void LoadEditDialog_Percent(SceneFunctionStatus trait, Button btn) { if (trait == null) { @@ -546,13 +544,12 @@ optionBaseView.AddChidren(topView); topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor }); - var btnTitle = new Button() { Gravity = Gravity.CenterHorizontal, TextAlignment = TextAlignment.Center, Width = Application.GetRealWidth(100), - Text = trait.name_text, + Text = FunctionList.List.GetNameText(trait.key), IsBold = true, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, @@ -580,8 +577,6 @@ }; topView.AddChidren(btnConfrim); - - Button btnMinusSignIcon = new Button() { X = Application.GetRealWidth(26), @@ -605,7 +600,7 @@ ProgressTextColor = CSS_Color.FirstLevelTitleColor, ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel, MaxValue = 100, - Progress = trait.curValue.ToString().Replace("{}", "") == "" ? 0 : Convert.ToInt32( trait.curValue), + Progress = trait.value.ToString().Replace("{}", "") == "" ? 0 : Convert.ToInt32( trait.value.Replace("{}","")), SeekBarPadding = Application.GetRealWidth(20), }; optionBaseView.AddChidren(controlBar); @@ -627,7 +622,6 @@ controlBar.Progress++; }; - dialog.Show(); pView.MouseUpEventHandler = (sender, e) => { dialog.Close(); @@ -638,9 +632,17 @@ }; btnConfrim.MouseUpEventHandler = (sender, e) => { dialog.Close(); - trait.curValue = controlBar.Progress; - sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ; - btn.Text = trait.curValue + trait.uintString; + trait.value = controlBar.Progress.ToString(); + btn.Text = trait.value + FunctionList.List.GetUintString(trait.key); + if (controlBar.Progress > 0) + { + var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff); + if (temp != null) + { + temp.value = "on"; + btnOnText.Text = FunctionList.List.GetValueText(temp.key, temp.value); + } + } }; } @@ -649,7 +651,7 @@ /// <summary> /// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥 /// </summary> - void LoadEditDialog_FunctionPar(FunctionAttributes trait, Button btn) + void LoadEditDialog_FunctionPar(SceneFunctionStatus trait, Button btn,List<string> statusList) { Button lastButton = new Button(); var lastData = ""; @@ -664,10 +666,10 @@ var optionBaseView = new FrameLayout() { - Y = Application.GetRealHeight(579 - 50 * trait.value.Count), + Y = Application.GetRealHeight(579 - 50 * statusList.Count), Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(343), - Height = Application.GetRealHeight(50 * trait.value.Count + 50), + Height = Application.GetRealHeight(50 * statusList.Count + 50), AnimateSpeed = 0.3f, Animate = Animate.DownToUp, BackgroundColor = CSS_Color.MainBackgroundColor, @@ -690,7 +692,7 @@ Gravity = Gravity.CenterHorizontal, TextAlignment = TextAlignment.Center, Width = Application.GetRealWidth(100), - Text = trait.name_text, + Text = FunctionList.List.GetNameText(trait.key), IsBold = true, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, @@ -718,7 +720,7 @@ }; topView.AddChidren(btnConfrim); int hei = 1; - foreach (var m in trait.value) + foreach (var m in statusList) { var row = new FrameLayout() { @@ -726,7 +728,7 @@ Height = Application.GetRealHeight(50), }; optionBaseView.AddChidren(row); - if (trait.value.Count > hei) + if (statusList.Count > hei) { optionBaseView.AddChidren(new Button() { @@ -750,7 +752,7 @@ }; row.AddChidren(btnChoose); - if (trait.curValue.ToString() == m) + if (trait.value == m) { lastButton = btnChoose; btnChoose.IsSelected = true; @@ -762,7 +764,7 @@ TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, Tag = m, - Text = trait.GetValueText(m) + Text = FunctionList.List.GetValueText(trait.key, m) }; row.AddChidren(btnPropertyTitle); @@ -792,8 +794,8 @@ }; btnConfrim.MouseUpEventHandler = (sender, e) => { dialog.Close(); - trait.curValue = lastData; - sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ; + trait.value = lastData; + //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ; btn.Text = lastText; }; -- Gitblit v1.8.0