private void UpdateClientList() { if (ClientListBox.InvokeRequired) { ClientListBox.Invoke(new Action(() => { UpdateClientList(); })); return; } ClientListBox.Items.Clear(); if (server == null || !server.Running) { return; } foreach (ConnectedClientInfo client in server.GetClients()) { ClientListBox.Items.Add(client); } if (selectedClient == null) { ClientSettingsPanel.Hide(); } }
private void MainForm_Load(object sender, EventArgs e) { this.KeyPreview = true; this.KeyDown += MainForm_KeyDown; ConsoleTextBox.BackColor = SystemColors.ControlLightLight; this.MaximizeBox = false; ISLogger.MessageOut += ISLogger_MessageOut; server.ClientConnected += Server_ClientConnected; server.ClientDisconnected += Server_ClientDisconnected; server.InputClientSwitched += Server_InputClientSwitched; server.ServerStopped += Server_ServerStopped; server.DisplayConfigChanged += Server_DisplayConfigChanged; ClientListBox.MouseClick += ClientListBox_MouseClick; LeftClientListBox.SelectionChangeCommitted += LeftClientListBox_SelectionChangeCommitted; RightClientListBox.SelectionChangeCommitted += RightClientListBox_SelectionChangeCommitted; AboveClientListBox.SelectionChangeCommitted += AboveClientListBox_SelectionChangeCommitted; BelowClientListBox.SelectionChangeCommitted += BelowClientListBox_SelectionChangeCommitted; ClientListBox.Hide(); ClientSettingsPanel.Hide(); trayIcon = new NotifyIcon(); try { trayIcon.Icon = new Icon("TrayIcon.ico"); }catch (Exception ex) { ISLogger.Write($"Failed to open TrayIcon.ico"); ISLogger.Write(ex.Message); } trayIcon.Visible = true; trayIcon.Click += TrayIcon_Click; }
private void Server_ServerStopped(object sender, EventArgs e) { if (this.InvokeRequired) { this.Invoke(new Action(() => { Server_ServerStopped(sender, e); })); return; } ServerPortTextBox.Visible = true; ServerStartButton.Text = "Start server"; ClientSettingsPanel.Hide(); UpdateClientList(); RedrawClientSettings(); }