55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using Aurora.Api;
|
|
using Aurora.Api.Control;
|
|
using Aurora.View;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
namespace WeldingCommon.Views.DoorInterlock
|
|
{
|
|
public class WinDoorInterlockPasswordViewModel : NotifyPropertyChangedBase
|
|
{
|
|
private readonly string _settingId;
|
|
private readonly ISettingEntry _settingManager;
|
|
|
|
public ICommand CMD_Ok { get; }
|
|
public ICommand CMD_Cancel { get; }
|
|
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
internal WinDoorInterlockPasswordViewModel(ISettingEntry settingManager, string settingId)
|
|
{
|
|
_settingId = settingId;
|
|
_settingManager = settingManager;
|
|
|
|
CMD_Ok = new DelegateCommand(BtnOK);
|
|
CMD_Cancel = new DelegateCommand(BtnCancle);
|
|
}
|
|
|
|
private void BtnOK(object obj)
|
|
{
|
|
var setting = _settingManager[_settingId] as DoorInterlockSetting;
|
|
|
|
Window win = obj as Window;
|
|
if (!int.TryParse(Password, out int password)) {
|
|
MessageDialog.Show(win, "Fail", "Password parsing Fail");
|
|
win.Close();
|
|
return;
|
|
}
|
|
|
|
if (setting.Password == password) {
|
|
win.DialogResult = true;
|
|
win.Close();
|
|
} else {
|
|
MessageDialog.Show(win, "Fail", "Password Fail");
|
|
}
|
|
}
|
|
|
|
private void BtnCancle(object obj)
|
|
{
|
|
Window win = obj as Window;
|
|
win.DialogResult = false;
|
|
win.Close();
|
|
}
|
|
}
|
|
}
|