| | |
| | | |
| | | VerticalScrolViewLayout contentView; |
| | | |
| | | string helloText = "上午好"; |
| | | |
| | | #region 天气控件 |
| | | Button btnOutdoorTemp; |
| | |
| | | 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"; |
| | |
| | | { |
| | | 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 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) |
| | | { |
| | | 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("科技系统更新数据失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <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) |
| | | { |
| | | 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"; |
| | | } |
| | | } |
| | | catch (Exception ex ) { |
| | | MainPage.Log($"科技系统更新异常1:{ex.Message}"); |
| | | } |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"科技系统更新异常123:{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | public void LoadPage() |
| | | { |
| | | #region 头部信息区域 |
| | | FrameLayout topView = new FrameLayout() |
| | | { |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | { |
| | | 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 |
| | | |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | { |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | var btnTitleText2 = new Button() |
| | | { |
| | | X = btnCollection.Right, |
| | | Text = "我的家庭", |
| | | TextID = StringId.MyHome, |
| | | TextSize = 16, |
| | | TextColor = 0xFF242424, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | |
| | | Height = Application.GetRealHeight(54), |
| | | }; |
| | | subTitleView.AddChidren(btnTitleText2); |
| | | if(Language.CurrentLanguage != "Chinese") |
| | | { |
| | | btnTitleText2.Text = "My Home"; |
| | | } |
| | | |
| | | int subFunctionCount = 0; |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | #if DEBUG |
| | | System.Threading.Thread.Sleep(200); |
| | | #endif |
| | | |
| | | foreach (var sub in FunctionList.List.GetAcstSubList()) |
| | | { |
| | | if (subViewList.ContainsKey(sub.sid)) |
| | |
| | | |
| | | 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(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | Control.Ins.SendReadCommand(sub); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | subFunctionCount++; |
| | | }); |
| | | |
| | |
| | | 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)) |
| | |
| | | TextAlignment = TextAlignment.Center, |
| | | TextColor = color, |
| | | TextSize = 20, |
| | | Text = value, |
| | | Text = value + unitString, |
| | | }; |
| | | contentView.AddChidren(btnValue); |
| | | |
| | |
| | | }; |
| | | contentView.AddChidren(btnText); |
| | | |
| | | if(!string.IsNullOrEmpty(unitString)) |
| | | if(!string.IsNullOrEmpty(unitStr2)) |
| | | { |
| | | btnText.Text += "(" + unitString + ")"; |
| | | btnText.Text += "(" + unitStr2 + ")"; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | value = value.Remove(value.IndexOf('.'), value.Length - value.IndexOf('.')); |
| | | } |
| | | btnValue.Text = value; |
| | | btnValue.Text = value + unitString; |
| | | } |
| | | } |
| | | |