From c00da77d00a479fa5d022346a6d9075f90a5c087 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期六, 14 九月 2024 10:05:34 +0800 Subject: [PATCH] 退出登录时间调整,新风,音乐 --- HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs | 1377 +++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 806 insertions(+), 571 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs index e071faa..61c562f 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs @@ -6,7 +6,25 @@ namespace HDL_ON.UI { - + public class VerticalScrolViewLayoutJinmao : VerticalScrolViewLayout + { + public VerticalScrolViewLayoutJinmao() + { +#if __IOS__ + try + { + //鑷姩鍋忕Щ鍙栨秷 + if (UIKit.UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) + { + (this.uiView as UIKit.UIScrollView).ContentInsetAdjustmentBehavior = UIKit.UIScrollViewContentInsetAdjustmentBehavior.Never; + } + }catch(Exception ex) + { + MainPage.Log("error", "閲戣寕iOS 婊氬姩瀹瑰櫒鍋忕Щ鍊艰缃紓甯革細" + ex.Message); + } +#endif + } + } /// <summary> /// 缁垮缓绉戞妧绯荤粺 @@ -16,7 +34,9 @@ { static AcstParentPage basePage; - VerticalScrolViewLayout bodyView; + VerticalScrolViewLayoutJinmao contentView; + + string helloText = "涓婂崍濂�"; #region 澶╂皵鎺т欢 Button btnOutdoorTemp; @@ -33,16 +53,14 @@ SensorDiyView sensorDiyView_Tvoc; SensorDiyView sensorDiyView_EleDay; SensorDiyView sensorDiyView_EleMonth; - SensorDiyView sensorDiyView_EleTotal; + SensorDiyView sensorDiyView_EleActivePower; #endregion /// <summary> /// 瀛愭帶鍖哄煙鍒楄〃 /// </summary> Dictionary<string, AcstSubControlView> subViewList; - Button btnWorkSceneControl; - Button btnModeControl; Button btnPowerControl; @@ -64,10 +82,53 @@ public AcstParentPage() { basePage = this; + var curTime = DateTime.Now; + if (Language.CurrentLanguage != "Chinese") + { + helloText = "Good morning"; + } + if (curTime.Hour >= 8 && curTime.Hour < 12) + { + helloText = "涓婂崍濂�"; + if (Language.CurrentLanguage != "Chinese") + { + helloText = "Good morning"; + } + curColor = CSS.CSS_Color.MainColor; + imageFolder = "blue"; + } + else if (curTime.Hour >= 12 && curTime.Hour < 18) + { + helloText = "涓嬪崍濂�"; + if (Language.CurrentLanguage != "Chinese") + { + helloText = "Good afternoon"; + } + curColor = 0xFFE7914F; + imageFolder = "orange"; + } + else + { + helloText = "鏅氫笂濂�"; + if (Language.CurrentLanguage != "Chinese") + { + helloText = "Good evening"; + } + + curColor = 0xFF9175F3; + imageFolder = "purple"; + } this.function = FunctionList.List.GetAcstParentList()[0]; this.BackgroundColor = CSS.CSS_Color.BackgroundColor; - bodyView = new VerticalScrolViewLayout(); - this.AddChidren(bodyView); + //this.AddChidren(new Button() { Height = Application.GetRealHeight(50), BackgroundColor = curColor }); + contentView = new VerticalScrolViewLayoutJinmao() + { + Height = Application.GetRealHeight(667 - 56), + VerticalScrollBarEnabled = false, + }; + basePage.AddChidren(contentView); + + subViewList = new Dictionary<string, AcstSubControlView>(); } /// <summary> @@ -93,75 +154,83 @@ /// </summary> public static void UpdateAcstParentInfo(Function temp) { - if (basePage == null) + try { - return; + if (basePage == null) + { + return; + } + Application.RunOnMainThread(() => + { + if (basePage.sensorDiyView_Temp != null) + basePage.sensorDiyView_Temp.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_temp.ToString()).state, true); + if (basePage.sensorDiyView_Humi != null) + basePage.sensorDiyView_Humi.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_humidity.ToString()).state, true); + if (basePage.sensorDiyView_Pm25 != null) + basePage.sensorDiyView_Pm25.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.pm25.ToString()).state, false); + if (basePage.sensorDiyView_Co2 != null) + basePage.sensorDiyView_Co2.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.co2.ToString()).state, false); + if (basePage.sensorDiyView_Tvoc != null) + basePage.sensorDiyView_Tvoc.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.tvoc.ToString()).state, false); + if (basePage.sensorDiyView_EleDay != null) + basePage.sensorDiyView_EleDay.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.day_electricity.ToString()).state, false); + if (basePage.sensorDiyView_EleMonth != null) + basePage.sensorDiyView_EleMonth.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.month_electricity.ToString()).state, false); + if (basePage.sensorDiyView_EleActivePower != null) + basePage.sensorDiyView_EleActivePower.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.active_power.ToString()).state, false); + + + + switch (temp.GetAttrState("mode")) + { + case "cool"://鍒跺喎 + basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeCoolIcon2.png"; + basePage.btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeCoolIcon2.png"; + break; + case "heat"://鍒剁儹 + basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHeatIcon2.png"; + basePage.btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHeatIcon2.png"; + break; + case "fan"://閫氶 + basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeFanIcon2.png"; + basePage.btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeFanIcon2.png"; + break; + case "dry"://闄ゆ箍 + basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeDeHumiIcon2.png"; + basePage.btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeDeHumiIcon2.png"; + break; + case "humidity"://鍔犳箍 + basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHumiIcon2.png"; + basePage.btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHumiIcon2.png"; + break; + case "heat_humidity"://鍒剁儹鍔犳箍 + basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHeatHumiIcon2.png"; + basePage.btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHeatHumiIcon2.png"; + break; + } + switch (temp.GetAttrState("scene")) + { + case "at_home"://鍦ㄥ + basePage.btnWorkSceneControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneAtHome2.png"; + basePage.btnWorkSceneControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/SceneAtHome2.png"; + break; + case "leave_home"://绂诲 + basePage.btnWorkSceneControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneAwayHomeIcon2.png"; + basePage.btnWorkSceneControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/SceneAwayHomeIcon2.png"; + break; + case "sleep"://鐫$湢 + basePage.btnWorkSceneControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneSleepIcon2.png"; + basePage.btnWorkSceneControl.SelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/SceneSleepIcon2.png"; + break; + } + basePage.btnModeControl.IsSelected = basePage.btnWorkSceneControl.IsSelected = basePage.btnPowerControl.IsSelected = temp.GetAttrState("on_off") == "on"; + }); } - if (basePage.sensorDiyView_Temp != null) - basePage.sensorDiyView_Temp.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_temp.ToString()).state); - if (basePage.sensorDiyView_Humi != null) - basePage.sensorDiyView_Humi.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_humidity.ToString()).state); - if (basePage.sensorDiyView_Pm25 != null) - basePage.sensorDiyView_Pm25.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.pm25.ToString()).state); - if (basePage.sensorDiyView_Co2 != null) - basePage.sensorDiyView_Co2.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.co2.ToString()).state); - if (basePage.sensorDiyView_Tvoc != null) - basePage.sensorDiyView_Tvoc.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.tvoc.ToString()).state); - if (basePage.sensorDiyView_EleDay != null) - basePage.sensorDiyView_EleDay.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.day_electricity.ToString()).state); - if (basePage.sensorDiyView_EleMonth != null) - basePage.sensorDiyView_EleMonth.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.month_electricity.ToString()).state); - if (basePage.sensorDiyView_EleTotal != null) - basePage.sensorDiyView_EleTotal.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.total_electricity.ToString()).state); - - - basePage.btnModeControl.IsSelected = basePage.btnWorkSceneControl.IsSelected = basePage.btnPowerControl.IsSelected = temp.trait_on_off.state == "on"; - - switch (temp.GetAttrState("mode")) + catch (Exception ex) { - case "cool"://鍒跺喎 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeCoolIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeCoolIcon2.png"; - break; - case "heat"://鍒剁儹 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHeatIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHeatIcon2.png"; - break; - case "fan"://閫氶 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeFanIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeFanIcon2.png"; - break; - case "dry"://闄ゆ箍 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeDeHumiIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeDeHumiIcon2.png"; - break; - case "humidity"://鍔犳箍 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHumiIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHumiIcon2.png"; - break; - case "heat_humidity"://鍒剁儹鍔犳箍 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHeatHumiIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHeatHumiIcon2.png"; - break; + MainPage.Log("绉戞妧绯荤粺鏇存柊鏁版嵁澶辫触:" + ex.Message); } - switch (temp.GetAttrState("scene")) - { - case "at_home"://鍦ㄥ - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneAtHome2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeCoolIcon2.png"; - break; - case "leave_home"://绂诲 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneAwayHomeIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/SceneAwayHomeIcon2.png"; - break; - case "sleep"://鐫$湢 - basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneSleepIcon2.png"; - basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/SceneSleepIcon2.png"; - break; - } - } - /// <summary> /// 鏇存柊瀛愭帶淇℃伅 @@ -169,51 +238,54 @@ /// <param name="temp"></param> public static void UpdateAcstSubInfo(Function temp) { - if(basePage == null) + try { - return; - } - Application.RunOnMainThread(() => { - var view = basePage.subViewList[temp.sid]; - if(view!= null) + if (basePage == null) { - view.btnSubHumidityValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%"; - view.btnSubTempValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%"; - view.btnSubPower.IsSelected = temp.GetAttrState(AcstSub_AttrEnum.on_off.ToString()) == "on"; + return; } - }); + Application.RunOnMainThread(() => + { + try + { + AcstSubControlView view = null; + basePage.subViewList.TryGetValue(temp.sid, out view); + if (view != null) + { + if (temp.spk == SPK.AcstSub) + { + view.btnSubHumidityValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%"; + view.btnSubTempValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "掳"; + view.btnSubPower.IsSelected = temp.GetAttrState(AcstSub_AttrEnum.on_off.ToString()) == "on"; + } + else if (temp.spk == SPK.WaterHeaterJinmao) + { + view.btnSubTempValues.Text = temp.GetAttrState(WaterHeaterJinmao_AttrEnum.temp.ToString()) + "掳"; + view.btnSubPower.IsSelected = temp.GetAttrState(WaterHeaterJinmao_AttrEnum.on_off.ToString()) == "on"; + } + } + } + catch (Exception ex) + { + MainPage.Log($"绉戞妧绯荤粺鏇存柊寮傚父1:{ex.Message}"); + } + }); + } + catch (Exception ex) + { + MainPage.Log($"绉戞妧绯荤粺鏇存柊寮傚父123:{ex.Message}"); + } } public void LoadPage() { - var curTime = DateTime.Now; - string helloText = "涓婂崍濂�"; - if (curTime.Hour >= 8 && curTime.Hour < 12) - { - helloText = "涓婂崍濂�"; - curColor = CSS.CSS_Color.MainColor; - imageFolder = "blue"; - } - else if (curTime.Hour >= 12 && curTime.Hour < 18) - { - helloText = "涓嬪崍濂�"; - curColor = 0xFFE7914F; - imageFolder = "orange"; - } - else - { - helloText = "鏅氫笂濂�"; - curColor = 0xFF9175F3; - imageFolder = "purple"; - } - #region 澶撮儴淇℃伅鍖哄煙 FrameLayout topView = new FrameLayout() { Height = Application.GetRealHeight(180), BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/TopViewBg.png", }; - bodyView.AddChidren(topView); + contentView.AddChidren(topView); var backView = new FrameLayout() { @@ -235,7 +307,8 @@ Button btnBackClick = new Button(); backView.AddChidren(btnBackClick); - btnBackClick.MouseUpEventHandler = (sender, e) => { + btnBackClick.MouseUpEventHandler = (sender, e) => + { this.RemoveFromParent(); }; @@ -334,30 +407,14 @@ #endregion - bodyView.AddChidren(new Button + contentView.AddChidren(new Button { Height = Application.GetRealHeight(8), }); #region 鏁版嵁 - var infoView = new FrameLayout() - { - Y = topView.Bottom, - Height = Application.GetRealHeight(104), - BackgroundColor = CSS.CSS_Color.MainBackgroundColor, - }; - bodyView.AddChidren(infoView); - var infoContentView = new FrameLayout() - { - Gravity = Gravity.Center, - Width = Application.GetRealWidth(343), - Height = Application.GetRealHeight(72), - BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/MsgViewBg.png", - }; - infoView.AddChidren(infoContentView); - - #region 浼犳劅鍣ㄦ暟鎹� + #region 浼犳劅鍣ㄦ暟鎹�昏 int sensorCount = 0; var tempObj = function.GetAttribute(AcstParent_AttrEnum.room_temp.ToString()); if (tempObj != null) @@ -384,39 +441,16 @@ { sensorCount++; } - - var sensorListView = new HorizontalScrolViewLayout() - { - Width = Application.GetRealWidth(60 * sensorCount), - Gravity = Gravity.Center, - }; - infoContentView.AddChidren(sensorListView); - - - if (tempObj != null) - { - sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempObj.state == "" ? "--" : tempObj.state + "掳", "娓╁害"); - } - if (humiObj != null) - { - sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiObj.state == "" ? "--" : humiObj.state + "%", "婀垮害"); - } - if (pm25Obj != null) - { - sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.state == "" ? "--" : pm25Obj.state, "PM2.5"); - } - if (co2Obj != null) - { - sensorDiyView_Co2 = new SensorDiyView(sensorListView, curColor, co2Obj.state == "" ? "--" : co2Obj.state, "CO2"); - } - if (tvocObj != null) - { - sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.state == "" ? "--" : tvocObj.state, "TVOC"); - } #endregion - #region 鑳借�楁暟鎹� + + #region 鑳借�楁暟鎹粺璁� int energyCount = 0; + var totalObj = function.GetAttribute(AcstParent_AttrEnum.active_power.ToString()); + if (totalObj != null) + { + energyCount++; + } var dayObj = function.GetAttribute(AcstParent_AttrEnum.day_electricity.ToString()); if (dayObj != null) { @@ -427,64 +461,146 @@ { energyCount++; } - var totalObj = function.GetAttribute(AcstParent_AttrEnum.total_electricity.ToString()); - if (totalObj != null) - { - energyCount++; - } - - var energyListView = new HorizontalScrolViewLayout() - { - Width = Application.GetRealWidth(100 * energyCount), - Gravity = Gravity.Center, - Visible = false, - }; - infoContentView.AddChidren(energyListView); - if (dayObj != null) - { - sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.state == "" ? "--" : dayObj.state + "KW", "浠婃棩鑰楃數",100); - } - if (monthObj != null) - { - sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.state == "" ? "--" : monthObj.state + "KWh", "鏈湀鑰楃數", 100); - } - if (totalObj != null) - { - sensorDiyView_EleTotal = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state + "KWh", "鎬昏�楃數閲�", 100); - } - - var btnChangeClick = new Button(); - infoView.AddChidren(btnChangeClick); - - bool showSensor = true; - EventHandler<MouseEventArgs> changeInfoEvent = (sender, e) => { - if (showSensor) - { - sensorListView.Visible = false; - showSensor = false; - energyListView.Visible = true; - } - else - { - sensorListView.Visible = true; - showSensor = true; - energyListView.Visible = false; - } - }; - btnChangeClick.MouseUpEventHandler = changeInfoEvent; - - #endregion + if (energyCount > 0 || sensorCount > 0) + { + var infoView = new FrameLayout() + { + //Y = topView.Bottom, + Height = Application.GetRealHeight(104), + BackgroundColor = CSS.CSS_Color.MainBackgroundColor, + }; + contentView.AddChidren(infoView); + + var infoContentView = new FrameLayout() + { + Gravity = Gravity.Center, + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(72), + BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/MsgViewBg.png", + }; + infoView.AddChidren(infoContentView); + + #region 浼犳劅鍣ㄦ暟鎹� + + var sensorListView = new HorizontalScrolViewLayout() + { + Width = Application.GetRealWidth(60 * sensorCount), + Gravity = Gravity.Center, + }; + if (sensorCount > 0) + { + infoContentView.AddChidren(sensorListView); + } + + if (tempObj != null) + { + string tempValues = tempObj.state == "" ? "--" : tempObj.state; + if (tempValues.Contains(".")) + { + tempValues = tempValues.Remove(tempValues.IndexOf('.'), tempValues.Length - tempValues.IndexOf('.')); + } + sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempValues, "掳", "", Language.StringByID(StringId.Temp)); + } + if (humiObj != null) + { + string humiValues = humiObj.state == "" ? "--" : humiObj.state; + if (humiValues.Contains(".")) + { + humiValues = humiValues.Remove(humiValues.IndexOf('.'), humiValues.Length - humiValues.IndexOf('.')); + } + sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiValues, "%", "", Language.StringByID(StringId.Humidity)); + } + if (pm25Obj != null) + { + sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.state == "" ? "--" : pm25Obj.state, "", "", "PM2.5"); + } + if (co2Obj != null) + { + sensorDiyView_Co2 = new SensorDiyView(sensorListView, curColor, co2Obj.state == "" ? "--" : co2Obj.state, "", "", "CO2"); + } + if (tvocObj != null) + { + sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.state == "" ? "--" : tvocObj.state, "", "", "TVOC"); + } + #endregion + + #region 鑳借�楁暟鎹� + var energyListView = new HorizontalScrolViewLayout() + { + Width = Application.GetRealWidth(100 * energyCount), + Gravity = Gravity.Center, + Visible = sensorCount == 0 + }; + if (energyCount > 0) + { + infoContentView.AddChidren(energyListView); + } + if (totalObj != null) + { + string text = "鐢ㄧ數鍔熺巼"; + if (Language.CurrentLanguage != "Chinese") + { + text = "Power"; + } + sensorDiyView_EleActivePower = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state, "", "KW", text, 100); + } + if (dayObj != null) + { + string text = "浠婃棩鑰楃數"; + if (Language.CurrentLanguage != "Chinese") + { + text = "Power of today"; + } + sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.state == "" ? "--" : dayObj.state, "", "KWh", text, 100); + } + if (monthObj != null) + { + string text = "鏈湀鑰楃數"; + if (Language.CurrentLanguage != "Chinese") + { + text = "Power of month"; + } + sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.state == "" ? "--" : monthObj.state, "", "KWh", text, 100); + } + + + var btnChangeClick = new Button(); + infoView.AddChidren(btnChangeClick); + + bool showSensor = true; + EventHandler<MouseEventArgs> changeInfoEvent = (sender, e) => + { + if (showSensor) + { + sensorListView.Visible = false; + showSensor = false; + energyListView.Visible = true; + } + else + { + sensorListView.Visible = true; + showSensor = true; + energyListView.Visible = false; + } + }; + if (sensorCount > 0 && energyCount > 0) + { + btnChangeClick.MouseUpEventHandler = changeInfoEvent; + } + + #endregion + } #endregion #region 瀛愭帶鍒楄〃 var subTitleView = new FrameLayout() { - Height = Application.GetRealHeight(54-11), + Height = Application.GetRealHeight(54 - 11), }; - bodyView.AddChidren(subTitleView); + contentView.AddChidren(subTitleView); var btnCollection = new Button() { @@ -498,7 +614,8 @@ }; subTitleView.AddChidren(btnCollection); //鏀惰棌 - btnCollection.MouseUpEventHandler = (sender, e) => { + btnCollection.MouseUpEventHandler = (sender, e) => + { function.collect = !function.collect; btnCollection.IsSelected = function.collect; @@ -511,7 +628,7 @@ var btnTitleText2 = new Button() { X = btnCollection.Right, - Text = "鎴戠殑瀹跺涵", + TextID = StringId.MyHome, TextSize = 16, TextColor = 0xFF242424, TextAlignment = TextAlignment.CenterLeft, @@ -526,49 +643,72 @@ { Height = Application.GetRealHeight(88), }; - bodyView.AddChidren(subFunctionListView); + contentView.AddChidren(subFunctionListView); subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) }); - foreach (var sub in FunctionList.List.GetAcstSubList()) + new System.Threading.Thread(() => { - if (subViewList.ContainsKey(sub.sid)) + try { - continue; - } - - if (subFunctionCount > 0 && subFunctionCount % 2 == 0) - { - subFunctionListView = new HorizontalScrolViewLayout() +#if DEBUG + System.Threading.Thread.Sleep(200); +#endif + var showList = FunctionList.List.GetAcstSubList(); + showList.AddRange(FunctionList.List.GetWaterHeaterJinmaoList()); + foreach (var sub in showList) { - Height = Application.GetRealHeight(93), - }; - bodyView.AddChidren(subFunctionListView); - subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) }); + if (subViewList.ContainsKey(sub.sid)) + { + continue; + } + + Application.RunOnMainThread(() => + { + if (subFunctionCount > 0 && subFunctionCount % 2 == 0) + { + subFunctionListView = new HorizontalScrolViewLayout() + { + Height = Application.GetRealHeight(93), + ScrollEnabled = false, + }; + contentView.AddChidren(subFunctionListView); + subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) }); + } + + AcstSubControlView subFunctionView = new AcstSubControlView(sub, subFunctionListView, imageFolder); + subViewList.Add(sub.sid, subFunctionView); + if (basePage != null) + { + new System.Threading.Thread(() => + { + Control.Ins.SendReadCommand(sub); + }) + { IsBackground = true }.Start(); + } + subFunctionCount++; + }); + + System.Threading.Thread.Sleep(10); + } } + catch { } + finally + { - AcstSubControlView subFunctionView = new AcstSubControlView(sub, subFunctionListView,imageFolder); - - subViewList.Add(sub.sid, subFunctionView); - - - - subFunctionCount++; - } - + } + }).Start(); #endregion - - bodyView.AddChidren(new Button() - { - Height = Application.GetRealHeight(72), - }); #region 搴曢儴鎺у埗鏍� var bottomView = new FrameLayout() { - Y = Application.GetRealHeight(667 - 56), - Height = Application.GetRealHeight(56), + Y = Application.GetRealHeight(667 - 66), + Height = Application.GetRealHeight(66+16), BackgroundColor = CSS.CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealHeight(16), + BorderColor = 0x00FFFFFF, + BorderWidth = 0, }; this.AddChidren(bottomView); @@ -586,19 +726,21 @@ bottomView.AddChidren(btnModeControl); btnModeControl.MouseUpEventHandler = (sender3, e3) => { - if(function.trait_on_off.state == "off") - { - return; - } + //if(function.trait_on_off.state == "off") + //{ + // return; + //} Dialog dialog = new Dialog(); var dialogView = new FrameLayout(); dialog.AddChidren(dialogView); - dialogView.MouseUpEventHandler = (sender, e) => { + dialogView.MouseUpEventHandler = (sender, e) => + { dialog.Close(); }; - var dialogContentView = new FrameLayout() { + var dialogContentView = new VerticalScrolViewLayout() + { X = Application.GetRealWidth(34), Y = Application.GetRealHeight(291), Width = Application.GetRealWidth(148), @@ -607,7 +749,8 @@ }; dialogView.AddChidren(dialogContentView); - var titleView = new FrameLayout() { + var titleView = new FrameLayout() + { X = Application.GetRealWidth(2), Y = Application.GetRealHeight(3), Width = Application.GetRealWidth(144), @@ -618,7 +761,7 @@ { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(100), - Text = "閫夋嫨妯″紡", + TextID = StringId.SelectMode, TextSize = 16, TextColor = CSS.CSS_Color.FirstLevelTitleColor, IsBold = true, @@ -626,191 +769,215 @@ }; titleView.AddChidren(btnTitleText); - #region 鍒跺喎 - var coolView = new FrameLayout() + if (function.GetAttribute(AcstParent_AttrEnum.mode.ToString()).value.Contains(AcstParent_Attr_ModeValueEnum.cool.ToString())) { - X = Application.GetRealWidth(2), - Y = titleView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(coolView); - coolView.AddChidren(new Button - { - Width = Application.GetRealWidth(112), - Gravity = Gravity.CenterHorizontal, - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton coolIconButton = new IconButton("FunctionIcon/Acst/grey/ModeCoolIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon.png", - Language.StringByID(StringId.Cool),curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == "cool"); - coolIconButton.Click(()=> { - dialog.Close(); - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon2.png"; - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add(AcstParent_AttrEnum.mode.ToString(), AcstParent_Attr_ModeValueEnum.cool.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) { IsBackground = true }.Start(); - }); - coolView.AddChidren(coolIconButton); - #endregion + #region 鍒跺喎 + var coolView = new FrameLayout() + { + X = Application.GetRealWidth(2), + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(coolView); + coolView.AddChidren(new Button + { + Width = Application.GetRealWidth(112), + Gravity = Gravity.CenterHorizontal, + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton coolIconButton = new IconButton("FunctionIcon/Acst/grey/ModeCoolIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon.png", + Language.StringByID(StringId.Cool), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == "cool"); + coolIconButton.Click(() => + { + dialog.Close(); + btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon2.png"; + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add(AcstParent_AttrEnum.mode.ToString(), AcstParent_Attr_ModeValueEnum.cool.ToString()); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + coolView.AddChidren(coolIconButton); + #endregion + } + if (function.GetAttribute(AcstParent_AttrEnum.mode.ToString()).value.Contains(AcstParent_Attr_ModeValueEnum.heat.ToString())) + { + #region 鍒剁儹 + var heatView = new FrameLayout() + { + X = Application.GetRealWidth(2), + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(heatView); + heatView.AddChidren(new Button + { + Width = Application.GetRealWidth(112), + Gravity = Gravity.CenterHorizontal, + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton heatIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHeatIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHeatIcon.png", + Language.StringByID(StringId.Heat), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == "heat"); + heatIconButton.Click(() => + { + dialog.Close(); + btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHeatIcon2.png"; + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("mode", "heat"); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + heatView.AddChidren(heatIconButton); + #endregion + } - #region 鍒剁儹 - var heatView = new FrameLayout() + if (function.GetAttribute(AcstParent_AttrEnum.mode.ToString()).value.Contains(AcstParent_Attr_ModeValueEnum.fan.ToString())) { - X = Application.GetRealWidth(2), - Y = coolView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(heatView); - heatView.AddChidren(new Button - { - Width = Application.GetRealWidth(112), - Gravity = Gravity.CenterHorizontal, - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton heatIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHeatIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHeatIcon.png", - Language.StringByID(StringId.Heat), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == "heat"); - heatIconButton.Click(() => { - dialog.Close(); - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHeatIcon2.png"; - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("mode", "heat"); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - heatView.AddChidren(heatIconButton); - #endregion + #region 閫氶 + var fanView = new FrameLayout() + { + X = Application.GetRealWidth(2), + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(fanView); + fanView.AddChidren(new Button + { + Width = Application.GetRealWidth(112), + Gravity = Gravity.CenterHorizontal, + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton fanIconButton = new IconButton("FunctionIcon/Acst/grey/ModeFanIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeFanIcon.png", + Language.StringByID(StringId.Ventilated), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.fan.ToString()); + fanIconButton.Click(() => + { + btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeFanIcon2.png"; + dialog.Close(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("mode", AcstParent_Attr_ModeValueEnum.fan.ToString()); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + fanView.AddChidren(fanIconButton); + #endregion + } - #region 闄ゆ箍 - var dehumiView = new FrameLayout() + if (function.GetAttribute(AcstParent_AttrEnum.mode.ToString()).value.Contains(AcstParent_Attr_ModeValueEnum.dry.ToString())) { - X = Application.GetRealWidth(2), - Y = heatView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(dehumiView); - dehumiView.AddChidren(new Button + #region 闄ゆ箍 + var dehumiView = new FrameLayout() + { + X = Application.GetRealWidth(2), + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(dehumiView); + dehumiView.AddChidren(new Button + { + Width = Application.GetRealWidth(112), + Gravity = Gravity.CenterHorizontal, + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton dehumiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeDeHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeDeHumiIcon.png", + Language.StringByID(StringId.Dry), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.dry.ToString()); + dehumiIconButton.Click(() => + { + btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeDeHumiIcon2.png"; + dialog.Close(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("mode", AcstParent_Attr_ModeValueEnum.dry.ToString()); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + dehumiView.AddChidren(dehumiIconButton); + #endregion + } + if (function.GetAttribute(AcstParent_AttrEnum.mode.ToString()).value.Contains(AcstParent_Attr_ModeValueEnum.heat_humidity.ToString())) { - Width = Application.GetRealWidth(112), - Gravity = Gravity.CenterHorizontal, - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton dehumiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeDeHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeDeHumiIcon.png", - Language.StringByID(StringId.Humidity), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.dry.ToString()); - dehumiIconButton.Click(() => { - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeDeHumiIcon2.png"; - dialog.Close(); - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("mode", AcstParent_Attr_ModeValueEnum.dry.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - dehumiView.AddChidren(dehumiIconButton); - #endregion - #region 閫氶 - var fanView = new FrameLayout() - { - X = Application.GetRealWidth(2), - Y = dehumiView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(fanView); - fanView.AddChidren(new Button - { - Width = Application.GetRealWidth(112), - Gravity = Gravity.CenterHorizontal, - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton fanIconButton = new IconButton("FunctionIcon/Acst/grey/ModeFanIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeFanIcon.png", - Language.StringByID(StringId.Ventilated), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.fan.ToString()); - fanIconButton.Click(() => { - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeFanIcon2.png"; - dialog.Close(); - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("mode", AcstParent_Attr_ModeValueEnum.fan.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - fanView.AddChidren(fanIconButton); - #endregion + #region 鍒剁儹闄ゆ箍 + var heatHumiView = new FrameLayout() + { + X = Application.GetRealWidth(2), + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(heatHumiView); + heatHumiView.AddChidren(new Button + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(112), + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton heatHumiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHeatHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHeatHumiIcon.png", + Language.StringByID(StringId.HeatingAndDehumidification), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.heat_humidity.ToString()); + heatHumiIconButton.Click(() => + { + btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHeatHumiIcon2.png"; + dialog.Close(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("mode", AcstParent_Attr_ModeValueEnum.heat_humidity.ToString()); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + heatHumiView.AddChidren(heatHumiIconButton); + #endregion + } - #region 鍒剁儹闄ゆ箍 - var heatHumiView = new FrameLayout() + if (function.GetAttribute(AcstParent_AttrEnum.mode.ToString()).value.Contains(AcstParent_Attr_ModeValueEnum.humidity.ToString())) { - X = Application.GetRealWidth(2), - Y = fanView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(heatHumiView); - heatHumiView.AddChidren(new Button - { - Gravity = Gravity.CenterHorizontal, - Width = Application.GetRealWidth(112), - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton heatHumiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHeatHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHeatHumiIcon.png", - "鍒剁儹闄ゆ箍", curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.heat_humidity.ToString()); - heatHumiIconButton.Click(() => { - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHeatHumiIcon2.png"; - dialog.Close(); - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("mode", AcstParent_Attr_ModeValueEnum.heat_humidity.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - heatHumiView.AddChidren(heatHumiIconButton); - #endregion - - #region 鍔犳箍 - var humiView = new FrameLayout() - { - X = Application.GetRealWidth(2), - Y = heatHumiView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(humiView); - humiView.AddChidren(new Button - { - Width = Application.GetRealWidth(112), - Gravity = Gravity.CenterHorizontal, - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton humiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHumiIcon.png", - "鍔犳箍", curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.humidity.ToString()); - humiIconButton.Click(() => { - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHumiIcon2.png"; - dialog.Close(); - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("mode", AcstParent_Attr_ModeValueEnum.humidity.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - humiView.AddChidren(humiIconButton); - #endregion + #region 鍔犳箍 + var humiView = new FrameLayout() + { + X = Application.GetRealWidth(2), + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(humiView); + humiView.AddChidren(new Button + { + Width = Application.GetRealWidth(112), + Gravity = Gravity.CenterHorizontal, + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton humiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHumiIcon.png", + Language.StringByID(StringId.Humidification), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.humidity.ToString()); + humiIconButton.Click(() => + { + btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHumiIcon2.png"; + dialog.Close(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("mode", AcstParent_Attr_ModeValueEnum.humidity.ToString()); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + humiView.AddChidren(humiIconButton); + #endregion + } dialog.Show(); }; @@ -826,15 +993,21 @@ IsSelected = function.trait_on_off.state == "on" }; bottomView.AddChidren(btnPowerControl); - btnPowerControl.MouseUpEventHandler = (sender, e) => { - btnPowerControl.IsSelected = !btnPowerControl.IsSelected; + btnPowerControl.MouseUpEventHandler = (sender, e) => + { + string msg = btnPowerControl.IsSelected ? "纭畾鍏抽棴鎬诲紑鍏冲悧锛�" : "纭畾鎵撳紑鎬诲紑鍏冲悧锛�"; + new PublicAssmebly().TipOptionMsg(StringId.Tip, msg, () => + { + btnPowerControl.IsSelected = !btnPowerControl.IsSelected; - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("onoff", btnPowerControl.IsSelected ? "on" : "off"); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add(FunctionAttributeKey.OnOff, btnPowerControl.IsSelected ? "on" : "off"); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); }; @@ -854,22 +1027,20 @@ btnWorkSceneControl.MouseUpEventHandler = (sender2, e2) => { - if (function.trait_on_off.state == "off") - { - return; - } Dialog dialog = new Dialog(); var dialogView = new FrameLayout(); dialog.AddChidren(dialogView); - dialogView.MouseUpEventHandler = (sender, e) => { + dialogView.MouseUpEventHandler = (sender, e) => + { dialog.Close(); }; - var dialogContentView = new FrameLayout() + var dialogContentView = new VerticalScrolViewLayout() { X = Application.GetRealWidth(194), Y = Application.GetRealHeight(419), + ScrollEnabled = false, Width = Application.GetRealWidth(148), Height = Application.GetRealHeight(191), BackgroundImagePath = "FunctionIcon/Acst/BgChooseScene.png", @@ -888,7 +1059,7 @@ { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(100), - Text = "閫夋嫨鍦烘櫙", + TextID = StringId.SelectScene, TextSize = 16, TextColor = CSS.CSS_Color.FirstLevelTitleColor, IsBold = true, @@ -896,98 +1067,116 @@ }; titleView.AddChidren(btnTitleText); - #region 鍦ㄥ - var atHomeView = new FrameLayout() + if (function.GetAttribute(AcstParent_AttrEnum.scene.ToString()).value.Contains(AcstParent_Attr_SceneValueEnum.at_home.ToString())) { - X = Application.GetRealWidth(2), - Y = titleView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(atHomeView); - atHomeView.AddChidren(new Button - { - Width = Application.GetRealWidth(112), - Gravity = Gravity.CenterHorizontal, - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton atHomeIconButton = new IconButton("FunctionIcon/Acst/grey/SceneAtHome.png", $"FunctionIcon/Acst/{imageFolder}/SceneAtHome.png", - "鍦ㄥ", curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.at_home.ToString()); - atHomeIconButton.Click(() => { - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAtHome2.png"; - dialog.Close(); - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add(AcstParent_AttrEnum.scene.ToString(), AcstParent_Attr_SceneValueEnum.at_home.ToString()); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - atHomeView.AddChidren(atHomeIconButton); - #endregion + #region 鍦ㄥ + var atHomeView = new VerticalScrolViewLayout() + { + X = Application.GetRealWidth(2), + //Y = titleView.Bottom, + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(atHomeView); + atHomeView.AddChidren(new Button + { + Width = Application.GetRealWidth(112), + Gravity = Gravity.CenterHorizontal, + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + + IconButton atHomeIconButton = new IconButton("FunctionIcon/Acst/grey/SceneAtHome.png", $"FunctionIcon/Acst/{imageFolder}/SceneAtHome.png", + Language.StringByID(StringId.AtHome), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.at_home.ToString()); + atHomeIconButton.Click(() => + { + btnWorkSceneControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAtHome2.png"; + dialog.Close(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add(AcstParent_AttrEnum.scene.ToString(), AcstParent_Attr_SceneValueEnum.at_home.ToString()); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + atHomeView.AddChidren(atHomeIconButton); + #endregion + } - #region 绂诲 - var awayHomeView = new FrameLayout() + if (function.GetAttribute(AcstParent_AttrEnum.scene.ToString()).value.Contains(AcstParent_Attr_SceneValueEnum.leave_home.ToString())) { - X = Application.GetRealWidth(2), - Y = atHomeView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(awayHomeView); - awayHomeView.AddChidren(new Button - { - Width = Application.GetRealWidth(112), - Gravity = Gravity.CenterHorizontal, - Height = 1, - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton awayHomeIconButton = new IconButton("FunctionIcon/Acst/grey/SceneAwayHomeIcon.png", $"FunctionIcon/Acst/{imageFolder}/SceneAwayHomeIcon.png", - "绂诲", curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.leave_home.ToString()); - awayHomeIconButton.Click(() => { - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAwayHomeIcon2.png"; - dialog.Close(); - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("scene", "leave_home"); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - awayHomeView.AddChidren(awayHomeIconButton); - #endregion + #region 绂诲 + var awayHomeView = new FrameLayout() + { + X = Application.GetRealWidth(2), + //Y = atHomeView.Bottom, + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(awayHomeView); + awayHomeView.AddChidren(new Button + { + Width = Application.GetRealWidth(112), + Gravity = Gravity.CenterHorizontal, + Height = 1, + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton awayHomeIconButton = new IconButton("FunctionIcon/Acst/grey/SceneAwayHomeIcon.png", $"FunctionIcon/Acst/{imageFolder}/SceneAwayHomeIcon.png", + Language.StringByID(StringId.AwayHome), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.leave_home.ToString()); + awayHomeIconButton.Click(() => + { + btnWorkSceneControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAwayHomeIcon2.png"; + dialog.Close(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("scene", "leave_home"); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + awayHomeView.AddChidren(awayHomeIconButton); + #endregion + } - #region 鐫$湢 - var sleepView = new FrameLayout() + + if (function.GetAttribute(AcstParent_AttrEnum.scene.ToString()).value.Contains(AcstParent_Attr_SceneValueEnum.sleep.ToString())) { - X = Application.GetRealWidth(2), - Y = awayHomeView.Bottom, - Width = Application.GetRealWidth(144), - Height = Application.GetRealHeight(44), - }; - dialogContentView.AddChidren(sleepView); - sleepView.AddChidren(new Button - { - Height = 1, - Gravity = Gravity.CenterHorizontal, - Width = Application.GetRealWidth(112), - BackgroundColor = CSS.CSS_Color.DividingLineColor, - }); - IconButton sleepIconButton = new IconButton("FunctionIcon/Acst/grey/SceneSleepIcon.png", $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon.png", - Language.StringByID(StringId.Humidity), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.sleep.ToString()); - sleepIconButton.Click(() => { - btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon2.png"; - dialog.Close(); - new System.Threading.Thread(() => { - Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add("scene", "sleep"); - Control.Ins.SendWriteCommand(function, d); - }) - { IsBackground = true }.Start(); - }); - sleepView.AddChidren(sleepIconButton); + + #region 鐫$湢 + var sleepView = new FrameLayout() + { + X = Application.GetRealWidth(2), + //Y = awayHomeView.Bottom, + Width = Application.GetRealWidth(144), + Height = Application.GetRealHeight(44), + }; + dialogContentView.AddChidren(sleepView); + sleepView.AddChidren(new Button + { + Height = 1, + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(112), + BackgroundColor = CSS.CSS_Color.DividingLineColor, + }); + IconButton sleepIconButton = new IconButton("FunctionIcon/Acst/grey/SceneSleepIcon.png", $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon.png", + Language.StringByID(StringId.Sleep), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.sleep.ToString()); + sleepIconButton.Click(() => + { + btnWorkSceneControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon2.png"; + dialog.Close(); + new System.Threading.Thread(() => + { + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("scene", "sleep"); + Control.Ins.SendWriteCommand(function, d); + }) + { IsBackground = true }.Start(); + }); + sleepView.AddChidren(sleepIconButton); + } #endregion dialog.Show(); }; @@ -998,12 +1187,13 @@ #endregion - - - - - InitGetWeatherAction(); + + new System.Threading.Thread(() => + { + Control.Ins.SendReadCommand(function); + }) + { IsBackground = true }.Start(); } @@ -1020,9 +1210,11 @@ private Button btnValue; private Button btnText; public string Tag; + public string unitString; - public SensorDiyView(HorizontalScrolViewLayout view,uint color,string value,string text,int setWidth = 60) + public SensorDiyView(HorizontalScrolViewLayout view, uint color, string value, string unitStr, string unitStr2, string text, int setWidth = 60) { + unitString = unitStr; if (string.IsNullOrEmpty(value)) { value = "--"; @@ -1045,7 +1237,7 @@ TextAlignment = TextAlignment.Center, TextColor = color, TextSize = 20, - Text = value, + Text = value + unitString, }; contentView.AddChidren(btnValue); @@ -1059,11 +1251,22 @@ Text = text, }; contentView.AddChidren(btnText); + + if (!string.IsNullOrEmpty(unitStr2)) + { + btnText.Text += "(" + unitStr2 + ")"; + } + + } - public void UpdateValue(string value) + public void UpdateValue(string value, bool isInt) { - btnText.Text = value; + if (value.Contains(".") && isInt) + { + value = value.Remove(value.IndexOf('.'), value.Length - value.IndexOf('.')); + } + btnValue.Text = value + unitString; } } @@ -1077,7 +1280,7 @@ public Button btnSubPower; public string Tag; - public AcstSubControlView(Function sub, HorizontalScrolViewLayout subFunctionListView,string imageFolder) + public AcstSubControlView(Function sub, HorizontalScrolViewLayout subFunctionListView, string imageFolder) { Tag = sub.sid; @@ -1093,11 +1296,12 @@ { X = Application.GetRealWidth(18 + 7), Y = Application.GetRealHeight(11), + Width = Application.GetRealWidth(120), Height = Application.GetRealHeight(40), TextAlignment = TextAlignment.CenterLeft, TextColor = 0xFF1b3053, TextSize = 13, - Text = sub.GetRoomListName(), + Text = sub.name, }; subFunctionView.AddChidren(btnRoomInfo); @@ -1116,36 +1320,12 @@ X = btnSubTempIcon.Right, Y = Application.GetRealHeight(45 + 11), Height = Application.GetRealHeight(14), - Width = Application.GetRealWidth(22), + Width = Application.GetRealWidth(35), TextColor = 0xFF1b3035, TextSize = 10, - Text = sub.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "掳C", TextAlignment = TextAlignment.CenterLeft, }; subFunctionView.AddChidren(btnSubTempValues); - - Button btnSubHumidityIcon = new Button() - { - X = btnSubTempValues.Right + Application.GetRealWidth(5), - Y = Application.GetRealHeight(47 + 11), - Width = Application.GetMinRealAverage(11), - Height = Application.GetMinRealAverage(11), - UnSelectedImagePath = "FunctionIcon/CAC/HvacCacHumidityIcon.png", - }; - subFunctionView.AddChidren(btnSubHumidityIcon); - - btnSubHumidityValues = new TextButton() - { - X = btnSubHumidityIcon.Right, - Y = Application.GetRealHeight(45 + 11), - Height = Application.GetRealHeight(14), - Width = Application.GetRealWidth(22), - TextColor = 0xFF1b3053, - TextSize = 10, - Text = sub.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%", - TextAlignment = TextAlignment.CenterLeft, - }; - subFunctionView.AddChidren(btnSubHumidityValues); btnSubPower = new Button() { @@ -1158,7 +1338,8 @@ TextAlignment = TextAlignment.Center, }; subFunctionView.AddChidren(btnSubPower); - btnSubPower.MouseUpEventHandler = (sender, e) => { + btnSubPower.MouseUpEventHandler = (sender, e) => + { btnSubPower.IsSelected = !btnSubPower.IsSelected; string onoff = btnSubPower.IsSelected ? "on" : "off"; Dictionary<string, string> d = new Dictionary<string, string>(); @@ -1166,20 +1347,71 @@ Control.Ins.SendWriteCommand(sub, d); }; - EventHandler<MouseEventArgs> eventHandler = (sender, e) => { - var page = new AcstSubPage(sub,imageFolder); - MainPage.BasePageView.AddChidren(page); - page.LoadPage(); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - }; + if (sub.spk == SPK.AcstSub) + { + btnSubTempValues.Text = sub.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "掳C"; + Button btnSubHumidityIcon = new Button() + { + X = btnSubTempValues.Right + Application.GetRealWidth(5), + Y = Application.GetRealHeight(47 + 11), + Width = Application.GetMinRealAverage(11), + Height = Application.GetMinRealAverage(11), + UnSelectedImagePath = "FunctionIcon/CAC/HvacCacHumidityIcon.png", + }; + subFunctionView.AddChidren(btnSubHumidityIcon); - btnRoomInfo.MouseUpEventHandler = eventHandler; - btnSubHumidityIcon.MouseUpEventHandler = eventHandler; - btnSubHumidityValues.MouseUpEventHandler = eventHandler; - btnSubPower.MouseUpEventHandler = eventHandler; - btnSubTempIcon.MouseUpEventHandler = eventHandler; - btnSubTempValues.MouseUpEventHandler = eventHandler; - subFunctionView.MouseUpEventHandler = eventHandler; + btnSubHumidityValues = new TextButton() + { + X = btnSubHumidityIcon.Right, + Y = Application.GetRealHeight(45 + 11), + Height = Application.GetRealHeight(14), + Width = Application.GetRealWidth(35), + TextColor = 0xFF1b3053, + TextSize = 10, + Text = sub.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%", + TextAlignment = TextAlignment.CenterLeft, + }; + subFunctionView.AddChidren(btnSubHumidityValues); + + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + var page = new AcstSubPage(sub, imageFolder); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(() => + { + btnRoomInfo.Text = sub.name; + }); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + + btnRoomInfo.MouseUpEventHandler = eventHandler; + btnSubTempIcon.MouseUpEventHandler = eventHandler; + btnSubTempValues.MouseUpEventHandler = eventHandler; + subFunctionView.MouseUpEventHandler = eventHandler; + btnSubHumidityIcon.MouseUpEventHandler = eventHandler; + btnSubHumidityValues.MouseUpEventHandler = eventHandler; + } + else if (sub.spk == SPK.WaterHeaterJinmao) + { + btnSubTempValues.Width = Application.GetRealWidth(45); + btnSubTempValues.Text = sub.GetAttrState(WaterHeaterJinmao_AttrEnum.temp.ToString()) + "掳C"; + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + var page = new WaterHeaterJinmaoPage(sub); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(() => + { + btnRoomInfo.Text = sub.name; + }); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + + btnRoomInfo.MouseUpEventHandler = eventHandler; + btnSubTempIcon.MouseUpEventHandler = eventHandler; + btnSubTempValues.MouseUpEventHandler = eventHandler; + subFunctionView.MouseUpEventHandler = eventHandler; + + } } } @@ -1192,7 +1424,7 @@ public Button btnText; - public IconButton(string iconPath,string iconPath2,string text,uint color,bool isSelect) + public IconButton(string iconPath, string iconPath2, string text, uint color, bool isSelect) { view = this; view.Width = Application.GetRealWidth(144); @@ -1223,19 +1455,22 @@ }; view.AddChidren(btnText); - + } public void Click(Action action) { - view.MouseUpEventHandler = (sender, e) => { + view.MouseUpEventHandler = (sender, e) => + { action(); }; - btnText.MouseUpEventHandler = (sender, e) => { + btnText.MouseUpEventHandler = (sender, e) => + { action(); }; - btnIcon.MouseUpEventHandler = (sender, e) => { + btnIcon.MouseUpEventHandler = (sender, e) => + { action(); }; } -- Gitblit v1.8.0