using PersonalFinanceWindow.ViewModel; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; 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; namespace PersonalFinanceWindow { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, EventArgs e) { DisplayLoginScreen(); } private void DisplayLoginScreen() { Login win = new Login(); win.ShowDialog(); //win.Owner = this; if (!win.DialogResult.HasValue || !win.DialogResult.Value) { this.Close(); } } private void File_Exit_Click(object sender, RoutedEventArgs e) { Application.Current.Shutdown(); } private void Window_About_Click(object sender, RoutedEventArgs e) { About win = new About(); win.Owner = this; win.ShowDialog(); if (!win.DialogResult.HasValue || !win.DialogResult.Value) this.Close(); } private void LoadPayment(object sender, RoutedEventArgs e) { (this.PaymentsList.DataContext as PaymentViewModel).LoadPayment(); } private void LoadAllPayment(object sender, RoutedEventArgs e) { (this.AllPaymentsList.DataContext as PaymentViewModel).LoadAllPayment(); } private void Save_Click(object sender, RoutedEventArgs e) { (this.PaymentsList.DataContext as ViewModelBase).SaveContext(); (this.UsersList.DataContext as ViewModelBase).SaveContext(); (this.ScheduledList.DataContext as ViewModelBase).SaveContext(); } private void Window_KeyUp(object sender, KeyEventArgs e) { //save -> CTRL + S if (e.Key == Key.S && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { Save_Click(sender, e); } } private void LoadScheduled(object sender, RoutedEventArgs e) { (this.ScheduledList.DataContext as ScheduledViewModel).LoadScheduled(); } private void LoadOverview(object sender, RoutedEventArgs e) { (this.Overview.DataContext as OverviewViewModel).LoadOverview(); } } }