public MainWindow()
        {
            InitializeComponent();

            Helper.CheckForUpdates();

            //check for log config and create if not existing
            try
            {
                if (!File.Exists(_logConfigPath))
                {
                    File.Copy("Files/log.config", _logConfigPath);
                }
                else
                {
                    //update log.config if newer
                    var localFile = new FileInfo(_logConfigPath);
                    var file = new FileInfo("Files/log.config");
                    if (file.LastWriteTime > localFile.LastWriteTime)
                    {

                        File.Copy("Files/log.config", _logConfigPath, true);

                    }
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                Console.WriteLine("Not authorized write " + _logConfigPath + ". Start as admin(?)");
                Console.WriteLine(ex.Message);
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex.Message);
            }

            //load config
            _config = new Config();
            _xmlManagerConfig = new XmlManager<Config> {Type = typeof (Config)};
            _config = _xmlManagerConfig.Load("config.xml");

            //load saved decks
            if (!File.Exists("PlayerDecks.xml"))
            {
                //avoid overwriting decks file with new releases.
                using (var sr = new StreamWriter("PlayerDecks.xml", false))
                {
                    sr.WriteLine("<Decks></Decks>");
                }
            }
            _xmlManager = new XmlManager<Decks> {Type = typeof (Decks)};
            _deckList = _xmlManager.Load("PlayerDecks.xml");

            //add saved decks to gui
            foreach (var deck in _deckList.DecksList)
            {
                ComboBoxDecks.Items.Add(deck.Name);
            }
            ComboBoxDecks.SelectedItem = _config.LastDeck;

            //hearthstone, loads db etc
            _hearthstone = new Hearthstone();

            //create overlay
            _overlay = new OverlayWindow(_config, _hearthstone) { Topmost = true };
            _overlay.Show();

            _playerWindow = new PlayerWindow(_config, _hearthstone.PlayerDeck);
            _opponentWindow = new OpponentWindow(_config, _hearthstone.EnemyCards);

            LoadConfig();

            //find hs directory
            if (!File.Exists(_config.HearthstoneDirectory + @"\Hearthstone.exe"))
            {
                MessageBox.Show("Please specify your Hearthstone directory", "Hearthstone directory not found",
                                MessageBoxButton.OK);
                var dialog = new OpenFileDialog();
                dialog.Title = "Select Hearthstone.exe";
                dialog.DefaultExt = "Hearthstone.exe";
                dialog.Filter = "Hearthstone.exe|Hearthstone.exe";
                var result = dialog.ShowDialog();
                if (result != true)
                {
                    return;
                }
                _config.HearthstoneDirectory = Path.GetDirectoryName(dialog.FileName);
                _xmlManagerConfig.Save("config.xml", _config);
            }

            //log reader
            _logReader = new HsLogReader(_config.HearthstoneDirectory);
            _logReader.CardMovement += LogReaderOnCardMovement;
            _logReader.GameStateChange += LogReaderOnGameStateChange;

            UpdateDbListView();

            _options = new OptionsWindow(_config, _overlay, _xmlManagerConfig, _playerWindow, _opponentWindow);

            _updateThread = new Thread(Update);
            _updateThread.Start();

            _initialized = true;

            UpdateDeckList();
            UseSelectedDeck();

            _logReader.Start();
        }
        public MainWindow()
        {
            InitializeComponent();

            Helper.CheckForUpdates();

            //check for log config and create if not existing
            try
            {
                if (!File.Exists(_logConfigPath))
                {
                    File.Copy("Files/log.config", _logConfigPath);
                }
                else
                {
                    //update log.config if newer
                    var localFile = new FileInfo(_logConfigPath);
                    var file      = new FileInfo("Files/log.config");
                    if (file.LastWriteTime > localFile.LastWriteTime)
                    {
                        File.Copy("Files/log.config", _logConfigPath, true);
                    }
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                Console.WriteLine("Not authorized write " + _logConfigPath + ". Start as admin(?)");
                Console.WriteLine(ex.Message);
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex.Message);
            }

            //load config
            _config           = new Config();
            _xmlManagerConfig = new XmlManager <Config> {
                Type = typeof(Config)
            };
            _config = _xmlManagerConfig.Load("config.xml");

            //load saved decks
            if (!File.Exists("PlayerDecks.xml"))
            {
                //avoid overwriting decks file with new releases.
                using (var sr = new StreamWriter("PlayerDecks.xml", false))
                {
                    sr.WriteLine("<Decks></Decks>");
                }
            }
            _xmlManager = new XmlManager <Decks> {
                Type = typeof(Decks)
            };
            _deckList = _xmlManager.Load("PlayerDecks.xml");

            //add saved decks to gui
            foreach (var deck in _deckList.DecksList)
            {
                ComboBoxDecks.Items.Add(deck.Name);
            }
            ComboBoxDecks.SelectedItem = _config.LastDeck;


            //hearthstone, loads db etc
            _hearthstone = new Hearthstone();



            //create overlay
            _overlay = new OverlayWindow(_config, _hearthstone)
            {
                Topmost = true
            };
            _overlay.Show();

            _playerWindow   = new PlayerWindow(_config, _hearthstone.PlayerDeck);
            _opponentWindow = new OpponentWindow(_config, _hearthstone.EnemyCards);

            LoadConfig();

            //find hs directory
            if (!File.Exists(_config.HearthstoneDirectory + @"\Hearthstone.exe"))
            {
                MessageBox.Show("Please specify your Hearthstone directory", "Hearthstone directory not found",
                                MessageBoxButton.OK);
                var dialog = new OpenFileDialog();
                dialog.Title      = "Select Hearthstone.exe";
                dialog.DefaultExt = "Hearthstone.exe";
                dialog.Filter     = "Hearthstone.exe|Hearthstone.exe";
                var result = dialog.ShowDialog();
                if (result != true)
                {
                    return;
                }
                _config.HearthstoneDirectory = Path.GetDirectoryName(dialog.FileName);
                _xmlManagerConfig.Save("config.xml", _config);
            }

            //log reader
            _logReader = new HsLogReader(_config.HearthstoneDirectory);
            _logReader.CardMovement    += LogReaderOnCardMovement;
            _logReader.GameStateChange += LogReaderOnGameStateChange;


            UpdateDbListView();

            _options = new OptionsWindow(_config, _overlay, _xmlManagerConfig, _playerWindow, _opponentWindow);

            _updateThread = new Thread(Update);
            _updateThread.Start();

            _initialized = true;

            UpdateDeckList();
            UseSelectedDeck();

            _logReader.Start();
        }