private void StartButton_Click(object sender, EventArgs e) { // Работа со списком серверов string tmp = localIPCoboBox.Text; int index = cfg.FindIP(tmp); ComboBoxRow item = new ComboBoxRow(tmp); if (index != -1) { item = (ComboBoxRow)localIPCoboBox.Items[index]; localIPCoboBox.Items.RemoveAt(index); cfg.Servers.RemoveAt(index); } localIPCoboBox.Items.Add(item); cfg.Servers.Add(item); if (localIPCoboBox.Items.Count > 0) { localIPCoboBox.Text = localIPCoboBox.Items[localIPCoboBox.Items.Count - 1].ToString(); } ConfigManager.SaveConfigData(cfg); // Запуск клиента string[] temp = localIPCoboBox.Text.Split(':'); string ip = temp[0]; int port = Convert.ToInt32(temp[1]); int timeout = Convert.ToInt32(timeoutTextBox.Text); ScreenViewers.Add(new ScreenViewer((int)qualityVal.Value, ip, port, timeout)); ScreenViewers[ScreenViewers.Count - 1].Show(); }
private async void CheckServers() { UpdateServersStripMenuItem.Enabled = false; ComboBoxRow[] rows = new ComboBoxRow[localIPCoboBox.Items.Count]; localIPCoboBox.Items.CopyTo(rows, 0); foreach (ComboBoxRow item in rows) { string[] temp = item.ToString().Split(':'); item.isAvailable = await Task.Factory.StartNew <bool>( () => SynchronousClient.CheckServer(temp[0], Convert.ToInt32(temp[1])), TaskCreationOptions.LongRunning); } UpdateServersStripMenuItem.Enabled = true; }
private void LocalIPCoboBox_DrawItem(object sender, DrawItemEventArgs e) { ComboBoxRow item = (ComboBoxRow)localIPCoboBox.Items[e.Index]; e.DrawBackground(); Brush b = Brushes.Black; if (item.isAvailable) { b = Brushes.ForestGreen; } e.Graphics.DrawString(item.Name != "" ? item.Name + " || " + item.IP : item.IP, e.Font, b, e.Bounds); }