From 47f179be722a61c95cc03c8f90e1aa91c12d1124 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期三, 23 十月 2024 18:49:23 +0800 Subject: [PATCH] UI走查,安卓 --- HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs | 652 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 371 insertions(+), 281 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs index 714191b..9684781 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,8 +34,9 @@ { static AcstParentPage basePage; - VerticalScrolViewLayout contentView; + VerticalScrolViewLayoutJinmao contentView; + string helloText = "涓婂崍濂�"; #region 澶╂皵鎺т欢 Button btnOutdoorTemp; @@ -41,9 +60,7 @@ /// </summary> Dictionary<string, AcstSubControlView> subViewList; - Button btnWorkSceneControl; - Button btnModeControl; Button btnPowerControl; @@ -65,134 +82,7 @@ public AcstParentPage() { basePage = this; - this.function = FunctionList.List.GetAcstParentList()[0]; - this.BackgroundColor = CSS.CSS_Color.BackgroundColor; - contentView = new VerticalScrolViewLayout() { - Height = Application.GetRealHeight(667 - 56), - }; - this.AddChidren(contentView); - subViewList = new Dictionary<string, AcstSubControlView>(); - } - /// <summary> - /// 鏇存柊澶╂皵淇℃伅 - /// </summary> - public void InitGetWeatherAction() - { - MainPage.CityWeatherAction = () => - { - Application.RunOnMainThread(() => - { - btnOutdoorTemp.Text = MainPage.cityInfo.temperature + "掳"; - btnWeather.Text = MainPage.cityInfo.weather; - btnHumidityValues.Text = MainPage.cityInfo.humidity + "%"; - btnHumidityValues.Width = btnHumidityValues.GetTextWidth() + Application.GetRealWidth(10); - btnPm25Values.Text = MainPage.cityInfo.pm25; - btnPm25Values.Width = btnPm25Values.GetTextWidth() + Application.GetRealWidth(10); - }); - }; - } - /// <summary> - /// 鏇存柊涓绘帶鏁版嵁淇℃伅 - /// </summary> - public static void UpdateAcstParentInfo(Function temp) - { - 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"; - }); - } - - - /// <summary> - /// 鏇存柊瀛愭帶淇℃伅 - /// </summary> - /// <param name="temp"></param> - public static void UpdateAcstSubInfo(Function temp) - { - if(basePage == null) - { - return; - } - Application.RunOnMainThread(() => { - var view = basePage.subViewList[temp.sid]; - if(view!= null) - { - 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"; - } - }); - } - - public void LoadPage() - { var curTime = DateTime.Now; - string helloText = "涓婂崍濂�"; if (Language.CurrentLanguage != "Chinese") { helloText = "Good morning"; @@ -224,24 +114,184 @@ { helloText = "Good evening"; } - + curColor = 0xFF9175F3; imageFolder = "purple"; } + this.function = FunctionList.List.GetAcstParentList()[0]; + this.BackgroundColor = CSS.CSS_Color.BackgroundColor; + //this.AddChidren(new Button() { Height = Application.GetRealHeight(50), BackgroundColor = curColor }); + contentView = new VerticalScrolViewLayoutJinmao() + { + Height = Application.GetRealHeight(667 - 56 -10), + VerticalScrollBarEnabled = false, + }; + basePage.AddChidren(contentView); + + subViewList = new Dictionary<string, AcstSubControlView>(); + } + /// <summary> + /// 鏇存柊澶╂皵淇℃伅 + /// </summary> + public void InitGetWeatherAction() + { + MainPage.CityWeatherAction = () => + { + Application.RunOnMainThread(() => + { + btnOutdoorTemp.Text = MainPage.cityInfo.temperature + "掳"; + btnWeather.Text = MainPage.cityInfo.weather; + btnHumidityValues.Text = MainPage.cityInfo.humidity + "%"; + btnHumidityValues.Width = btnHumidityValues.GetTextWidth() + Application.GetRealWidth(10); + btnPm25Values.Text = MainPage.cityInfo.pm25; + btnPm25Values.Width = btnPm25Values.GetTextWidth() + Application.GetRealWidth(10); + }); + }; + } + /// <summary> + /// 鏇存柊涓绘帶鏁版嵁淇℃伅 + /// </summary> + public static void UpdateAcstParentInfo(Function temp) + { + try + { + 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"; + }); + } + catch (Exception ex) + { + MainPage.Log("绉戞妧绯荤粺鏇存柊鏁版嵁澶辫触:" + ex.Message); + } + } + + /// <summary> + /// 鏇存柊瀛愭帶淇℃伅 + /// </summary> + /// <param name="temp"></param> + public static void UpdateAcstSubInfo(Function temp) + { + try + { + if (basePage == null) + { + 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() + { #region 澶撮儴淇℃伅鍖哄煙 FrameLayout topView = new FrameLayout() { - Height = Application.GetRealHeight(180), + Height = Application.GetRealWidth(203), BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/TopViewBg.png", }; contentView.AddChidren(topView); var backView = new FrameLayout() { - Y = Application.GetRealHeight(32), + Y = Application.GetRealWidth(56), Width = Application.GetRealWidth(100), - Height = Application.GetRealHeight(34), + Height = Application.GetRealWidth(34), }; topView.AddChidren(backView); @@ -249,7 +299,7 @@ { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(12), - Height = Application.GetRealHeight(20), + Height = Application.GetRealWidth(20), UnSelectedImagePath = "FunctionIcon/Acst/BackIcon.png", }; backView.AddChidren(btnBackIcon); @@ -257,32 +307,32 @@ Button btnBackClick = new Button(); backView.AddChidren(btnBackClick); - btnBackClick.MouseUpEventHandler = (sender, e) => { + btnBackClick.MouseUpEventHandler = (sender, e) => + { this.RemoveFromParent(); }; var btnHelloText = new Button() { - X = Application.GetRealWidth(25), - Y = Application.GetRealHeight(55), + X = Application.GetRealWidth(26), + Y = Application.GetRealWidth(87), Width = Application.GetRealWidth(200), - Height = Application.GetRealHeight(38), - TextSize = 20, + Height = Application.GetRealWidth(24), + TextSize = 17, Text = helloText, TextColor = 0xFFFFFFFF, TextAlignment = TextAlignment.CenterLeft, }; topView.AddChidren(btnHelloText); - btnOutdoorTemp = new Button() { - X = Application.GetRealWidth(25), - Y = Application.GetRealHeight(90), + X = Application.GetRealWidth(26), + Y = Application.GetRealWidth(108), Width = Application.GetRealWidth(85), - Height = Application.GetRealHeight(66), + Height = Application.GetRealWidth(66), TextColor = 0xFFFFFFFF, - TextSize = 50, + TextSize = 44, TextAlignment = TextAlignment.TopLeft, Text = MainPage.cityInfo.temperature + "掳" }; @@ -290,22 +340,21 @@ btnWeather = new Button() { - X = btnOutdoorTemp.Right, - Y = Application.GetRealHeight(95), + X = Application.GetRealWidth(105), + Y = Application.GetRealWidth(118), Width = Application.GetRealWidth(80), - Height = Application.GetRealHeight(26), + Height = Application.GetRealWidth(18), Text = MainPage.cityInfo.weather, TextColor = 0xFFFFFFFF, - TextSize = 14, + TextSize = 12, TextAlignment = TextAlignment.CenterLeft, }; topView.AddChidren(btnWeather); - var environmentalView = new FrameLayout() { - Y = Application.GetRealHeight(150), - Height = Application.GetRealHeight(32), + Y = Application.GetRealWidth(168), + Height = Application.GetRealWidth(32), }; topView.AddChidren(environmentalView); @@ -313,8 +362,8 @@ { X = Application.GetRealWidth(25), Gravity = Gravity.CenterVertical, - Width = Application.GetMinRealAverage(16), - Height = Application.GetMinRealAverage(16), + Width = Application.GetMinRealAverage(14), + Height = Application.GetMinRealAverage(14), UnSelectedImagePath = "Public/DeviceInfoIcon/HumidityIcon.png", }; environmentalView.AddChidren(btnHumidityIcon); @@ -324,7 +373,7 @@ X = btnHumidityIcon.Right + Application.GetRealWidth(4), Gravity = Gravity.CenterVertical, TextColor = 0xFFFFFFFF, - TextSize = 16, + TextSize = 13, Text = MainPage.cityInfo.humidity + "%", TextAlignment = TextAlignment.CenterLeft, }; @@ -335,8 +384,8 @@ { X = btnHumidityValues.Right + Application.GetRealWidth(14), Gravity = Gravity.CenterVertical, - Width = Application.GetMinRealAverage(16), - Height = Application.GetMinRealAverage(16), + Width = Application.GetMinRealAverage(14), + Height = Application.GetMinRealAverage(14), UnSelectedImagePath = "Public/DeviceInfoIcon/Pm25Icon.png", }; environmentalView.AddChidren(btnPm25Icon); @@ -346,7 +395,7 @@ X = btnPm25Icon.Right + Application.GetRealWidth(4), Gravity = Gravity.CenterVertical, TextColor = 0xFFFFFFFF, - TextSize = 16, + TextSize = 13, Text = MainPage.cityInfo.pm25, TextAlignment = TextAlignment.CenterLeft, }; @@ -358,7 +407,7 @@ contentView.AddChidren(new Button { - Height = Application.GetRealHeight(8), + Height = Application.GetRealWidth(8), }); #region 鏁版嵁 @@ -416,7 +465,7 @@ { var infoView = new FrameLayout() { - Y = topView.Bottom, + //Y = topView.Bottom, Height = Application.GetRealHeight(104), BackgroundColor = CSS.CSS_Color.MainBackgroundColor, }; @@ -450,7 +499,7 @@ { tempValues = tempValues.Remove(tempValues.IndexOf('.'), tempValues.Length - tempValues.IndexOf('.')); } - sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempValues, "掳", Language.StringByID(StringId.Temp)); + sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempValues, "掳", "", Language.StringByID(StringId.Temp)); } if (humiObj != null) { @@ -459,19 +508,19 @@ { humiValues = humiValues.Remove(humiValues.IndexOf('.'), humiValues.Length - humiValues.IndexOf('.')); } - sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiValues , "%", Language.StringByID(StringId.Humidity)); + 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"); + 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 @@ -493,7 +542,7 @@ { text = "Power"; } - sensorDiyView_EleActivePower = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state, "KW", text, 100); + sensorDiyView_EleActivePower = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state, "", "KW", text, 100); } if (dayObj != null) { @@ -502,7 +551,7 @@ { text = "Power of today"; } - sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.state == "" ? "--" : dayObj.state, "KWh", text, 100); + sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.state == "" ? "--" : dayObj.state, "", "KWh", text, 100); } if (monthObj != null) { @@ -511,7 +560,7 @@ { text = "Power of month"; } - sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.state == "" ? "--" : monthObj.state, "KWh", text, 100); + sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.state == "" ? "--" : monthObj.state, "", "KWh", text, 100); } @@ -547,63 +596,58 @@ var subTitleView = new FrameLayout() { - Height = Application.GetRealHeight(54-11), + Height = Application.GetRealWidth(56), }; contentView.AddChidren(subTitleView); var btnCollection = new Button() { - X = Application.GetRealWidth(6), - Y = Application.GetRealHeight(10), - Width = Application.GetRealWidth(39), - Height = Application.GetRealWidth(39), + X = Application.GetRealWidth(16), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth(19), + Height = Application.GetRealWidth(19), IsSelected = function.collect, UnSelectedImagePath = "FunctionIcon/Acst/grey/CollectionIcon.png", SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/CollectionIcon.png", }; subTitleView.AddChidren(btnCollection); //鏀惰棌 - btnCollection.MouseUpEventHandler = (sender, e) => { + btnCollection.MouseUpEventHandler = (sender, e) => + { function.collect = !function.collect; btnCollection.IsSelected = function.collect; - - //var http = new DAL.Server.HttpServerRequest(); - //http.CollectDevice(function.deviceId); function.CollectFunction(); - }; var btnTitleText2 = new Button() { - X = btnCollection.Right, - Text = "鎴戠殑瀹跺涵", + X = btnCollection.Right + Application.GetRealWidth(6), + TextID = StringId.MyHome, TextSize = 16, TextColor = 0xFF242424, TextAlignment = TextAlignment.CenterLeft, IsBold = true, - Height = Application.GetRealHeight(54), + Height = Application.GetRealWidth(38), + Gravity = Gravity.CenterVertical, }; subTitleView.AddChidren(btnTitleText2); - if(Language.CurrentLanguage != "Chinese") - { - btnTitleText2.Text = "My Home"; - } int subFunctionCount = 0; var subFunctionListView = new HorizontalScrolViewLayout() { - Height = Application.GetRealHeight(88), + Height = Application.GetRealWidth(72), }; contentView.AddChidren(subFunctionListView); + contentView.AddChidren(new Button { Height = Application.GetRealWidth(16) }); - - subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) }); new System.Threading.Thread(() => { try { - foreach (var sub in FunctionList.List.GetAcstSubList()) + var showList = FunctionList.List.GetAcstSubList(); + showList.AddRange(FunctionList.List.GetWaterHeaterJinmaoList()); + foreach (var sub in showList) { if (subViewList.ContainsKey(sub.sid)) { @@ -616,28 +660,36 @@ { subFunctionListView = new HorizontalScrolViewLayout() { - Height = Application.GetRealHeight(93), + Height = Application.GetRealWidth(72), + ScrollEnabled = false, }; contentView.AddChidren(subFunctionListView); - subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) }); + contentView.AddChidren(new Button { Height = Application.GetRealWidth(16) }); } + + subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(16) }); AcstSubControlView subFunctionView = new AcstSubControlView(sub, subFunctionListView, imageFolder); subViewList.Add(sub.sid, subFunctionView); - new System.Threading.Thread(() => + + if (basePage != null) { - Control.Ins.SendReadCommand(sub); - }) - { IsBackground = true }.Start(); - subFunctionCount++; + new System.Threading.Thread(() => + { + Control.Ins.SendReadCommand(sub); + }) + { IsBackground = true }.Start(); + } + subFunctionCount++; }); System.Threading.Thread.Sleep(10); } } catch { } - finally{ - + finally + { + } }).Start(); #endregion @@ -646,16 +698,19 @@ #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); btnModeControl = new Button() { X = Application.GetRealWidth(89), - Gravity = Gravity.CenterVertical, + Y = Application.GetRealWidth(16), Width = Application.GetRealWidth(38), Height = Application.GetRealWidth(38), UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeCoolIcon2.png", @@ -674,11 +729,13 @@ var dialogView = new FrameLayout(); dialog.AddChidren(dialogView); - dialogView.MouseUpEventHandler = (sender, e) => { + dialogView.MouseUpEventHandler = (sender, e) => + { dialog.Close(); }; - var dialogContentView = new VerticalScrolViewLayout() { + var dialogContentView = new VerticalScrolViewLayout() + { X = Application.GetRealWidth(34), Y = Application.GetRealHeight(291), Width = Application.GetRealWidth(148), @@ -687,7 +744,8 @@ }; dialogView.AddChidren(dialogContentView); - var titleView = new FrameLayout() { + var titleView = new FrameLayout() + { X = Application.GetRealWidth(2), Y = Application.GetRealHeight(3), Width = Application.GetRealWidth(144), @@ -921,7 +979,8 @@ btnPowerControl = new Button() { - Gravity = Gravity.Center, + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(16), Width = Application.GetRealWidth(38), Height = Application.GetRealWidth(38), UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png", @@ -950,7 +1009,7 @@ btnWorkSceneControl = new Button() { - Gravity = Gravity.CenterVertical, + Y = Application.GetRealWidth(16), X = Application.GetRealWidth(249), Width = Application.GetRealWidth(38), Height = Application.GetRealWidth(38), @@ -964,15 +1023,12 @@ 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(); }; @@ -1152,7 +1208,7 @@ public string Tag; public string unitString; - public SensorDiyView(HorizontalScrolViewLayout view,uint color,string value,string unitStr,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)) @@ -1177,7 +1233,7 @@ TextAlignment = TextAlignment.Center, TextColor = color, TextSize = 20, - Text = value, + Text = value + unitString, }; contentView.AddChidren(btnValue); @@ -1188,25 +1244,25 @@ TextAlignment = TextAlignment.Center, TextColor = 0xFF949AA5, TextSize = 12, - Text = text , + Text = text, }; contentView.AddChidren(btnText); - if(!string.IsNullOrEmpty(unitString)) + if (!string.IsNullOrEmpty(unitStr2)) { - btnText.Text += "(" + unitString + ")"; + btnText.Text += "(" + unitStr2 + ")"; } } - public void UpdateValue(string value,bool isInt) + public void UpdateValue(string value, bool isInt) { if (value.Contains(".") && isInt) { value = value.Remove(value.IndexOf('.'), value.Length - value.IndexOf('.')); } - btnValue.Text = value; + btnValue.Text = value + unitString; } } @@ -1220,36 +1276,40 @@ 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; var subFunctionView = new FrameLayout() { - Width = Application.GetRealWidth(177), - Height = Application.GetRealHeight(93), - BackgroundImagePath = "FunctionIcon/Acst/grey/BgSubControlView.png", + Width = Application.GetRealWidth(163), + Height = Application.GetRealWidth(72), + Radius = (uint)Application.GetRealWidth(6), + BorderColor = 0x00FFFFFF, + BorderWidth = (uint)Application.GetRealWidth(1), + BackgroundColor = CSS.CSS_Color.MainBackgroundColor, + //BackgroundImagePath = "FunctionIcon/Acst/grey/BgSubControlView.png", }; subFunctionListView.AddChidren(subFunctionView); var btnRoomInfo = new Button() { - X = Application.GetRealWidth(18 + 7), - Y = Application.GetRealHeight(11), - Height = Application.GetRealHeight(40), + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(120), + Height = Application.GetRealWidth(44), TextAlignment = TextAlignment.CenterLeft, TextColor = 0xFF1b3053, - TextSize = 13, + TextSize = 14, Text = sub.name, }; subFunctionView.AddChidren(btnRoomInfo); var btnSubTempIcon = new Button() { - X = Application.GetRealWidth(16 + 7), - Y = Application.GetRealHeight(47 + 11), - Width = Application.GetMinRealAverage(11), - Height = Application.GetMinRealAverage(11), + X = Application.GetRealWidth(13), + Y = Application.GetRealWidth(48), + Width = Application.GetRealWidth(12), + Height = Application.GetRealWidth(12), UnSelectedImagePath = "FunctionIcon/CAC/HvacCacTempIcon.png", }; subFunctionView.AddChidren(btnSubTempIcon); @@ -1257,51 +1317,28 @@ btnSubTempValues = new TextButton() { X = btnSubTempIcon.Right, - Y = Application.GetRealHeight(45 + 11), - Height = Application.GetRealHeight(14), + Y = Application.GetRealWidth(46), + Height = Application.GetRealWidth(15), Width = Application.GetRealWidth(35), TextColor = 0xFF1b3035, - TextSize = 10, - Text = sub.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "掳C", + TextSize = 11, 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(35), - TextColor = 0xFF1b3053, - TextSize = 10, - Text = sub.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%", - TextAlignment = TextAlignment.CenterLeft, - }; - subFunctionView.AddChidren(btnSubHumidityValues); - btnSubPower = new Button() { - X = Application.GetRealWidth(121 + 7), + X = Application.GetRealWidth(120), Gravity = Gravity.CenterVertical, - Width = Application.GetRealWidth(28), - Height = Application.GetRealWidth(28), + Width = Application.GetRealWidth(29), + Height = Application.GetRealWidth(29), UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png", SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerIcon.png", 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>(); @@ -1309,21 +1346,71 @@ Control.Ins.SendWriteCommand(sub, d); }; - 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; - }; + 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.GetRealWidth(48), + Width = Application.GetRealWidth(12), + Height = Application.GetRealWidth(12), + UnSelectedImagePath = "FunctionIcon/CAC/HvacCacHumidityIcon.png", + }; + subFunctionView.AddChidren(btnSubHumidityIcon); - btnRoomInfo.MouseUpEventHandler = eventHandler; - btnSubHumidityIcon.MouseUpEventHandler = eventHandler; - btnSubHumidityValues.MouseUpEventHandler = eventHandler; - btnSubTempIcon.MouseUpEventHandler = eventHandler; - btnSubTempValues.MouseUpEventHandler = eventHandler; - subFunctionView.MouseUpEventHandler = eventHandler; + btnSubHumidityValues = new TextButton() + { + X = btnSubHumidityIcon.Right, + Y = Application.GetRealWidth(46), + Height = Application.GetRealWidth(15), + 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; + + } } } @@ -1336,7 +1423,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); @@ -1367,19 +1454,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