From 37c315988c2dc11e4f477233f7a9f87d57bb61aa Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期一, 08 三月 2021 09:17:15 +0800
Subject: [PATCH] 数据结构优化修改

---
 HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs |   98 +++++++++++++++++++++++++------------------------
 1 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs b/HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs
index 1686f8f..629a706 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs
@@ -44,7 +44,9 @@
         /// </summary>
         Button btnSwitch;
 
-        AC acDevice;
+        AC acFunction = new AC();
+
+
 
         #endregion
 
@@ -55,7 +57,6 @@
         /// </summary>
         public override void InitFrameWhiteContent()
         {
-            acDevice = device as AC;
 
             base.ShowColltionButton = false;
             base.SetTitleText(Language.StringByID(StringId.Electric));
@@ -85,16 +86,10 @@
             {
                 Gravity = Gravity.CenterHorizontal,
                 OpenAngle = 160,
-                ThumbImagePath = device.GetAttrState(FunctionAttributeKey.OnOff)  == "on" ? "FunctionIcon/AC/DiyThumbIconOn.png" : "FunctionIcon/AC/DiyThumbIcon.png",
                 ThumbImageHeight = Application.GetRealWidth(50),
                 ProgressBarColor = CSS_Color.MainColor,
                 OfflineProgressBarColor = CSS_Color.PromptingColor2,
-                IsOffline = device.GetAttrState(FunctionAttributeKey.OnOff) == "off",
-                MinValue = device.GetAttribute(FunctionAttributeKey.OnOff).min,
-                MaxValue = device.GetAttribute(FunctionAttributeKey.OnOff).max,
-                //IsClickable = acDevice.trait_on_off.curValue.ToString() == "on",
                 ArcColor = CSS_Color.BackgroundColor,
-                Progress = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp)),
 #if __IOS__
                 Y = Application.GetRealHeight(120 + 25),
                 Width = Application.GetRealWidth(260 - 40),
@@ -109,6 +104,13 @@
 
             };
             FrameWhiteCentet1.AddChidren(arcBar);
+
+
+            arcBar.ThumbImagePath = device.GetAttrState(FunctionAttributeKey.OnOff) == "on" ? "FunctionIcon/AC/DiyThumbIconOn.png" : "FunctionIcon/AC/DiyThumbIcon.png";
+            arcBar.IsOffline = device.GetAttrState(FunctionAttributeKey.OnOff) == "off";
+            arcBar.MinValue = device.GetAttribute(FunctionAttributeKey.SetTemp).min;
+            arcBar.MaxValue = device.GetAttribute(FunctionAttributeKey.SetTemp).max;
+            arcBar.Progress = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp));
 
             btnTemp = new Button()
             {
@@ -176,7 +178,7 @@
                 Y = Application.GetRealHeight(334),
                 Width = Application.GetRealWidth(30),
                 Height = Application.GetRealWidth(30),
-                UnSelectedImagePath = acDevice.GetModeIconPath(),
+                UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode)),
             };
             FrameWhiteCentet1.AddChidren(btnMode);
 
@@ -186,7 +188,7 @@
                 Y = Application.GetRealHeight(337),
                 Width = Application.GetRealWidth(30),
                 Height = Application.GetRealWidth(30),
-                UnSelectedImagePath = acDevice.GetFanIconPath(),
+                UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed)),
             };
             FrameWhiteCentet1.AddChidren(btnWindSpeed);
 
@@ -281,9 +283,9 @@
                 };
                 modeChangeView.AddChidren(btnModeText);
 
-                btnModeIcon.UnSelectedImagePath = acDevice.GetModeIconPath(false);
-                btnModeIcon.SelectedImagePath = acDevice.GetModeIconPath();
-                btnModeText.Text = acDevice.GetModeAttrText( m);
+                btnModeIcon.UnSelectedImagePath = acFunction.GetModeIconPath(m, false);
+                btnModeIcon.SelectedImagePath = acFunction.GetModeIconPath(m);
+                btnModeText.Text = acFunction.GetModeAttrText( m);
 
                 if (modeList.IndexOf(m) < modeList.Count - 1)
                 {
@@ -303,14 +305,14 @@
                 EventHandler<MouseEventArgs> eventHandler1 = (sender, e) =>
                 {
                     btnModeIcon.IsSelected = btnModeText.IsSelected = true;
-                    acDevice.SetAttrState(FunctionAttributeKey.Mode, m);
-                    btnMode.UnSelectedImagePath = acDevice.GetModeIconPath();
+                    device.SetAttrState(FunctionAttributeKey.Mode, m);
+                    btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(m);
                     System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                     btnMode.UnSelectedImagePath = btnModeIcon.UnSelectedImagePath;
                     d.Add(FunctionAttributeKey.Mode, m);
-                    Control.Ins.SendWriteCommand(acDevice, d);
+                    Control.Ins.SendWriteCommand(device, d);
                     dialog.Close();
-                    if (acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
+                    if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                     {
                         arcBar.IsClickable = false;
                     }
@@ -404,9 +406,9 @@
                     TextSize = CSS_FontSize.TextFontSize,
                 };
                 modeChangeView.AddChidren(btnFanText);
-                btnFanIcon.UnSelectedImagePath = acDevice.GetModeIconPath(false);
-                btnFanIcon.SelectedImagePath = acDevice.GetModeIconPath();
-                btnFanText.Text = acDevice.GetModeAttrText(m);
+                btnFanIcon.UnSelectedImagePath = acFunction.GetModeIconPath(m,false);
+                btnFanIcon.SelectedImagePath = acFunction.GetModeIconPath(m);
+                btnFanText.Text = acFunction.GetModeAttrText(m);
 
                 if (modeList.IndexOf(m) < modeList.Count - 1)
                 {
@@ -427,11 +429,11 @@
                 EventHandler<MouseEventArgs> eventHandler1 = (sender, e) =>
                 {
                     btnFanIcon.IsSelected = btnFanText.IsSelected = true;
-                    acDevice.SetAttrState(FunctionAttributeKey.FanSpeed, m);
-                    btnWindSpeed.UnSelectedImagePath = acDevice.GetFanIconPath();
+                    device.SetAttrState(FunctionAttributeKey.FanSpeed, m);
+                    btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(m);
                     System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                     d.Add(FunctionAttributeKey.FanSpeed, m);
-                    Control.Ins.SendWriteCommand(acDevice, d);
+                    Control.Ins.SendWriteCommand(device, d);
                     btnWindSpeed.UnSelectedImagePath = btnFanIcon.UnSelectedImagePath;
                     dialog.Close();
                 };
@@ -473,53 +475,53 @@
         {
             btnMinus.MouseUpEventHandler = (sender, e) =>
             {
-                if (acDevice.trait_on_off.curValue.ToString() == "off" || acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
+                if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                 {
                     return;
                 }
-                var temp = Convert.ToInt32(acDevice.GetAttrState(FunctionAttributeKey.SetTemp));
-                if (temp <= acDevice.GetAttribute(FunctionAttributeKey.Mode).min)
+                var temp = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp));
+                if (temp <= device.GetAttribute(FunctionAttributeKey.Mode).min)
                 {
                     return;
                 }
                 temp--;
                 arcBar.Progress = temp;
                 btnTemp.Text = temp.ToString();
-                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
+                device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                 d.Add(FunctionAttributeKey.SetTemp, temp.ToString());
-                Control.Ins.SendWriteCommand(acDevice, d);
+                Control.Ins.SendWriteCommand(device, d);
             };
             btnPlus.MouseUpEventHandler = (sender, e) =>
             {
-                if (acDevice.trait_on_off.curValue.ToString() == "off" || acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
+                if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                 {
                     return;
                 }
-                var temp = Convert.ToInt32(acDevice.GetAttrState(FunctionAttributeKey.SetTemp));
-                if (temp >= acDevice.GetAttribute(FunctionAttributeKey.SetTemp).max)
+                var temp = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp));
+                if (temp >= device.GetAttribute(FunctionAttributeKey.SetTemp).max)
                 {
                     return;
                 }
                 temp++;
                 arcBar.Progress = temp;
                 btnTemp.Text = temp.ToString();
-                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
+                device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                 d.Add(FunctionAttributeKey.SetTemp, temp.ToString());
-                Control.Ins.SendWriteCommand(acDevice, d);
+                Control.Ins.SendWriteCommand(device, d);
             };
             arcBar.OnStopTrackingTouchEvent = (sender, e) =>
             {
-                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
+                device.SetAttrState(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                 btnTemp.Text = arcBar.Progress.ToString();
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                 d.Add(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
-                Control.Ins.SendWriteCommand(acDevice, d);
+                Control.Ins.SendWriteCommand(device, d);
             };
             arcBar.OnProgressChangedEvent = (sender, e) =>
             {
-                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString());
+                device.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString());
                 btnTemp.Text = e.ToString();
             };
         }
@@ -530,7 +532,7 @@
         {
             btnMode.MouseUpEventHandler = (sender, e) =>
             {
-                if (acDevice.trait_on_off.curValue.ToString() == "off")
+                if (device.trait_on_off.curValue.ToString() == "off")
                 {
                     return;
                 }
@@ -538,7 +540,7 @@
             };
             btnWindSpeed.MouseUpEventHandler = (sender, e) =>
             {
-                if (acDevice.trait_on_off.curValue.ToString() == "off")
+                if (device.trait_on_off.curValue.ToString() == "off")
                 {
                     return;
                 }
@@ -548,8 +550,8 @@
             btnSwitch.MouseUpEventHandler = (sender, e) =>
             {
                 btnSwitch.IsSelected = !btnSwitch.IsSelected;
-                acDevice.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
-                if (acDevice.trait_on_off.curValue.ToString() == "on")
+                device.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
+                if (device.trait_on_off.curValue.ToString() == "on")
                 {
                     arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIconOn.png";
                     btnSwitch.IsSelected = true;
@@ -562,8 +564,8 @@
                     arcBar.IsOffline = true;
                 }
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                d.Add(FunctionAttributeKey.OnOff, acDevice.trait_on_off.curValue.ToString());
-                Control.Ins.SendWriteCommand(acDevice, d);
+                d.Add(FunctionAttributeKey.OnOff, device.trait_on_off.curValue.ToString());
+                Control.Ins.SendWriteCommand(device, d);
             };
         }
 
@@ -579,16 +581,16 @@
             Application.RunOnMainThread(() =>
             {
                 btnTemp.Text = device.GetAttrState(FunctionAttributeKey.SetTemp);
-                btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(acDevice.GetAttrState(FunctionAttributeKey.IndoorTemp))) + "掳C";
-                btnMode.UnSelectedImagePath = acDevice.GetModeIconPath();
-                btnWindSpeed.UnSelectedImagePath = acDevice.GetFanIconPath();
-                arcBar.Progress = Convert.ToInt32(Convert.ToDouble(acDevice.GetAttrState(FunctionAttributeKey.SetTemp)));
-                if (acDevice.trait_on_off.curValue.ToString() == "on")
+                btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.IndoorTemp))) + "掳C";
+                btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode));
+                btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed));
+                arcBar.Progress = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp)));
+                if (device.trait_on_off.curValue.ToString() == "on")
                 {
                     arcBar.IsOffline = false;
                     btnSwitch.IsSelected = true;
                     arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIconOn.png";
-                    if (acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
+                    if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                     {
                         arcBar.IsClickable = false;
                     }

--
Gitblit v1.8.0