From 8e940d7f0c873cfedf7f6d8c885be98b96f1d046 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期二, 10 九月 2024 15:43:41 +0800 Subject: [PATCH] 金茂光伏,金茂热水器 --- HDL_ON/UI/UI2/FuntionControlView/Acst/WaterHeaterJinmaoPage.cs | 423 +++++++++++++++++++++++++++------------------------- 1 files changed, 220 insertions(+), 203 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/WaterHeaterJinmaoPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/WaterHeaterJinmaoPage.cs index 485c9a1..3197659 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Acst/WaterHeaterJinmaoPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Acst/WaterHeaterJinmaoPage.cs @@ -180,9 +180,10 @@ initContentView(); initBottomView(); initControlEvent(); - Control.Ins.SendReadCommand(function); UpdateStatus(); + + Control.Ins.SendReadCommand(function); } /// <summary> /// 鍔犺浇鍐呭鍖哄煙 @@ -505,177 +506,181 @@ setTempView.AddChidren(setTemp_Temp_MaxValuesTextButton); #endregion - contentView.AddChidren(new Button() + + if (function.attributes.Find((obj) => obj.key == WaterHeaterJinmao_AttrEnum.flow.ToString()) != null) { - Height = Application.GetRealWidth(12), - }); + contentView.AddChidren(new Button() + { + Height = Application.GetRealWidth(12), + }); - #region flow 鐑按娴侀噺 - var flowView = new FrameLayout() - { - Gravity = Gravity.CenterHorizontal, - Width = Application.GetRealWidth(343), - Height = Application.GetRealWidth(186), - BackgroundColor = CSS_Color.MainBackgroundColor, - Radius = (uint)Application.GetRealHeight(12), - BorderColor = 0x00FFFFFF, - BorderWidth = 0, - }; - contentView.AddChidren(flowView); + #region flow 鐑按娴侀噺 + var flowView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealWidth(186), + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealHeight(12), + BorderColor = 0x00FFFFFF, + BorderWidth = 0, + }; + contentView.AddChidren(flowView); - flow_ValuesButton = new Button() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealWidth(14), - Width = Application.GetRealWidth(200), - Height = Application.GetRealWidth(25), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 16, - TextColor = CSS_Color.FirstLevelTitleColor, - Text = "鐑按娴侀噺锛�" + function.GetAttrState(WaterHeaterJinmao_AttrEnum.flow.ToString()) + "L/min", - IsBold = true, - }; - flowView.AddChidren(flow_ValuesButton); + flow_ValuesButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(14), + Width = Application.GetRealWidth(200), + Height = Application.GetRealWidth(25), + TextAlignment = TextAlignment.CenterLeft, + TextSize = 16, + TextColor = CSS_Color.FirstLevelTitleColor, + Text = "鐑按娴侀噺锛�" + function.GetAttrState(WaterHeaterJinmao_AttrEnum.flow.ToString()) + "L/min", + IsBold = true, + }; + flowView.AddChidren(flow_ValuesButton); - var flow_HotWaterVolumeTextButton = new Button() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealWidth(55), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(20), - Text = "鐑按閲�", - TextAlignment = TextAlignment.CenterLeft, - TextColor = CSS_Color.FirstLevelTitleColor, - TextSize = CSS_FontSize.TextFontSize, - }; - flowView.AddChidren(flow_HotWaterVolumeTextButton); + var flow_HotWaterVolumeTextButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(55), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(20), + Text = "鐑按閲�", + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + }; + flowView.AddChidren(flow_HotWaterVolumeTextButton); - string volumeString = function.GetAttrState(WaterHeaterJinmao_AttrEnum.volume.ToString()); - string recyclVolumeString = function.GetAttrState(WaterHeaterJinmao_AttrEnum.recycl_volume.ToString()); - double volume = 0; - double.TryParse(volumeString, out volume); - double recyclVolume = 0; - double.TryParse(recyclVolumeString, out recyclVolume); - int recyclVolumePercent = (int)(recyclVolume / volume * 100); + string volumeString = function.GetAttrState(WaterHeaterJinmao_AttrEnum.volume.ToString()); + string recyclVolumeString = function.GetAttrState(WaterHeaterJinmao_AttrEnum.recycl_volume.ToString()); + double volume = 0; + double.TryParse(volumeString, out volume); + double recyclVolume = 0; + double.TryParse(recyclVolumeString, out recyclVolume); + int recyclVolumePercent = (int)(recyclVolume / volume * 100); - flow_VolumeButton = new Button() - { - X = Application.GetRealWidth(343 - 116), - Y = Application.GetRealWidth(55), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(26), - Text = volumeString + "t", - TextAlignment = TextAlignment.CenterRight, - TextColor = CSS_Color.FirstLevelTitleColor, - TextSize = CSS_FontSize.TextFontSize, - }; - flowView.AddChidren(flow_VolumeButton); + flow_VolumeButton = new Button() + { + X = Application.GetRealWidth(343 - 116), + Y = Application.GetRealWidth(55), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(26), + Text = volumeString + "t", + TextAlignment = TextAlignment.CenterRight, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + }; + flowView.AddChidren(flow_VolumeButton); - flow_ValuesBar = new DiyImageSeekBar() - { - Gravity = Gravity.CenterHorizontal, - Y = Application.GetRealWidth(79), - Width = Application.GetRealWidth(Application.DesignWidth - 64), - Height = Application.GetRealHeight(8), - SeekBarViewHeight = Application.GetRealHeight(8), - ThumbImageHeight = Application.GetRealHeight(0), - ProgressBarColor = 0xFF42D163, - SeekBarBackgroundColor = 0xFFFFB848, - MaxValue = 100, - Progress = recyclVolumePercent, - SeekBarPadding = Application.GetRealWidth(0), - IsProgressTextShow = false, - ProgressChangeDelayTime = 0, - Enable = false, - IsClickable = false, - }; - flowView.AddChidren(flow_ValuesBar); + flow_ValuesBar = new DiyImageSeekBar() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(79), + Width = Application.GetRealWidth(Application.DesignWidth - 64), + Height = Application.GetRealHeight(8), + SeekBarViewHeight = Application.GetRealHeight(8), + ThumbImageHeight = Application.GetRealHeight(0), + ProgressBarColor = 0xFF42D163, + SeekBarBackgroundColor = 0xFFFFB848, + MaxValue = 100, + Progress = recyclVolumePercent, + SeekBarPadding = Application.GetRealWidth(0), + IsProgressTextShow = false, + ProgressChangeDelayTime = 0, + Enable = false, + IsClickable = false, + }; + flowView.AddChidren(flow_ValuesBar); - var flow_HeatRecoveryCapacitytTextButton = new Button() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealWidth(103), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(20), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 14, - TextColor = 0xFF00C22D, - Text = "鐑洖鏀堕噺" - }; - flowView.AddChidren(flow_HeatRecoveryCapacitytTextButton); + var flow_HeatRecoveryCapacitytTextButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(103), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(20), + TextAlignment = TextAlignment.CenterLeft, + TextSize = 14, + TextColor = 0xFF00C22D, + Text = "鐑洖鏀堕噺" + }; + flowView.AddChidren(flow_HeatRecoveryCapacitytTextButton); - flow_HeatRecoveryProgressButton = new Button() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealWidth(125), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(22), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 14, - TextColor = 0xFF00C22D, - Text = recyclVolumePercent + "%" - }; - flowView.AddChidren(flow_HeatRecoveryProgressButton); + flow_HeatRecoveryProgressButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(125), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(22), + TextAlignment = TextAlignment.CenterLeft, + TextSize = 14, + TextColor = 0xFF00C22D, + Text = recyclVolumePercent + "%" + }; + flowView.AddChidren(flow_HeatRecoveryProgressButton); - flow_HeatRecoverytValuesButton = new Button() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealWidth(148), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(22), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 14, - TextColor = CSS_Color.FirstLevelTitleColor, - Text = recyclVolume + "t" - }; - flowView.AddChidren(flow_HeatRecoverytValuesButton); + flow_HeatRecoverytValuesButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(148), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(22), + TextAlignment = TextAlignment.CenterLeft, + TextSize = 14, + TextColor = CSS_Color.FirstLevelTitleColor, + Text = recyclVolume + "t" + }; + flowView.AddChidren(flow_HeatRecoverytValuesButton); - var flow_ElectricDriveTextButton = new Button() - { - X = Application.GetRealWidth(343 - 116), - Y = Application.GetRealWidth(103), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(20), - TextAlignment = TextAlignment.CenterRight, - TextSize = 14, - TextColor = 0xFFFC9C04, - Text = "鐢电洿椹遍噺", - }; - flowView.AddChidren(flow_ElectricDriveTextButton); + var flow_ElectricDriveTextButton = new Button() + { + X = Application.GetRealWidth(343 - 116), + Y = Application.GetRealWidth(103), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(20), + TextAlignment = TextAlignment.CenterRight, + TextSize = 14, + TextColor = 0xFFFC9C04, + Text = "鐢电洿椹遍噺", + }; + flowView.AddChidren(flow_ElectricDriveTextButton); - flow_ElectricDriveProgressButton = new Button() - { - X = Application.GetRealWidth(343 - 116), - Y = Application.GetRealWidth(125), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(22), - TextAlignment = TextAlignment.CenterRight, - TextSize = 14, - TextColor = 0xFFFC9C04, - Text = "0%" - }; - if(volume > 0) - { - flow_ElectricDriveProgressButton.Text = (100 - recyclVolumePercent) + "%"; + flow_ElectricDriveProgressButton = new Button() + { + X = Application.GetRealWidth(343 - 116), + Y = Application.GetRealWidth(125), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(22), + TextAlignment = TextAlignment.CenterRight, + TextSize = 14, + TextColor = 0xFFFC9C04, + Text = "0%" + }; + if (volume > 0) + { + flow_ElectricDriveProgressButton.Text = (100 - recyclVolumePercent) + "%"; + } + flowView.AddChidren(flow_ElectricDriveProgressButton); + + flow_ElectricDriveValuesButton = new Button() + { + X = Application.GetRealWidth(343 - 116), + Y = Application.GetRealWidth(148), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(22), + TextAlignment = TextAlignment.CenterRight, + TextSize = 14, + TextColor = CSS_Color.FirstLevelTitleColor, + Text = (volume - recyclVolume) + "t" + }; + flowView.AddChidren(flow_ElectricDriveValuesButton); + + #endregion } - flowView.AddChidren(flow_ElectricDriveProgressButton); - - flow_ElectricDriveValuesButton = new Button() - { - X = Application.GetRealWidth(343 - 116), - Y = Application.GetRealWidth(148), - Width = Application.GetRealWidth(100), - Height = Application.GetRealWidth(22), - TextAlignment = TextAlignment.CenterRight, - TextSize = 14, - TextColor = CSS_Color.FirstLevelTitleColor, - Text = (volume - recyclVolume) + "t" - }; - flowView.AddChidren(flow_ElectricDriveValuesButton); - - #endregion contentView.AddChidren(new Button() { @@ -816,6 +821,9 @@ TextColor = CSS_Color.FirstLevelTitleColor, TextAlignment = TextAlignment.BottomLeft, }; +#if __IOS__ + socialContribution_Info2_UintButton.Y = Application.GetRealWidth(66); +#endif socialContribution_InfoView_2.AddChidren(socialContribution_Info2_UintButton); var socialContribution_Info2_TipButton = new Button() @@ -882,6 +890,9 @@ TextColor = CSS_Color.FirstLevelTitleColor, TextAlignment = TextAlignment.BottomLeft, }; +#if __IOS__ + socialContribution_Info3_UintButton.Y = Application.GetRealWidth(66); +#endif socialContribution_InfoView_3.AddChidren(socialContribution_Info3_UintButton); var socialContribution_Info3_TipButton = new Button() @@ -988,10 +999,15 @@ #if __IOS__ setTemp_ValuesButton.Width = setTemp_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); #else - setTemp_ValuesButton.Width = setTemp_ValuesButton.GetTextWidth(); + setTemp_ValuesButton.Width = setTemp_ValuesButton.GetTextWidth(); #endif setTemp_ValuesButton.Gravity = Gravity.CenterHorizontal; + +#if __IOS__ + setTemp_UintButton.X = setTemp_ValuesButton.Right - Application.GetRealWidth(4); +#else setTemp_UintButton.X = setTemp_ValuesButton.Right + Application.GetRealWidth(4); +#endif new System.Threading.Thread(() => { var dic = new Dictionary<string, string>(); @@ -1035,16 +1051,22 @@ //鍏嶈垂鐑按 Application.RunOnMainThread(() => { - bodyView.updateFreeMode(); - bodyView.updateTemp(); - bodyView.updateModeUI(); - bodyView.updateSetTemp(); - bodyView.updateFlow(); - bodyView.updateVolume(); - bodyView.updateSocialContribution1(); - bodyView.updateSocialContribution2(); - bodyView.updateSocialContribution3(); - bodyView.updatePowerButton(); + try + { + bodyView.updateFreeMode(); + bodyView.updateTemp(); + bodyView.updateModeUI(); + bodyView.updateSetTemp(); + bodyView.updateFlow(); + bodyView.updateVolume(); + bodyView.updateSocialContribution1(); + bodyView.updateSocialContribution2(); + bodyView.updateSocialContribution3(); + bodyView.updatePowerButton(); + }catch (Exception ex) + { + MainPage.Log("Error", $"閲戣寕鐑按鎺т欢鏇存柊寮傚父锛歿ex.Message}"); + } }); } @@ -1084,8 +1106,11 @@ btnTempValues.TextSize = 28; } btnTempValues.Gravity = Gravity.CenterHorizontal; - +#if __IOS__ + btnTempValuesUint.X = btnTempValues.Right - Application.GetRealWidth(4); +#else btnTempValuesUint.X = btnTempValues.Right ; +#endif } /// <summary> @@ -1137,8 +1162,11 @@ #endif setTemp_ValuesButton.Gravity = Gravity.CenterHorizontal; +#if __IOS__ + setTemp_UintButton.X = setTemp_ValuesButton.Right - Application.GetRealWidth(4); +#else setTemp_UintButton.X = setTemp_ValuesButton.Right + Application.GetRealWidth(4); - +#endif double dd = 35; double.TryParse(function.GetAttrState(WaterHeaterJinmao_AttrEnum.set_temp.ToString(), "0"), out dd); @@ -1151,7 +1179,10 @@ /// </summary> private void updateFlow() { - flow_ValuesButton.Text = "鐑按娴侀噺锛�" + function.GetAttrState(WaterHeaterJinmao_AttrEnum.flow.ToString()) + "L/min"; + if (function.attributes.Find((obj) => obj.key == WaterHeaterJinmao_AttrEnum.flow.ToString()) != null) + { + flow_ValuesButton.Text = "鐑按娴侀噺锛�" + function.GetAttrState(WaterHeaterJinmao_AttrEnum.flow.ToString()) + "L/min"; + } } /// <summary> @@ -1159,6 +1190,14 @@ /// </summary> private void updateVolume() { + if (function.attributes.Find((obj) => obj.key == WaterHeaterJinmao_AttrEnum.volume.ToString()) == null) + { + return; + } + if (function.attributes.Find((obj) => obj.key == WaterHeaterJinmao_AttrEnum.recycl_volume.ToString()) == null) + { + return; + } volumeString = function.GetAttrState(WaterHeaterJinmao_AttrEnum.volume.ToString()); recyclVolumeString = function.GetAttrState(WaterHeaterJinmao_AttrEnum.recycl_volume.ToString()); volume = 0; @@ -1183,23 +1222,16 @@ private void updateSocialContribution1() { socialContribution_Info1_ValuesButton.Text = function.GetAttrState(WaterHeaterJinmao_AttrEnum.energy_electricity.ToString()); -#if __IOS__ - socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); -#else socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth(); -#endif if (socialContribution_Info1_ValuesButton.Width > Application.GetRealWidth(61)) { socialContribution_Info1_ValuesButton.TextSize = 14; -#if __IOS__ - socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); -#else - socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth(); -#endif + socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth(); socialContribution_Info1_UintButton.Height = Application.GetRealWidth(25); } #if __IOS__ - socialContribution_Info1_UintButton.X = socialContribution_Info1_ValuesButton.Right ; + socialContribution_Info1_ValuesButton.Width += Application.GetRealWidth(6); + socialContribution_Info1_UintButton.X = socialContribution_Info1_ValuesButton.Right - Application.GetRealWidth(4); #else socialContribution_Info1_UintButton.X = socialContribution_Info1_ValuesButton.Right +Application.GetRealWidth(2); #endif @@ -1210,23 +1242,15 @@ private void updateSocialContribution2() { socialContribution_Info2_ValuesButton.Text = function.GetAttrState(WaterHeaterJinmao_AttrEnum.co2.ToString()); -#if __IOS__ - socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); -#else socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth(); -#endif if (socialContribution_Info2_ValuesButton.Width > Application.GetRealWidth(61)) { socialContribution_Info2_ValuesButton.TextSize = 14; -#if __IOS__ - socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); -#else - socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth(); -#endif - socialContribution_Info2_UintButton.Y = socialContribution_Info2_UintButton.Y - Application.GetRealWidth(4); + socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth(); } #if __IOS__ - socialContribution_Info2_UintButton.X = socialContribution_Info2_ValuesButton.Right; + socialContribution_Info2_ValuesButton.Width += Application.GetRealWidth(6); + socialContribution_Info2_UintButton.X = socialContribution_Info2_ValuesButton.Right - Application.GetRealWidth(4); #else socialContribution_Info2_UintButton.X = socialContribution_Info2_ValuesButton.Right +Application.GetRealWidth(2); #endif @@ -1237,24 +1261,17 @@ /// </summary> private void updateSocialContribution3() { - socialContribution_Info3_ValuesButton.Text = function.GetAttrState(WaterHeaterJinmao_AttrEnum.trees.ToString()); -#if __IOS__ - socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); -#else socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth(); -#endif if (socialContribution_Info3_ValuesButton.Width > Application.GetRealWidth(61)) { socialContribution_Info3_ValuesButton.TextSize = 14; -#if __IOS__ - socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); -#else - socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth(); -#endif + socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth(); + //socialContribution_Info3_UintButton.Height = Application.GetRealWidth(23); } #if __IOS__ - socialContribution_Info3_UintButton.X = socialContribution_Info3_ValuesButton.Right; + socialContribution_Info3_ValuesButton.Width += Application.GetRealWidth(6); + socialContribution_Info3_UintButton.X = socialContribution_Info3_ValuesButton.Right - Application.GetRealWidth(4); #else socialContribution_Info3_UintButton.X = socialContribution_Info3_ValuesButton.Right +Application.GetRealWidth(2); #endif -- Gitblit v1.8.0