Files
elwig/WGneu/Windows/MainWindow.xaml.cs
2023-03-09 21:17:46 +01:00

58 lines
1.7 KiB
C#

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WGneu.Documents;
using WGneu.Models;
namespace WGneu.Windows {
public partial class MainWindow : Window {
private readonly WgContext _context = new WgContext();
public MainWindow() {
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
_context.Countries.Load();
Button4.IsEnabled = App.IsPrintingReady;
}
protected override void OnClosing(CancelEventArgs e) {
_context.Dispose();
base.OnClosing(e);
}
private void Button2_Click(object sender, EventArgs e) {
var w = new MemberListWindow();
w.Show();
}
private void Button4_Click(object sender, EventArgs e) {
Task.Run(async () => {
try {
using var letter = new BusinessLetter("Test Dokument", _context.Members.First());
await letter.Generate();
letter.Show();
} catch (Exception e) {
MessageBox.Show(e.ToString(), "PDF Generation", MessageBoxButton.OK, MessageBoxImage.Error);
}
});
}
}
}