using N2_Patcher.Control;
using N2_Patcher.Model;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Navigation;

namespace N2_Patcher
{
	public partial class MainWindow : Window
	{
		public static bool SelfUpgrade;

		public static bool InProgress;

		public static bool AutoPatch;

		public static bool IsPatched;

		public static bool IsReady;

		public static List<PatchItem> Patchlist;

		public static string PatcherHash;

		public static long BytesHave;

		public static long BytesNeed;

		public static int FilesHave;

		public static int FilesNeed;

		public static double BytesHaveOld;

		public static double BytesHaveAtm;

		public static string news1;

		public static string news2;

		public static string news3;

		public static MainWindow WPF;

		private string _newsLink = "";

		public MainWindow()
		{
			Functions.ClearOldVersion();
			this.InitializeComponent();
			MainWindow.AutoPatch = true;
			MainWindow.WPF = this;
			MainWindow.WPF.btn_start.IsEnabled = false;
			Program.Patchlist_Thread();
			Program.newsThread();
			base.DataContext = this;
			PicWarpper picWarpper = new PicWarpper();
		}

		private void BtnClose(object sender, MouseButtonEventArgs e)
		{
			Environment.Exit(0);
		}

		private void BtnConfig(object sender, MouseButtonEventArgs e)
		{
			Program.Config_EXE();
		}

		private void BtnDiscord(object sender, MouseButtonEventArgs e)
		{
			Program.URL(Config.getDiscord(), "Discord");
		}

		private void BtnHome(object sender, MouseButtonEventArgs e)
		{
			Program.URL(Config.getHomepage(), "Homepage");
		}

		private void BtnMinimize(object sender, MouseButtonEventArgs e)
		{
			base.WindowState = System.Windows.WindowState.Minimized;
		}

		private void btnNextNews(object sender, MouseButtonEventArgs e)
		{
			NewsSystem.next();
		}

		private void btnPrevNews(object sender, MouseButtonEventArgs e)
		{
			NewsSystem.prev();
		}

		private void BtnStartMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			if (!MainWindow.InProgress)
			{
				if (!MainWindow.AutoPatch)
				{
					Program.Patchlist_Thread();
				}
				else
				{
					Program.Start_EXE();
				}
			}
		}

		private void BtnVoteForCoins(object sender, MouseButtonEventArgs e)
		{
			Program.URL(Config.getVoteForCoins(), "Vote4Coins");
		}

		private void ImgBgMouseLeftDown(object sender, MouseButtonEventArgs e)
		{
			if (e.ButtonState == MouseButtonState.Pressed)
			{
				base.DragMove();
			}
		}

		private void LinkOnRequestNavigate(object sender, RequestNavigateEventArgs e)
		{
			Process.Start(e.Uri.ToString());
		}

		private void newsLink(object sender, MouseButtonEventArgs e)
		{
			Program.URL(this._newsLink, null);
		}

		public void ReadyForStart()
		{
			MainWindow.WPF.btn_start.IsEnabled = true;
		}

		public void setNewsLink(string url)
		{
			this._newsLink = url;
		}
	}
}