From a1b0ab7044100daaa7e0f1da2d2ca45e38098963 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 29 三月 2021 09:13:25 +0800
Subject: [PATCH] 2021-3-29-2
---
HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs | 337 ++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 218 insertions(+), 119 deletions(-)
diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
index 51edfaf..c8b1509 100644
--- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
+++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
@@ -9,7 +9,7 @@
public partial class FunctionControlZone : FrameLayout
{
#region 鍖哄煙鎺т欢
- FrameLayout bodyDiv;
+ static FrameLayout bodyDiv;
/// <summary>
/// 鍔熻兘/鍦烘櫙icon
/// </summary>
@@ -38,6 +38,7 @@
public FunctionControlZone(Function func)
{
bodyDiv = this;
+ bodyDiv.Tag = func.sid;
function = func;
}
@@ -52,6 +53,7 @@
/// </summary>
public void LoadFunctionDiv()
{
+ //todo 澧炲姞璁惧锛屽鍔犲姛鑳藉垪琛ㄥ崱鐗�
if (function == null)
{
this.RemoveFromParent();
@@ -59,127 +61,180 @@
}
LoadDiv();
- if (function.functionCategory == FunctionCategory.Curtain || function.functionCategory == FunctionCategory.Music || function.functionCategory == FunctionCategory.Scene)//绐楀笜娌℃湁寮�鍏虫寜閽�
+ //switch (function.spk)
+ //{
+ // case SPK.CurtainSwitch:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
+ // break;
+ // case SPK.CurtainTrietex:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/MotorCurtainIcon.png";
+ // break;
+ // case SPK.CurtainRoller:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/RollingShutterIcon.png";
+ // break;
+ // case SPK.SensorPir:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/ArmSensorPirIcon.png";
+ // break;
+ // case SPK.SensorWater:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/ArmSensorWaterImmersionIcon.png";
+ // break;
+ // case SPK.SensorSmoke:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/ArmSensorSmokeIcon.png";
+ // break;
+ // case SPK.SensorDoorWindow:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/ArmSensorDoorIcon.png";
+ // break;
+ // case SPK.MusicStandard:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png";
+ // break;
+ // case SPK.ClothesHanger:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerGrayIcon.png";
+ // break;
+ // case SPK.ElectricSocket:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png";
+ // break;
+ // case SPK.ElectricFan:
+ // case SPK.ElectricTuyaFan:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png";
+ // break;
+ // case SPK.ElectricTV:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png";
+ // break;
+ // case SPK.ElectricTuyaAirCleaner:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/AirCleanerThiinIcon.png";
+ // break;
+ // case SPK.ElectricTuyaWeepRobot:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobotThinIcon.png";
+ // break;
+ // case SPK.ElectricTuyaWaterValve:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WaterValve/WaterValveIcon.png";
+ // break;
+ // case SPK.AcStandard:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
+ // break;
+ // case SPK.AcIr:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
+ // break;
+ // case SPK.FloorHeatStandard:
+ // btnIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
+ // break;
+ // default:
+ // btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png";
+ // break;
+ //}
+ btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png";
+
+ if (function.Spk_Prefix == FunctionCategory.Curtain//绐楀笜娌℃湁寮�鍏虫寜閽�
+ || function.Spk_Prefix == FunctionCategory.Music//闊充箰娌℃湁寮�鍏虫寜閽�
+ || function.Spk_Prefix == FunctionCategory.Sensor//浼犳劅鍣ㄦ病鏈夊紑鍏虫寜閽�
+ )
{
- switch (function.functionCategory)
+ switch (function.Spk_Prefix)
{
case FunctionCategory.Curtain:
- btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
+
CurtainFragment();
break;
+ case FunctionCategory.Sensor:
+ var powerLowTipAttr = function.attributes.Find((obj) => obj.key == FunctionAttributeKey.BatteryState);
+ if (powerLowTipAttr != null)
+ {
+ if (powerLowTipAttr.state.ToLower() == "low")
+ {
+ Button btnTipPowerLow = new Button()
+ {
+ X = Application.GetRealWidth(307),
+ Y = Application.GetRealHeight(25),
+ Width = Application.GetRealWidth(24),
+ Height = Application.GetRealWidth(24),
+ UnSelectedImagePath = "FunctionIcon/ArmSensor/PowerLowIcon.png",
+ SelectedImagePath = "FunctionIcon/ArmSensor/PowerLowIcon.png",
+ };
+ this.AddChidren(btnTipPowerLow);
+ }
+ }
+
+ break;
case FunctionCategory.Music:
- btnIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png";
MusicFragment();
break;
- case FunctionCategory.Scene:
- btnIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
- if ((function as Scene).sceneType == SceneType.MovieScene)
- {
- var movieIcon = new Button()
- {
- X = Application.GetRealWidth(52),
- Y = Application.GetRealHeight(14),
- Width = Application.GetRealWidth(16),
- Height = Application.GetRealWidth(16),
- UnSelectedImagePath = "FunctionIcon/Scene/MovieMark.png",
- };
- bodyDiv.AddChidren(movieIcon);
- btnName.X = Application.GetRealWidth(52 + 16);
- }
- //鍔犺浇鍦烘櫙鎺у埗浜嬩欢
- LoadEvent_ControlScene();
- break;
+
}
}
else
{
- #region 鍔犺浇寮�鍏虫寜閽�
- /// <summary>
- /// 寮�鍏虫寜閽�
- /// </summary>
- Button btnSwitch;
- if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer)
+ if (function.spk == SPK.ClothesHanger)//鏅捐。鏋�
{
- btnSwitch = new Button()
- {
- X = Application.GetRealWidth(303),
- Y = Application.GetRealHeight(78),
- Width = Application.GetMinRealAverage(32),
- Height = Application.GetMinRealAverage(32),
- UnSelectedImagePath = "Public/PowerClose.png",
- SelectedImagePath = "Public/PowerOpen.png",
- IsSelected = function.on_off == "on",
- Tag = function.functionType + "_Switch_" + function.sid,
- };
- bodyDiv.AddChidren(btnSwitch);
+ ClothesHangerFragment();
}
else
{
- btnSwitch = new Button()
+ #region 鍔犺浇寮�鍏虫寜閽�
+
+ /// <summary>
+ /// 寮�鍏虫寜閽�
+ /// </summary>
+ Button btnSwitch;
+ if (function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
{
- X = Application.GetRealWidth(303),
- Y = Application.GetRealHeight(58),
- Width = Application.GetMinRealAverage(32),
- Height = Application.GetMinRealAverage(32),
- UnSelectedImagePath = "Public/PowerClose.png",
- SelectedImagePath = "Public/PowerOpen.png",
- IsSelected = function.on_off == "on",
- Tag = function.functionType + "_Switch_" + function.sid,
- };
- bodyDiv.AddChidren(btnSwitch);
- }
- //鍔犺浇寮�鍏虫寜閽簨浠�
- LoadEvent_SwitchFunction(btnSwitch);
+ btnSwitch = new Button()
+ {
+ X = Application.GetRealWidth(303),
+ Y = Application.GetRealHeight(78),
+ Width = Application.GetMinRealAverage(32),
+ Height = Application.GetMinRealAverage(32),
+ UnSelectedImagePath = "Public/PowerClose.png",
+ SelectedImagePath = "Public/PowerOpen.png",
+ IsSelected = function.trait_on_off.curValue.ToString() == "on",
+ Tag = function.sid + "_Switch",
+ };
+ bodyDiv.AddChidren(btnSwitch);
+ //鍔犺浇寮�鍏虫寜閽簨浠�
+ LoadEvent_SwitchFunction(btnSwitch, function.attributes.Find((obj) => obj.key == FunctionAttributeKey.FadeTime));
+ }
+ else
+ {
+ btnSwitch = new Button()
+ {
+ X = Application.GetRealWidth(303),
+ Y = Application.GetRealHeight(58),
+ Width = Application.GetMinRealAverage(32),
+ Height = Application.GetMinRealAverage(32),
+ UnSelectedImagePath = "Public/PowerClose.png",
+ SelectedImagePath = "Public/PowerOpen.png",
+ IsSelected = function.trait_on_off.curValue.ToString() == "on",
+ Tag = function.sid + "_Switch",
+ };
+ bodyDiv.AddChidren(btnSwitch);
+ //鍔犺浇寮�鍏虫寜閽簨浠�
+ LoadEvent_SwitchFunction(btnSwitch);
+ }
- switch (function.functionCategory)
- {
- case FunctionCategory.Thermostat:
- switch (function.functionType)
- {
- case FunctionType.AC:
- btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
- LoadLastStatesButton();
- break;
- case FunctionType.FloorHeating:
- btnIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
- LoadLastStatesButton();
- break;
- }
- break;
- case FunctionCategory.Light:
- btnIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png";
- btnSwitch.IsSelected = function.on_off == "on";
- LoadLightControl();
- break;
- case FunctionCategory.SwitchDevice:
- switch (function.functionType)
- {
- case FunctionType.Socket:
- btnIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png";
- break;
- }
- btnSwitch.IsSelected = function.on_off == "on";
- break;
- case FunctionCategory.Electrical:
- switch (function.functionType)
- {
- case FunctionType.Fan:
- btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png";
- break;
- case FunctionType.TV:
- btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png";
- break;
- }
- btnSwitch.IsSelected = function.on_off == "on";
- break;
+ switch (function.Spk_Prefix)
+ {
+ case FunctionCategory.AC:
+ LoadLastStatesButton();
+ break;
+ case FunctionCategory.IR:
+ LoadLastStatesButton();
+ break;
+ case FunctionCategory.FloorHeat:
+ LoadLastStatesButton();
+ break;
+ case FunctionCategory.Light:
+ //btnIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png";
+ btnSwitch.IsSelected = function.trait_on_off.curValue.ToString() == "on";
+ LoadLightControl();
+ break;
+ case FunctionCategory.Electric:
+ btnSwitch.IsSelected = function.trait_on_off.curValue.ToString() == "on";
+ break;
+ }
+ #endregion
}
- #endregion
}
- if (function.functionCategory != FunctionCategory.Scene)
- {
- LoadEvent_DivSkipEvent();
- }
+ LoadEvent_DivSkipEvent();
LoadEvent_FunctionCollection();
}
@@ -231,9 +286,14 @@
Height = Application.GetMinRealAverage(40),
SelectedImagePath = "Collection/CollectionIcon.png",
UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
- IsSelected = function.collection
+ IsSelected = function.collect
};
- bodyDiv.AddChidren(btnCollectionIcon);
+ //bodyDiv.AddChidren(btnCollectionIcon);
+ //2020-12-16 濡傛灉鏄垚鍛橀殣钘忔敹钘忓姛鑳�
+ if (!DB_ResidenceData.Instance.CurrentRegion.IsOthreShare && function.Spk_Prefix != FunctionCategory.Sensor)
+ {
+ bodyDiv.AddChidren(btnCollectionIcon);
+ }
}
/// <summary>
@@ -241,16 +301,16 @@
/// </summary>
void LoadLightControl()
{
- switch (function.functionType)
+ switch (function.spk)
{
- case FunctionType.Dimmer:
- case FunctionType.RGB:
+ case SPK.LightDimming:
+ case SPK.LightRGB:
#region Dimmer
var btnDimmerMinValues = new Button()
{
X = Application.GetRealWidth(14),
Y = Application.GetRealHeight(85),
- Width = Application.GetRealWidth(22),
+ Width = Application.GetRealWidth(30),
Height = Application.GetRealHeight(21),
Text = "0%",
TextAlignment = TextAlignment.CenterLeft,
@@ -268,12 +328,13 @@
SeekBarViewHeight = Application.GetRealHeight(8),
ThumbImagePath = "Public/ThumbImage.png",
ThumbImageHeight = Application.GetRealHeight(54),
- ProgressBarColor = (function as Light).on_off == "on" ? CSS_Color.AuxiliaryColor1 : CSS_Color.PromptingColor2,
+ ProgressBarColor = function.trait_on_off.curValue.ToString() == "on" ? CSS_Color.AuxiliaryColor1 : CSS_Color.PromptingColor2,
ProgressTextColor = CSS_Color.FirstLevelTitleColor,
- ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+ ProgressTextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
MaxValue = 100,
- Progress = (function as Light).brightness,
- Tag = function.functionType + "_DimmerBar_" + function.sid
+ Progress = Convert.ToInt32(function.GetAttrState(FunctionAttributeKey.BatteryState)),
+ Tag = function.sid + "_DimmerBar",
+ SeekBarPadding = Application.GetRealWidth(20),
};
bodyDiv.AddChidren(dimmerControlBar);
@@ -281,7 +342,7 @@
{
X = Application.GetRealWidth(14 + 22+180),
Y = Application.GetRealHeight(85),
- Width = Application.GetRealWidth(35),
+ Width = Application.GetRealWidth(45),
Height = Application.GetRealHeight(21),
Text = "100%",
TextAlignment = TextAlignment.CenterLeft,
@@ -310,7 +371,8 @@
Height = Application.GetMinRealAverage(32),
UnSelectedImagePath = "FunctionIcon/Curtain/CurtainCloseIcon.png",
SelectedImagePath = "FunctionIcon/Curtain/CurtainCloseOnIcon.png",
- Tag = function.functionType + "_off_" + function.sid
+ IsSelected = function.GetAttrState(FunctionAttributeKey.Percent) == "0",
+ Tag = function.sid + "_off"
};
bodyDiv.AddChidren(btnCurtainClose);
@@ -322,6 +384,7 @@
Height = Application.GetMinRealAverage(32),
UnSelectedImagePath = "FunctionIcon/Curtain/CurtainStopIcon.png",
SelectedImagePath = "FunctionIcon/Curtain/CurtainStopOnIcon.png",
+ Tag = function.sid + "_stop",
};
bodyDiv.AddChidren(btnCurtainStop);
@@ -333,11 +396,44 @@
Height = Application.GetMinRealAverage(32),
UnSelectedImagePath = "FunctionIcon/Curtain/CurtainOpenIcon.png",
SelectedImagePath = "FunctionIcon/Curtain/CurtainOpenOnIcon.png",
- Tag = function.functionType + "_on_" + function.sid
+ Tag = function.sid + "_on",
+ IsSelected = function.GetAttrState(FunctionAttributeKey.Percent) != "0"
};
bodyDiv.AddChidren(btnCurtainOpen);
- LoadEvent_ControlCurtain(btnCurtainStop, btnCurtainOpen, btnCurtainClose, function as Curtain);
+ LoadEvent_ControlCurtain(btnCurtainStop, btnCurtainOpen, btnCurtainClose, function);
#endregion
+ }
+ /// <summary>
+ /// 鍔犺浇鏅捐。鏋跺姛鑳芥帶鍒跺崱鐗�
+ /// </summary>
+ void ClothesHangerFragment()
+ {
+ #region ClothesHanger
+ var btnClothesHangerUp = new Button()
+ {
+ X = Application.GetRealWidth(233),
+ Y = Application.GetRealHeight(58),
+ Width = Application.GetMinRealAverage(32),
+ Height = Application.GetMinRealAverage(32),
+ UnSelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerUpIcon1.png",
+ SelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerUpIcon1On.png",
+ };
+ bodyDiv.AddChidren(btnClothesHangerUp);
+
+ var btnClothesHangerDown = new Button()
+ {
+ X = Application.GetRealWidth(303),
+ Y = Application.GetRealHeight(58),
+ Width = Application.GetMinRealAverage(32),
+ Height = Application.GetMinRealAverage(32),
+ UnSelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerDownIcon1.png",
+ SelectedImagePath = "FunctionIcon/Electrical/ClothesHanger/ClothesHangerDownIcon1On.png",
+ };
+ bodyDiv.AddChidren(btnClothesHangerDown);
+ LoadEvent_ControlClothesHanger(function, btnClothesHangerUp, btnClothesHangerDown);
+ #endregion
+
+
}
/// <summary>
@@ -366,7 +462,7 @@
UnSelectedImagePath = "MusicIcon/pause.png",
SelectedImagePath = "MusicIcon/play.png",
IsSelected = (function as A31MusicModel).A31PlayStatus.status == "play" ,
- Tag = function.functionType + "_State_" + function.sid
+ Tag = function.spk + "_State_" + function.sid
};
bodyDiv.AddChidren(btnPlay);
@@ -384,12 +480,15 @@
#endregion
}
-
/// <summary>
/// 鍔犺浇鍔熻兘鐘舵�佷俊鎭寜閽�
/// </summary>
void LoadLastStatesButton()
{
+ if(function.spk == SPK.LightSwitch)
+ {
+ return;
+ }
var btnLastStates = new Button()
{
X = Application.GetRealWidth(10 + 32 + 8),
@@ -401,8 +500,8 @@
SelectedTextColor = CSS_Color.PromptingColor1,
TextColor = 0x00000000,
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
- Tag = function.functionType + "_laststates_" + function.sid,
- IsSelected = function.on_off == "on"
+ Tag = function.spk + "_laststates_" + function.sid,
+ IsSelected = function.trait_on_off.curValue.ToString() == "on"
};
bodyDiv.AddChidren(btnLastStates);
}
--
Gitblit v1.8.0