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; }
/* * METHOD : selectAllButton_Click() * * DESCRIPTION : Select all clients in the list box. For a broadcast chat. * Will update the broad cast chat tab with graphical notifications depending on which packet is determining * the message type. * * RETURNS : N/A */ private void selectAllButton_Click(object sender, RoutedEventArgs e) { if (ClientListBox.Items.Count > 0) { BroadcastChatTab.Focus(); BroadcastChatTab.Foreground = new SolidColorBrush(Colors.Goldenrod); PrivateChatTab.Foreground = new SolidColorBrush(Colors.Black); GroupChatTab.Foreground = new SolidColorBrush(Colors.Black); ClientListBox.SelectAll(); // enable button SendButton.IsEnabled = true; // Prepares for a broadcast chat - text all users on all computers on the same server. Array clientSelected = Array.CreateInstance(typeof(string), ClientListBox.SelectedItems.Count); ClientListBox.SelectedItems.CopyTo(clientSelected, 0); for (int i = 0; i < ClientListBox.Items.Count; i++) { guiPacketBuffer.RequestToChat = guiPacketBuffer.RequestToChat + clientSelected.GetValue(i); if (i < (clientSelected.Length - 1)) { guiPacketBuffer.RequestToChat = guiPacketBuffer.RequestToChat + "|"; } guiPacketBuffer.MessageType = "B"; // signals broadcast chat type } } else { MessageBox.Show("You must have online clients in your queue in order to send a message."); } }
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 StartServer(int port) { server.Start(port); ServerStartButton.Invoke(new Action(() => { ServerStartButton.Text = "Stop server"; ClientSettingsPanel.Show(); selectedClient = GetlocalhostInfo(); ClientListBox.Show(); UpdateClientList(); RedrawClientSettings(); ReadServerSettings(); })); }
private void ClientListBox_MouseDoubleClick(object sender, MouseEventArgs e) { int index = ClientListBox.IndexFromPoint(e.Location); if (index != ListBox.NoMatches) { var client = (Client)ClientListBox.Items[index]; var form = new AppointmentForm(client, Workers); form.Show(); } }
/* * METHOD : Deselect_Click() * * DESCRIPTION : Deselects all clients that have been selected in the * list box. * * RETURNS : N/A */ private void Deselect_Click(object sender, RoutedEventArgs e) { if (ClientListBox.Items.Count > 0) { ClientListBox.UnselectAll(); } else { MessageBox.Show("You must have online clients in your queue in order to send a message."); } }
private void StopServer() { server.Stop(); ServerStartButton.Invoke(new Action(() => { ServerStartButton.Text = "Start server"; ClientListBox.Hide(); for (int i = 0; i < SettingsCheckedListBox.Items.Count; i++) { SettingsCheckedListBox.SetItemChecked(i, false); } UpdateClientList(); RedrawClientSettings(); })); }
private void ClientListBox_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { int iIndex = ClientListBox.IndexFromPoint(e.Location); if (iIndex != ListBox.NoMatches) { ConnectedClientInfo info = ClientListBox.Items[iIndex] as ConnectedClientInfo; selectedClient = info; ClientSettingsPanel.Show(); //UpdateClientList(); RedrawClientSettings(); } }
private void PopulateClientListBox() { var custRep = new ClientRepository(Context); CustomerList = custRep.GetAll(cl => cl.State).ToList(); ClientListBox.Items.Clear(); foreach (var cust in CustomerList) { ClientListBox.Items.Add($"{cust.Name} | {cust.Email} | {cust.PhoneNumber}"); } ClientListBox.Refresh(); }
private void CustomerSearchBar_TextChanged(object sender, EventArgs e) { var custRep = new ClientRepository(Context); if (CustomersSearchBar.Text != "") { CustomerList = custRep.Search(CustomersSearchBar.Text); ClientListBox.Items.Clear(); foreach (var cust in CustomerList) { ClientListBox.Items.Add($"{cust.Name} | {cust.Email} | {cust.PhoneNumber}"); } ClientListBox.Refresh(); } else { CustomerList = custRep.GetAll(cl => cl.State).ToList(); PopulateClientListBox(); } }