Пример #1
0
        private void OpenLogFile(LogOption option, string previousFile = null, int lastMins = -1)
        {
            CurrentLogOption = option;

            try
            {
                string theFile;
                bool   success = true;
                if (previousFile != null)
                {
                    theFile = previousFile;
                }
                else
                {
                    // WPF doesn't have its own file chooser so use Win32 Version
                    Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog
                    {
                        // filter to txt files
                        DefaultExt = ".txt",
                        Filter     = "eqlog_Player_server (.txt .txt.gz)|*.txt;*.txt.gz",
                    };

                    // show dialog and read result
                    success = dialog.ShowDialog() == true;
                    theFile = dialog.FileName;
                }


                if (success)
                {
                    StopProcessing();
                    CastProcessor    = new ActionProcessor <LineData>("CastProcessor", CastLineParser.Process);
                    DamageProcessor  = new ActionProcessor <LineData>("DamageProcessor", DamageLineParser.Process);
                    HealingProcessor = new ActionProcessor <LineData>("HealProcessor", HealingLineParser.Process);
                    MiscProcessor    = new ActionProcessor <LineData>("MiscProcessor", MiscLineParser.Process);

                    fileText.Text = "-- " + theFile;
                    StartLoadTime = DateTime.Now;
                    FilePosition  = LineCount = 0;
                    DebugUtil.Reset();

                    string name   = "You";
                    string server = "Uknown";
                    if (theFile.Length > 0)
                    {
                        LOG.Info("Selected Log File: " + theFile);

                        string          file    = Path.GetFileName(theFile);
                        MatchCollection matches = ParseFileName.Matches(file);
                        if (matches.Count == 1)
                        {
                            if (matches[0].Groups.Count > 1)
                            {
                                name = matches[0].Groups[1].Value;
                            }

                            if (matches[0].Groups.Count > 2)
                            {
                                server = matches[0].Groups[2].Value;
                            }
                        }
                    }

                    var changed = ConfigUtil.ServerName != server;
                    if (changed)
                    {
                        PetPlayersView.Clear();
                        VerifiedPetsView.Clear();
                        VerifiedPlayersProperty.Clear();
                        verifiedPetsWindow.Title    = string.Format(CultureInfo.CurrentCulture, PETS_LIST_TITLE, VerifiedPetsView.Count);
                        verifiedPlayersWindow.Title = string.Format(CultureInfo.CurrentCulture, PLAYER_LIST_TITLE, VerifiedPlayersProperty.Count);
                        PlayerManager.Instance.Save();
                    }

                    ConfigUtil.ServerName = server;
                    ConfigUtil.PlayerName = name;

                    if (changed)
                    {
                        PlayerManager.Instance.Clear();
                    }

                    DataManager.Instance.Clear();
                    PlayerChatManager = new ChatManager();

                    CurrentLogFile = theFile;
                    NpcDamageManager.ResetTime();
                    EQLogReader = new LogReader(theFile, FileLoadingCallback, CurrentLogOption == LogOption.MONITOR, lastMins);
                    EQLogReader.Start();
                    UpdateLoadingProgress();
                }
            }
            catch (Exception e)
            {
                if (!(e is InvalidCastException || e is ArgumentException || e is FormatException))
                {
                    throw;
                }
            }
        }