public frmMain() { _message.Add("frmMain loaded"); SetTextOnSplashScreen("Initializing Components"); WOTHelper.SetInternetZone(); InitializeComponent(); repositoryItemRadioGroup2.SelectedIndexChanged += new EventHandler(repositoryItemRadioGroup2_SelectedIndexChanged); repositoryItemRecentBattlesDisplayList.SelectedIndexChanged += new EventHandler(repositoryItemRecentBattlesDisplayList_SelectedIndexChanged); _chart.ObjectHotTracked += new HotTrackEventHandler(_chart_ObjectHotTracked); _browser.ObjectForScripting = this; _message = new MessageQueue(); _message.ItemAdded += new MessageQueue_OnAdd(NewMessage); #if DEBUG _browser.IsWebBrowserContextMenuEnabled = true; #else _browser.IsWebBrowserContextMenuEnabled = false; #endif //dockPanel3.Visibility = DockVisibility.Hidden; //dockPanel4.Visibility = DockVisibility.Hidden; //dockPanelGraph.Visibility = DockVisibility.Hidden; //dockPanel2.Visibility = DockVisibility.Hidden; bar6.Visible = false; bar6.Offset = 0; barLastPlayedGames.Visible = false; barLastPlayedGames.Offset = 0; helpProvider1.HelpNamespace = Path.Combine(WOTHelper.GetEXEPath(), "Help", "WoT_Stats.chm"); //ScriptWrapper.Initialise(WOTHelper.GetCustomScript()); using (PlayerListing players = new PlayerListing(_message)) { if (players.Count() > 0) { string errorMessage = ""; foreach (KeyValuePair<string, Player> player in players) { SetTextOnSplashScreen("Initializing Dossier of " + player.Value.PlayerID); if (!File.Exists(player.Value.WatchFile)) { string dir = player.Value.WatchFile.Remove(player.Value.WatchFile.LastIndexOf('\\')); if (Directory.Exists(dir)) { foreach (FileInfo item in new DirectoryInfo(dir).GetFiles().Where(x => x.Extension.ToLower() == ".dat")) { if (WOTHelper.PlayerIdFromDatFile(item.Name) == player.Value.PlayerID) { player.Value.WatchFile = item.FullName; players.SetPlayerWatchFile(player.Value.PlayerID, item.FullName); players.Save(); break; } } } } if (File.Exists(player.Value.WatchFile)) { DossierManager dm = new DossierManager(player.Value.PlayerID, player.Value.WatchFile, player.Value.Monitor, _message, this); dm.CurrentFileChange += DossierFileChanged; dictPlayers.Add(player.Value.PlayerID.Replace("_", "*"), dm); //try //{ _currentStatsFile.Add(player.Value.PlayerID.Replace("_", "*"), new WOTCompare(new Dossier(dm.GetFileB(), dm.GetPlayerName, _message).GetStats(), new Dossier(dm.GetFileA(), dm.GetPlayerName, _message).GetStats())); dm.RefreshDossier(); //} //catch (Exception ex) //{ // _message.Add("Error: cannot refresh dossier file. - " + ex.Message); //} //BarButtonItem buttonOpen = new BarButtonItem(barManager1, player.Value.PlayerID); //buttonOpen.ItemClick += new ItemClickEventHandler(buttonOpen_ItemClick); //buttonOpen.Name = player.Value.PlayerID; //barCompare.AddItem(buttonOpen); CreatePlayerMenu(player.Value.PlayerID); SetTextOnSplashScreen("Initializing Monitor"); if (UserSettings.StartMonOnStartUp == true) { dm.StartDossierWatch(); barStaticItem1.Glyph = WOTStatistics.Stats.Properties.Resources.bullet_square_green; barStaticItem1.Caption = "Monitor Status : Running"; } else { barStaticItem1.Glyph = WOTStatistics.Stats.Properties.Resources.bullet_square_red; barStaticItem1.Caption = "Monitor Status : Stopped"; } } else { // _HasPlayerError = true; if (errorMessage.Length > 1) errorMessage += Environment.NewLine + Environment.NewLine; errorMessage += Translations.TranslationGet("STR_PLAYERERROR", "DE", "Dossier file not found for player : " + player.Value.PlayerID + Environment.NewLine + "Please check the dossier file location on the edit player screen in setup." + Environment.NewLine + "Player not loaded.").Replace("{playerid}", player.Value.PlayerID); } if (errorMessage.Length > 1) DevExpress.XtraEditors.XtraMessageBox.Show(errorMessage, "WOT Statistics", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } try { if (splashScreenManagerWaitForm.IsSplashFormVisible) { splashScreenManagerWaitForm.CloseWaitForm(); } } catch {} // if (splashScreenManagerWaitForm.IsSplashFormVisible) //splashScreenManagerWaitForm.CloseWaitForm(); _message.Add("frmMain DONE"); try { DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm(); } catch { } }
private void PlayerRefresh() { try { splashScreenManagerWaitForm.ShowWaitForm(); } catch { } using (PlayerListing pl = new PlayerListing(_message)) { if (pl.Count() == dictPlayers.Count) { foreach (DossierManager item in dictPlayers.Values) { Player player = pl.GetPlayer(item.GetPlayerName); if (item.WatchPath != player.WatchFile || item.FTPFileFetch != (player.Monitor.ToUpper() == "YES" ? true : false)) { item.SetValues(player.WatchFile, player.Monitor.ToUpper() == "YES" ? true : false); _currentStatsFile[player.PlayerID.Replace("_", "*")] = new WOTCompare(new Dossier(item.GetFileB(), item.GetPlayerName, _message).GetStats(), new Dossier(item.GetFileA(), item.GetPlayerName, _message).GetStats()); item.RefreshDossier(); } } } else { if (pl.Count() > dictPlayers.Count) { foreach (KeyValuePair<string, Player> player in pl) { if (!dictPlayers.ContainsKey(player.Value.PlayerID.Replace("_", "*"))) { DossierManager dm = new DossierManager(player.Value.PlayerID, player.Value.WatchFile, player.Value.Monitor, _message, this); dm.CurrentFileChange += new DossierManager_CurrentFileChanged(DossierFileChanged); dm.StartDossierWatch(); dictPlayers.Add(player.Value.PlayerID.Replace("_", "*"), dm); _currentStatsFile.Add(player.Value.PlayerID.Replace("_", "*"), new WOTCompare(new Dossier(dm.GetFileB(), dm.GetPlayerName, _message).GetStats(), new Dossier(dm.GetFileA(), dm.GetPlayerName, _message).GetStats())); dm.RefreshDossier(); CreatePlayerMenu(player.Value.PlayerID); } } } else { List<string> keysToRemove = new List<string>(); foreach (KeyValuePair<string, DossierManager> item in dictPlayers) { if (pl.GetPlayer(item.Value.GetPlayerName).PlayerID == "Unknown") { keysToRemove.Add(item.Key); _currentStatsFile.Remove(item.Key); navBarControl1.Groups.Remove(navBarControl1.Groups[item.Value.GetPlayerName]); } } foreach (string key in keysToRemove) { dictPlayers.Remove(key); } _currentPlayer = ""; _currentPage = ""; } } } if (_currentPlayer == "") { try { navBarControl1.Groups[0].Expanded = true; navBarControl1.Groups[0].ItemLinks[0].PerformClick(); navBarControl1.Groups[0].SelectedLink = navBarControl1.Groups[0].ItemLinks[0]; } catch { if (panelControl1.Controls.Contains(_chart)) { panelControl1.Controls.Remove(_chart); panelControl1.Controls.Add(_browser); _browser.Dock = DockStyle.Fill; } bar3.Visible = false; bar3.Offset = 0; dockPanel2.Visible = false; bar5.Visible = false; bar5.Offset = 0; dockPanelGraph.Visible = false; barLastPlayedGames.Visible = false; barLastPlayedGames.Offset = 0; _browser.DocumentText = new WOTHtml(_message).Blank(); } } else { if (_currentPage != "Compare") CreateWebPage(_currentPage, _currentPlayer); } try { if (splashScreenManagerWaitForm.IsSplashFormVisible) { splashScreenManagerWaitForm.CloseWaitForm(); } } catch { } }