From 5b77d9d57a6cddb474a66ca54401ad5ab0892db3 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 23 十一月 2022 14:23:42 +0800
Subject: [PATCH] Merge branch 'dev--wxr' into LcSdkV1

---
 HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs |  196 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 196 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs
new file mode 100644
index 0000000..93f3500
--- /dev/null
+++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs
@@ -0,0 +1,196 @@
+锘縰sing System;
+using System.Collections.Generic;
+using HDL_ON.DriverLayer;
+using HDL_ON.Entity;
+using HDL_ON.Stan;
+using HDL_ON.UI.CSS;
+using Shared;
+
+namespace HDL_ON.UI
+{
+    /// <summary>
+	/// 鏈烘鎵嬫帶鍒堕〉闈�
+	/// </summary>
+    public class MechanicalArmPage : DeviceFunctionCardCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+        /// <summary>
+        /// 鍥剧墖鎺т欢
+        /// </summary>
+        private PicViewControl btnPictrue = null;
+        /// <summary>
+        /// 寮�鍏崇姸鎬佹彁绀烘帶浠�
+        /// </summary>
+        private Button btnTipStatus = null;
+
+        /// <summary>
+        /// 寮�鍏虫帶浠�
+        /// </summary>
+        private IconViewControl btnSwitch = null;
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鍒濆鍖栫櫧鑹插尯鍩熺殑鍐呭
+        /// </summary>
+        public override void InitFrameWhiteContent()
+        {
+            base.SetTitleText(Language.StringByID(StringId.WaterValve));
+
+            //鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹�
+            this.InitFrameWhiteContent1();
+            //鍒锋柊鐣岄潰鐘舵��
+            this.RefreshFormStatu();
+            //璇诲彇鐘舵��
+            new System.Threading.Thread(() =>
+            {
+                Control.Ins.ReadFunctionsInfo(new List<string>() { device.deviceId });
+            })
+            { IsBackground = true }.Start();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹�
+        /// </summary>
+        private void InitFrameWhiteContent1()
+        {
+            btnTipStatus = new Button()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(79),
+                Width = Application.GetRealWidth(100),
+                Height = Application.GetRealHeight(34),
+                BackgroundColor = 0x171B2D4D,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                Radius = (uint)Application.GetRealHeight(17),
+                TextID = StringId.ValveClosed,
+            };
+            FrameWhiteCentet1.AddChidren(btnTipStatus);
+
+            //鍥剧墖鎺т欢
+            this.btnPictrue = new PicViewControl(327, 327);
+            btnPictrue.Y = Application.GetRealHeight(127);
+            btnPictrue.Gravity = Gravity.CenterHorizontal;
+            btnPictrue.UnSelectedImagePath = "FunctionIcon/Electrical/MechanicalArm/MechanicalArmBg.png";
+            btnPictrue.SelectedImagePath = "FunctionIcon/Electrical/MechanicalArm/MechanicalArmOnBg.png";
+            FrameWhiteCentet1.AddChidren(btnPictrue);
+            btnPictrue.ButtonClickEvent += (sender, e) =>
+            {
+                //鍙戦�佸紑鍏冲懡浠�
+                this.SendSwitchComand();
+            };
+
+            //寮�鍏冲浘鏍�
+            this.btnSwitch = new IconViewControl(40);
+            btnSwitch.Gravity = Gravity.CenterHorizontal;
+            btnSwitch.Y = Application.GetRealHeight(468);
+            btnSwitch.UnSelectedImagePath = "Public/PowerClose.png";
+            btnSwitch.SelectedImagePath = "Public/PowerOpen.png";
+            FrameWhiteCentet1.AddChidren(btnSwitch);
+            btnSwitch.ButtonClickEvent += (sender, e) =>
+            {
+                //鍙戦�佸紑鍏冲懡浠�
+                this.SendSwitchComand();
+            };
+
+            var pack = new DAL.Server.HttpServerRequest().GetDeviceInfoList(new List<string>() { base.device.deviceId });
+        }
+        #endregion
+
+        #region 鈻� 璁惧鐘舵�佸弽棣坃______________________
+
+        /// <summary>
+        /// 璁惧鐘舵�佸弽棣�
+        /// </summary>
+        /// <param name="i_LocalDevice"></param>
+        public override void DeviceStatuPush(Function i_LocalDevice)
+        {
+            //涓嶆槸鍚屼竴涓笢瑗�
+            if (this.device.sid != i_LocalDevice.sid) { return; }
+
+            //鍒锋柊鐣岄潰鐘舵��
+            this.RefreshFormStatu();
+        }
+
+        #endregion
+
+        #region 鈻� 鍙戦�佸悇绉嶅懡浠______________________
+
+        /// <summary>
+        /// 鍙戦�佸紑鍏冲懡浠�
+        /// </summary>
+        private void SendSwitchComand()
+        {
+            //if (!device.online)
+            //{
+            //    new Tip()
+            //    {
+            //        CloseTime = 1,
+            //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+            //        Direction = AMPopTipDirection.None,
+            //    }.Show(MainPage.BaseView);
+            //    return;
+            //}
+            string statu = this.btnSwitch.IsSelected == true ? "off" : "on";
+            string tipMsg = "纭畾鎵撳紑?";
+            if (this.btnSwitch.IsSelected)
+            {
+                tipMsg = "纭畾鍏抽棴?";
+            }
+            Action action = () => {
+
+                this.btnPictrue.CanClick = false;
+                this.btnSwitch.CanClick = false;
+
+                HdlThreadLogic.Current.RunThread(() =>
+                {
+                    var dic = new Dictionary<string, string>();
+                    dic.Add(FunctionAttributeKey.OnOff, statu);
+                    Control.Ins.SendWriteCommand(this.device, dic, true);
+                    HdlThreadLogic.Current.RunMain(() =>
+                    {
+                        this.btnPictrue.CanClick = true;
+                        this.btnSwitch.CanClick = true;
+                    });
+                });
+            };
+            new PublicAssmebly().TipOptionMsg(StringId.EmptyString, tipMsg, action);
+
+        }
+
+        #endregion
+
+        #region 鈻� 鍒锋柊鐣岄潰鐘舵�乢______________________
+
+        /// <summary>
+        /// 鍒锋柊鐣岄潰鐘舵��
+        /// </summary>
+        private void RefreshFormStatu()
+        {
+            Application.RunOnMainThread(() =>
+            {
+                var onoffStatu = device.attributes.Find((obj) => obj.key == FunctionAttributeKey.OnOff);
+
+                if (onoffStatu != null)
+                {
+                    if (onoffStatu.state == "on")
+                    {
+                        btnTipStatus.TextID = StringId.ValveOpened;
+                        btnTipStatus.TextColor = 0xFF4BC803;
+                        btnTipStatus.BackgroundColor = 0x174BC803;
+                    }
+                    else
+                    {
+                        btnTipStatus.TextID = StringId.ValveClosed;
+                        btnTipStatus.TextColor = CSS_Color.FirstLevelTitleColor;
+                        btnTipStatus.BackgroundColor = 0x171B2D4D;
+                    }
+                    this.btnSwitch.IsSelected = this.btnPictrue.IsSelected = onoffStatu.state.ToString() == "on";
+                }
+            });
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0