using System;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DoorLock
{
public class RemotelyUnlock : DoorLockCommonLayout, ZigBee.Common.IStatus
{
///
/// 构造函数
///
///
public RemotelyUnlock(ZigBee.Device.DoorLock doorLock)
{
this.doorLock = doorLock;
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
ZigBee.Device.ZbGateway.StatusList.Add(this);
}
#region ◆ 变量申明__________________________
ZigBee.Device.DoorLock doorLock;
#endregion
///
/// UI显示
///
public void Show()
{
this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.RemotelyUnlock));
EventHandler eHandlerBack = (sender, e) =>
{
RemoveFromParent();
};
this.btnBack.MouseUpEventHandler += eHandlerBack;
this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
this.MidFrameLayout(this);
MidFrameLayoutContent();
}
public void MidFrameLayoutContent()
{
var passwordText = new EditText()
{
Y = Application.GetRealHeight(140),
Width = Application.GetRealWidth(480 * 2),
Height = Application.GetRealHeight(70),
Gravity = Gravity.CenterHorizontal,
//PlaceholderText = Language.StringByID(R.MyInternationalizationString.InputSixPassword),
TextAlignment = TextAlignment.Center,
TextColor = 0xff000000,
//UnSelectedImagePath = "Register/Register_Password_kuang.png",
//PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor,
Radius = (uint)Application.GetRealHeight(0),
//SecureTextEntry = true,
TextSize = 15,
BackgroundColor = 0xff00ff00,
};
this.midFrameLayout.AddChidren(passwordText);
var btnTip = new Button()
{
Height = Application.GetRealHeight(60),
Width = Application.GetRealWidth(60),
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(200),
Enable = false,
Visible = false,
};
this.midFrameLayout.AddChidren(btnTip);
var btnLock = new Button()
{
Height = Application.GetRealHeight(500),
Width = Application.GetRealWidth(501),
//UnSelectedImagePath = "DoorLockPic/door_lock_close.png",
//SelectedImagePath = "DoorLockPic/door_lock_open.png",
BackgroundColor = 0xff00ffff,
SelectedBackgroundColor = 0xff00ff00,
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(370),
Enable = false,
};
this.midFrameLayout.AddChidren(btnLock);
btnLock.MouseUpEventHandler += (sender, e) =>
{
btnLock.IsSelected = !btnLock.IsSelected;
};
passwordText.Text = getDynamicPassword();
var delayTime = DateTime.Now.AddSeconds(+300);//5分钟内有效
new System.Threading.Thread(() =>
{
while (true)
{
if (DateTime.Now >= delayTime)
{
Application.RunOnMainThread(() =>
{
passwordText.Text = "密码失效";
});
}
}
})
{ IsBackground = true }.Start();
}
///
/// 重写移除方法
///
public override void RemoveFromParent()
{
ZbGateway.StatusList.Remove(this);
base.RemoveFromParent();
}
///
/// 生成6位动态密码
///
///
string getDynamicPassword()
{
var password = "";
password = new Random().Next(100000, 999999).ToString();
return password;
}
#region ◆ 接口实现__________________________
///
/// 处理变化事件 --将弃用 改用DeviceInfoChange()
///
/// The changed.
/// Common.
public void Changed(CommonDevice common)
{
}
///
/// 处理变化事件
///
///
///
public void DeviceInfoChange(CommonDevice common, string typeTag)
{
}
///
/// Changeds the IL ogic status.
///
/// Logic.
public void ChangedILogicStatus(ZigBee.Device.Logic logic)
{
}
///
/// Changeds the IS cene status.
///
/// Scene.
public void ChangedISceneStatus(Scene scene)
{
}
#endregion
}
}