using System;
|
using System.Collections.Generic;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class TempPasswordList : Dialog
|
{
|
DoorLock doorLock;
|
FrameLayout mainFrameLayout = new FrameLayout { BackgroundColor = 0xFF3b3d3c };
|
|
public TempPasswordList (DoorLock door_lock)
|
{
|
this.doorLock = door_lock;
|
AddChidren (mainFrameLayout);
|
if (doorLock.tempPasswordRemark == "") {
|
readStatus (door_lock);
|
} else {
|
showUserTempPassword ();
|
}
|
}
|
|
void readStatus (DoorLock door_lock)
|
{
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load));
|
});
|
var tempPasswordBYtes = Control.ControlBytesSendHasReturn (Command.ReadDoorLockUseRemark, door_lock.SubnetID, door_lock.DeviceID, new byte [] { door_lock.PhysicsLoopID, 0x04, (byte)10 });
|
if (tempPasswordBYtes != null) {
|
door_lock.tempPasswordRemark = CommonPage.MyEncodingGB2312.GetString (tempPasswordBYtes, 3, 20);
|
} else {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
});
|
return;
|
}
|
IO.FileUtils.SaveEquipmentMessage (door_lock, door_lock.PhysicsLoopID.ToString ());
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
showUserTempPassword ();
|
});
|
});
|
}
|
void showUserTempPassword ()
|
{
|
#region 标题
|
var topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
};
|
|
mainFrameLayout.AddChidren (topView);
|
|
var title = new Button () {
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.UserTempPassword,
|
TextSize = 19,
|
};
|
topView.AddChidren (title);
|
|
var logo = new Button () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (logo);
|
var back = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
Close ();
|
};
|
|
var btnl = new Button () {
|
Height = 1,
|
BackgroundColor = 0xFF000000,
|
Y = topView.Height - 1
|
};
|
topView.AddChidren (btnl);
|
#endregion
|
|
#region middleVerticalScrolViewLayout
|
var middleLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (Application.DesignHeight - 126 - 98),
|
Y = topView.Bottom,
|
};
|
|
mainFrameLayout.AddChidren (middleLayout);
|
|
var frameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (93),
|
};
|
middleLayout.AddChidren (frameLayout);
|
|
var btnHeadshot = new Button () {
|
X = Application.GetRealWidth (25),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (56),
|
Height = Application.GetRealHeight (57),
|
UnSelectedImagePath = doorLock.tempPasswordImage,
|
};
|
frameLayout.AddChidren (btnHeadshot);
|
|
var btnRemarkName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = Application.GetRealHeight (57),
|
Text = doorLock.tempPasswordRemark,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnHeadshot.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
};
|
frameLayout.AddChidren (btnRemarkName);
|
|
var btnEdit = new Button () {
|
Gravity = Gravity.CenterVertical,
|
X = Application.GetRealWidth (485),
|
Width = Application.GetRealWidth (80),
|
Height = Application.GetRealHeight (80),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
};
|
frameLayout.AddChidren (btnEdit);
|
btnEdit.MouseUpEventHandler += (sender, e) => {
|
#region Dialog
|
var dialog = new Dialog () {
|
BackgroundColor = 0xFFF5F6F7,
|
Width = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (800),
|
};
|
var btnEquipmentTitle = new Button () {
|
Width = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (70),
|
BackgroundColor = 0xFF484848,
|
TextID = R.MyInternationalizationString.ChangeInformation,
|
TextAlignment = TextAlignment.Center,
|
Gravity = Gravity.CenterHorizontal,
|
};
|
dialog.AddChidren (btnEquipmentTitle);
|
var lblTitleName = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight (80),
|
Width = Application.GetRealWidth (450),
|
Height = Application.GetRealHeight (50),
|
TextID = R.MyInternationalizationString.Remark,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = 0xf01A1A1A,
|
};
|
dialog.AddChidren (lblTitleName);
|
var etRemarkBox = new EditText () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = lblTitleName.Bottom + Application.GetRealHeight (10),
|
Width = Application.GetRealWidth (450),
|
Height = Application.GetRealHeight (50),
|
TextAlignment = TextAlignment.CenterLeft,
|
UnSelectedImagePath = "Item/DialogTextBox.png",
|
SelectedImagePath = "Item/DialogTextBox.png",
|
TextColor = 0xf01A1A1A,
|
Text = btnRemarkName.Text,
|
};
|
dialog.AddChidren (etRemarkBox);
|
|
var lblIcon = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = etRemarkBox.Bottom + Application.GetRealHeight (10),
|
Width = Application.GetRealWidth (450),
|
Height = btnEquipmentTitle.Height,
|
TextID = R.MyInternationalizationString.Headshot,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = 0xf01A1A1A,
|
};
|
dialog.AddChidren (lblIcon);
|
|
VerticalScrolViewLayout verIconLayout = new VerticalScrolViewLayout () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = lblIcon.Y + lblIcon.Height + Application.GetRealHeight (5),
|
Width = Application.GetRealWidth (450),
|
Height = Application.GetRealHeight (200),
|
BackgroundImagePath = "Item/RoomIconBackground.png",
|
};
|
FrameLayout inVerFramelayout = new FrameLayout () {
|
X = 0,
|
Width = lblIcon.Width,
|
Height = Application.GetRealHeight (200),
|
BackgroundColor = 0xff2f2f2f,
|
};
|
verIconLayout.AddChidren (inVerFramelayout);
|
dialog.AddChidren (verIconLayout);
|
|
Button btnBG = new Button () {
|
Width = Application.GetRealWidth (270),
|
Height = LayoutParams.MatchParent,
|
UnSelectedImagePath = btnHeadshot.UnSelectedImagePath,
|
};
|
inVerFramelayout.AddChidren (btnBG);
|
#if wallon
|
btnBG.Gravity = Gravity.Center;
|
#else
|
var pid = Guid.NewGuid ();
|
Button btnTakePictrue = new Button () {
|
Width = inVerFramelayout.Width - btnBG.Width,
|
Height = inVerFramelayout.Height / 2,
|
TextID = R.MyInternationalizationString.TakePhoto,
|
TextColor = 0xff000000,
|
BackgroundColor = 0xF0D7D7D7,
|
X = btnBG.Right,
|
};
|
inVerFramelayout.AddChidren (btnTakePictrue);
|
btnTakePictrue.MouseUpEventHandler += (sender1, e1) => {
|
pid = Guid.NewGuid ();
|
Camera.TakePicture ((obj) => {
|
if (obj == null) {
|
return;
|
}
|
btnBG.UnSelectedImagePath = pid.ToString();
|
}, pid.ToString(), false);
|
};
|
|
Button btnLineP = new Button () {
|
Width = btnTakePictrue.Width,
|
Height = 1,
|
BackgroundColor = 0xF0FFFFFF,
|
X = btnBG.Right,
|
Y = btnTakePictrue.Bottom,
|
};
|
inVerFramelayout.AddChidren (btnLineP);
|
Button btnSelectPictrue = new Button () {
|
Width = btnTakePictrue.Width,
|
Height = btnTakePictrue.Height,
|
TextID = R.MyInternationalizationString.SelectPicture,
|
TextColor = 0xff000000,
|
BackgroundColor = 0xF0D7D7D7,
|
X = btnBG.Right,
|
Y = btnLineP.Bottom,
|
};
|
inVerFramelayout.AddChidren (btnSelectPictrue);
|
btnSelectPictrue.MouseUpEventHandler += (sender1, e1) => {
|
pid = Guid.NewGuid ();
|
Camera.SelectPicture ((obj) => {
|
if (obj == null) {
|
return;
|
}
|
btnBG.UnSelectedImagePath = pid.ToString();
|
}, pid.ToString(), false);
|
};
|
|
Button btnLineS = new Button () {
|
Width = btnTakePictrue.Width,
|
Height = 1,
|
BackgroundColor = 0xF0FFFFFF,
|
X = btnBG.Right,
|
Y = btnSelectPictrue.Bottom,
|
};
|
inVerFramelayout.AddChidren (btnLineS);
|
#endif
|
|
var systempictureLayout = new FrameLayout {
|
Height = Application.GetRealHeight (260),
|
Y = verIconLayout.Bottom + Application.GetRealHeight (20),
|
};
|
dialog.AddChidren (systempictureLayout);
|
|
HorizontalScrolViewLayout horizontalScrolViewLayout = new HorizontalScrolViewLayout () {
|
Width = Application.GetRealWidth (450),
|
Height = Application.GetRealHeight (180),
|
Gravity = Gravity.CenterHorizontal,
|
BackgroundColor = 0xff2f2f2f,
|
};
|
systempictureLayout.AddChidren (horizontalScrolViewLayout);
|
for (int i = 0; i < 7; i++) {
|
Button butHeadshotPic = new Button () {
|
Width = Application.GetRealWidth (200),
|
Height = LayoutParams.MatchParent,
|
};
|
butHeadshotPic.UnSelectedImagePath = "DoorLockPic/door_lock_ headshot_h" + (i).ToString () + ".png";
|
butHeadshotPic.MouseUpEventHandler += (sender1, e1) => {
|
btnBG.UnSelectedImagePath = butHeadshotPic.UnSelectedImagePath;
|
};
|
horizontalScrolViewLayout.AddChidren (butHeadshotPic);
|
Button btnNull = new Button () {
|
Width = 1,
|
BackgroundColor = 0xFFFFFFFF
|
};
|
horizontalScrolViewLayout.AddChidren (btnNull);
|
}
|
FrameLayout BottomView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = 0xF0121212,
|
Y = dialog.Height - Application.GetRealHeight (90),
|
};
|
dialog.AddChidren (BottomView);
|
Button btnBack = new Button () {
|
Width = Application.GetRealWidth (119),
|
Height = LayoutParams.MatchParent,
|
UnSelectedImagePath = "Item/PositioningDialogBack.png",
|
SelectedImagePath = "Item/PositioningDialogBack.png",
|
};
|
BottomView.AddChidren (btnBack);
|
btnBack.MouseUpEventHandler += (sender1, e1) => {
|
dialog.Close ();
|
};
|
Button btnLineH = new Button () {
|
Width = 1,
|
Height = LayoutParams.MatchParent,
|
BackgroundColor = 0xF0909090,
|
X = btnBack.Right,
|
};
|
BottomView.AddChidren (btnLineH);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = LayoutParams.MatchParent,
|
X = btnLineH.Right,
|
TextID = R.MyInternationalizationString.SAVE,
|
TextAlignment = TextAlignment.Center,
|
Radius = 1,
|
};
|
BottomView.AddChidren (btnSave);
|
btnSave.MouseUpEventHandler += (sender1, e1) => {
|
//如果输入的备注为空就返回
|
if (string.IsNullOrEmpty (etRemarkBox.Text.Trim ())) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.RemarkIsEmpty), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
|
MainPage.Loading.Start ("Saving.....");
|
var remarkBytes = CommonPage.MyEncodingGB2312.GetBytes (etRemarkBox.Text);
|
System.Threading.Tasks.Task.Run (() => {
|
bool isSuccess = false;
|
try {
|
var sendBytes = new byte [3 + 20];
|
sendBytes [0] = doorLock.PhysicsLoopID;
|
sendBytes [1] = 0x04;
|
sendBytes [2] = 10;
|
System.Array.Copy (remarkBytes, 0, sendBytes, 3, 20 < remarkBytes.Length ? 20 : remarkBytes.Length);
|
var setPasswordInfoBytes = Control.ControlBytesSendHasReturn (Command.SetDoorLockUseRemark, doorLock.SubnetID, doorLock.DeviceID, sendBytes);
|
if (setPasswordInfoBytes != null && setPasswordInfoBytes [0] == 0xF8) {
|
isSuccess = true;
|
} else {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
isSuccess = false;
|
return;
|
}
|
} catch {
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
if (isSuccess) {
|
btnRemarkName.Text = etRemarkBox.Text;
|
if (btnBG.UnSelectedImagePath == "HeadShotPicture") {
|
string newHeadshotPic = "DoorLook_Password_" + 10;
|
IO.FileUtils.ReNameFile (btnBG.UnSelectedImagePath, "Image_" + newHeadshotPic);
|
btnBG.UnSelectedImagePath = "Image_" + newHeadshotPic;
|
//btnHeadshot.UnSelectedImagePath = newHeadshotPic;
|
}
|
btnHeadshot.UnSelectedImagePath = btnBG.UnSelectedImagePath;
|
doorLock.tempPasswordRemark = etRemarkBox.Text.Trim ();
|
doorLock.tempPasswordImage = btnHeadshot.UnSelectedImagePath;
|
IO.FileUtils.SaveEquipmentMessage (doorLock, doorLock.PhysicsLoopID.ToString ());
|
}
|
dialog.Close ();
|
});
|
}
|
});
|
};
|
|
dialog.Show ();
|
#endregion
|
|
};
|
|
var btnScence = new Button () {
|
X = btnEdit.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (56),
|
Height = Application.GetRealHeight (57),
|
UnSelectedImagePath = "Scene/Scene.png",
|
//UnSelectedImagePath = "DoorLockPic/door_lock_scence.png",
|
//SelectedImagePath = "DoorLockPic/door_lock_scence_on.png",
|
};
|
frameLayout.AddChidren (btnScence);
|
btnScence.MouseUpEventHandler += (sender, e) => {
|
doorLock.doorLockSceneTargetsUserID = doorLock.tempPasswordID;
|
doorLock.doorLockSceneRemark = doorLock.tempPasswordRemark;//开锁场景类型
|
doorLock.doorLockSceneTargetsMethod = 0x05;
|
IO.FileUtils.SaveEquipmentMessage (doorLock, doorLock.PhysicsLoopID.ToString ());
|
// new DoorLockScene (doorLock).Show ();
|
|
DoorLockScene recordView = new DoorLockScene (doorLock);
|
UserMiddle.DevicePageView.AddChidren (recordView);
|
recordView.DoorLockSceneShow ();
|
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
};
|
|
var line = new Button () {
|
Height = Application.GetRealHeight (1),
|
BackgroundColor = 0xFF000000,
|
Y = Application.GetRealHeight (92),
|
};
|
frameLayout.AddChidren (line);
|
#endregion
|
|
#region bottomFrameLayout
|
var bottomFrameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (98),
|
Y = Application.GetRealHeight (Application.DesignHeight - 97),
|
};
|
|
mainFrameLayout.AddChidren (bottomFrameLayout);
|
var bottomLine = new Button () {
|
Height = Application.GetRealHeight (1),
|
BackgroundColor = 0xFFffffff,
|
};
|
bottomFrameLayout.AddChidren (bottomLine);
|
|
var refreshPasswordListBtn = new Button () {
|
Y = bottomLine.Bottom,
|
Height = Application.GetRealHeight (97),
|
TextID = R.MyInternationalizationString.ReFresh,
|
TextSize = 15,
|
BackgroundColor = 0xFF121212,
|
SelectedBackgroundColor = 0xFFFC5806,
|
};
|
bottomFrameLayout.AddChidren (refreshPasswordListBtn);
|
refreshPasswordListBtn.MouseUpEventHandler += (sender, e) => {
|
readStatus (doorLock);
|
};
|
#endregion
|
}
|
}
|
}
|