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(); _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(); } } } }