From 82abd35282a7afa5987eb3adf4efda8af171bbff Mon Sep 17 00:00:00 2001 From: MaxXor Date: Thu, 9 Jul 2015 21:16:21 +0200 Subject: [PATCH] Added more documentation to main form. not complete yet --- Server/Core/Commands/ConnectionHandler.cs | 4 +- Server/Core/Commands/MiscHandler.cs | 2 +- Server/Forms/FrmMain.cs | 56 ++++++++++++++++++++--- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/Server/Core/Commands/ConnectionHandler.cs b/Server/Core/Commands/ConnectionHandler.cs index 01101f93..ee36eff2 100644 --- a/Server/Core/Commands/ConnectionHandler.cs +++ b/Server/Core/Commands/ConnectionHandler.cs @@ -64,12 +64,12 @@ namespace xServer.Core.Commands public static void HandleStatus(Client client, Status packet) { - FrmMain.Instance.SetClientStatus(client, packet.Message); + FrmMain.Instance.SetStatusByClient(client, packet.Message); } public static void HandleUserStatus(Client client, UserStatus packet) { - FrmMain.Instance.SetClientUserStatus(client, packet.Message); + FrmMain.Instance.SetUserStatusByClient(client, packet.Message); } } } \ No newline at end of file diff --git a/Server/Core/Commands/MiscHandler.cs b/Server/Core/Commands/MiscHandler.cs index 210356a4..3e6b6387 100644 --- a/Server/Core/Commands/MiscHandler.cs +++ b/Server/Core/Commands/MiscHandler.cs @@ -51,7 +51,7 @@ namespace xServer.Core.Commands if (client.Value.FrmFm == null) { - FrmMain.Instance.SetClientStatus(client, "Download aborted, please keep the File Manager open."); + FrmMain.Instance.SetStatusByClient(client, "Download aborted, please keep the File Manager open."); new Packets.ServerPackets.DownloadFileCanceled(packet.ID).Execute(client); return; } diff --git a/Server/Forms/FrmMain.cs b/Server/Forms/FrmMain.cs index c48d965b..0c469834 100644 --- a/Server/Forms/FrmMain.cs +++ b/Server/Forms/FrmMain.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Windows.Forms; -using xServer.Core; using xServer.Core.Commands; using xServer.Core.Extensions; using xServer.Core.Helper; @@ -232,13 +231,18 @@ namespace xServer.Forms PacketHandler.HandlePacket(client, packet); } + /// + /// Sets the tooltip text of the listview item of a client. + /// + /// The client on which the change is performed. + /// The new tooltip text. public void SetToolTipText(Client c, string text) { try { lstClients.Invoke((MethodInvoker) delegate { - var item = GetListviewItemOfClient(c); + var item = GetListViewItemByClient(c); if (item != null) item.ToolTipText = text; }); @@ -248,6 +252,10 @@ namespace xServer.Forms } } + /// + /// Adds a connected client to the Listview. + /// + /// The client to add. public void AddClientToListview(ListViewItem clientItem) { try @@ -270,6 +278,10 @@ namespace xServer.Forms } } + /// + /// Removes a connected client from the Listview. + /// + /// The client to remove. public void RemoveClientFromListview(Client c) { try @@ -294,13 +306,18 @@ namespace xServer.Forms } } - public void SetClientStatus(Client c, string text) + /// + /// Sets the status of a client. + /// + /// The client to update the status of. + /// The new status. + public void SetStatusByClient(Client c, string text) { try { lstClients.Invoke((MethodInvoker) delegate { - var item = GetListviewItemOfClient(c); + var item = GetListViewItemByClient(c); if (item != null) item.SubItems[STATUS_ID].Text = text; }); @@ -310,13 +327,21 @@ namespace xServer.Forms } } - public void SetClientUserStatus(Client c, string text) + /// + /// Sets the user status of a client. + /// + /// + /// Can be "Active" or "Idle". + /// + /// The client to update the user status of. + /// The new user status. + public void SetUserStatusByClient(Client c, string text) { try { lstClients.Invoke((MethodInvoker) delegate { - var item = GetListviewItemOfClient(c); + var item = GetListViewItemByClient(c); if (item != null) item.SubItems[USERSTATUS_ID].Text = text; }); @@ -326,7 +351,12 @@ namespace xServer.Forms } } - private ListViewItem GetListviewItemOfClient(Client c) + /// + /// Gets the Listview item which belongs to the client. + /// + /// The client to get the Listview item of. + /// Listview item of the client. + private ListViewItem GetListViewItemByClient(Client c) { ListViewItem itemClient = null; @@ -339,6 +369,10 @@ namespace xServer.Forms return itemClient; } + /// + /// Gets all selected clients. + /// + /// An array of selected Clients. private Client[] GetSelectedClients() { List clients = new List(); @@ -358,6 +392,10 @@ namespace xServer.Forms return clients.ToArray(); } + /// + /// Gets all connected and authenticated clients. + /// + /// An array of all Clients. private Client[] GetAllClients() { List clients = new List(); @@ -367,6 +405,10 @@ namespace xServer.Forms return clients.ToArray(); } + /// + /// Displays a popup with information about a client. + /// + /// The client. public void ShowPopup(Client c) { try