private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { StatusLabel.Content = String.Format("XDistance:{0} YPos:{1}",bot.myState.XDistance,bot.enemyState.Y); if (log.Count == 0 || !log[0].Message.Equals(bot.getStatus()) ) { var le = new LogEntry(); le.Message = bot.getStatus(); le.BotScriptInfo = String.Format("{0}:{1} - {2}{3}", bot.myState.ScriptName, bot.myState.ScriptFrame, bot.myState.State, bot.myState.StateTimer); le.EnemyScriptInfo = String.Format("{0}:{1} - {2}{3}", bot.enemyState.ScriptName, bot.enemyState.ScriptFrame, bot.enemyState.State, bot.enemyState.StateTimer); log.Insert(0, le); Log.Items.Refresh(); } while (log.Count > 200) log.RemoveAt(log.Count - 1); RefreshBotData(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { HotKeyHost hotKeyHost = new HotKeyHost((HwndSource)HwndSource.FromVisual(App.Current.MainWindow)); hotKeyHost.AddHotKey(new CustomHotKey("ToggleOverlay", Key.F1, ModifierKeys.None, true,this)); hotKeyHost.AddHotKey(new CustomHotKey("ToggleBot", Key.F2, ModifierKeys.None, true, this)); hotKeyHost.AddHotKey(new CustomHotKey("ChangeBotMode", Key.F3, ModifierKeys.None, true, this)); backgroundWorker.WorkerReportsProgress = true; backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += backgroundWorker_DoWork; backgroundWorker.ProgressChanged += backgroundWorker_ProgressChanged; LoadBots(); var le = new LogEntry(); le.BotScriptInfo = "init"; le.EnemyScriptInfo = "init"; le.Message = "Loaded!"; log.Insert(0, le); System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 5); // dispatcherTimer.Start(); }