From 0a8ec482a5ad10bf3cd7010c89630b42ecaca741 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 05 二月 2021 10:19:31 +0800
Subject: [PATCH] Merge branch 'NewFilePath' into CJL
---
HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs | 139 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 139 insertions(+), 0 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs
new file mode 100644
index 0000000..f2e04a4
--- /dev/null
+++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs
@@ -0,0 +1,139 @@
+锘縰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
+{
+ public class TuyaWaterValvePage : DeviceFunctionCardCommonForm
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+ /// <summary>
+ /// 鍥剧墖鎺т欢
+ /// </summary>
+ private PicViewControl btnPictrue = null;
+ /// <summary>
+ /// 寮�鍏虫帶浠�
+ /// </summary>
+ private IconViewControl btnSwitch = null;
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鍒濆鍖栫櫧鑹插尯鍩熺殑鍐呭
+ /// </summary>
+ public override void InitFrameWhiteContent()
+ {
+ base.SetTitleText(Language.StringByID(StringId.AirCleaner));
+
+ //娣诲姞绗簩绱㈠紩椤�
+ this.AddSecondPage();
+ //鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹�
+ this.InitFrameWhiteContent1();
+ //鍒锋柊鐣岄潰鐘舵��
+ this.RefreshFormStatu();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹�
+ /// </summary>
+ private void InitFrameWhiteContent1()
+ {
+ //鍥剧墖鎺т欢
+ this.btnPictrue = new PicViewControl(130, 118);
+ btnPictrue.Y = Application.GetRealHeight(95);
+ btnPictrue.Gravity = Gravity.CenterHorizontal;
+ btnPictrue.UnSelectedImagePath = "FunctionIcon/Electrical/WaterValve/WaterValveBg.png";
+ btnPictrue.SelectedImagePath = "FunctionIcon/Electrical/WaterValve/WaterValveOnBg.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();
+ };
+ }
+ #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()
+ {
+ this.btnPictrue.CanClick = false;
+ this.btnSwitch.CanClick = false;
+
+ string statu = this.btnSwitch.IsSelected == true ? "off" : "on";
+ //btnSwitch.IsSelected = !btnSwitch.IsSelected;
+ 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;
+ });
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 鍒锋柊鐣岄潰鐘舵�乢______________________
+
+ /// <summary>
+ /// 鍒锋柊鐣岄潰鐘舵��
+ /// </summary>
+ private void RefreshFormStatu()
+ {
+ Application.RunOnMainThread(() =>
+ {
+ foreach (var data in this.device.attributes)
+ {
+ if (data.key == FunctionAttributeKey.OnOff)
+ {
+ this.btnSwitch.IsSelected = this.btnPictrue.IsSelected = data.curValue.ToString() == "on";
+ }
+ }
+ });
+ }
+ #endregion
+
+ }
+}
--
Gitblit v1.8.0