private void SetupDatabaseToolStripMenuItemClick(object sender, EventArgs e)
        {
            var form = new FormDatabase();

            form.Init(_database);
            if (form.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            _database      = new Database().Read();;
            _pokerDatabase = IoC.Resolve <DatabaseResolver>().Resolve(_database);
            try
            {
                StartWorking(1);
                _pokerDatabase.PokerSite(_pokersite);
                _gametypes = _pokerDatabase.ReadGametypes().ToList();
                InitializeMenu();
            }
            catch (Exception exception)
            {
                MessageBox.Show(this, @"Error while reading gametypes from the database", @"Error reading from database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var errorForm = new FormError(exception);
                errorForm.Show();
            }
            finally
            {
                StopWorking();
            }
        }
        private void LoadPlayersFromDatabase(IList <GameType> gameTypes, bool tourney, bool allPlayer)
        {
            try
            {
                if (Properties.Settings.Default.NotesFile == string.Empty)
                {
                    MissingNotes(false);
                    return;
                }
                if (_pokerDatabase == null)
                {
                    MessageBox.Show(this, @"You do not have a database, please setup database first", @"No database", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                _unsavedNotes = true;
                StartWorking(_notes.Count);
                //_formWork.Subscribe(_pokerDatabase);

                var players = allPlayer || gameTypes == null?_pokerDatabase.ReadPlayer().ToList() : _pokerDatabase.ReadPlayer(gameTypes, tourney).ToList();

                _formWork.InitMaximum(players.Count(), null);

                var singlePlayerRating = IoC.Resolve <SinglePlayerRating>();
                singlePlayerRating.Parameters(_ratings.ToList(), _labels, _database, _pokersite, Properties.Settings.Default.AutorateText);

                _players.DefaultLabel = _labels.FirstOrDefault(s => s.Name == "No Label");
                foreach (var player in players)
                {
                    player.Label = _players.DefaultLabel;
                    singlePlayerRating.Rate(player);
                    _players.Add(player);
                    _formWork.Step();
                }
                _notes = _players.Playerslist;

                InitializeListView(_notes);
                StopWorking();
            }
            catch (Exception exception)
            {
                MessageBox.Show(this, @"Error while reading playerstats from the database", @"Error reading from database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var errorForm = new FormError(exception);
                errorForm.Show();
                return;
            }
            MessageBox.Show(this, @"Playerstats successful retrieved from database", @"Reading successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void FormMainLoad(object sender, EventArgs e)
        {
            Database datenbank = null;

            try
            {
                var checkUpdates = Properties.Settings.Default.CheckUpdates;
                if (checkUpdates)
                {
                    checkForUpdatesToolStripMenuItem.Checked = true;
                    UpdateChecker();
                }
                textBoxSearch.Select();

                //iniatialize notes
                var notes = Properties.Settings.Default.NotesFile;
                if (string.IsNullOrEmpty(notes))
                {
                    MissingNotes(false);
                    return;
                }
                if (!File.Exists(notes))
                {
                    MissingNotes(true);
                    return;
                }
                _pokersiteNotes = IoC.Resolve <NoteFileResolver>().Resolve(notes);
                if (_pokersiteNotes.GetType() == typeof(PartyPokerNotes))
                {
                    ButtonLabel.Enabled       = false;
                    buttonAddLabel.Enabled    = false;
                    buttonDeleteLabel.Enabled = false;
                    TextBoxLabel.Enabled      = false;
                    _pokersite = PokerSiteEnum.Partypoker;
                }
                else
                {
                    ButtonLabel.Enabled       = true;
                    buttonAddLabel.Enabled    = true;
                    buttonDeleteLabel.Enabled = true;
                    TextBoxLabel.Enabled      = true;
                    _pokersite = PokerSiteEnum.Pokerstars;
                }

                //iniatialize database
                StartWorking(0);
                _database = new Database().Read() ?? new Database {
                    Server = "localhost", Port = "5432"
                };
                _pokerDatabase = IoC.Resolve <DatabaseResolver>().Resolve(_database);
                if (_pokerDatabase != null)
                {
                    _pokerDatabase.PokerSite(_pokersite);
                    _gametypes = _pokerDatabase.ReadGametypes().ToList();
                }

                _ratings = _ratingDefinitions.Read(Properties.Settings.Default.DefinitionFile) ?? new List <Rating>();
                ReadLabelsPlayers();
                InitializeLabels();
                InitializeListView(_notes);
                InitializeMenu();
            }
            catch (Exception exception)
            {
                MessageBox.Show(this, @"Error while initializing", @"Error initialize", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var errorForm = new FormError(exception);
                errorForm.Show();
            }
            finally
            {
                StopWorking();
            }
        }