/// <summary>
        /// Registeres a new File to the Storage.
        /// </summary>
        /// <param name="file"></param>
        public void RegisterFile(string file)
        {
            lock (this)
            {
                if (scannedFiles.Contains(file.ToLower()))
                {
                    return;
                }

                // Kick den alten
                if (configuration.KnownFiles.Contains(file.ToLower()))
                {
                    UnregisterFile(file);
                }

                var result = AiAnalysis.Analyse(file, true);

                if (result.Count > 0)
                {
                    configuration.KnownFiles.Add(file.ToLower());
                    foreach (var player in result)
                    {
                        var playerInfo = new PlayerInfoFilename(player, file.ToLower());
                        knownPlayer.Add(playerInfo);
                    }
                }

                SaveConfiguration();
            }
        }
        /// <summary>
        /// Adds all included Player without adding to the registered files.
        /// </summary>
        /// <param name="file"></param>
        private void ScanFile(string file)
        {
            try
            {
                var result = AiAnalysis.Analyse(file.ToLower(), false);
                foreach (var player in result)
                {
                    knownPlayer.Add(new PlayerInfoFilename(player, file));
                }

                scannedFiles.Add(file.ToLower());
            }
            catch (Exception) { throw; }
        }
Beispiel #3
0
        /// <summary>
        /// Loads all players from filename and add them to the global player-list.
        /// </summary>
        /// <param name="filename">filename</param>
        /// <param name="knownOnly">if only known players should be added</param>
        /// <returns>true, if there was no Exception</returns>
        /// <param name="silent">starts silent start without error-messages</param>
        private List <PlayerInfoFilename> loadPlayerFile(string filename, bool knownOnly, bool silent)
        {
            List <PlayerInfo>         foundPlayers = new List <PlayerInfo>();
            List <PlayerInfoFilename> output       = new List <PlayerInfoFilename>();

            try {
                FileInfo file = new FileInfo(filename.ToLower());

                // Load playerinfo
                try {
                    foundPlayers.AddRange(AiAnalysis.Analyse(file.FullName, false));
                }
                catch (Exception ex) {
                    if (!silent)
                    {
                        showException(ex);
                    }
                    return(output);
                }

                // Add found players
                if (foundPlayers.Count > 0)
                {
                    if (!config.knownPlayerFiles.Contains(file.FullName))
                    {
                        config.knownPlayerFiles.Add(file.FullName);
                    }
                    bool found = false;
                    foreach (PlayerInfo playerInfo in foundPlayers)
                    {
                        PlayerInfoFilename info = new PlayerInfoFilename(playerInfo, file.FullName);
                        output.Add(info);

                        if (!players.Contains(info))
                        {
                            if (knownOnly)
                            {
                                if (!config.knownPlayer.Contains(info.GetHashCode()))
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                if (!config.knownPlayer.Contains(info.GetHashCode()))
                                {
                                    config.knownPlayer.Add(info.GetHashCode());
                                }
                            }
                            players.Add(info);
                            found = true;
                        }
                    }

                    if (!found && !knownOnly && !silent)
                    {
                        MessageBox.Show(
                            this,
                            string.Format(Resource.SimulatorPluginTeamSetupStillLoaded, file.FullName),
                            Resource.SimulationPluginMessageBoxTitle,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (!silent)
                    {
                        MessageBox.Show(
                            this,
                            string.Format(Resource.SimulatorPluginTeamSetupNoFolksFound, file.FullName),
                            Resource.SimulationPluginMessageBoxTitle,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex) {
                showException(
                    new Exception(
                        string.Format(
                            Resource.SimulatorPluginTeamSetupFileloadException,
                            filename,
                            ex.Message),
                        ex));
            }

            UpdatePanel();
            return(output);
        }