兼容win7版应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

using AIK.ViewModels.Integral;
using AIK.Common.Language;
using CommunityToolkit.Mvvm.DependencyInjection;
using System;
using System.Windows;
namespace AIK.Views.MenuPages.Integral
{
public partial class IntegralRechargeWindow : Window
{
private readonly IntegralRechargeViewModel _viewModel;
public IntegralRechargeWindow()
{
InitializeComponent();
_viewModel = Ioc.Default.GetRequiredService<IntegralRechargeViewModel>();
_viewModel.PaymentCreated += OnPaymentCreated;
DataContext = _viewModel;
#if !(CN || TEST)
PaymentMethodRadioButton.Content = AiKLanguage.LanguageKey?.GetValueOrDefault("PaymentMethodPaypal") ?? "PayPal";
#endif
}
public void SetCurrentIntegral(int currentIntegral)
{
_viewModel.CurrentIntegral = currentIntegral;
}
protected override void OnClosed(EventArgs e)
{
_viewModel.PaymentCreated -= OnPaymentCreated;
base.OnClosed(e);
}
private void OnPaymentCreated(AIK.Models.ApiModels.Payment.PaymentParametersPC payment, decimal amount, byte[]? qrCodeBytes)
{
#if CN || TEST
if (!amount.Equals(_viewModel.Amount.GetValueOrDefault()))
{
return;
}
var window = new PaymentQrCodeWindow(payment, amount, qrCodeBytes)
{
Owner = this
};
#else
var window = new PaymentQrCodeWindow(payment, amount, null)
{
Owner = this
};
#endif
var result = window.ShowDialog();
if (result == true)
{
Close();
}
}
}
}