using System;
|
using ZigBee.Device;
|
namespace Shared.Phone.UserCenter.DoorLock
|
{
|
public class RemotelyUnlock : DoorLockCommonLayout, ZigBee.Common.IStatus
|
{
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
/// <param name="doorLock"></param>
|
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
|
|
/// <summary>
|
/// UI显示
|
/// </summary>
|
public void Show()
|
{
|
this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.RemotelyUnlock));
|
|
EventHandler<MouseEventArgs> 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();
|
}
|
|
/// <summary>
|
/// 重写移除方法
|
/// </summary>
|
public override void RemoveFromParent()
|
{
|
ZbGateway.StatusList.Remove(this);
|
base.RemoveFromParent();
|
}
|
|
/// <summary>
|
/// 生成6位动态密码
|
/// </summary>
|
/// <returns></returns>
|
string getDynamicPassword()
|
{
|
var password = "";
|
password = new Random().Next(100000, 999999).ToString();
|
return password;
|
}
|
|
#region ◆ 接口实现__________________________
|
/// <summary>
|
/// 处理变化事件 --将弃用 改用DeviceInfoChange()
|
/// </summary>
|
/// <returns>The changed.</returns>
|
/// <param name="common">Common.</param>
|
public void Changed(CommonDevice common)
|
{
|
|
}
|
/// <summary>
|
/// 处理变化事件
|
/// </summary>
|
/// <param name="common"></param>
|
/// <param name="typeTag"></param>
|
public void DeviceInfoChange(CommonDevice common, string typeTag)
|
{
|
}
|
/// <summary>
|
/// Changeds the IL ogic status.
|
/// </summary>
|
/// <param name="logic">Logic.</param>
|
public void ChangedILogicStatus(ZigBee.Device.Logic logic)
|
{
|
}
|
/// <summary>
|
/// Changeds the IS cene status.
|
/// </summary>
|
/// <param name="scene">Scene.</param>
|
public void ChangedISceneStatus(Scene scene)
|
{
|
}
|
#endregion
|
|
}
|
}
|