using System;
|
using HDL_ON.Common;
|
using HDL_ON.DAL.Server;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock
|
{
|
/// <summary>
|
/// 萤石视频门锁-人脸开锁触发模式配置界面
|
/// </summary>
|
public class VideoDoorlockFaceUnlockTriggerSettingPage :FrameLayout
|
{
|
FrameLayout bodyView;
|
|
Function device;
|
FaceUnlockSetupObj faceUnlockSetup;
|
public VideoDoorlockFaceUnlockTriggerSettingPage(Function function,FaceUnlockSetupObj setupObj)
|
{
|
bodyView = this;
|
device = function;
|
faceUnlockSetup = setupObj;
|
}
|
|
public void LoadPage()
|
{
|
new TopViewDiv(bodyView, Language.StringByID(StringId.TriggerMode)).LoadTopView();
|
bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
|
|
var contentView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(600),
|
};
|
bodyView.AddChidren(contentView);
|
|
#region 自动触发
|
var autoView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetRealWidth(164),
|
Height = Application.GetRealWidth(60),
|
Radius = (uint)Application.GetRealWidth(12),
|
BackgroundColor = faceUnlockSetup.mode == 0 ? CSS_Color.MainColor : CSS_Color.MainBackgroundColor,
|
BorderColor = CSS_Color.MainColor,
|
BorderWidth = 1,
|
};
|
contentView.AddChidren(autoView);
|
|
var btnAutoIcon = new Button()
|
{
|
X = Application.GetRealWidth(28),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
UnSelectedImagePath = faceUnlockSetup.mode == 0 ? "FunctionIcon/DoorLock/AutomaitcTriggerIcon_white.png" : "FunctionIcon/DoorLock/AutomaitcTriggerIcon_blue.png",
|
};
|
autoView.AddChidren(btnAutoIcon);
|
|
var btnAutoText = new Button
|
{
|
X = btnAutoIcon.Right + Application.GetRealWidth(4),
|
Width = Application.GetRealWidth(90),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.HeadlineFontSize,
|
TextColor = faceUnlockSetup.mode == 1 ? CSS_Color.MainColor : CSS_Color.MainBackgroundColor,
|
TextID = StringId.AutomaticTriggering,
|
};
|
autoView.AddChidren(btnAutoText);
|
|
|
#endregion
|
|
|
#region 手动触发
|
var manualView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(196),
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetRealWidth(164),
|
Height = Application.GetRealWidth(60),
|
Radius = (uint)Application.GetRealWidth(12),
|
BackgroundColor = faceUnlockSetup.mode == 1 ? CSS_Color.MainColor : CSS_Color.MainBackgroundColor,
|
BorderColor = CSS_Color.MainColor,
|
BorderWidth = 1,
|
};
|
contentView.AddChidren(manualView);
|
|
var btnManualIcon = new Button()
|
{
|
X = Application.GetRealWidth(28),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
UnSelectedImagePath = faceUnlockSetup.mode == 1 ? "FunctionIcon/DoorLock/ManualTriggerIcon_white.png" : "FunctionIcon/DoorLock/ManualTriggerIcon_blue.png",
|
};
|
manualView.AddChidren(btnManualIcon);
|
|
var btnManualText = new Button
|
{
|
X = btnManualIcon.Right + Application.GetRealWidth(4),
|
Width = Application.GetRealWidth(90),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.HeadlineFontSize,
|
TextColor = faceUnlockSetup.mode == 0 ? CSS_Color.MainColor : CSS_Color.MainBackgroundColor,
|
TextID = StringId.ManualTriggering,
|
};
|
manualView.AddChidren(btnManualText);
|
#endregion
|
|
|
btnAutoText.MouseUpEventHandler = (sender, e) =>
|
{
|
if (faceUnlockSetup.mode == 0)
|
return;
|
|
var waitPage = new Loading();
|
bodyView.AddChidren(waitPage);
|
waitPage.Start("");
|
|
new System.Threading.Thread(() =>
|
{
|
try
|
{
|
var pack = ApiUtlis.Ins.HttpRequest.SetFaceUnlockCfg(device.deviceId, faceUnlockSetup.enabled, 0);
|
if (pack != null && pack.Code == StateCode.SUCCESS)
|
{
|
faceUnlockSetup.mode = 0;
|
Application.RunOnMainThread(() =>
|
{
|
//更新界面
|
autoView.BackgroundColor = CSS_Color.MainColor;
|
btnAutoIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/AutomaitcTriggerIcon_white.png";
|
btnAutoText.TextColor = CSS_Color.MainBackgroundColor;
|
manualView.BackgroundColor = CSS_Color.MainBackgroundColor;
|
btnManualIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/ManualTriggerIcon_blue.png";
|
btnManualText.TextColor = CSS_Color.MainColor;
|
automaitcTipView.Visible = true;
|
manualTipView.Visible = false;
|
|
});
|
}
|
else
|
{
|
//失败提示
|
Application.RunOnMainThread(() =>
|
{
|
if (!string.IsNullOrEmpty(pack.message))
|
{
|
var tip = new Tip()
|
{
|
MaxWidth = Application.GetRealWidth(300),
|
Text = $"{pack.message}({pack.Code})",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
}
|
});
|
}
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"btnFaceUnlockSwitchIcon error : {ex.Message}");
|
}
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
waitPage.Hide();
|
});
|
}
|
})
|
{ IsBackground = true }.Start();
|
};
|
|
|
btnManualText.MouseUpEventHandler = (sender, e) =>
|
{
|
if (faceUnlockSetup.mode == 1)
|
return;
|
|
var waitPage = new Loading();
|
bodyView.AddChidren(waitPage);
|
waitPage.Start("");
|
|
new System.Threading.Thread(() =>
|
{
|
try
|
{
|
var pack = ApiUtlis.Ins.HttpRequest.SetFaceUnlockCfg(device.deviceId, faceUnlockSetup.enabled, 1);
|
if (pack != null && pack.Code == StateCode.SUCCESS)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
faceUnlockSetup.mode = 1;
|
//更新界面
|
autoView.BackgroundColor = CSS_Color.MainBackgroundColor;
|
btnAutoIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/AutomaitcTriggerIcon_blue.png";
|
btnAutoText.TextColor = CSS_Color.MainColor;
|
manualView.BackgroundColor = CSS_Color.MainColor;
|
btnManualIcon.UnSelectedImagePath = "FunctionIcon/DoorLock/ManualTriggerIcon_white.png";
|
btnManualText.TextColor = CSS_Color.MainBackgroundColor;
|
automaitcTipView.Visible = false;
|
manualTipView.Visible = true;
|
|
});
|
}
|
else
|
{
|
//失败提示
|
Application.RunOnMainThread(() =>
|
{
|
if (!string.IsNullOrEmpty(pack.message))
|
{
|
var tip = new Tip()
|
{
|
MaxWidth = Application.GetRealWidth(300),
|
Text = $"{pack.message}({pack.Code})",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
}
|
});
|
}
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"btnFaceUnlockSwitchIcon error : {ex.Message}");
|
}
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
waitPage.Hide();
|
});
|
}
|
})
|
{ IsBackground = true }.Start();
|
};
|
|
|
loadAutomaitcTipView();
|
loadManualTipView();
|
|
if(faceUnlockSetup.mode == 0)
|
{
|
automaitcTipView.Visible = true;
|
manualTipView.Visible = false;
|
}
|
else
|
{
|
automaitcTipView.Visible = false;
|
manualTipView.Visible = true;
|
}
|
|
}
|
FrameLayout automaitcTipView;
|
FrameLayout manualTipView;
|
|
/// <summary>
|
/// 加载自动触发方式提示
|
/// </summary>
|
void loadAutomaitcTipView()
|
{
|
automaitcTipView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(128 + 64),
|
Height = Application.GetRealHeight(667 - 128 - 64),
|
BackgroundColor = CSS_Color.MainBackgroundColor
|
};
|
bodyView.AddChidren(automaitcTipView);
|
|
var btnAutomaitcImage = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetRealWidth(200),
|
UnSelectedImagePath = "FunctionIcon/DoorLock/FaceUnlockImage.png",
|
};
|
automaitcTipView.AddChidren(btnAutomaitcImage);
|
|
var btnAutomaitcTip = new Button()
|
{
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(30),
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnAutomaitcImage.Bottom,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextAlignment = TextAlignment.TopCenter,
|
IsMoreLines = true,
|
TextID = StringId.FaceUnlockTip
|
};
|
automaitcTipView.AddChidren(btnAutomaitcTip);
|
|
var btnAutomaitcNote = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(400),
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(50),
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextColor = CSS_Color.PromptingColor1,
|
TextID = StringId.FaceUnlockNote,
|
};
|
automaitcTipView.AddChidren(btnAutomaitcNote);
|
|
}
|
/// <summary>
|
/// 加载手动触发方式提示
|
/// </summary>
|
void loadManualTipView()
|
{
|
manualTipView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(128 + 64),
|
Height = Application.GetRealHeight(667 - 128 - 64),
|
BackgroundColor = CSS_Color.MainBackgroundColor
|
};
|
bodyView.AddChidren(manualTipView);
|
|
var btnNumber1 = new Button()
|
{
|
X = Application.GetRealWidth(84),
|
//Y = Application.GetRealHeight()
|
Width = Application.GetRealWidth(24),
|
Height = Application.GetRealWidth(24),
|
Radius = (uint)Application.GetRealWidth(12),
|
BorderColor = CSS_Color.MainColor,
|
BorderWidth = 1,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.MainColor,
|
TextAlignment = TextAlignment.Center,
|
Text = "1",
|
};
|
manualTipView.AddChidren(btnNumber1);
|
|
var btnNumber2 = new Button()
|
{
|
X = Application.GetRealWidth(267),
|
//Y = Application.GetRealHeight()
|
Width = Application.GetRealWidth(24),
|
Height = Application.GetRealWidth(24),
|
Radius = (uint)Application.GetRealWidth(12),
|
BorderColor = CSS_Color.MainColor,
|
BorderWidth = 1,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.MainColor,
|
TextAlignment = TextAlignment.Center,
|
Text = "2",
|
};
|
manualTipView.AddChidren(btnNumber2);
|
|
var btnImage1 = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(31),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealWidth(160),
|
UnSelectedImagePath = "FunctionIcon/DoorLock/TouchUnlcokImage.png",
|
};
|
manualTipView.AddChidren(btnImage1);
|
|
var btnAutomaitcImage = new Button()
|
{
|
X = btnImage1.Right + Application.GetRealWidth(24),
|
Y = Application.GetRealHeight(31),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealWidth(160),
|
UnSelectedImagePath = "FunctionIcon/DoorLock/FaceUnlockImage.png",
|
};
|
manualTipView.AddChidren(btnAutomaitcImage);
|
|
var btnManualTip = new Button()
|
{
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(30),
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnAutomaitcImage.Bottom,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextAlignment = TextAlignment.TopCenter,
|
IsMoreLines = true,
|
TextID = StringId.FaceManualUnlockTip
|
};
|
manualTipView.AddChidren(btnManualTip);
|
}
|
}
|
}
|