From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28
---
ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs | 299 +++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 205 insertions(+), 94 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs
index dae9d4c..bbc4894 100644
--- a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
+using Shared.Phone.Device.DeviceLogic;
using Shared.Phone.UserView;
using ZigBee.Device;
namespace Shared.Phone.Device.Light
@@ -19,7 +20,7 @@
/// <summary>
/// The action.
/// </summary>
- public Action action;
+ public Action<DeviceUI, Common.Room> action;
/// <summary>
/// The light image.
@@ -70,6 +71,10 @@
/// </summary>
private Button OffBtn;
+ /// <summary>
+ /// IsDrawerLockMode
+ /// </summary>
+ public bool IsDrawerLockMode;
#endregion
#region 鈼� 鎺ュ彛__________________________
@@ -139,8 +144,22 @@
return;
}
light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData;
- SetONOFFStatu(light.OnOffStatus == 1);
- StatuBtn.Text = CommonFormResouce.GetSwitchStatu(light.OnOffStatus == 1);
+ StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}";
+
+ if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�)
+ {
+ SetONOFFStatu(light.OnOffStatus == 1);
+ }
+ else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇)
+ {
+ deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1;
+ }
+ else
+ {
+ deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1;
+ }
+
+
light.LastDateTime = DateTime.Now;
}
}
@@ -169,7 +188,7 @@
return;
}
deviceUI.CommonDevice.IsOnline = common.IsOnline;
- OnBtn.IsSelected = OffBtn.IsSelected= deviceUI.CommonDevice.IsOnline == 1;
+ //OnBtn.IsSelected = OffBtn.IsSelected= deviceUI.CommonDevice.IsOnline == 1;
deviceUI.CommonDevice.LastDateTime = DateTime.Now;
}
catch (Exception ex)
@@ -188,9 +207,13 @@
public override void RemoveFromParent()
{
ZbGateway.StatusList.Remove(this);
- //action();
- //action = null;
+ action(device, room);
+ action = null;
RemoveUpdateControlDeviceStatuAction();
+ if (IsDrawerLockMode)
+ {
+ CommonPage.Instance.IsDrawerLockMode = false;
+ }
base.RemoveFromParent();
}
@@ -228,8 +251,7 @@
{
UserHomeView.ReadStatus(light, () =>
{
- light.ReadOnOffStatus();
- light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+ ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
});
}
else
@@ -237,13 +259,11 @@
//闃叉鐭椂闂村唴澶氭璇诲彇鐘舵��
if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds)
{
- light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
- light.ReadOnOffStatus();
+ ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
}
}
- var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName);
- if (de == null)
+ if(Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false)
{
collectionBtn.IsSelected = false;
}
@@ -273,16 +293,6 @@
{
RemoveFromParent();
};
-
- var sharedBtn = new Button
- {
- X = Application.GetRealWidth(850),
- Width = Application.GetMinReal(69),
- Height = Application.GetMinReal(69),
- Gravity = Gravity.CenterVertical,
- UnSelectedImagePath = "Item/Shared.png"
- };
- top.topView.AddChidren(sharedBtn);
var moreBtn = new Button
{
@@ -338,9 +348,10 @@
Width = Application.GetRealWidth(500),
Height = Application.GetRealHeight(60),
Gravity = Gravity.CenterHorizontal,
- Text = device.CommonDevice.DeviceEpointName,
+ Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice),
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
- TextSize = 15
+ TextSize = 15,
+ IsBold=true
};
itemView.AddChidren(deviceNameBtn);
@@ -351,43 +362,10 @@
Height = Application.GetRealHeight(60),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
- Text = CommonFormResouce.GetSwitchStatu(device.CommonDevice.IsOnline == 1)
+ Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}",
+ TextSize = 10
};
itemView.AddChidren(StatuBtn);
-
- deviceIMG = new Button()
- {
- Y = Application.GetRealHeight(340),
- Width = Application.GetMinRealAverage(579),
- Height = Application.GetMinRealAverage(579),
- Gravity = Gravity.CenterHorizontal,
- UnSelectedImagePath = "Light/OnOff.png",
- };
- itemView.AddChidren(deviceIMG);
-
- OffBtn = new Button
- {
- X = Application.GetRealWidth(294),
- Y = Application.GetRealHeight(588),
- Width = Application.GetMinRealAverage(81),
- Height = Application.GetMinRealAverage(81),
- UnSelectedImagePath = "Light/OFF.png",
- SelectedImagePath = "Light/OFFSelected.png",
- IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 0
- };
- itemView.AddChidren(OffBtn);
-
- OnBtn = new Button
- {
- X = Application.GetRealWidth(590),
- Y = Application.GetRealHeight(588),
- Width = Application.GetMinRealAverage(81),
- Height = Application.GetMinRealAverage(81),
- UnSelectedImagePath = "Light/ON.png",
- SelectedImagePath = "Light/ONSelected.png",
- IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
- };
- itemView.AddChidren(OnBtn);
var roomBG = new Button
{
@@ -424,9 +402,142 @@
Height = Application.GetRealHeight(50),
Text = room.Name,
TextAlignment = TextAlignment.CenterLeft,
- TextColor = ZigbeeColor.Current.GXCTextWhiteColor
+ TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
+ TextSize = 12
};
itemView.AddChidren(roomName);
+
+ AddByFunctionType(itemView);
+ }
+
+ /// <summary>
+ /// AddByFunctionType
+ /// </summary>
+ private void AddByFunctionType(FrameLayout itemView)
+ {
+ if(device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�)
+ {
+ AddOnOff(itemView);
+ }
+ else if(device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇)
+ {
+ AddPlug(itemView);
+ }
+ else
+ {
+ AddLight(itemView);
+ }
+ }
+
+ /// <summary>
+ /// AddOnOff
+ /// </summary>
+ private void AddOnOff(FrameLayout itemView)
+ {
+ deviceIMG = new Button()
+ {
+ Y = Application.GetRealHeight(340),
+ Width = Application.GetMinRealAverage(579),
+ Height = Application.GetMinRealAverage(579),
+ Gravity = Gravity.CenterHorizontal,
+ UnSelectedImagePath = "Light/OnOff.png",
+ };
+ itemView.AddChidren(deviceIMG);
+
+ OffBtn = new Button
+ {
+ X = Application.GetRealWidth(294),
+ Y = Application.GetRealHeight(588),
+ Width = Application.GetMinRealAverage(81),
+ Height = Application.GetMinRealAverage(81),
+ UnSelectedImagePath = "Light/OFF.png",
+ SelectedImagePath = "Light/OFFSelected.png",
+ IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 0
+ };
+ itemView.AddChidren(OffBtn);
+
+ OnBtn = new Button
+ {
+ X = Application.GetRealWidth(590),
+ Y = Application.GetRealHeight(588),
+ Width = Application.GetMinRealAverage(81),
+ Height = Application.GetMinRealAverage(81),
+ UnSelectedImagePath = "Light/ON.png",
+ SelectedImagePath = "Light/ONSelected.png",
+ IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+ };
+ itemView.AddChidren(OnBtn);
+
+ OnBtn.MouseUpEventHandler += ON;
+ OffBtn.MouseUpEventHandler += OFF;
+ }
+
+ /// <summary>
+ /// light
+ /// </summary>
+ /// <param name="itemView"></param>
+ private void AddLight(FrameLayout itemView)
+ {
+ deviceIMG = new Button()
+ {
+ Y = Application.GetRealHeight(389),
+ Width = Application.GetMinRealAverage(377),
+ Height = Application.GetMinRealAverage(435),
+ Gravity = Gravity.CenterHorizontal,
+ UnSelectedImagePath = "Light/DeskLamp.png",
+ SelectedImagePath = "Light/DeskLampSelected.png",
+ IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+ };
+ itemView.AddChidren(deviceIMG);
+
+ switchBtn = new Button()
+ {
+ Y = Application.GetRealHeight(996),
+ Width = Application.GetMinRealAverage(81),
+ Height = Application.GetMinRealAverage(81),
+ Gravity = Gravity.CenterHorizontal,
+ UnSelectedImagePath = "Item/Switch.png",
+ SelectedImagePath = "Item/SwitchSelected.png",
+ IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+ };
+ itemView.AddChidren(switchBtn);
+
+ switchBtn.MouseUpEventHandler += Switch;
+ deviceIMG.MouseUpEventHandler += Switch;
+ }
+
+ /// <summary>
+ /// plug
+ /// </summary>
+ /// <param name="itemView"></param>
+ private void AddPlug(FrameLayout itemView)
+ {
+ deviceIMG = new Button()
+ {
+ Y = Application.GetRealHeight(344),
+ Width = Application.GetMinRealAverage(567),
+ Height = Application.GetMinRealAverage(567),
+ Gravity = Gravity.CenterHorizontal,
+ UnSelectedImagePath = "Light/Plug.png",
+ SelectedImagePath = "Light/PlugSelected.png",
+ IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+ };
+ itemView.AddChidren(deviceIMG);
+
+ switchBtn = new Button()
+ {
+ Y = Application.GetRealHeight(996),
+ Width = Application.GetMinRealAverage(81),
+ Height = Application.GetMinRealAverage(81),
+ Gravity = Gravity.CenterHorizontal,
+ UnSelectedImagePath = "Item/Switch.png",
+ SelectedImagePath = "Item/SwitchSelected.png",
+ IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+ };
+ itemView.AddChidren(switchBtn);
+
+ switchBtn.MouseUpEventHandler += Switch;
+ deviceIMG.MouseUpEventHandler += Switch;
}
#endregion
@@ -437,8 +548,6 @@
/// </summary>
private void BindEvent()
{
- OnBtn.MouseUpEventHandler += ON;
- OffBtn.MouseUpEventHandler += OFF;
collectionBtn.MouseUpEventHandler += Collection;
}
@@ -451,35 +560,36 @@
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="eventArgs">Event arguments.</param>
- //private void Switch(object sender, MouseEventArgs eventArgs)
- //{
- // sendedControlCommand = false;
- // zbGateway.ReportAction += UpdateDeviceControllStatu;
- // switchBtn.IsSelected = !switchBtn.IsSelected;
- // deviceIMG.IsSelected = !deviceIMG.IsSelected;
- // StatuBtn.Text = CommonFormResouce.GetSwitchStatu(deviceIMG.IsSelected);
- // if (switchBtn.IsSelected == true)
- // {
- // (device.CommonDevice as ToggleLight).SwitchControl(1);
- // }
- // else
- // {
- // (device.CommonDevice as ToggleLight).SwitchControl(0);
- // }
- // //鎺у埗寤舵椂鍥炶皟
- // DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
- // {
- // if (Parent == null)
- // {
- // return;
- // }
- // RemoveUpdateControlDeviceStatuAction();
- // if (sendedControlCommand == false)
- // {
- // DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
- // }
- // });
- //}
+ private void Switch(object sender, MouseEventArgs eventArgs)
+ {
+ sendedControlCommand = false;
+ zbGateway.ReportAction += UpdateDeviceControllStatu;
+ switchBtn.IsSelected = !switchBtn.IsSelected;
+ deviceIMG.IsSelected = !deviceIMG.IsSelected;
+ StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}";
+
+ if (switchBtn.IsSelected == true)
+ {
+ (device.CommonDevice as ToggleLight).SwitchControl(1);
+ }
+ else
+ {
+ (device.CommonDevice as ToggleLight).SwitchControl(0);
+ }
+ //鎺у埗寤舵椂鍥炶皟
+ DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
+ {
+ if (Parent == null)
+ {
+ return;
+ }
+ RemoveUpdateControlDeviceStatuAction();
+ if (sendedControlCommand == false)
+ {
+ DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
+ }
+ });
+ }
/// <summary>
/// ON
@@ -546,8 +656,9 @@
OnBtn.IsSelected = false;
OffBtn.IsSelected = true;
}
+ StatuBtn.Text = statu ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}";
}
-
+
#endregion
@@ -563,9 +674,9 @@
UserView.HomePage.Instance.AddChidren(detailInfo);
UserView.HomePage.Instance.PageIndex += 1;
detailInfo.Show(device, room);
- detailInfo.action = () =>
+ detailInfo.EditAction += (curDev, curRoom) =>
{
- Show(device, room);
+ Show(curDev, curRoom);
};
}
--
Gitblit v1.8.0