using System;
|
using Shared.Common;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter.DoorLock
|
{
|
public class TemporaryPassword : DoorLockCommonLayout, ZigBee.Common.IStatus
|
{
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
/// <param name="doorLock"></param>
|
public TemporaryPassword(ZigBee.Device.DoorLock doorLock)
|
{
|
this.doorLock = doorLock;
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
|
ZigBee.Device.ZbGateway.StatusList.Add(this);
|
}
|
|
#region ◆ 变量申明__________________________
|
ZigBee.Device.DoorLock doorLock;
|
public System.Collections.Generic.List<Button> pawButtonList = new System.Collections.Generic.List<Button> { };//临时密码中的6位数字
|
Button passwordText; //临时密码
|
#endregion
|
|
/// <summary>
|
/// UI显示
|
/// </summary>
|
public void Show()
|
{
|
this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.TemporaryPassword));
|
|
EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
this.btnBack.MouseUpEventHandler += eHandlerBack;
|
this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
|
this.MidFrameLayout(this);
|
|
MidFrameLayoutContent();
|
|
}
|
|
/// <summary>
|
/// 读门锁临时密码信息
|
/// </summary>
|
/// <param name="door_lock">Door lock.</param>
|
void readStatus()
|
{
|
System.Threading.Tasks.Task.Run(() =>
|
{
|
|
});
|
}
|
|
public void MidFrameLayoutContent()
|
{
|
var MidTopFrameLayout = new FrameLayout()
|
{
|
X = Application.GetRealWidth(196),
|
Y = Application.GetRealHeight(276),
|
Width = Application.GetRealWidth(668),
|
Height = Application.GetRealHeight(527),
|
BackgroundColor = ZigbeeColor.Current.XMWhite,
|
};
|
this.midFrameLayout.AddChidren(MidTopFrameLayout);
|
|
var topPic = new Button()
|
{
|
Height = Application.GetRealHeight(184),
|
Width = Application.GetRealWidth(184),
|
X = Application.GetRealWidth(449),
|
Y = Application.GetRealHeight(58),
|
TextAlignment = TextAlignment.Center,
|
Text = Language.StringByID(R.MyInternationalizationString.RandomPasword),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray1,
|
};
|
this.midFrameLayout.AddChidren(topPic);
|
|
var randomPassword = new EditText()
|
{
|
Y = Application.GetRealHeight(153),
|
Height = Application.GetRealHeight(84),
|
TextAlignment = TextAlignment.Center,
|
TextColor = Shared.Common.ZigbeeColor.Current.XMOrange,
|
TextSize = 24,
|
Text = GetTempPassword(),
|
};
|
MidTopFrameLayout.AddChidren(randomPassword);
|
|
var validTime = new Button()
|
{
|
Height = Application.GetRealHeight(55),
|
Width = Application.GetRealWidth(115),
|
X = Application.GetRealWidth(78),
|
Y = Application.GetRealHeight(386),
|
Text = "12:00",
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12,
|
};
|
MidTopFrameLayout.AddChidren(validTime);
|
|
var validTimeDate = new Button()
|
{
|
Height = Application.GetRealHeight(49),
|
Width = Application.GetRealWidth(135),
|
X = Application.GetRealWidth(69),
|
Y = Application.GetRealHeight(441),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
|
Text = "8" + Language.StringByID(R.MyInternationalizationString.Month) + "1" + Language.StringByID(R.MyInternationalizationString.Day),
|
};
|
MidTopFrameLayout.AddChidren(validTimeDate);
|
|
var inValidTime = new Button()
|
{
|
Height = Application.GetRealHeight(55),
|
Width = Application.GetRealWidth(115),
|
X = Application.GetRealWidth(492),
|
Y = Application.GetRealHeight(386),
|
Text = "10:00",
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12,
|
};
|
MidTopFrameLayout.AddChidren(inValidTime);
|
|
var inValidTimeDate = new Button()
|
{
|
Height = Application.GetRealHeight(49),
|
Width = Application.GetRealWidth(135),
|
X = Application.GetRealWidth(484),
|
Y = Application.GetRealHeight(441),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray2,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = "8" + Language.StringByID(R.MyInternationalizationString.Month) + "2" + Language.StringByID(R.MyInternationalizationString.Day),
|
};
|
MidTopFrameLayout.AddChidren(inValidTimeDate);
|
|
//var inputCountText = new EditText()
|
//{
|
// Width = Application.GetRealWidth(780),
|
// Height = Application.GetRealHeight(100),
|
// X = Application.GetRealWidth(80),
|
// Y = validCountText.Bottom + Application.GetRealHeight(10),
|
// PlaceholderText = doorLock.tempPasswordObj.times.ToString(),
|
// PlaceholderTextColor = 0xffc1c1c1,
|
// TextAlignment = TextAlignment.Center,
|
// //UnSelectedImagePah = "Register/Register_Kuang.png",
|
// BackgroundColor = 0xff00ff00,
|
//};
|
//this.midFrameLayout.AddChidren(inputCountText);
|
|
//var unitCount = new Button()
|
//{
|
// Height = Application.GetRealHeight(50),
|
// Width = Application.GetRealWidth(100),
|
// X = inputCountText.Right + Application.GetRealWidth(2),
|
// Y = Application.GetRealHeight(490),
|
// Text = Language.StringByID(R.MyInternationalizationString.Ci),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextSize = 12,
|
// TextColor = 0xff000000,
|
//};
|
//this.midFrameLayout.AddChidren(unitCount);
|
|
//var remindPic2 = new Button()
|
//{
|
// Height = Application.GetRealHeight(40),
|
// Width = Application.GetRealWidth(40),
|
// X = Application.GetRealWidth(80),
|
// Y = inputCountText.Bottom + Application.GetRealHeight(18),
|
// //UnSelectedImagePath = "DoorLockPic/door_lock_alert.png",
|
// BackgroundColor = 0xff0000ff,
|
//};
|
//this.midFrameLayout.AddChidren(remindPic2);
|
|
//var maxValidCount = new Button()
|
//{
|
// Width = Application.GetRealWidth(550),
|
// Height = Application.GetRealHeight(80),
|
// X = remindPic2.Right + Application.GetRealWidth(8),
|
// Y = inputCountText.Bottom,
|
// Text = Language.StringByID(R.MyInternationalizationString.MaxValicCount),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextSize = 10,
|
// TextColor = 0xff000000,
|
//};
|
//this.midFrameLayout.AddChidren(maxValidCount);
|
|
//var remindFrameLayout = new FrameLayout()
|
//{
|
// Height = Application.GetRealHeight(350),
|
// Y = remindPic2.Bottom + Application.GetRealHeight(90),
|
// BackgroundColor = 0xff00ffff,
|
//};
|
//this.midFrameLayout.AddChidren(remindFrameLayout);
|
|
//var TempPasswordText = new Button()
|
//{
|
// X = Application.GetRealWidth(80),
|
// Y = Application.GetRealHeight(10),
|
// Width = Application.GetRealWidth(300),
|
// Height = Application.GetRealHeight(80),
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Text = Language.StringByID(R.MyInternationalizationString.DynamicTempPassword),
|
// TextColor = 0xffff0000,
|
//};
|
//remindFrameLayout.AddChidren(TempPasswordText);
|
|
//for (int i = 0; i < 6; i++)
|
//{
|
// passwordText = new Button()
|
// {
|
// Height = Application.GetRealHeight(150),
|
// Width = Application.GetRealWidth(80),
|
// TextAlignment = TextAlignment.Center,
|
// Y = TempPasswordText.Bottom + Application.GetRealHeight(10),
|
// TextSize = 28,
|
// BackgroundColor = 0xff0000ff,
|
// };
|
// remindFrameLayout.AddChidren(passwordText);
|
// if (i == 0)
|
// {
|
// passwordText.X = Application.GetRealWidth(90);
|
// }
|
// else
|
// {
|
// passwordText.X = (i + 1) * Application.GetRealWidth(90) + (i + 1) * Application.GetRealWidth(10);
|
// }
|
// if (i == 1 || i == 3 || i == 5)
|
// {
|
// passwordText.BackgroundColor = 0xff00ff00;
|
// }
|
// pawButtonList.Add(passwordText);
|
//}
|
|
BottomFrameLayoutContent();
|
}
|
|
public void BottomFrameLayoutContent()
|
{
|
var bottomFrameLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(1025),
|
Y = Application.GetRealHeight(896),
|
BackgroundColor = ZigbeeColor.Current.XMWhite,
|
};
|
this.midFrameLayout.AddChidren(bottomFrameLayout);
|
|
var informationEdit = new Button()
|
{
|
Height = Application.GetRealHeight(60),
|
X = Application.GetRealWidth(58),
|
Y = Application.GetRealHeight(81),
|
Text = Language.StringByID(R.MyInternationalizationString.InformationEdit),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12,
|
};
|
bottomFrameLayout.AddChidren(informationEdit);
|
for (int i = 0; i < 3; i++)
|
{
|
var btnValidTime = new Button()
|
{
|
Width = Application.GetRealWidth(743),
|
Height = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(58),
|
Text = Language.StringByID(R.MyInternationalizationString.ValidTime),
|
TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12,
|
};
|
bottomFrameLayout.AddChidren(btnValidTime);
|
|
var btnNext = new Button()
|
{
|
Width = Application.GetRealWidth(58),
|
Height = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(956),
|
Y = Application.GetRealHeight(204),
|
BackgroundColor = ZigbeeColor.Current.XMOrange,
|
};
|
bottomFrameLayout.AddChidren(btnNext);
|
|
var btnLine = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(965),
|
Height = Application.GetRealHeight(5),
|
X = Application.GetRealWidth(58),
|
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
|
};
|
bottomFrameLayout.AddChidren(btnLine);
|
|
if (i == 0)
|
{
|
btnValidTime.Y = Application.GetRealHeight(204);
|
btnValidTime.Text = Language.StringByID(R.MyInternationalizationString.ValidTime);
|
btnNext.Y = btnValidTime.Y;
|
btnLine.Y = Application.GetRealHeight(308);
|
btnNext.MouseDownEventHandler += (sender, e) =>
|
{
|
var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "ValidTime");
|
Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
|
Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
tempPage.Show();
|
};
|
}
|
else if (i == 1)
|
{
|
btnValidTime.Y = Application.GetRealHeight(343);
|
btnValidTime.Text = Language.StringByID(R.MyInternationalizationString.InValidTime);
|
btnNext.Y = btnValidTime.Y;
|
btnLine.Y = Application.GetRealHeight(446);
|
btnNext.MouseDownEventHandler += (sender, e) =>
|
{
|
var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "InValidTime");
|
Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
|
Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
|
tempPage.Show();
|
};
|
}
|
else if (i == 2)
|
{
|
btnValidTime.Y = Application.GetRealHeight(481);
|
btnValidTime.Text = Language.StringByID(R.MyInternationalizationString.ClearTempPassword);
|
btnNext.Y = btnValidTime.Y;
|
btnLine.Y = Application.GetRealHeight(1025 - 449);
|
}
|
}
|
|
|
//var bottomLine = new Button()
|
//{
|
// Height = Application.GetRealHeight(1),
|
// BackgroundColor = 0xff000000,
|
//};
|
//bottomFrameLayout.AddChidren(bottomLine);
|
|
//var generateTempPassword = new Button()
|
//{
|
// Y = bottomLine.Bottom,
|
// Height = Application.GetRealHeight(180),
|
// TextID = R.MyInternationalizationString.GenerateTemporaryPassword,
|
// TextSize = 15,
|
// BackgroundColor = 0xFF121212,
|
// SelectedBackgroundColor = 0xFFFC5806,
|
//};
|
//bottomFrameLayout.AddChidren(generateTempPassword);
|
//string tempPaw = "";
|
//generateTempPassword.MouseUpEventHandler += (sender, e) =>
|
//{
|
// tempPaw = GetTempPassword();
|
// for (int i = 0; i < tempPaw.Length; i++)
|
// {
|
// for (int j = 0; j < pawButtonList.Count; j++)
|
// {
|
// if (i == j)
|
// {
|
// pawButtonList[j].Text = tempPaw[i].ToString();
|
// }
|
// }
|
// }
|
//};
|
}
|
|
/// <summary>
|
/// 生成6位临时密码
|
/// </summary>
|
/// <returns></returns>
|
public string GetTempPassword()
|
{
|
string 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
|
}
|
}
|