From 64390bc739286477167e186f1f2b40a27a73a9a5 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 02 三月 2021 17:31:01 +0800
Subject: [PATCH] 20210302-1
---
HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 205 insertions(+), 35 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs
index 945a64c..fa00457 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs
@@ -3,6 +3,8 @@
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
using System.Collections.Generic;
+using System;
+using HDL_ON.DriverLayer;
namespace HDL_ON.UI
{
@@ -30,9 +32,22 @@
/// </summary>
Button btnDown;
/// <summary>
- /// 鏂囨湰鎺т欢
+ /// 鐑樺共鎺т欢
/// </summary>
- private NormalViewControl btnSuctionView = null;
+ ClothesHangerControl hotDryView;
+ /// <summary>
+ /// 椋庡共鎺т欢
+ /// </summary>
+ ClothesHangerControl windDryView;
+ /// <summary>
+ /// 娑堟瘨鎺т欢
+ /// </summary>
+ ClothesHangerControl disinfectView;
+ /// <summary>
+ /// 鐓ф槑鎺т欢
+ /// </summary>
+ ClothesHangerControl lightingView;
+
#endregion
@@ -56,7 +71,7 @@
//璇诲彇鐘舵��
new System.Threading.Thread(() =>
{
- DriverLayer.Control.Ins.SendReadCommand(device);
+ Control.Ins.SendReadCommand(device);
})
{ IsBackground = true }.Start();
}
@@ -123,77 +138,109 @@
int index = 0;
List<string> attrs = device.GetAttributes();
- ClothesHangerControl hotDryView = new ClothesHangerControl(
+
+ hotDryView = new ClothesHangerControl(
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerHotDryIcon.png",
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerHotDryIconOn.png",
Language.StringByID(StringId.HotDry),
device.GetAttrState(FunctionAttributeKey.HotDryTimeLeft));
hotDryView.X = 0;
- hotDryView.Y = Application.GetRealHeight(288);
+ hotDryView.Y = Application.GetRealHeight(304);
hotDryView.Width = Application.GetRealWidth(96);
hotDryView.Height = Application.GetRealHeight(74);//28 29 14 3
- if (attrs.Contains(menu[0]) || true)
+ if (attrs.Contains(menu[0]))
{
FrameWhiteCentet1.AddChidren(hotDryView);
+
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ string onoff = hotDryView.Lighting ? "false" : "true";
+ device.SetAttrState(FunctionAttributeKey.HotDry, onoff);
+ Dictionary<string, string> d = new Dictionary<string, string>();
+ d.Add(FunctionAttributeKey.HotDry, onoff);
+ Control.Ins.SendWriteCommand(device, d);
+ };
+ hotDryView.SetThouchEvent(eventHandler);
+
index++;
}
- ClothesHangerControl windDryView = new ClothesHangerControl(
+ windDryView = new ClothesHangerControl(
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerWindDryIcon.png",
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerWindDryIconOn.png",
Language.StringByID(StringId.WindDry),
device.GetAttrState(FunctionAttributeKey.WindDryTimeLeft));
- windDryView.Y = Application.GetRealHeight(288);
+ windDryView.Y = Application.GetRealHeight(304);
windDryView.Width = Application.GetRealWidth(96);
windDryView.Height = Application.GetRealHeight(74);
- if (attrs.Contains(menu[1]) || true)
+ if (attrs.Contains(menu[1]))
{
if(index == 1)
{
windDryView.Gravity = Gravity.CenterHorizontal;
}
FrameWhiteCentet1.AddChidren(windDryView);
+
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ string onoff = windDryView.Lighting ? "false" : "true";
+ device.SetAttrState(FunctionAttributeKey.WindDry, onoff);
+ Dictionary<string, string> d = new Dictionary<string, string>();
+ d.Add(FunctionAttributeKey.WindDry, onoff);
+ Control.Ins.SendWriteCommand(device, d);
+ };
+ windDryView.SetThouchEvent(eventHandler);
+
index++;
}
- ClothesHangerControl disinfectDryView = new ClothesHangerControl(
+ disinfectView = new ClothesHangerControl(
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerDisinfectIcon.png",
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerDisinfectIconOn.png",
Language.StringByID(StringId.Disinfect),
device.GetAttrState(FunctionAttributeKey.DisinfectTimeLeft));
- disinfectDryView.Y = Application.GetRealHeight(288);
- disinfectDryView.Width = Application.GetRealWidth(96);
- disinfectDryView.Height = Application.GetRealHeight(74);
- if (attrs.Contains(menu[2]) || true)
+ disinfectView.Y = Application.GetRealHeight(304);
+ disinfectView.Width = Application.GetRealWidth(96);
+ disinfectView.Height = Application.GetRealHeight(74);
+ if (attrs.Contains(menu[2]))
{
if(index == 1)
{
- disinfectDryView.Gravity = Gravity.CenterHorizontal;
+ disinfectView.Gravity = Gravity.CenterHorizontal;
}
else if (index == 2)
{
- disinfectDryView.X = Application.GetRealWidth(266 - 33);
+ disinfectView.X = Application.GetRealWidth(266 - 33);
}
- FrameWhiteCentet1.AddChidren(disinfectDryView);
+ FrameWhiteCentet1.AddChidren(disinfectView);
+
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ string onoff = disinfectView.Lighting ? "false" : "true";
+ device.SetAttrState(FunctionAttributeKey.Disinfect, onoff);
+ Dictionary<string, string> d = new Dictionary<string, string>();
+ d.Add(FunctionAttributeKey.Disinfect, onoff);
+ Control.Ins.SendWriteCommand(device, d);
+ };
+ disinfectView.SetThouchEvent(eventHandler);
+
index++;
}
- ClothesHangerControl lightingView = new ClothesHangerControl(
+ lightingView = new ClothesHangerControl(
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerLightIcon.png",
"FunctionIcon/Electrical/ClothesHanger/ClothesHangerLightIconOn.png",
Language.StringByID(StringId.Lighting),
"");
lightingView.Width = Application.GetRealWidth(96);
lightingView.Height = Application.GetRealHeight(74);
- if (attrs.Contains(menu[3]) || true)
+ if (attrs.Contains(menu[3]))
{
if(index >2)
{
- lightingView.Y = Application.GetRealHeight(375);
+ lightingView.Y = Application.GetRealHeight(409);
}else
{
+ lightingView.Y = Application.GetRealHeight(304);
if (index == 1)
{
lightingView.Gravity = Gravity.CenterHorizontal;
@@ -204,8 +251,44 @@
}
}
FrameWhiteCentet1.AddChidren(lightingView);
+
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ string onoff = lightingView.Lighting ? "off" : "on";
+ device.SetAttrState(FunctionAttributeKey.OnOff, onoff);
+ Dictionary<string, string> d = new Dictionary<string, string>();
+ d.Add(FunctionAttributeKey.OnOff, onoff);
+ Control.Ins.SendWriteCommand(device, d);
+ };
+ lightingView.SetThouchEvent(eventHandler);
+
index++;
}
+
+ #endregion
+
+
+ #region 鏃堕棿璁剧疆
+ var timeSetView = new ClothesHangerControl(
+ "FunctionIcon/Electrical/ClothesHanger/ClothesHangerTimeIcon.png",
+ "FunctionIcon/Electrical/ClothesHanger/ClothesHangerTimeIconOn.png",
+ Language.StringByID(StringId.Time),
+ "");
+ timeSetView.Width = Application.GetRealWidth(96);
+ timeSetView.Height = Application.GetRealHeight(74);
+ timeSetView.Y = Application.GetRealHeight(409);
+ timeSetView.X = Application.GetRealWidth(266 - 33);
+
+
+ EventHandler<MouseEventArgs> eventHandler_timeSetView = (sender, e) =>
+ {
+ var setTimePage = new ClothesHangerSetTimePage(device);
+ MainPage.BasePageView.AddChidren(setTimePage);
+ setTimePage.LoadPage();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ };
+ timeSetView.SetThouchEvent(eventHandler_timeSetView);
+
+ FrameWhiteCentet1.AddChidren(timeSetView);
#endregion
}
@@ -242,16 +325,52 @@
private void RefreshFormStatu()
{
Application.RunOnMainThread(() => {
- var temp = device.status.Find((sta) => sta.key == FunctionAttributeKey.Status);
- if (temp != null)
+ btnIcon.IsSelected = true;
+ #region 鐐逛寒鏂囨湰
+ var hotDryTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.HotDry);
+ if (hotDryTemp != null)
{
- if (temp.value == "true")
- {
- }
- else
- {
- }
+ hotDryView.SetViewStatus(hotDryTemp.value == "true");
}
+ var windDryTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.WindDry);
+ if (windDryTemp != null)
+ {
+ windDryView.SetViewStatus(windDryTemp.value == "true");
+ }
+ var disinfectTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.Disinfect);
+ if (disinfectTemp != null)
+ {
+ disinfectView.SetViewStatus(disinfectTemp.value == "true");
+ }
+ var lightTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.OnOff);
+ if (lightTemp != null)
+ {
+ lightingView.SetViewStatus(lightTemp.value == "on");
+ }
+ #endregion
+
+ #region 淇敼鏃堕棿
+ var hotDryTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.HotDryTimeLeft);
+ if (hotDryTimeLeftTemp != null)
+ {
+ hotDryView.ChangeTime(hotDryTimeLeftTemp.value);
+ MainPage.Log($"鐑樺共鍓╀綑鏃堕棿{hotDryTimeLeftTemp.value}");
+ }
+ var windDryTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.WindDryTimeLeft);
+ if (windDryTimeLeftTemp != null)
+ {
+ windDryView.ChangeTime(windDryTimeLeftTemp.value);
+ MainPage.Log($"椋庡共鍓╀綑鏃堕棿{windDryTimeLeftTemp.value}");
+ }
+ var disinfectTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.DisinfectTimeLeft);
+ if (disinfectTimeLeftTemp != null)
+ {
+ disinfectView.ChangeTime(disinfectTimeLeftTemp.value);
+ MainPage.Log($"娑堟瘨鍓╀綑鏃堕棿{disinfectTimeLeftTemp.value}");
+ }
+ #endregion
+
+
});
}
@@ -279,11 +398,19 @@
private Button btnIcon;
private Button btnTitle;
private Button btnTime;
+ /// <summary>
+ /// 鍊掕鏃舵椂闂�
+ /// </summary>
+ private int leftTime = 0;
+ /// <summary>
+ /// 鎺т欢鏄惁鐐逛寒
+ /// </summary>
+ public bool Lighting = false;
+
+
public ClothesHangerControl(string iconPath1, string iconPath2,string title,string time)
{
-
-
btnIcon = new Button()
{
Gravity = Gravity.CenterHorizontal,
@@ -298,6 +425,7 @@
{
Gravity = Gravity.Center,
Text = title,
+ Height = Application.GetRealHeight(42),
TextColor = CSS_Color.TextualColor,
SelectedTextColor = CSS_Color.MainColor,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
@@ -307,8 +435,10 @@
btnTime = new Button()
{
Gravity = Gravity.CenterHorizontal,
+ Y = btnTitle.Bottom,
+ Height = Application.GetRealHeight(32),
Text = time,
- TextColor = CSS_Color.TextualColor,
+ TextColor = 0x00000000,
SelectedTextColor = CSS_Color.MainColor,
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
};
@@ -320,17 +450,57 @@
/// <param name="newTime"></param>
public void ChangeTime (string newTime)
{
- btnTime.Text = newTime;
+ int.TryParse(newTime, out leftTime);
+ leftTime *= 60;
+ if (countdownThread == null)
+ {
+ countdownThread = new System.Threading.Thread(() => {
+ while(true)
+ {
+ if(leftTime > 1)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ btnTime.Text = new TimeSpan(0, 0, leftTime).ToString();
+ });
+ System.Threading.Thread.Sleep(1000);
+ leftTime--;
+ }else
+ {
+ Application.RunOnMainThread(() =>
+ {
+ btnTime.Text = "";
+ });
+ }
+ }
+ }) { IsBackground = true };
+ countdownThread.Start();
+ }
}
- public void ChangeViewStatus(bool state)
+ public void SetViewStatus(bool state)
{
- btnIcon.IsSelected = btnTitle.IsSelected = btnTime.IsSelected = state;
+ btnIcon.IsSelected = btnTitle.IsSelected = btnTime.IsSelected = Lighting = state;
}
public bool GetViewState()
{
- return btnIcon.IsSelected;
+ return Lighting;
}
+
+ /// <summary>
+ /// 璁剧疆鐐瑰嚮浜嬩欢
+ /// </summary>
+ public void SetThouchEvent(EventHandler<MouseEventArgs> eventHandler)
+ {
+ btnIcon.MouseUpEventHandler = eventHandler;
+ btnTime.MouseUpEventHandler = eventHandler;
+ btnTitle.MouseUpEventHandler = eventHandler;
+ }
+
+ /// <summary>
+ /// 鍊掕鏃剁嚎绋�
+ /// </summary>
+ System.Threading.Thread countdownThread;
}
}
--
Gitblit v1.8.0