From 418b0d0a4002bc06ba3a55d1809fe46043f06c09 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 26 九月 2022 14:07:58 +0800
Subject: [PATCH] 光伏更新,金茂科技系统更新

---
 HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubPage.cs |  352 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 278 insertions(+), 74 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubPage.cs
index 17a0485..593a132 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubPage.cs
@@ -1,95 +1,299 @@
 锘縰sing System;
+using System.Collections.Generic;
+using HDL_ON.DriverLayer;
+using HDL_ON.Entity;
+using HDL_ON.UI.CSS;
 using Shared;
 
 namespace HDL_ON.UI
 {
     public class AcstSubPage : FrameLayout
     {
-        FrameLayout bodyView;
+        static AcstSubPage bodyView;
+
+        Button btnTempValues;
+        Button btnHumiValues;
+
+        Button btnSetTempValues;
+        DiyImageSeekBar tempBar;
+        Button btnPowerControl;
+
+        Function function;
+
+        uint curColor;
 
         string imageFolder = "blue";
 
-        public AcstSubPage()
+        public static void UpdateStatus(Function temp)
         {
+            if(bodyView == null)
+            {
+                return;
+            }
+            Application.RunOnMainThread(() => {
+                bodyView.btnTempValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_temp.ToString());
+                bodyView.btnHumiValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString());
+                bodyView.btnSetTempValues.Width = bodyView.btnSetTempValues.GetTextWidth() + Application.GetRealWidth(10);
+                bodyView.tempBar.Progress = Convert.ToInt32(temp.GetAttrState(FunctionAttributeKey.SetTemp)) + 16;
+                if(temp.trait_on_off.curValue.ToString() == "on")
+                {
+                    bodyView.btnPowerControl.IsSelected = true;
+                    bodyView.tempBar.IsOffline = false;
+                }
+                else
+                {
+                    bodyView.btnPowerControl.IsSelected = false;
+                    bodyView.tempBar.IsOffline = true;
+                }
+            });
+
+        }
+
+        public AcstSubPage(Function temp, string path)
+        {
+            function = temp;
+            imageFolder = path;
+            switch (imageFolder)
+            {
+                case "blue":
+                    curColor = CSS.CSS_Color.MainColor;
+                    break;
+                case "orange":
+                    curColor = 0xFFFFB848;
+                    break;
+                case "purple":
+                    curColor = 0xFF9175F3;
+                    break;
+            }
             bodyView = this;
         }
 
-
-
         public void LoadPage()
         {
-            //涓�涓儗鏅浘鐗�
-            //var framePic = new FrameLayout();
-            //framePic.Y = Application.GetRealHeight(120);
-            //framePic.Width = Application.GetRealWidth(303);
-            //framePic.Height = Application.GetRealHeight(175);
-            //framePic.Gravity = Gravity.CenterHorizontal;
-            //framePic.BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/TempAndHumiBack.png";
-            //this.FrameWhiteCentet1.AddChidren(framePic);
+            new TopViewDiv(bodyView, function.GetRoomListName()).LoadTopView();
 
-            ////瀹ゅ唴婀垮害 鐨勫鍣�(涓轰簡閲嶆柊璁$畻鍧愭爣浣跨敤)
-            //int frameWidth = framePic.Width / 2 - this.GetPictrueRealSize(21);
-            //var frameHumidity = new FrameLayout();
-            //frameHumidity.X = this.GetPictrueRealSize(21);
-            //frameHumidity.Y = this.GetPictrueRealSize(12);
-            //frameHumidity.Width = frameWidth;
-            //frameHumidity.Height = frameWidth;
-            //framePic.AddChidren(frameHumidity);
-            ////瀹ゅ唴婀垮害鍊�
-            //this.btnHumidity = new NormalViewControl(20, this.GetPicChidrenTextHeight(30), false);
-            //btnHumidity.Y = this.GetPictrueRealSize(39);
-            //btnHumidity.TextSize = 30;
-            //btnHumidity.TextColor = CSS_Color.FirstLevelTitleColor;
-            //btnHumidity.TextAlignment = TextAlignment.TopCenter;
-            //frameHumidity.AddChidren(btnHumidity);
-            ////%
-            //this.btnHumidityUnit = new NormalViewControl(10, 10, true);
-            //btnHumidityUnit.Y = btnHumidity.Y + this.GetPictrueRealSize(8);
-            //btnHumidityUnit.TextColor = CSS_Color.TextualColor;
-            //btnHumidityUnit.Text = "%";
-            //btnHumidityUnit.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
-            //btnHumidityUnit.Width = btnHumidityUnit.GetRealWidthByText();
-            //frameHumidity.AddChidren(btnHumidityUnit);
-            ////瀹ゅ唴婀垮害
-            //var btnHumidityView = new NormalViewControl(frameHumidity.Width, this.GetPicChidrenTextHeight(18), false);
-            //btnHumidityView.Y = btnHumidity.Bottom + this.GetPictrueRealSize(8);
-            //btnHumidityView.TextAlignment = TextAlignment.Center;
-            //btnHumidityView.TextColor = CSS_Color.TextualColor;
-            //btnHumidityView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
-            //btnHumidityView.TextID = StringId.IndoorHumidity;
-            //frameHumidity.AddChidren(btnHumidityView);
+            var contentView = new FrameLayout()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(79),
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealHeight(570),
+                BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(6),
+            };
+            bodyView.AddChidren(contentView);
 
-            ////瀹ゅ唴娓╁害 鐨勫鍣�(涓轰簡閲嶆柊璁$畻鍧愭爣浣跨敤)
-            //var frameTemperature = new FrameLayout();
-            //frameTemperature.Y = frameHumidity.Y;
-            //frameTemperature.X = frameHumidity.Right;
-            //frameTemperature.Width = frameWidth;
-            //frameTemperature.Height = frameWidth;
-            //framePic.AddChidren(frameTemperature);
-            ////瀹ゅ唴娓╁害鍊�
-            //this.btnTemperature = new NormalViewControl(20, this.GetPicChidrenTextHeight(30), false);
-            //btnTemperature.Y = btnHumidity.Y;
-            //btnTemperature.TextSize = 30;
-            //btnTemperature.TextColor = CSS_Color.FirstLevelTitleColor;
-            //btnTemperature.TextAlignment = TextAlignment.TopCenter;
-            //btnTemperature.GetRealWidthByText();
-            //frameTemperature.AddChidren(btnTemperature);
-            ////鈩�
-            //this.btnTemperatureUnit = new NormalViewControl(10, 10, true);
-            //btnTemperatureUnit.Y = btnTemperature.Y + this.GetPictrueRealSize(8);
-            //btnTemperatureUnit.TextColor = CSS_Color.TextualColor;
-            //btnTemperatureUnit.Text = "鈩�";
-            //btnTemperatureUnit.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
-            //btnTemperatureUnit.Width = btnTemperatureUnit.GetRealWidthByText();
-            //frameTemperature.AddChidren(btnTemperatureUnit);
-            ////瀹ゅ唴娓╁害
-            //var btnTemperatureView = new NormalViewControl(frameTemperature.Width, this.GetPicChidrenTextHeight(18), false);
-            //btnTemperatureView.Y = btnTemperature.Bottom + this.GetPictrueRealSize(8);
-            //btnTemperatureView.TextAlignment = TextAlignment.Center;
-            //btnTemperatureView.TextColor = CSS_Color.TextualColor;
-            //btnTemperatureView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
-            //btnTemperatureView.TextID = StringId.IndoorTemp;
-            //frameTemperature.AddChidren(btnTemperatureView);
+
+            #region 娓╂箍搴︽暟鎹�
+            var tempHumiView = new FrameLayout()
+            {
+                Y = Application.GetRealWidth(58),
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(303),
+                Height = Application.GetRealWidth(175),
+                BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/TempAndHumiBack.png"
+            };
+            contentView.AddChidren(tempHumiView);
+
+            var tempValuesView = new FrameLayout()
+            {
+                X = Application.GetRealWidth(21),
+                Y = Application.GetRealWidth(17),
+                Width = Application.GetRealWidth(130),
+                Height = Application.GetRealWidth(132),
+            };
+            tempHumiView.AddChidren(tempValuesView);
+            btnTempValues = new Button()
+            {
+                Y = Application.GetRealWidth(45),
+                Height = Application.GetRealWidth(35),
+                IsBold = true,
+                TextSize = 30,
+                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                TextAlignment = TextAlignment.TopRight,
+                Text = "---",
+            };
+            btnTempValues.Text = function.GetAttrState(AcstSub_AttrEnum.room_temp.ToString());
+            btnTempValues.Width = btnTempValues.GetTextWidth();
+            btnTempValues.Gravity = Gravity.CenterHorizontal;
+            tempValuesView.AddChidren(btnTempValues);
+            var btnTempValuesUint = new Button()
+            {
+                X = btnTempValues.Right,
+                Y = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.TopLeft,
+                Width = Application.GetRealWidth(30),
+                Height = Application.GetRealWidth(30),
+                TextSize = 10,
+                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                Text = "掳C"
+            };
+            tempValuesView.AddChidren(btnTempValuesUint);
+
+
+
+            var humiValuesView = new FrameLayout()
+            {
+                X = Application.GetRealWidth(130+21),
+                Y = Application.GetRealWidth(17),
+                Width = Application.GetRealWidth(130),
+                Height = Application.GetRealWidth(132),
+            };
+            tempHumiView.AddChidren(humiValuesView);
+            btnHumiValues = new Button()
+            {
+                Y = Application.GetRealWidth(45),
+                Height = Application.GetRealWidth(35),
+                IsBold = true,
+                TextSize = 30,
+                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                Text = "---",
+                TextAlignment = TextAlignment.TopRight,
+            };
+            btnHumiValues.Text = function.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString());
+            btnHumiValues.Width = btnTempValues.GetTextWidth();
+            btnHumiValues.Gravity = Gravity.CenterHorizontal;
+            humiValuesView.AddChidren(btnHumiValues);
+            var btnHumiValuesUint = new Button()
+            {
+                X = btnTempValues.Right,
+                Y = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.TopLeft,
+                Width = Application.GetRealWidth(30),
+                Height = Application.GetRealWidth(30),
+                TextSize = 10,
+                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                Text = "%"
+            };
+            humiValuesView.AddChidren(btnHumiValuesUint);
+
+
+            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+                var page = new AcstSubHistoryPage(function);
+                MainPage.BasePageView.AddChidren(page);
+                page.LoadPage();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+            var btnClick = new Button();
+            tempHumiView.AddChidren(btnClick);
+            btnClick.MouseUpEventHandler = eventHandler;
+
+            #endregion
+
+
+            btnSetTempValues = new Button()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(260),
+                Width = Application.GetRealWidth(71),
+                Height = Application.GetRealHeight(90),
+                TextAlignment = TextAlignment.TopRight,
+                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                IsBold = true,
+                TextSize = 60,
+                Text = function.GetAttrState(AcstSub_AttrEnum.set_temp.ToString(), "--")
+            };
+            contentView.AddChidren(btnSetTempValues);
+
+            var btnSetTempUnit = new Button()
+            {
+                X = btnSetTempValues.Right + Application.GetRealWidth(3),
+                Y = Application.GetRealHeight(267),
+                Width = Application.GetRealWidth(30),
+                Height = Application.GetRealHeight(50),
+                TextSize = 23,
+                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                Text = "掳C",
+                TextAlignment = TextAlignment.TopLeft,
+            };
+            contentView.AddChidren(btnSetTempUnit);
+
+
+
+            var btnMinValuesText = new Button()
+            {
+                X = Application.GetRealWidth(35),
+                Y = Application.GetRealHeight(388),
+                Width = Application.GetRealWidth(30),
+                Height = Application.GetRealHeight(52),
+                Text = "16",
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.PromptingColor1,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+            };
+            contentView.AddChidren(btnMinValuesText);
+
+            tempBar = new DiyImageSeekBar()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(378),
+                Width = Application.GetRealWidth(238),
+                Height = Application.GetRealHeight(72),
+                SeekBarViewHeight = Application.GetRealHeight(14),
+                ThumbImagePath = "FunctionIcon/Acst/ThumbImage.png",
+                ThumbImageHeight = Application.GetRealHeight(51),
+                ProgressBarColor = function.trait_on_off.curValue.ToString() == "on" ? curColor : CSS_Color.DividingLineColor,
+                MaxValue = 14,
+                Progress = Convert.ToInt32(function.GetAttrState(FunctionAttributeKey.SetTemp)) + 16,
+                SeekBarPadding = Application.GetRealWidth(20),
+                IsProgressTextShow = false,
+                ProgressChangeDelayTime = 0,
+                IsOffline = function.trait_on_off.curValue.ToString() == "off",
+            };
+            contentView.AddChidren(tempBar);
+            tempBar.OnProgressChangedEvent = (sender, e) => {
+                btnSetTempValues.Text = (e + 16).ToString();
+            };
+            tempBar.OnStopTrackingTouchEvent = (sender, e) => {
+                new System.Threading.Thread(() => {
+                    var d = new Dictionary<string, string>();
+                    d.Add(FunctionAttributeKey.SetTemp, e.ToString());
+                    Control.Ins.SendWriteCommand(function, d);
+                })
+                { IsBackground = true }.Start();
+
+            };
+
+            var btnMaxValuesText = new Button()
+            {
+                X = tempBar.Right + Application.GetRealWidth(10),
+                Y = btnMinValuesText.Y,
+                Width = Application.GetRealWidth(45),
+                Height = Application.GetRealHeight(52),
+                Text = "30",
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.PromptingColor1,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+            };
+            contentView.AddChidren(btnMaxValuesText);
+
+
+
+
+
+            btnPowerControl = new Button()
+            {
+                Y = Application.GetRealHeight(496),
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(46),
+                Height = Application.GetRealWidth(46),
+                UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png",
+                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerIcon.png",
+                TextAlignment = TextAlignment.Center,
+                IsSelected = function.trait_on_off.curValue.ToString() == "on"
+            };
+            contentView.AddChidren(btnPowerControl);
+            btnPowerControl.MouseUpEventHandler = (sender, e) => {
+                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();
+            };
+
         }
     }
 }

--
Gitblit v1.8.0