using eKasa.Uninstaller.Controls;
using System.Windows;
using System.Windows.Input;

namespace eKasa.Uninstaller {
	public partial class MainWindow : Window {
		#region UserControls
		readonly static public WelcomePage ucwelcome = new();
		readonly static public OptionsPage ucoptions = new();
		readonly static public ProgressPage ucprogress = new();
		readonly static public DonePage ucdone = new();
		readonly static public ErrorPage ucerror = new();
		#endregion

		public MainWindow() {
			InitializeComponent();
			content.Children.Add(ucwelcome);
		}

		private void MainWindow_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) DragMove(); }

		private void MainWindow_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.System && e.SystemKey == Key.F4) e.Handled = true; }

		private void Terminate_Click(object sender, RoutedEventArgs e) {
			var result = MessageBox.Show("Kaldırma işlemini iptal etmek istediğinize emin misiniz?", "Çıkışı Onayla!", MessageBoxButton.YesNo, MessageBoxImage.Question);
			if (result == MessageBoxResult.Yes) {
				Application.Current.Shutdown();
			}
		}

		int page = 0;
		private void Next_Click(object sender, RoutedEventArgs e) {
			content.Children.Clear();
			switch (page) {
				case 0:
					content.Children.Clear();
					content.Children.Add(ucoptions);
					next.Content = "KALDIR";
					break;
				case 1:
					content.Children.Clear();
					content.Children.Add(ucprogress);
					next.Content = "KALDIRILIYOR";
					next.IsEnabled = false;
					terminate.Visibility = Visibility.Hidden;
					ucprogress.BeginUninstall();
					terminate.Click -= Terminate_Click;
					break;
			}
			page++;
		}
	}
}