Ejemplo n.º 1
0
        private void ContextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var selectedItems      = BotList.SelectedItems;
            var selectedBotsTokens = new List <string>();

            foreach (var selectedBot in selectedItems)
            {
                int idx   = BotList.Items.IndexOf(selectedBot as ListViewItem);
                var token = BotList.Items[idx].Text;
                selectedBotsTokens.Add(token);
            }

            switch (e.ClickedItem.Text)
            {
            case "Запустить":
            {
                var args = new LaunchSeveralBotsArgs()
                {
                    BotsTokens = selectedBotsTokens
                };
                OnLaunchContextMenuItemClick?.Invoke(sender, args);
                break;
            }

            case "Остановить":
            {
                var args = new StopSeveralBotsArgs()
                {
                    BotsTokens = selectedBotsTokens
                };
                OnStopContextMenuItemClick?.Invoke(sender, args);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        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();
        }