public MainWindowViewModel() { hotkeyUtil = new HotkeyUtil(App.Current.MainWindow); //MainWindow should be MainWindow.xaml, per ms documentation OnAnonymizePlayersChanged += MainWindowViewModel_OnAnonymizePlayersChanged; App.Current.Exit += Current_Exit; SettingsVM = new SettingsViewModel(); SettingsVM.OnAutoEndSessionChanged += SettingsVM_OnAutoEndSessionChanged; OpacityVM = new WindowOpacityVM(SettingsVM); RequestInputVM = new RequestUserInputViewModel("Seconds before session auto-ends"); RequestInputVM.UserInputAccepted += RequestInputVM_UserInputAccepted; RequestInputVM.ValidateUserInput += RequestInputVM_ValidateUserInput; RequestInputVM.OnCancelled += RequestInputVM_OnCancelled; UpdateDamageLogsCommand = new RelayCommand <object>((_) => selectDamageLogsPath(true)); ResetTrackerCommand = new RelayCommand <object>((_) => resetParser()); SaveSessionCommand = new RelayCommand <object>((_) => saveSession()); ReselectDamageLogsCommand = new RelayCommand <object>((_) => reselectDamageLogs()); SetAccentColorCommand = new RelayCommand <object>((_) => setAccentColor()); SetBackgroundImageCommand = new RelayCommand <object>((_) => setBackgroundImage()); OpenSessionLogsCommand = new RelayCommand <object>((_) => openSessionLogsFolder()); ExitCommand = new RelayCommand <object>((_) => App.Current.Shutdown()); ChangeAutoEndTimeoutCommand = new RelayCommand <object>((_) => changeAutoEndTimeout()); if (string.IsNullOrWhiteSpace(Settings.Default.DamageLogsPath)) { selectDamageLogsPath(false); } loadSettings(); if (CurrentDamageParser == null) { initializeDamageParser(Settings.Default.DamageLogsPath); } try { CurrentDamageParser.Start(TimeSpan.FromSeconds(Settings.Default.ParserTickRate)); } catch (Exception) { MessageBox.Show("Error starting parser! Ensure the damagelogs folder is correctly set."); Settings.Default.DamageLogsPath = ""; Settings.Default.Save(); } allPlayersTab = new AllPlayersTabViewModel(this); allPlayersTab.UserDoubleClickedEvent += AllPlayersTab_UserDoubleClickedEvent; AllTabs.Add(allPlayersTab); SelectedTab = allPlayersTab; initializeHotkeys(); StatusBarText = $"Welcome to ApexParse v{App.VersionString}"; ClockFormat = new ClockFormatViewModel(); UpdateClockTask(); }
private void resetAllTabs() { lock (tabManipulationLock) { AllTabs.Clear(); allPlayersTab.ClearPlayers(); playerTabDict.Clear(); AllTabs.Add(allPlayersTab); selfPlayerTab = null; } SelectedTab = allPlayersTab; }
private void synchronizeTabState() { lock (tabManipulationLock) { if (selfPlayerTab == null && CurrentDamageParser.SelfPlayer != null) { selfPlayerTab = new GraphPlayerTabVM(this, DetailedDamageVisibleSettings, CurrentDamageParser.SelfPlayer); AllTabs.Insert(1, selfPlayerTab); playerTabDict.Add(CurrentDamageParser.SelfPlayer, selfPlayerTab); selfPlayerTab.SetEnabledLineSeries(LineSeriesSettings.GetEnumValue()); if (OpenGraphForSelfAutomatically) { SelectedTab = selfPlayerTab; } } foreach (var player in CurrentDamageParser.Players) //add { if (DamageParser.IsBlacklistedUsername(player.Name)) { continue; //skip blacklisted } if (!playerTabDict.ContainsKey(player)) { var newTab = new GraphPlayerTabVM(this, DetailedDamageVisibleSettings, player); AllTabs.Add(newTab); playerTabDict.Add(player, newTab); newTab.SetEnabledLineSeries(LineSeriesSettings.GetEnumValue()); } } List <GraphPlayerTabVM> toRemove = new List <GraphPlayerTabVM>(); //remove foreach (var tab in AllTabs.Where(t => t is GraphPlayerTabVM).Cast <GraphPlayerTabVM>()) { if (!CurrentDamageParser.DoesPlayerIdExist(tab.Player.ID)) { toRemove.Add(tab); } } foreach (var rem in toRemove) { AllTabs.Remove(rem); playerTabDict.Remove(rem.Player); } } }