107 lines
3.3 KiB
C#
107 lines
3.3 KiB
C#
|
|
|||
|
using Microsoft.UI.Xaml;
|
|||
|
using Microsoft.UI.Xaml.Controls;
|
|||
|
using Newtonsoft.Json;
|
|||
|
using RustTools.DataList;
|
|||
|
using WinUIEx.Messaging;
|
|||
|
namespace RustTools.Themes;
|
|||
|
/// <summary>
|
|||
|
/// <20>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
public sealed partial class RediscoverPassGrid : UserControl
|
|||
|
{
|
|||
|
public event RoutedEventHandler BackClick
|
|||
|
{
|
|||
|
add => BackButton.Click += value;
|
|||
|
remove => BackButton.Click -= value;
|
|||
|
}
|
|||
|
public RediscoverPassGrid()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
accountBox.TextChanged += AccountBox_TextChanged;
|
|||
|
codeBox.TextChanged += AccountBox_TextChanged;
|
|||
|
passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
|
|||
|
passwordyesBox.PasswordChanged += PasswordBox_PasswordChanged;
|
|||
|
}
|
|||
|
|
|||
|
private void AccountBox_TextChanged(object sender, TextChangedEventArgs e)
|
|||
|
{
|
|||
|
redisButton.IsEnabled = IsEnabledButton;
|
|||
|
}
|
|||
|
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
redisButton.IsEnabled = IsEnabledButton;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
private async void ButtonIcon_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
Toast.IsOpen = false;
|
|||
|
if (accountBox.Text == string.Empty) {
|
|||
|
|
|||
|
Toast.IsOpen = true;
|
|||
|
Toast.Title = "<22><>ʾ";
|
|||
|
Toast.Subtitle = "<22>˺Ų<CBBA><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>";
|
|||
|
return;
|
|||
|
}
|
|||
|
try
|
|||
|
{
|
|||
|
var v = await ApiFox.user.requestChangePassword(accountBox.Text);
|
|||
|
var message = JsonConvert.DeserializeObject<DataList.Message>(v);
|
|||
|
Toast.IsOpen = true;
|
|||
|
Toast.Title = "<22><>ʾ";
|
|||
|
Toast.Subtitle = message.message;
|
|||
|
await Task.Delay(millisecondsDelay: 1000);
|
|||
|
Toast.IsOpen = false;
|
|||
|
}
|
|||
|
catch (Exception ex) {
|
|||
|
Toast.IsOpen = true;
|
|||
|
Toast.Title = "<22><>ʾ";
|
|||
|
Toast.Subtitle = ex.Message;
|
|||
|
await Task.Delay(millisecondsDelay: 1000);
|
|||
|
Toast.IsOpen = false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public bool IsEnabledButton =>!string.IsNullOrEmpty(accountBox.Text)&&
|
|||
|
!string.IsNullOrEmpty(passwordBox.Password) &&
|
|||
|
!string.IsNullOrEmpty(passwordyesBox.Password) &&
|
|||
|
!string.IsNullOrEmpty(codeBox.Text);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
private async void Button_Click(object sender, RoutedEventArgs e)
|
|||
|
{
|
|||
|
Toast.IsOpen = false;
|
|||
|
try
|
|||
|
{
|
|||
|
var v = await ApiFox.user.changePassword(accountBox.Text, passwordBox.Password, codeBox.Text);
|
|||
|
var message = JsonConvert.DeserializeObject<DataList.Message>(v);
|
|||
|
Toast.IsOpen = true;
|
|||
|
Toast.Title = "<22><>ʾ";
|
|||
|
Toast.Subtitle = message.message;
|
|||
|
await Task.Delay(millisecondsDelay: 1000);
|
|||
|
Toast.IsOpen = false;
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Toast.IsOpen = true;
|
|||
|
Toast.Title = "<22><>ʾ";
|
|||
|
Toast.Subtitle = ex.Message;
|
|||
|
await Task.Delay(millisecondsDelay: 1000);
|
|||
|
Toast.IsOpen = false;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void RediscoverPassGrid_BackClick(object sender, RoutedEventArgs e) => throw new NotImplementedException();
|
|||
|
}
|