private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			if(Helper.MainWindow.DeckPickerList.SelectedDeck == null) return;
			var screenShotWindow = new PlayerWindow(Config.Instance, Helper.MainWindow.DeckPickerList.SelectedDeck.Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			var source = PresentationSource.FromVisual(screenShotWindow);
			if(source == null) return;

			var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY,
			                                     Helper.MainWindow.DeckPickerList.SelectedDeck.Name);

			screenShotWindow.Shutdown();
			if(fileName == null)
				await Helper.MainWindow.ShowMessageAsync("", "Error saving screenshot");
			else
				await Helper.MainWindow.ShowSavedFileMessage(fileName, "Screenshots");

			After_Click();
		}
Пример #2
0
 private void BtnShowWindows_Click(object sender, RoutedEventArgs e)
 {
     //show playeroverlay and enemy overlay
     _playerWindow.Show();
     _playerWindow.Activate();
     _opponentWindow.Show();
     _opponentWindow.Activate();
 }
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();

            if (selectedDeck == null)
            {
                return;
            }
            Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
            var screenShotWindow = new PlayerWindow(Config.Instance, selectedDeck.GetSelectedDeckVersion().Cards, true);

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

            var deck       = DeckList.Instance.ActiveDeckVersion;
            var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, deck.Name);

            screenShotWindow.Shutdown();

            if (pngEncoder != null)
            {
                var fileName = Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png");

                if (fileName != null)
                {
                    using (var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                        pngEncoder.Save(stream);

                    await this.ShowSavedFileMessage(fileName);

                    Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
                }
            }
        }
Пример #4
0
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            if (Helper.MainWindow.DeckPickerList.SelectedDeck == null)
            {
                return;
            }
            var screenShotWindow = new PlayerWindow(Config.Instance, Helper.MainWindow.DeckPickerList.SelectedDeck.Cards, true);

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

            var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY,
                                                 Helper.MainWindow.DeckPickerList.SelectedDeck.Name);

            screenShotWindow.Shutdown();
            if (fileName == null)
            {
                await Helper.MainWindow.ShowMessageAsync("", "Error saving screenshot");
            }
            else
            {
                await Helper.MainWindow.ShowSavedFileMessage(fileName, "Screenshots");
            }

            After_Click();
        }
Пример #5
0
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            if (DeckList.Instance.ActiveDeck == null)
            {
                return;
            }
            Logger.WriteLine("Creating screenshot of " + DeckList.Instance.ActiveDeckVersion.GetDeckInfo(), "Screenshot");
            var screenShotWindow = new PlayerWindow(Config.Instance, DeckList.Instance.ActiveDeckVersion.Cards, true);

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

            var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, DeckList.Instance.ActiveDeckVersion.Name);

            screenShotWindow.Shutdown();
            if (fileName == null)
            {
                await this.ShowMessageAsync("", "Error saving screenshot");
            }
            else
            {
                await ShowSavedFileMessage(fileName, "Screenshots");
            }
        }
		private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();
            if(selectedDeck == null)
				return;
			Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
			var screenShotWindow = new PlayerWindow(Config.Instance, selectedDeck.GetSelectedDeckVersion().Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			var source = PresentationSource.FromVisual(screenShotWindow);
			if(source == null)
				return;

			var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var deck = DeckList.Instance.ActiveDeckVersion;
			var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, deck.Name);
			screenShotWindow.Shutdown();

			if(pngEncoder != null)
			{
				var fileName = Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png");

				if(fileName != null)
				{
					using(var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
						pngEncoder.Save(stream);

					await this.ShowSavedFileMessage(fileName);
					Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
				}
			}
		}
		private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();
			if(selectedDeck == null)
				return;
			Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
			var screenShotWindow = new PlayerWindow(Config.Instance, selectedDeck.GetSelectedDeckVersion().Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			var source = PresentationSource.FromVisual(screenShotWindow);
			if(source == null)
				return;

			var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var deck = selectedDeck.GetSelectedDeckVersion();
			var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, deck.Name);
			screenShotWindow.Shutdown();

			if(pngEncoder != null)
			{
				var saveOperation = await this.ShowScreenshotUploadSelectionDialog();
				var tmpFile = new FileInfo(Path.Combine(Config.Instance.DataDir, string.Format("tmp{0}.png", DateTime.Now.ToFileTime())));
				var fileName = saveOperation.SaveLocal
					               ? Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png") : tmpFile.FullName;
				if(fileName != null)
				{
					string imgurUrl = null;
					using(var ms = new MemoryStream())
					using(var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
					{
						pngEncoder.Save(ms);
						ms.WriteTo(fs);
						if(saveOperation.Upload)
						{
							var controller = await this.ShowProgressAsync("Uploading...", "");
							imgurUrl = await Imgur.Upload(Config.Instance.ImgurClientId, ms, deck.Name);
							await controller.CloseAsync();
						}
					}

					if(imgurUrl != null)
					{
						await this.ShowSavedAndUploadedFileMessage(saveOperation.SaveLocal ? fileName : null, imgurUrl);
						Logger.WriteLine("Uploaded screenshot to " + imgurUrl, "Export");
					}
					else
						await this.ShowSavedFileMessage(fileName);
					Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
				}
				if(tmpFile.Exists)
				{
					try
					{
						tmpFile.Delete();
					}
					catch(Exception ex)
					{
						Logger.WriteLine(ex.ToString(), "ExportScreenshot");
					}
				}
			}
		}
Пример #8
0
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();

            if (selectedDeck == null)
            {
                return;
            }
            Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
            var screenShotWindow = new PlayerWindow(_game, selectedDeck.Cards.ToSortedCardList());

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            //adjusting the DPI is apparently no longer/not necessary?
            var dpiX = 96.0;             //* source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0;             //* source.CompositionTarget.TransformToDevice.M22;

            var deck       = selectedDeck.GetSelectedDeckVersion();
            var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, 96, 96, deck.Name);

            screenShotWindow.Shutdown();

            if (pngEncoder != null)
            {
                var saveOperation = await this.ShowScreenshotUploadSelectionDialog();

                var tmpFile  = new FileInfo(Path.Combine(Config.Instance.DataDir, string.Format("tmp{0}.png", DateTime.Now.ToFileTime())));
                var fileName = saveOperation.SaveLocal
                                                       ? Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png") : tmpFile.FullName;
                if (fileName != null)
                {
                    string imgurUrl = null;
                    using (var ms = new MemoryStream())
                        using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                        {
                            pngEncoder.Save(ms);
                            ms.WriteTo(fs);
                            if (saveOperation.Upload)
                            {
                                var controller = await this.ShowProgressAsync("Uploading...", "");

                                imgurUrl = await Imgur.Upload(Config.Instance.ImgurClientId, ms, deck.Name);

                                await controller.CloseAsync();
                            }
                        }

                    if (imgurUrl != null)
                    {
                        await this.ShowSavedAndUploadedFileMessage(saveOperation.SaveLocal?fileName : null, imgurUrl);

                        Logger.WriteLine("Uploaded screenshot to " + imgurUrl, "Export");
                    }
                    else
                    {
                        await this.ShowSavedFileMessage(fileName);
                    }
                    Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
                }
                if (tmpFile.Exists)
                {
                    try
                    {
                        tmpFile.Delete();
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine(ex.ToString(), "ExportScreenshot");
                    }
                }
            }
        }
        public MainWindow()
        {
            // Set working directory to path of executable
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            InitializeComponent();

            Trace.Listeners.Add(new TextBoxTraceListener(Options.TextBoxLog));

            EnableMenuItems(false);

            try
            {
                if (File.Exists("Updater_new.exe"))
                {
                    if (File.Exists("Updater.exe"))
                    {
                        File.Delete("Updater.exe");
                    }
                    File.Move("Updater_new.exe", "Updater.exe");
                }
            }
            catch
            {
                Logger.WriteLine("Error updating updater");
            }

            Helper.MainWindow = this;
            /*_configPath =*/
            Config.Load();
            HsLogReader.Create();

            var configVersion = string.IsNullOrEmpty(Config.Instance.CreatedByVersion)
                                    ? null
                                    : new Version(Config.Instance.CreatedByVersion);

            Version currentVersion;

            if (Config.Instance.CheckForUpdates)
            {
                currentVersion   = Helper.CheckForUpdates(out NewVersion);
                _lastUpdateCheck = DateTime.Now;
            }
            else
            {
                currentVersion = Helper.GetCurrentVersion();
            }

            var versionString = string.Empty;

            if (currentVersion != null)
            {
                versionString             = string.Format("{0}.{1}.{2}", currentVersion.Major, currentVersion.Minor, currentVersion.Build);
                Help.TxtblockVersion.Text = "Version: " + versionString;

                // Assign current version to the config instance so that it will be saved when the config
                // is rewritten to disk, thereby telling us what version of the application created it
                Config.Instance.CreatedByVersion = currentVersion.ToString();
            }

            ConvertLegacyConfig(currentVersion, configVersion);

            if (Config.Instance.SelectedTags.Count == 0)
            {
                Config.Instance.SelectedTags.Add("All");
            }

            _foundHsDirectory = FindHearthstoneDir();

            if (_foundHsDirectory)
            {
                _updatedLogConfig = UpdateLogConfigFile();
            }

            //hearthstone, loads db etc - needs to be loaded before playerdecks, since cards are only saved as ids now
            Game.Reset();

            _decksPath = Config.Instance.DataDir + "PlayerDecks.xml";
            SetupDeckListFile();
            try
            {
                DeckList = XmlManager <Decks> .Load(_decksPath);
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    e.Message + "\n\n" + e.InnerException +
                    "\n\n If you don't know how to fix this, please delete " + _decksPath +
                    " (this will cause you to lose your decks).",
                    "Error loading PlayerDecks.xml");
                Application.Current.Shutdown();
            }

            foreach (var deck in DeckList.DecksList)
            {
                DeckPickerList.AddDeck(deck);
            }

            SetupDefaultDeckStatsFile();
            DefaultDeckStats.Load();


            SetupDeckStatsFile();
            DeckStatsList.Load();

            _notifyIcon = new NotifyIcon {
                Icon = new Icon(@"Images/HearthstoneDeckTracker16.ico"), Visible = true, ContextMenu = new ContextMenu(), Text = "Hearthstone Deck Tracker v" + versionString
            };
            _notifyIcon.ContextMenu.MenuItems.Add("Use no deck", (sender, args) => DeselectDeck());
            _notifyIcon.ContextMenu.MenuItems.Add(new MenuItem("Autoselect deck")
            {
                MenuItems =
                {
                    new MenuItem("On",
                                 (sender, args) =>
                                 AutoDeckDetection(true)),
                    new MenuItem("Off",
                                 (sender, args) =>
                                 AutoDeckDetection(false))
                }
            }); _notifyIcon.ContextMenu.MenuItems.Add(new MenuItem("Class cards first")
            {
                MenuItems =
                {
                    new MenuItem("Yes",
                                 (sender, args) =>
                                 SortClassCardsFirst(true)),
                    new MenuItem("No",
                                 (sender, args) =>
                                 SortClassCardsFirst(false))
                }
            });
            _notifyIcon.ContextMenu.MenuItems.Add("Show", (sender, args) => ActivateWindow());
            _notifyIcon.ContextMenu.MenuItems.Add("Exit", (sender, args) => Close());
            _notifyIcon.MouseClick += (sender, args) => { if (args.Button == MouseButtons.Left)
                                                          {
                                                              ActivateWindow();
                                                          }
            };

            //create overlay
            Overlay = new OverlayWindow {
                Topmost = true
            };

            PlayerWindow   = new PlayerWindow(Config.Instance, Game.IsUsingPremade ? Game.PlayerDeck : Game.PlayerDrawn);
            OpponentWindow = new OpponentWindow(Config.Instance, Game.OpponentCards);
            TimerWindow    = new TimerWindow(Config.Instance);
            StatsWindow    = new StatsWindow();

            if (Config.Instance.PlayerWindowOnStart)
            {
                PlayerWindow.Show();
            }
            if (Config.Instance.OpponentWindowOnStart)
            {
                OpponentWindow.Show();
            }
            if (Config.Instance.TimerWindowOnStartup)
            {
                TimerWindow.Show();
            }
            if (!DeckList.AllTags.Contains("All"))
            {
                DeckList.AllTags.Add("All");
                WriteDecks();
            }
            if (!DeckList.AllTags.Contains("Favorite"))
            {
                if (DeckList.AllTags.Count > 1)
                {
                    DeckList.AllTags.Insert(1, "Favorite");
                }
                else
                {
                    DeckList.AllTags.Add("Favorite");
                }
                WriteDecks();
            }
            if (!DeckList.AllTags.Contains("Arena"))
            {
                DeckList.AllTags.Add("Arena");
                WriteDecks();
            }
            if (!DeckList.AllTags.Contains("Constructed"))
            {
                DeckList.AllTags.Add("Constructed");
                WriteDecks();
            }
            if (!DeckList.AllTags.Contains("None"))
            {
                DeckList.AllTags.Add("None");
                WriteDecks();
            }

            Options.ComboboxAccent.ItemsSource    = ThemeManager.Accents;
            Options.ComboboxTheme.ItemsSource     = ThemeManager.AppThemes;
            Options.ComboboxLanguages.ItemsSource = Helper.LanguageDict.Keys;

            Options.ComboboxKeyPressGameStart.ItemsSource = EventKeys;
            Options.ComboboxKeyPressGameEnd.ItemsSource   = EventKeys;

            LoadConfig();

            FillElementSorters();

            //this has to happen before reader starts
            var lastDeck = DeckList.DecksList.FirstOrDefault(d => d.Name == Config.Instance.LastDeck);

            DeckPickerList.SelectDeck(lastDeck);

            TurnTimer.Create(90);

            SortFilterDecksFlyout.HideStuffToCreateNewTag();
            TagControlEdit.OperationSwitch.Visibility = Visibility.Collapsed;
            TagControlEdit.PnlSortDecks.Visibility    = Visibility.Collapsed;


            UpdateDbListView();

            _doUpdate = _foundHsDirectory;
            UpdateOverlayAsync();

            _initialized = true;
            Options.MainWindowInitialized();

            DeckPickerList.UpdateList();
            if (lastDeck != null)
            {
                DeckPickerList.SelectDeck(lastDeck);
                UpdateDeckList(lastDeck);
                UseDeck(lastDeck);
            }

            if (_foundHsDirectory)
            {
                HsLogReader.Instance.Start();
            }

            Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst);
            DeckPickerList.SortDecks();

            // Set Language
            var culture = Config.Instance.SelectedLanguage.Insert(2, "-");

            WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.Culture = System.Globalization.CultureInfo.GetCultureInfo(culture);
            if (!Directory.Exists(culture))
            {
                var langPath = Path.Combine("Lang", culture);
                if (Directory.Exists(langPath))
                {
                    Helper.CopyFolder(langPath, culture);
                    _showRestartMessage = true;
                }
            }
        }
		public MainWindow(GameV2 game)
		{
		    _game = game;

			InitializeComponent();
			Trace.Listeners.Add(new TextBoxTraceListener(Options.OptionsTrackerLogging.TextBoxLog));


			Helper.MainWindow = this;
			//Config.Load();
			EnableMenuItems(false);


			try
			{
				if(File.Exists("HDTUpdate_new.exe"))
				{
					if(File.Exists("HDTUpdate.exe"))
						File.Delete("HDTUpdate.exe");
					File.Move("HDTUpdate_new.exe", "HDTUpdate.exe");
				}
			}
			catch(Exception e)
			{
				Logger.WriteLine("Error updating updater\n" + e);
			}
			try
			{
				//updater used pre v0.9.6
				if(File.Exists("Updater.exe"))
					File.Delete("Updater.exe");
			}
			catch(Exception e)
			{
				Logger.WriteLine("Error deleting Updater.exe\n" + e);
			}


			HsLogReaderV2.Create();

			var configVersion = string.IsNullOrEmpty(Config.Instance.CreatedByVersion) ? null : new Version(Config.Instance.CreatedByVersion);

			var currentVersion = Helper.GetCurrentVersion();
			var versionString = string.Empty;
			if(currentVersion != null)
			{
				versionString = string.Format("{0}.{1}.{2}", currentVersion.Major, currentVersion.Minor, currentVersion.Build);
				Help.TxtblockVersion.Text = "Version: " + versionString;

				// Assign current version to the config instance so that it will be saved when the config
				// is rewritten to disk, thereby telling us what version of the application created it
				Config.Instance.CreatedByVersion = currentVersion.ToString();
			}

			ConvertLegacyConfig(currentVersion, configVersion);

			if(Config.Instance.SelectedTags.Count == 0)
				Config.Instance.SelectedTags.Add("All");

			_foundHsDirectory = FindHearthstoneDir();

			if(_foundHsDirectory)
				_updatedLogConfig = UpdateLogConfigFile();

			//hearthstone, loads db etc - needs to be loaded before playerdecks, since cards are only saved as ids now
			_game.Reset();

			if(!Directory.Exists(Config.Instance.DataDir))
				Config.Instance.Reset("DataDirPath");

			SetupDeckListFile();
			DeckList.Load();

			// Don't load active deck if it's archived
			if(DeckList.Instance.ActiveDeck != null && DeckList.Instance.ActiveDeck.Archived)
				DeckList.Instance.ActiveDeck = null;

			UpdateDeckList(DeckList.Instance.ActiveDeck);

			SetupDefaultDeckStatsFile();
			DefaultDeckStats.Load();


			SetupDeckStatsFile();
			DeckStatsList.Load();

			_notifyIcon = new NotifyIcon
			{
				Icon = new Icon(@"Images/HearthstoneDeckTracker16.ico"),
				Visible = true,
				ContextMenu = new ContextMenu(),
				Text = "Hearthstone Deck Tracker v" + versionString
			};

			MenuItem startHearthstonMenuItem = new MenuItem("Start Launcher/Hearthstone", (sender, args) => StartHearthstoneAsync());
			startHearthstonMenuItem.Name = "startHearthstone";
			_notifyIcon.ContextMenu.MenuItems.Add(startHearthstonMenuItem);

			MenuItem useNoDeckMenuItem = new MenuItem("Use no deck", (sender, args) => UseNoDeckContextMenu());
			useNoDeckMenuItem.Name = "useNoDeck";
			_notifyIcon.ContextMenu.MenuItems.Add(useNoDeckMenuItem);

			MenuItem autoSelectDeckMenuItem = new MenuItem("Autoselect deck", (sender, args) => AutoDeckDetectionContextMenu());
			autoSelectDeckMenuItem.Name = "autoSelectDeck";
			_notifyIcon.ContextMenu.MenuItems.Add(autoSelectDeckMenuItem);

			MenuItem classCardsFirstMenuItem = new MenuItem("Class cards first", (sender, args) => SortClassCardsFirstContextMenu());
			classCardsFirstMenuItem.Name = "classCardsFirst";
			_notifyIcon.ContextMenu.MenuItems.Add(classCardsFirstMenuItem);

			_notifyIcon.ContextMenu.MenuItems.Add("Show", (sender, args) => ActivateWindow());
			_notifyIcon.ContextMenu.MenuItems.Add("Exit", (sender, args) => Close());
			_notifyIcon.MouseClick += (sender, args) =>
			{
				if(args.Button == MouseButtons.Left)
					ActivateWindow();
			};

			//create overlay
			Overlay = new OverlayWindow(_game) {Topmost = true};

			PlayerWindow = new PlayerWindow(_game,Config.Instance, _game.IsUsingPremade ? _game.PlayerDeck : _game.PlayerDrawn);
			OpponentWindow = new OpponentWindow(_game, Config.Instance, _game.OpponentCards);
			TimerWindow = new TimerWindow(Config.Instance);
			StatsWindow = new StatsWindow();

			if(Config.Instance.PlayerWindowOnStart)
				PlayerWindow.Show();
			if(Config.Instance.OpponentWindowOnStart)
				OpponentWindow.Show();
			if(Config.Instance.TimerWindowOnStartup)
				TimerWindow.Show();

			LoadConfig();
			if(!Config.Instance.NetDeckClipboardCheck.HasValue)
			{
				var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
				                        @"Google\Chrome\User Data\Default\Extensions\lpdbiakcpmcppnpchohihcbdnojlgeel");

				if(Directory.Exists(path))
				{
					Config.Instance.NetDeckClipboardCheck = true;
					Config.Save();
				}
			}

			if(!Config.Instance.RemovedNoteUrls)
				RemoveNoteUrls();
			if(!Config.Instance.ResolvedDeckStatsIssue)
				ResolveDeckStatsIssue();

			TurnTimer.Create(90);

			SortFilterDecksFlyout.HideStuffToCreateNewTag();
			TagControlEdit.OperationSwitch.Visibility = Visibility.Collapsed;
			TagControlEdit.GroupBoxSortingAllConstructed.Visibility = Visibility.Collapsed;
			TagControlEdit.GroupBoxSortingArena.Visibility = Visibility.Collapsed;

			FlyoutNotes.ClosingFinished += (sender, args) => DeckNotesEditor.SaveDeck();


			UpdateDbListView();

			_doUpdate = _foundHsDirectory;

			SelectDeck(DeckList.Instance.ActiveDeck, true);

			if(_foundHsDirectory)
				HsLogReaderV2.Instance.Start(_game);

			Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst);
			DeckPickerList.PropertyChanged += DeckPickerList_PropertyChanged;
			DeckPickerList.UpdateDecks();
			DeckPickerList.UpdateArchivedClassVisibility();

			CopyReplayFiles();

			LoadHearthStats();

			UpdateOverlayAsync();
			UpdateAsync();

			BackupManager.Run();

			_initialized = true;

			PluginManager.Instance.LoadPlugins();
			Options.OptionsTrackerPlugins.Load();
			PluginManager.Instance.StartUpdateAsync();
		}
Пример #11
0
		public MainWindow()
		{
			// Set working directory to path of executable
			Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

			InitializeComponent();

			EnableMenuItems(false);

			try
			{
				if(File.Exists("Updater_new.exe"))
				{
					if(File.Exists("Updater.exe"))
						File.Delete("Updater.exe");
					File.Move("Updater_new.exe", "Updater.exe");
				}
			}
			catch
			{
				Logger.WriteLine("Error updating updater");
			}

			Helper.MainWindow = this;
			_configPath = Config.Load();
			HsLogReader.Create();

			var configVersion = string.IsNullOrEmpty(Config.Instance.CreatedByVersion)
				                    ? null
				                    : new Version(Config.Instance.CreatedByVersion);

			Version currentVersion;
			if(Config.Instance.CheckForUpdates)
			{
				currentVersion = Helper.CheckForUpdates(out NewVersion);
				_lastUpdateCheck = DateTime.Now;
			}
			else
				currentVersion = Helper.GetCurrentVersion();

			var versionString = string.Empty;
			if(currentVersion != null)
			{
				versionString = string.Format("{0}.{1}.{2}", currentVersion.Major, currentVersion.Minor, currentVersion.Build);
				Help.TxtblockVersion.Text = "Version: " + versionString;

				// Assign current version to the config instance so that it will be saved when the config
				// is rewritten to disk, thereby telling us what version of the application created it
				Config.Instance.CreatedByVersion = currentVersion.ToString();
			}

			ConvertLegacyConfig(currentVersion, configVersion);

			if(Config.Instance.SelectedTags.Count == 0)
				Config.Instance.SelectedTags.Add("All");

			if(Config.Instance.GenerateLog)
			{
				Directory.CreateDirectory("Logs");
				var listener = new TextWriterTraceListener(Config.Instance.LogFilePath);
				Trace.Listeners.Add(listener);
				Trace.AutoFlush = true;
			}

			_foundHsDirectory = FindHearthstoneDir();

			if(_foundHsDirectory)
				_updatedLogConfig = UpdateLogConfigFile();

			//hearthstone, loads db etc - needs to be loaded before playerdecks, since cards are only saved as ids now
			Game.Reset();

			_decksPath = Config.Instance.HomeDir + "PlayerDecks.xml";
			SetupDeckListFile();
			try
			{
				DeckList = XmlManager<Decks>.Load(_decksPath);
			}
			catch(Exception e)
			{
				MessageBox.Show(
					e.Message + "\n\n" + e.InnerException +
					"\n\n If you don't know how to fix this, please delete " + _decksPath +
					" (this will cause you to lose your decks).",
					"Error loading PlayerDecks.xml");
				Application.Current.Shutdown();
			}

			foreach(var deck in DeckList.DecksList)
				DeckPickerList.AddDeck(deck);

			SetupDeckStatsFile();
			DeckStatsList.Load();

			_notifyIcon = new NotifyIcon {Icon = new Icon(@"Images/HearthstoneDeckTracker.ico"), Visible = true, ContextMenu = new ContextMenu(), Text = "Hearthstone Deck Tracker v" + versionString};
			_notifyIcon.ContextMenu.MenuItems.Add("Show", (sender, args) => ActivateWindow());
			_notifyIcon.ContextMenu.MenuItems.Add("Exit", (sender, args) => Close());
			_notifyIcon.MouseClick += (sender, args) => { if(args.Button == MouseButtons.Left) ActivateWindow(); };

			//create overlay
			Overlay = new OverlayWindow {Topmost = true};

			PlayerWindow = new PlayerWindow(Config.Instance, Game.IsUsingPremade ? Game.PlayerDeck : Game.PlayerDrawn);
			OpponentWindow = new OpponentWindow(Config.Instance, Game.OpponentCards);
			TimerWindow = new TimerWindow(Config.Instance);
			StatsWindow = new StatsWindow();

			if(Config.Instance.PlayerWindowOnStart)
				PlayerWindow.Show();
			if(Config.Instance.OpponentWindowOnStart)
				OpponentWindow.Show();
			if(Config.Instance.TimerWindowOnStartup)
				TimerWindow.Show();
			if(!DeckList.AllTags.Contains("All"))
			{
				DeckList.AllTags.Add("All");
				WriteDecks();
			}
			if(!DeckList.AllTags.Contains("Arena"))
			{
				DeckList.AllTags.Add("Arena");
				WriteDecks();
			}
			if(!DeckList.AllTags.Contains("Constructed"))
			{
				DeckList.AllTags.Add("Constructed");
				WriteDecks();
			}

			Options.ComboboxAccent.ItemsSource = ThemeManager.Accents;
			Options.ComboboxTheme.ItemsSource = ThemeManager.AppThemes;
			Options.ComboboxLanguages.ItemsSource = Helper.LanguageDict.Keys;

			Options.ComboboxKeyPressGameStart.ItemsSource = EventKeys;
			Options.ComboboxKeyPressGameEnd.ItemsSource = EventKeys;

			LoadConfig();

			FillElementSorters();

			//this has to happen before reader starts
			var lastDeck = DeckList.DecksList.FirstOrDefault(d => d.Name == Config.Instance.LastDeck);
			DeckPickerList.SelectDeck(lastDeck);

			TurnTimer.Create(90);

			SortFilterDecksFlyout.HideStuffToCreateNewTag();
			TagControlEdit.OperationSwitch.Visibility = Visibility.Collapsed;
			TagControlEdit.PnlSortDecks.Visibility = Visibility.Collapsed;


			UpdateDbListView();

			_doUpdate = _foundHsDirectory;
			UpdateOverlayAsync();

			_initialized = true;
			Options.MainWindowInitialized();

			DeckPickerList.UpdateList();
			if(lastDeck != null)
			{
				DeckPickerList.SelectDeck(lastDeck);
				UpdateDeckList(lastDeck);
				UseDeck(lastDeck);
			}

			if(_foundHsDirectory)
				HsLogReader.Instance.Start();

			Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst);
			DeckPickerList.SortDecks();
		}
        // Logic for dealing with legacy config file semantics
        // Use difference of versions to determine what should be done

        public MainWindow()
        {
            InitializeComponent();

            Helper.MainWindow = this;
            _configPath = Config.Load();
            HsLogReader.Create();

            var configVersion = string.IsNullOrEmpty(Config.Instance.CreatedByVersion)
                                    ? null
                                    : new Version(Config.Instance.CreatedByVersion);

            var currentVersion = Helper.CheckForUpdates(out NewVersion);
            if (currentVersion != null)
            {
                TxtblockVersion.Text = string.Format("Version: {0}.{1}.{2}", currentVersion.Major, currentVersion.Minor,
                                                     currentVersion.Build);

                // Assign current version to the config instance so that it will be saved when the config
                // is rewritten to disk, thereby telling us what version of the application created it
                Config.Instance.CreatedByVersion = currentVersion.ToString();
            }

            ConvertLegacyConfig(currentVersion, configVersion);

            if (Config.Instance.SelectedTags.Count == 0)
                Config.Instance.SelectedTags.Add("All");

            if (Config.Instance.GenerateLog)
            {
                Directory.CreateDirectory("Logs");
                var listener = new TextWriterTraceListener(Config.Instance.LogFilePath);
                Trace.Listeners.Add(listener);
                Trace.AutoFlush = true;
            }

            _foundHsDirectory = FindHearthstoneDir();

            if (_foundHsDirectory)
                _updatedLogConfig = UpdateLogConfigFile();

            //hearthstone, loads db etc - needs to be loaded before playerdecks, since cards are only saved as ids now
            //Game.Create();
            Game.Reset();
            Game.opponentSeer.PopularDecksChanged += opponentSeer_PopularDecksChanged;

            _decksPath = Config.Instance.HomeDir + "PlayerDecks.xml";
            SetupDeckListFile();
            try
            {
                DeckList = XmlManager<Decks>.Load(_decksPath);
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    e.Message + "\n\n" + e.InnerException +
                    "\n\n If you don't know how to fix this, please delete " + _decksPath +
                    " (this will cause you to lose your decks).",
                    "Error loading PlayerDecks.xml");
                Application.Current.Shutdown();
            }

            foreach (var deck in DeckList.DecksList)
            {
                DeckPickerList.AddDeck(deck);
            }

            _notifyIcon = new NotifyIcon { Icon = new Icon(@"Images/HearthstoneDeckTracker.ico") };
            _notifyIcon.MouseDoubleClick += NotifyIconOnMouseDoubleClick;
            _notifyIcon.Visible = false;

            NewDeck = new Deck();
            ListViewNewDeck.ItemsSource = NewDeck.Cards;

            //create overlay
            Overlay = new OverlayWindow { Topmost = true };
            if (_foundHsDirectory)
                Overlay.Show();

            PlayerWindow = new PlayerWindow(Config.Instance, Game.IsUsingPremade ? Game.PlayerDeck : Game.PlayerDrawn);
            OpponentWindow = new OpponentWindow(Config.Instance, Game.OpponentCards);
            TimerWindow = new TimerWindow(Config.Instance);

            if (Config.Instance.WindowsOnStartup)
            {
                PlayerWindow.Show();
                OpponentWindow.Show();
            }
            if (Config.Instance.TimerWindowOnStartup)
            {
                TimerWindow.Show();
            }
            if (!DeckList.AllTags.Contains("All"))
            {
                DeckList.AllTags.Add("All");
                WriteDecks();
            }
            if (!DeckList.AllTags.Contains("Arena"))
            {
                DeckList.AllTags.Add("Arena");
                WriteDecks();
            }
            if (!DeckList.AllTags.Contains("Constructed"))
            {
                DeckList.AllTags.Add("Constructed");
                WriteDecks();
            }

            ComboboxAccent.ItemsSource = ThemeManager.Accents;
            ComboboxTheme.ItemsSource = ThemeManager.AppThemes;
            ComboboxLanguages.ItemsSource = Helper.LanguageDict.Keys;

            ComboboxKeyPressGameStart.ItemsSource = EventKeys;
            ComboboxKeyPressGameEnd.ItemsSource = EventKeys;

            LoadConfig();

            //this has to happen before reader starts
            var lastDeck = DeckList.DecksList.FirstOrDefault(d => d.Name == Config.Instance.LastDeck);
            DeckPickerList.SelectDeck(lastDeck);

            DeckOptionsFlyout.DeckOptionsButtonClicked += sender => { FlyoutDeckOptions.IsOpen = false; };

            DeckImportFlyout.DeckOptionsButtonClicked += sender => { FlyoutDeckImport.IsOpen = false; };

            TurnTimer.Create(90);

            SortFilterDecksFlyout.HideStuffToCreateNewTag();
            TagControlNewDeck.OperationSwitch.Visibility = Visibility.Collapsed;
            TagControlMyDecks.OperationSwitch.Visibility = Visibility.Collapsed;
            TagControlNewDeck.PnlSortDecks.Visibility = Visibility.Collapsed;
            TagControlMyDecks.PnlSortDecks.Visibility = Visibility.Collapsed;

            //SortFilterDecksFlyout.SelectedTagsChanged += SortFilterDecksFlyoutOnSelectedTagsChanged;
            //SortFilterDecksFlyout.OperationChanged += SortFilterDecksFlyoutOnOperationChanged;

            UpdateDbListView();

            _doUpdate = _foundHsDirectory;
            UpdateOverlayAsync();

            _initialized = true;

            DeckPickerList.UpdateList();
            if (lastDeck != null)
            {
                DeckPickerList.SelectDeck(lastDeck);
                UpdateDeckList(lastDeck);
                UseDeck(lastDeck);
            }

            if (_foundHsDirectory)
            {
                HsLogReader.Instance.Start();
            }

            Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst);
            DeckPickerList.SortDecks();
        }
		public MainWindow()
		{
			InitializeComponent();

			var version = Helper.CheckForUpdates(out _newVersion);
			if (version != null)
			{
				TxtblockVersion.Text = string.Format("Version: {0}.{1}.{2}", version.Major, version.Minor,
													 version.Build);
			}

			#region load config
			_config = new Config();
			_xmlManagerConfig = new XmlManager<Config> { Type = typeof(Config) };

			bool foundConfig = false;
			try
			{
				if (File.Exists("config.xml"))
				{
					_config = _xmlManagerConfig.Load("config.xml");
					foundConfig = true;
				}
				else if (File.Exists(_config.AppDataPath + @"\config.xml"))
				{
					_config = _xmlManagerConfig.Load(_config.AppDataPath + @"\config.xml");
					foundConfig = true;
				}
				else if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)))

				//save locally if appdata doesn't exist (when e.g. not on C)
				{
					_config.SaveInAppData = false;
				}

			}
			catch (Exception e)
			{
				MessageBox.Show(
					e.Message + "\n\n" + e.InnerException +
					"\n\n If you don't know how to fix this, please delete " + _config.ConfigPath,
					"Error loading config.xml");
				Application.Current.Shutdown();
			}
			_configPath = _config.ConfigPath;
			if (!foundConfig)
			{
				if (_config.HomeDir != string.Empty)
					Directory.CreateDirectory(_config.HomeDir);
				using (var sr = new StreamWriter(_config.ConfigPath, false))
				{
					sr.WriteLine("<Config></Config>");
				}
			}
			else
			{
				//check if config needs to be moved
				if (_config.SaveInAppData)
				{
					if (File.Exists("config.xml"))
					{
						Directory.CreateDirectory(_config.HomeDir);
						if (File.Exists(_config.ConfigPath))
						{
							//backup in case the file already exists
							File.Move(_configPath, _configPath + DateTime.Now.ToFileTime());
						}
						File.Move("config.xml", _config.ConfigPath);
						Logger.WriteLine("Moved config to appdata");
					}
				}
				else
				{
					if (File.Exists(_config.AppDataPath + @"\config.xml"))
					{
						if (File.Exists(_config.ConfigPath))
						{
							//backup in case the file already exists
							File.Move(_configPath, _configPath + DateTime.Now.ToFileTime());
						}
						File.Move(_config.AppDataPath + @"\config.xml", _config.ConfigPath);
						Logger.WriteLine("Moved config to local");
					}
				}
			}
			#endregion

			if (_config.SelectedTags.Count == 0)
				_config.SelectedTags.Add("All");

			_config.Debug = IS_DEBUG;

			if (_config.GenerateLog)
			{
				Directory.CreateDirectory("Logs");
				var listener = new TextWriterTraceListener(_config.LogFilePath);
				Trace.Listeners.Add(listener);
				Trace.AutoFlush = true;
			}

			#region find hearthstone dir
			if (string.IsNullOrEmpty(_config.HearthstoneDirectory) || !File.Exists(_config.HearthstoneDirectory + @"\Hearthstone.exe"))
			{
				using (var hsDirKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Hearthstone"))
				{
					if (hsDirKey != null)
					{
						var hsDir = (string)hsDirKey.GetValue("InstallLocation");

						//verify the installlocation actually is correct (possibly moved?)
						if (File.Exists(hsDir + @"\Hearthstone.exe"))
						{
							_config.HearthstoneDirectory = hsDir;
							WriteConfig();
							_foundHsDirectory = true;
						}
					}
				}
			}
			else
			{
				_foundHsDirectory = true;
			}

			if (_foundHsDirectory)
			{

				//check for log config and create if not existing
				try
				{
					//always overwrite is true by default. 
					if (!File.Exists(_logConfigPath))
					{
						_updatedLogConfig = true;
						File.Copy("Files/log.config", _logConfigPath, true);
						Logger.WriteLine(string.Format("Copied log.config to {0} (did not exist)", _configPath));
					}
					else
					{
						//update log.config if newer
						var localFile = new FileInfo(_logConfigPath);
						var file = new FileInfo("Files/log.config");
						if (file.LastWriteTime > localFile.LastWriteTime)
						{
							_updatedLogConfig = true;
							File.Copy("Files/log.config", _logConfigPath, true);
							Logger.WriteLine(string.Format("Copied log.config to {0} (file newer)", _configPath));
						}
						else if (_config.AlwaysOverwriteLogConfig)
						{
							File.Copy("Files/log.config", _logConfigPath, true);
							Logger.WriteLine(string.Format("Copied log.config to {0} (AlwaysOverwriteLogConfig)", _configPath));
						}
					}
				}
				catch (Exception e)
				{
					if (_updatedLogConfig)
					{
						MessageBox.Show(
							e.Message + "\n\n" + e.InnerException +
							"\n\n Please manually copy the log.config from the Files directory to \"%LocalAppData%/Blizzard/Hearthstone\".",
							"Error writing log.config");
						Application.Current.Shutdown();
					}
				}
			}
			#endregion

			string languageTag = _config.SelectedLanguage;
			//hearthstone, loads db etc - needs to be loaded before playerdecks, since cards are only saved as ids now
			_game = Helper.LanguageDict.ContainsValue(languageTag) ? new Game(languageTag) : new Game("enUS");
			_game.Reset();

			#region playerdecks
			_decksPath = _config.HomeDir + "PlayerDecks.xml";

			if (_config.SaveInAppData)
			{
				if (File.Exists("PlayerDecks.xml"))
				{
					if (File.Exists(_decksPath))
					{
						//backup in case the file already exists
						File.Move(_decksPath, _decksPath + DateTime.Now.ToFileTime());
					}
					File.Move("PlayerDecks.xml", _decksPath);
					Logger.WriteLine("Moved decks to appdata");
				}
			}
			else
			{
				var appDataPath = _config.AppDataPath + @"\PlayerDecks.xml";
				if (File.Exists(appDataPath))
				{
					if (File.Exists(_decksPath))
					{
						//backup in case the file already exists
						File.Move(_decksPath, _decksPath + DateTime.Now.ToFileTime());
					}
					File.Move(appDataPath, _decksPath);
					Logger.WriteLine("Moved decks to local");
				}
			}

			//load saved decks
			if (!File.Exists(_decksPath))
			{
				//avoid overwriting decks file with new releases.
				using (var sr = new StreamWriter(_decksPath, false))
				{
					sr.WriteLine("<Decks></Decks>");
				}
			}
			else
			{
				//the new playerdecks.xml wont work with versions below 0.2.19, make copy
				if (!File.Exists(_decksPath + ".old"))
				{
					File.Copy(_decksPath, _decksPath + ".old");
				}
			}

			_xmlManager = new XmlManager<Decks> { Type = typeof(Decks) };
			try
			{
				_deckList = _xmlManager.Load(_decksPath);
			}
			catch (Exception e)
			{
				MessageBox.Show(
					e.Message + "\n\n" + e.InnerException +
					"\n\n If you don't know how to fix this, please delete " + _decksPath + " (this will cause you to lose your decks).",
					"Error loading PlayerDecks.xml");
				Application.Current.Shutdown();
			}
			#endregion

			foreach (var deck in _deckList.DecksList)
			{
				DeckPickerList.AddDeck(deck);
			}
			DeckPickerList.SelectedDeckChanged += DeckPickerListOnSelectedDeckChanged;

			_notifyIcon = new System.Windows.Forms.NotifyIcon();
			_notifyIcon.Icon = new Icon(@"Images/HearthstoneDeckTracker.ico");
			_notifyIcon.MouseDoubleClick += NotifyIconOnMouseDoubleClick;
			_notifyIcon.Visible = false;

			_xmlManagerDeck = new XmlManager<Deck>();
			_xmlManagerDeck.Type = typeof(Deck);

			_newDeck = new Deck();
			ListViewNewDeck.ItemsSource = _newDeck.Cards;


			//create overlay
			_overlay = new OverlayWindow(_config, _game) { Topmost = true };
			if (_foundHsDirectory)
			{
				_overlay.Show();
			}
			_playerWindow = new PlayerWindow(_config, _game.IsUsingPremade ? _game.PlayerDeck : _game.PlayerDrawn);
			_opponentWindow = new OpponentWindow(_config, _game.OpponentCards);
			_timerWindow = new TimerWindow(_config);

			if (_config.WindowsOnStartup)
			{
				_playerWindow.Show();
				_opponentWindow.Show();
			}
			if (_config.TimerWindowOnStartup)
			{
				_timerWindow.Show();
			}
			if (!_deckList.AllTags.Contains("All"))
			{
				_deckList.AllTags.Add("All");
				WriteDecks();
			}
			if (!_deckList.AllTags.Contains("Arena"))
			{
				_deckList.AllTags.Add("Arena");
				WriteDecks();
			}
			if (!_deckList.AllTags.Contains("Constructed"))
			{
				_deckList.AllTags.Add("Constructed");
				WriteDecks();
			}

			ComboboxAccent.ItemsSource = ThemeManager.Accents;
			ComboboxTheme.ItemsSource = ThemeManager.AppThemes;
			ComboboxLanguages.ItemsSource = Helper.LanguageDict.Keys;

			ComboboxKeyPressGameStart.ItemsSource = EventKeys.Split(',');
			ComboboxKeyPressGameEnd.ItemsSource = EventKeys.Split(',');

			LoadConfig();

			_deckImporter = new DeckImporter(_game);
			_deckExporter = new DeckExporter(_config);

			//this has to happen before reader starts
			var lastDeck = _deckList.DecksList.FirstOrDefault(d => d.Name == _config.LastDeck);
			DeckPickerList.SelectDeck(lastDeck);

			//deck options flyout button events
			DeckOptionsFlyout.BtnDeleteDeck.Click += DeckOptionsFlyoutBtnDeleteDeck_Click;
			DeckOptionsFlyout.BtnExportHs.Click += DeckOptionsFlyoutBtnExportHs_Click;
			DeckOptionsFlyout.BtnNotes.Click += DeckOptionsFlyoutBtnNotes_Click;
			DeckOptionsFlyout.BtnScreenshot.Click += DeckOptionsFlyoutBtnScreenhot_Click;
			DeckOptionsFlyout.BtnCloneDeck.Click += DeckOptionsFlyoutCloneDeck_Click;
			DeckOptionsFlyout.BtnTags.Click += DeckOptionsFlyoutBtnTags_Click;
			DeckOptionsFlyout.BtnSaveToFile.Click += DeckOptionsFlyoutBtnSaveToFile_Click;
			DeckOptionsFlyout.BtnClipboard.Click += DeckOptionsFlyoutBtnClipboard_Click;

			DeckOptionsFlyout.DeckOptionsButtonClicked += CloseDeckOptionsFlyout;

			//deck import flyout button events
			DeckImportFlyout.BtnWeb.Click += DeckImportFlyoutBtnWebClick;
			DeckImportFlyout.BtnArenavalue.Click += DeckImportFlyoutBtnArenavalue_Click;
			DeckImportFlyout.BtnFile.Click += DeckImportFlyoutBtnFile_Click;
			DeckImportFlyout.BtnIdString.Click += DeckImportFlyoutBtnIdString_Click;

			DeckImportFlyout.DeckOptionsButtonClicked += CloseDeckImportFlyout;

			//log reader
			_logReader = new HsLogReader(_config.HearthstoneDirectory, _config.UpdateDelay);
			_logReader.CardMovement += LogReaderOnCardMovement;
			_logReader.GameStateChange += LogReaderOnGameStateChange;
			_logReader.Analyzing += LogReaderOnAnalyzing;
			_logReader.TurnStart += LogReaderOnTurnStart;
			_logReader.CardPosChange += LogReaderOnCardPosChange;
			_logReader.SecretPlayed += LogReaderOnSecretPlayed;

			_turnTimer = new TurnTimer(90);
			_turnTimer.TimerTick += TurnTimerOnTimerTick;

			TagControlFilter.HideStuffToCreateNewTag();
			TagControlNewDeck.OperationSwitch.Visibility = Visibility.Collapsed;
			TagControlMyDecks.OperationSwitch.Visibility = Visibility.Collapsed;

			TagControlNewDeck.NewTag += TagControlOnNewTag;
			TagControlNewDeck.SelectedTagsChanged += TagControlOnSelectedTagsChanged;
			TagControlNewDeck.DeleteTag += TagControlOnDeleteTag;
			TagControlMyDecks.NewTag += TagControlOnNewTag;
			TagControlMyDecks.SelectedTagsChanged += TagControlOnSelectedTagsChanged;
			TagControlMyDecks.DeleteTag += TagControlOnDeleteTag;
			TagControlFilter.SelectedTagsChanged += TagControlFilterOnSelectedTagsChanged;
			TagControlFilter.OperationChanged += TagControlFilterOnOperationChanged;


			UpdateDbListView();

			_doUpdate = _foundHsDirectory;
			UpdateOverlayAsync();

			_initialized = true;

			DeckPickerList.UpdateList();
			if (lastDeck != null)
			{
				DeckPickerList.SelectDeck(lastDeck);
				UpdateDeckList(lastDeck);
				UseDeck(lastDeck);
			}

			if (_foundHsDirectory)
			{
				_logReader.Start();
			}

			Helper.SortCardCollection(ListViewDeck.Items, _config.CardSortingClassFirst);

		}
		private async void DeckOptionsFlyoutBtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			if (DeckPickerList.SelectedDeck == null) return;
			PlayerWindow screenShotWindow = new PlayerWindow(_config, DeckPickerList.SelectedDeck.Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			PresentationSource source = PresentationSource.FromVisual(screenShotWindow);
			if (source == null) return;

			double dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			double dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, DeckPickerList.SelectedDeck.Name);

			screenShotWindow.Shutdown();
			if (fileName == null)
			{
				await this.ShowMessageAsync("", "Error saving screenshot");
			}
			else
			{
				await ShowSavedFileMessage(fileName, "Screenshots");
			}
		}