From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/DataCorrectionForm.cs |  402 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 402 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/DataCorrectionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/DataCorrectionForm.cs
new file mode 100755
index 0000000..591b6fa
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/DataCorrectionForm.cs
@@ -0,0 +1,402 @@
+锘縰sing Shared.Common;
+using ZigBee.Device;
+namespace Shared.Phone.UserCenter.DevicePanel
+{
+    public class DataCorrectionForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________ 
+        /// <summary>
+        /// 闈㈡澘鐨勫洖璺�
+        /// </summary>
+        private CommonDevice device;
+        /// <summary>
+        /// 淇濆瓨瀹屾垚鎸夐挳
+        /// </summary>
+        Button btnFinifh;
+        /// <summary>
+        /// 鏍℃娓╁害鍊�
+        /// </summary>
+        double correctTValue = 0;
+        /// <summary>
+        /// 鏍℃婀垮害鍊�
+        /// </summary>
+        double correctHValue = 0;
+        /// <summary>
+        /// 鏈夋晥鏂囨湰
+        /// </summary>
+        private string invalidText1 = "";
+        /// <summary>
+        /// 鏈夋晥鏂囨湰
+        /// </summary>
+        private string invalidText2 = "";
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹___________________________ 
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="i_device">璁惧鐨勬煇涓�鍥炶矾</param>
+        public void ShowForm(CommonDevice device)
+        {
+            this.device = device;
+
+            //璁剧疆澶撮儴淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.DataCorrection));
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
+            this.InitMiddleFrame();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private async void InitMiddleFrame()
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+            TemperatureDataUI();
+            TipUI();
+        }
+
+        #endregion
+
+        #region 鈻� 娓╁害璁剧疆_______________________ 
+        /// <summary>
+        ///  娓╁害璁剧疆
+        /// </summary>
+        private void TemperatureDataUI()
+        {
+            var listview = new VerticalScrolViewLayout();
+            listview.Height = Application.GetRealHeight(320);
+            bodyFrameLayout.AddChidren(listview);
+            listview.ScrollEnabled = false;
+
+            for (int i = 0; i < 2; i++)
+            {
+                var rowLayout = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(23 + 127),
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                };
+                listview.AddChidren(rowLayout);
+
+                var devicePic = new Button()
+                {
+                    X = Application.GetRealWidth(58),
+                    Y = Application.GetRealHeight(46),
+                    Width = Application.GetMinRealAverage(81),
+                    Height = Application.GetMinRealAverage(81),
+                };
+                rowLayout.AddChidren(devicePic);
+
+                var btnName = new Button()
+                {
+                    Width = Application.GetRealWidth(790),
+                    X = devicePic.Right + Application.GetRealWidth(20),
+                    TextColor = Shared.Common.ZigbeeColor.Current.TextBlack,
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextSize = 15,
+                };
+                rowLayout.AddChidren(btnName);
+
+                var tframeLayout = new FrameLayout()
+                {
+                    X = Application.GetRealWidth(714 - 29),
+                    Y = Application.GetRealHeight(35),
+                    Width = Application.GetMinRealAverage(118 + 98 * 2),
+                    Height = Application.GetMinRealAverage(81),
+                    BackgroundImagePath = "BindPic/CorrectTemperatureBackGround.png",
+                };
+                rowLayout.AddChidren(tframeLayout);
+
+                var btnReduction = new Button()
+                {
+                    Width = Application.GetMinRealAverage(98),
+                    Height = Application.GetMinRealAverage(81),
+                };
+                tframeLayout.AddChidren(btnReduction);
+
+                var btnNum = new EditText()
+                {
+                    Width = Application.GetMinReal(115),
+                    Height = Application.GetRealHeight(80),
+                    X = Application.GetRealWidth(98),
+                    Text = "0",
+                    PlaceholderTextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
+                    TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
+                    TextSize = 20,
+                    TextAlignment = TextAlignment.Center,
+                };
+                tframeLayout.AddChidren(btnNum);
+
+                var btnAdd = new Button()
+                {
+                    X = Application.GetRealWidth(98 + 118),
+                    Width = Application.GetMinRealAverage(98),
+                    Height = Application.GetMinRealAverage(81),
+                };
+                tframeLayout.AddChidren(btnAdd);
+
+                var line2 = new Button()
+                {
+                    Y = rowLayout.Height - 1,
+                    X = devicePic.Right + Application.GetRealWidth(20),
+                    Width = Application.GetRealWidth(965 - 116),
+                    Height = 1,
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
+                };
+                rowLayout.AddChidren(line2);
+
+                int curIndex = i;
+                if (curIndex == 0)
+                {
+                    devicePic.UnSelectedImagePath = "Device/SensorTemperature.png";
+                    btnName.Text = Language.StringByID(R.MyInternationalizationString.Temperature) + "  (鈩�)";
+                    invalidText1 = btnNum.Text;
+                }
+                else
+                {
+                    line2.Visible = false;
+                    devicePic.UnSelectedImagePath = "Device/SensorHumidity.png";
+                    btnName.Text = Language.StringByID(R.MyInternationalizationString.Humidity) + "  (%)";
+                    invalidText2 = btnNum.Text;
+                }
+
+                btnNum.TextChangeEventHandler += (sender, e) =>
+                {
+                    if (!string.IsNullOrEmpty((sender as EditText).Text))
+                    {
+                        var curText = (sender as EditText).Text;
+                        var textFir = curText.Substring(0, 1);
+                        double curV;
+                        var res = double.TryParse(curText, out curV);
+                        if (!res)
+                        {
+                            if (textFir != "-")
+                            {
+                                curV = 0D;
+                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NumTip), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                                return;
+                            }
+                        }
+                        if (curIndex == 0)
+                        {
+                            correctTValue = curV;
+                        }
+                        else
+                        {
+                            correctHValue = curV;
+                        }
+                    }
+                    if (curIndex == 0)
+                    {
+                        invalidText1 = btnNum.Text;
+                    }
+                    else
+                    {
+                        invalidText2 = btnNum.Text;
+                    }
+                   
+                };
+
+                btnReduction.MouseDownEventHandler += async (sender, e) =>
+                {
+                    if(!string.IsNullOrEmpty(btnNum.Text))
+                    {
+                        double vTemp = double.Parse(btnNum.Text);
+                        vTemp -= 0.1;
+                        btnNum.Text = vTemp.ToString();
+                        if (curIndex == 0)
+                        {
+                            correctTValue = double.Parse(btnNum.Text);
+                        }
+                        else
+                        {
+                            correctHValue = double.Parse(btnNum.Text);
+                        }
+                    }
+                    if (curIndex == 0)
+                    {
+                        invalidText1 = btnNum.Text;
+                    }
+                    else
+                    {
+                        invalidText2 = btnNum.Text;
+                    }
+                };
+
+                btnAdd.MouseDownEventHandler += async (sender, e) =>
+                {
+                    if (!string.IsNullOrEmpty(btnNum.Text))
+                    {
+                        double vTemp = double.Parse(btnNum.Text);
+                        vTemp += 0.1;
+                        btnNum.Text = vTemp.ToString();
+                        if (curIndex == 0)
+                        {
+                            correctTValue = double.Parse(btnNum.Text);
+                        }
+                        else
+                        {
+                            correctHValue = double.Parse(btnNum.Text);
+                        }
+                    }
+                    if (curIndex == 0)
+                    {
+                        invalidText1 = btnNum.Text;
+                    }
+                    else
+                    {
+                        invalidText2 = btnNum.Text;
+                    }
+                };
+            }
+        }
+        #endregion
+
+        #region 鈻� 搴曢儴鎻愮ず_______________________ 
+        /// <summary>
+        ///  搴曢儴鎻愮ず
+        /// </summary>
+        private void TipUI()
+        {
+            var bottomFrameLayout = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(1426),
+                Height = Application.GetMinRealAverage(58),
+            };
+            bodyFrameLayout.AddChidren(bottomFrameLayout);
+
+            var temperatureAttentionPic = new Button()
+            {
+                Width = Application.GetMinRealAverage(58),
+                Height = Application.GetMinRealAverage(58),
+                UnSelectedImagePath = "BindPic/TemperaTureAttention.png"
+            };
+            bottomFrameLayout.AddChidren(temperatureAttentionPic);
+
+            var btnText = new Button()
+            {
+                Width = Application.GetRealWidth(790),
+                X = Application.GetRealWidth(56),
+                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextSize = 12,
+                Text = Language.StringByID(R.MyInternationalizationString.DataCorrectionTip),
+            };
+            bottomFrameLayout.AddChidren(btnText);
+
+            btnFinifh = new Button()
+            {
+                Width = Application.GetRealWidth(907),
+                Height = Application.GetRealHeight(127),
+                Y = Application.GetRealHeight(1426 + 58 + 12),
+                Gravity = Gravity.CenterHorizontal,
+                Radius = (uint)Application.GetRealHeight(127) / 2,
+                TextID = R.MyInternationalizationString.Save,
+                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                IsBold = true,
+                TextSize = 16,
+            };
+            bodyFrameLayout.AddChidren(btnFinifh);
+            btnFinifh.MouseUpEventHandler += (sender, e) =>
+            {
+                SaveTarget();
+            };
+
+            bottomFrameLayout.Width = temperatureAttentionPic.Width + Application.GetRealWidth(10) + btnText.GetTextWidth();
+            bottomFrameLayout.Gravity = Gravity.CenterHorizontal;
+        }
+        #endregion
+
+        #region 鈻� 淇濆瓨_______________________ 
+        /// <summary>
+        /// 淇濆瓨 
+        /// </summary>
+        /// <param name="curControlDev"></param>
+        void SaveTarget()
+        {
+            System.Threading.Tasks.Task.Run(async () =>
+            {
+                try
+                {
+                    if (string.IsNullOrEmpty(invalidText1) )
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.TNumTip), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                        });
+                        return;
+                    }
+                    if ( string.IsNullOrEmpty(invalidText2))
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.HNumTip), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                        });
+                        return;
+                    }
+                    Application.RunOnMainThread(() =>
+                    {
+                        CommonPage.Loading.Start();
+                    });
+                    this.ShowProgressBar();
+                    bool result = false;
+                    int direction = 0;
+                    double sendValue = 0;
+                    //娓╁害
+                    sendValue = correctTValue;
+                    if (correctTValue > 0)
+                    {
+                        direction = 1;
+                    }
+                    else if (correctTValue < 0)
+                    {
+                        direction = 2;
+                        sendValue = System.Math.Abs(correctTValue);
+                    }
+
+                    result = await HdlDevicePanelLogic.Current.CorrectTemperature(device, sendValue, direction, 0);
+                    if (result == false)
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            CommonPage.Loading.Hide();
+                        });
+                        return;
+                    }
+                    //婀垮害
+                    direction = 0;
+                    sendValue = correctHValue;
+                    if (correctHValue > 0)
+                    {
+                        direction = 1;
+                    }
+                    else if (correctHValue < 0)
+                    {
+                        direction = 2;
+                        sendValue = (-1) * correctHValue;
+                    }
+                    result = await HdlDevicePanelLogic.Current.CorrectTemperature(device, sendValue, direction, 1);
+                    if (result == false)
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            CommonPage.Loading.Hide();
+                        });
+                        return;
+                    }
+                    Application.RunOnMainThread(() =>
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.SetSuccessXm), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                        CommonPage.Loading.Hide();
+                    });
+                }
+                catch { }
+            });
+        }
+        #endregion  
+    }
+}

--
Gitblit v1.8.0