Introduction
The misuse of official computers is a common practice among users in many work environments where proper monitoring mechanisms do not exist. It results in the waste of resources and in not meeting the overall objectives of an organization. So, to achieve the maximum and desired results in a work environment, an effective mechanism through which the administrator can monitor and control the workstations under the use of employees is needed.
Purpose
The purpose of this project is to develop a Xamarin.Forms-based application which will serve the administrator with on-demand remote surveillance and controlling of workstations of the workplace. The project will involve the development of two applications, one will run on workstations and the other one will run on the mobile phone of the administrator. Both the applications will be connected through Wi-Fi. The implementation of such a mechanism will allow the administrator, to not only have an eye on the activities of users but also, will make him/her able to remotely control the specific workstation(s).
Scope of Project
There will be two applications in this project,
- Server Application
Server Application will continuously run on each workstation in workplace. The server application will be connected with the Client Application through a Wi-Fi connection. It will take a screenshot of user activity on the demand of the administrator and will transfer the same to client/mobile application. This application will interpret and execute commands received from the Client/mobile application.
- Client / Xamarin.Forms Application
Android application will run on Administrator’s smart mobile phone and will provide an effective interface through which the Administrator will be able to connect it with the Server Application. Through this application, the Administrator will be able to instruct the Server Application to take the screenshot(s) and send to this application. Through this application, the Administrator will also be able to control any workstation and perform the activities such as sending a message, turning the workstation into sleep mode and shutting down any workstation etc.
- Creating Connection Between Computer and Mobile
- Screenshot taking and sending to Client / Xamarin.Forms Mobile Application
Server Application will take the screenshot(s) of user activity on any workstation on demand of the Administrator through Client/mobile Application. Screenshot(s) will be transferred to the client/mobile application. - Controlling Work Stations
The administrator will be able to control any workstation through sending commands. Administrator will be able to perform sending a message to the workstation turning that into sleep mode, locking the workstation, and shutting down the workstation.
Server Application
Step 1 - Create Console Application
Let’s create a console app project with .NET framework.

Step 2 - Add Appropriate Namespace
Create an instance of TcpClient and TcpListener inside your Program class by using appropriate namespaces. Also, declare a local variable type string with the name ipString.
- public static TcpClient client;
- private static TcpListener listener;
- private static string ipString;
Step 3 - Get Your Machine IP Address
Let’s write a method inside your Main function that will catch and return your machine's IP Address.
- IPAddress[] localIp = Dns.GetHostAddresses(Dns.GetHostName());
- foreach(IPAddress address in localIp) {
- if (address.AddressFamily == AddressFamily.InterNetwork) {
- ipString = address.ToString();
- }
- }
Step 4 - Start Listening On 1234 Port
Now, in this step, we are ready to start listening. I am using 1234 as my port number and I will use the current machine's local IP address and my port number for endpoints. After following all these steps, now, we can accept any TCP client and connect with clients.
- IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ipString), 1234);
- listener = new TcpListener(ep);
- listener.Start();
- Console.WriteLine(@"
- ===================================================
- Started listening requests at: {0}:{1}
- ===================================================",
- ep.Address, ep.Port);
- client = listener.AcceptTcpClient();
- Console.WriteLine("Connected to client!" + " \n");

Step 5 - Build Connection With Client
After connecting with the client, I will perform my first function that will sleep the workstations using client command. While the client is connected with the Server, if a client will send SLP2 command, then the server will execute the sleep function that I will write in the next step.
- while (client.Connected) {
- try {
- const int bytesize = 1024 * 1024;
- byte[] buffer = new byte[bytesize];
- string x = client.GetStream().Read(buffer, 0, bytesize).ToString();
- var data = ASCIIEncoding.ASCII.GetString(buffer);
- if (data.ToUpper().Contains("SLP2")) {
- Console.WriteLine("Pc is going to Sleep Mode!" + " \n");
- Sleep();
- }
- } catch (Exception exc) {
- client.Dispose();
- client.Close();
- }
- }
Step 6 - Sleep Method
First, add the following namespaces to your project; then write the sleep function inside your Main function.



selman onalPosted Mar 6, 2023, 6:53 AM
Hello, when I add the namespace using System.Windows.Forms; to the project, It makes an error CS0204 which is there is no forms type or namespaece in System.Windows. Could you please help?
Fernando CruzPosted Mar 20, 2022, 5:52 PM
Hola, me sale un error en la linea "Application.Current.MainPage = new NavigationPage(new OperationsPage());", especificamente en OperationsPage() me dice Gravedad C?digo Descripci?n Proyecto Archivo L?nea Estado suprimidoError CS0246 El nombre del tipo o del espacio de nombres 'OperationsPage' no se encontr? (?falta una directiva using o una referencia de ensamblado?), quisiera que porfa me ayudaras a solucionarlo, gracias.
Ahmad KelanyPosted May 1, 2020, 10:26 AM
Is there a way to connect to the PC by its PC Name instead of the IP?