private static void StopBots(IEnumerable <string> tokens = null) { int total = Bots.Count(); int count = 0; foreach (var tBot in Bots.Keys) { tBot.StopReceiving(); Bots[tBot].Status = BotStatus.Offline; count++; BotStopped?.Invoke(null, new BotStoppedArgs(Bots[tBot], (double)count / total * 100)); } }
public static void Init() { Form = new MainForm(); Form.OnLaunchAllButtonClick += delegate(object sender, EventArgs e) { OnLaunchAllButtonClick?.Invoke(sender, null); }; Form.OnClientsButtonClick += delegate(object sender, EventArgs e) { OnClientsButtonClick?.Invoke(sender, null); }; Form.OnStopAllButtonClick += delegate(object sender, EventArgs e) { OnStopAllButtonClick?.Invoke(sender, null); }; Form.OnLaunchContextMenuItemClick += delegate(object sender, LaunchSeveralBotsArgs e) { OnLaunchContextMenuItemClick?.Invoke(sender, e); }; Form.OnStopContextMenuItemClick += delegate(object sender, StopSeveralBotsArgs e) { OnStopContextMenuItemClick?.Invoke(sender, e); }; Form.Show(); DBHelper.CheckDB(); BotController.BotLaunched += delegate(object sender, BotLaunchedArgs e) { BotLaunched?.Invoke(sender, e); }; BotController.BotStopped += delegate(object sender, BotStoppedArgs e) { BotStopped?.Invoke(sender, e); }; BotController.BotChecked += delegate(object sender, BotCheckedArgs e) { BotChecked?.Invoke(sender, e); }; BotController.Init(); ClientController.Init(); Form.Hide(); Form.ShowDialog(); }