更新密码数据123
This commit is contained in:
@@ -1,15 +1,29 @@
|
||||
using Avalonia.Input;
|
||||
using Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.ViewModels;
|
||||
using Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Services;
|
||||
using Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Models;
|
||||
using SukiUI.Controls;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Views
|
||||
{
|
||||
public partial class MainWindow : SukiWindow
|
||||
{
|
||||
public MainWindow()
|
||||
private readonly MachineLicenseService licenseService;
|
||||
private bool isLicenseWindowOpen;
|
||||
|
||||
public MainWindow() : this(new MachineLicenseService())
|
||||
{
|
||||
}
|
||||
|
||||
public MainWindow(MachineLicenseService licenseService)
|
||||
{
|
||||
this.licenseService = licenseService;
|
||||
InitializeComponent();
|
||||
Closed += OnClosed;
|
||||
KeyDown += OnKeyDown;
|
||||
DataContextChanged += OnDataContextChanged;
|
||||
}
|
||||
|
||||
private void OnClosed(object? sender, EventArgs e)
|
||||
@@ -19,5 +33,83 @@ namespace Footwear_Test_methodsfor_wholeshoe_Slipresistanceperformance.Views
|
||||
viewModel.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDataContextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (DataContext is MainWindowViewModel viewModel)
|
||||
{
|
||||
viewModel.LicenseLockRequested -= OnLicenseLockRequested;
|
||||
viewModel.LicenseLockRequested += OnLicenseLockRequested;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.F12
|
||||
&& e.KeyModifiers.HasFlag(KeyModifiers.Control)
|
||||
&& e.KeyModifiers.HasFlag(KeyModifiers.Shift))
|
||||
{
|
||||
e.Handled = true;
|
||||
_ = ShowAdministrationAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLicenseLockRequested(string message) => _ = ShowLicenseLockAsync(message);
|
||||
|
||||
private async Task ShowAdministrationAsync()
|
||||
{
|
||||
if (isLicenseWindowOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
isLicenseWindowOpen = true;
|
||||
try
|
||||
{
|
||||
var window = new LicenseWindow(licenseService, LicenseWindowMode.Administration, "验证管理密码后可修改两次密码和时效。");
|
||||
await window.ShowDialog(this);
|
||||
if (DataContext is MainWindowViewModel viewModel)
|
||||
{
|
||||
viewModel.RefreshLicenseState();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
isLicenseWindowOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ShowLicenseLockAsync(string message)
|
||||
{
|
||||
if (isLicenseWindowOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
isLicenseWindowOpen = true;
|
||||
try
|
||||
{
|
||||
var check = licenseService.Check();
|
||||
var mode = check.State == LicenseCheckState.Expired
|
||||
? LicenseWindowMode.Unlock
|
||||
: LicenseWindowMode.Blocked;
|
||||
var window = new LicenseWindow(licenseService, mode, message);
|
||||
await window.ShowDialog(this);
|
||||
if (!window.Succeeded)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (DataContext is MainWindowViewModel viewModel)
|
||||
{
|
||||
viewModel.RefreshLicenseState();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
isLicenseWindowOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user