From 38df05b600e7a41106f710a3e4287e37fbf35d03 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 27 十月 2022 09:10:34 +0800 Subject: [PATCH] 备份 --- HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs | 151 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 102 insertions(+), 49 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs index 2178573..774698a 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs @@ -33,7 +33,7 @@ SensorDiyView sensorDiyView_Tvoc; SensorDiyView sensorDiyView_EleDay; SensorDiyView sensorDiyView_EleMonth; - SensorDiyView sensorDiyView_EleTotal; + SensorDiyView sensorDiyView_EleActivePower; #endregion /// <summary> /// 瀛愭帶鍖哄煙鍒楄〃 @@ -113,8 +113,8 @@ 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); + if (basePage.sensorDiyView_EleActivePower != null) + basePage.sensorDiyView_EleActivePower.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.active_power.ToString()).state); @@ -180,7 +180,7 @@ if(view!= null) { view.btnSubHumidityValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%"; - view.btnSubTempValues.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"; } }); @@ -189,22 +189,39 @@ public void LoadPage() { var curTime = DateTime.Now; - string helloText = "涓婂崍濂�"; + string helloText = "涓婂崍濂�"; + 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"; } @@ -392,33 +409,40 @@ Width = Application.GetRealWidth(60 * sensorCount), Gravity = Gravity.Center, }; - infoContentView.AddChidren(sensorListView); - + if (sensorCount > 0) + { + infoContentView.AddChidren(sensorListView); + } if (tempObj != null) { - sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempObj.state == "" ? "--" : tempObj.state + "掳", "娓╁害"); + sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempObj.state == "" ? "--" : tempObj.state, "掳", Language.StringByID(StringId.Temp)); } if (humiObj != null) { - sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiObj.state == "" ? "--" : humiObj.state + "%", "婀垮害"); + sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiObj.state == "" ? "--" : humiObj.state, "%", Language.StringByID(StringId.Humidity)); } if (pm25Obj != null) { - sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.state == "" ? "--" : pm25Obj.state, "PM2.5"); + 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"); + 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"); + sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.state == "" ? "--" : tvocObj.state, "", "TVOC"); } #endregion #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) { @@ -429,31 +453,45 @@ { 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) + if (energyCount > 0) { - 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); + infoContentView.AddChidren(energyListView); } if (totalObj != null) { - sensorDiyView_EleTotal = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state + "KWh", "鎬昏�楃數閲�", 100); + 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 , "KW", 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); @@ -473,8 +511,10 @@ energyListView.Visible = false; } }; - btnChangeClick.MouseUpEventHandler = changeInfoEvent; - + if (sensorCount > 0 && energyCount > 0) + { + btnChangeClick.MouseUpEventHandler = changeInfoEvent; + } #endregion @@ -521,6 +561,10 @@ Height = Application.GetRealHeight(54), }; subTitleView.AddChidren(btnTitleText2); + if(Language.CurrentLanguage != "Chinese") + { + btnTitleText2.Text = "My Home"; + } int subFunctionCount = 0; @@ -620,7 +664,7 @@ { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(100), - Text = "閫夋嫨妯″紡", + TextID = StringId.SelectScene, TextSize = 16, TextColor = CSS.CSS_Color.FirstLevelTitleColor, IsBold = true, @@ -769,7 +813,7 @@ 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()); + 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(); @@ -800,7 +844,7 @@ 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()); + 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(); @@ -828,15 +872,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(FunctionAttributeKey.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(); + }); }; @@ -890,7 +940,7 @@ { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(100), - Text = "閫夋嫨鍦烘櫙", + TextID = StringId.SelectScene, TextSize = 16, TextColor = CSS.CSS_Color.FirstLevelTitleColor, IsBold = true, @@ -915,7 +965,7 @@ 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()); + Language.StringByID(StringId.AtHome), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.at_home.ToString()); atHomeIconButton.Click(() => { btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAtHome2.png"; dialog.Close(); @@ -947,7 +997,7 @@ 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()); + Language.StringByID(StringId.AwayHome), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.leave_home.ToString()); awayHomeIconButton.Click(() => { btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAwayHomeIcon2.png"; dialog.Close(); @@ -978,7 +1028,7 @@ 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()); + Language.StringByID(StringId.Sleep), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.sleep.ToString()); sleepIconButton.Click(() => { btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon2.png"; dialog.Close(); @@ -1019,9 +1069,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 text,int setWidth = 60) { + unitString = unitStr; if (string.IsNullOrEmpty(value)) { value = "--"; @@ -1044,7 +1096,7 @@ TextAlignment = TextAlignment.Center, TextColor = color, TextSize = 20, - Text = value, + Text = value + unitString, }; contentView.AddChidren(btnValue); @@ -1062,7 +1114,7 @@ public void UpdateValue(string value) { - btnText.Text = value; + btnValue.Text = value + unitString; } } @@ -1096,7 +1148,7 @@ TextAlignment = TextAlignment.CenterLeft, TextColor = 0xFF1b3053, TextSize = 13, - Text = sub.GetRoomListName(), + Text = sub.name, }; subFunctionView.AddChidren(btnRoomInfo); @@ -1168,14 +1220,15 @@ EventHandler<MouseEventArgs> eventHandler = (sender, e) => { var page = new AcstSubPage(sub,imageFolder); MainPage.BasePageView.AddChidren(page); - page.LoadPage(); + page.LoadPage(()=> { + btnRoomInfo.Text = sub.name; + }); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; btnRoomInfo.MouseUpEventHandler = eventHandler; btnSubHumidityIcon.MouseUpEventHandler = eventHandler; btnSubHumidityValues.MouseUpEventHandler = eventHandler; - btnSubPower.MouseUpEventHandler = eventHandler; btnSubTempIcon.MouseUpEventHandler = eventHandler; btnSubTempValues.MouseUpEventHandler = eventHandler; subFunctionView.MouseUpEventHandler = eventHandler; -- Gitblit v1.8.0