using ProgramGui.Model;
using ProgramGui.View;
using ProgramGui.ViewModel;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Threading;

namespace ProgramGui
{
   /// <summary>
   /// Interaction logic for MainWindow.xaml
   /// </summary>
   public partial class MainWindow : Window
   {
      public MainWindowViewModel _mainWindowViewModel;

      public ImpedanceCheckWindow _impedanceCheckWindow;

      public MainWindow()
      {
         InitializeComponent();

         Uri iconUri = new Uri("pack://application:,,,/ProgramGui;component/Resources/Icons/app.ico");
         this.Icon = BitmapFrame.Create(iconUri);

         WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

         _mainWindowViewModel = new MainWindowViewModel(this);
         DataContext = _mainWindowViewModel;
      }

      private void btnClose_Click(object sender, RoutedEventArgs e)
      {
         this.Hide();
      }

      private void btnMax_Click(object sender, RoutedEventArgs e)
      {
         if (this.WindowState == WindowState.Maximized)
         {
            this.WindowState = WindowState.Normal;
            imgMax.Source = new BitmapImage(new System.Uri("pack://application:,,,/Resources/Images/Title_Bar_Buttons/maximize.png"));
         }
         else
         {
            this.WindowState = WindowState.Maximized;
            imgMax.Source = new BitmapImage(new System.Uri("pack://application:,,,/Resources/Images/Title_Bar_Buttons/restore.png"));
         }
      }

      private void btnMin_Click(object sender, RoutedEventArgs e)
      {
         this.WindowState = WindowState.Minimized;
      }

      private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
      {
         DragMove();
      }
   }
}
