private void SetupFileMonitor() { var mon = new FileMonitor(); //TODO Temporary solution to run on main thread. Refactor filemon to use TPL in order to achieve this mon.BattleLobbyCreated += (_, e) => RunOnMainThread(() => ProcessLobbyFile(e.Data)); mon.RejoinFileCreated += (_, e) => RunOnMainThread(() => ProcessRejoinFile(e.Data)); mon.ReplayFileCreated += (_, e) => RunOnMainThread(() => ProcessReplayFile(e.Data)); mon.StartMonitoring(); }
public SettingsWindow() { if (Settings.UpgradeRequired) { Settings.Upgrade(); Settings.UpgradeRequired = false; Settings.Save(); } InitializeComponent(); var v = Assembly.GetExecutingAssembly().GetName().Version; Title = $"HotsStats v{v.Major}.{v.Minor}"; if (Settings.SettingsWindowTop <= 0) { WindowStartupLocation = WindowStartupLocation.CenterScreen; } var mon = new FileMonitor(); mon.BattleLobbyCreated += (o, e) => Dispatcher.BeginInvoke(new Action(() => { ProcessLobbyFile(e.Data); })); mon.RejoinFileCreated += (o, e) => Dispatcher.BeginInvoke(new Action(() => { ProcessRejoinFile(e.Data); })); mon.ReplayFileCreated += (o, e) => Dispatcher.BeginInvoke(new Action(() => { ProcessReplayFile(e.Data); })); mon.StartMonitoring(); hotKey = new HotKey(Key.Tab, KeyModifier.Shift | KeyModifier.NoRepeat); hotKey.Pressed += (o, e) => { if (currentWindow != null) { currentWindow.Visibility = currentWindow.IsVisible ? Visibility.Collapsed : Visibility.Visible; } }; Closing += (o, e) => { Settings.Save(); Application.Current.Shutdown(); }; }
public SettingsWindow() { SetExceptionHandlers(); this.ShowActivated = false; logger.Info("App started"); if (Settings.UpgradeRequired) { Settings.Upgrade(); Settings.UpgradeRequired = false; Settings.Save(); } InitializeComponent(); var v = Assembly.GetExecutingAssembly().GetName().Version; Title = $"HotsStats v{v.Major}.{v.Minor}" + (v.Build == 0 ? "" : $".{v.Build}"); if (Settings.SettingsWindowTop <= 0) { WindowStartupLocation = WindowStartupLocation.CenterScreen; } GameModeCombo.ItemsSource = new List <GameMode> { GameMode.QuickMatch, GameMode.HeroLeague, GameMode.TeamLeague }; icon = new System.Windows.Forms.NotifyIcon(); icon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); icon.Visible = false; icon.Click += (o, e) => { Show(); WindowState = WindowState.Normal; icon.Visible = false; }; var mon = new FileMonitor(); mon.BattleLobbyCreated += (o, e) => Dispatcher.BeginInvoke(new Action(() => { ProcessLobbyFile(e.Data); })); mon.RejoinFileCreated += (o, e) => Dispatcher.BeginInvoke(new Action(() => { ProcessRejoinFile(e.Data); })); mon.ReplayFileCreated += (o, e) => Dispatcher.BeginInvoke(new Action(() => { ProcessReplayFile(e.Data); })); mon.StartMonitoring(); hotKey = new HotKey(Key.Tab, KeyModifier.Shift | KeyModifier.NoRepeat); hotKey.Pressed += (o, e) => { if (currentWindow != null) { currentWindow.Visibility = currentWindow.IsVisible ? Visibility.Collapsed : Visibility.Visible; } }; Closed += (o, e) => { Settings.Save(); updateManager?.Dispose(); }; if (!App.Debug && Settings.AutoUpdate) { CheckForUpdates(); } }