Xeno-rat
Loading...
Searching...
No Matches
xeno_rat_server.Forms.WebCam Class Reference
Inheritance diagram for xeno_rat_server.Forms.WebCam:
Collaboration diagram for xeno_rat_server.Forms.WebCam:

Public Member Functions

 WebCam (Node _client)
 
async Task RecvThread ()
 Asynchronously receives image data and updates the picture box with the received image.
 
async Task RefreshCams ()
 Refreshes the list of cameras and updates the UI accordingly.
 
async Task SetCamera (int index)
 Sets the camera with the specified index.
 
async Task SetQuality (int quality)
 Sets the quality of the client and sends the quality value to the server.
 
async Task< string[]> GetCamera ()
 Asynchronously retrieves the list of cameras from the client and returns the result.
 
void TempOnDisconnect (Node node)
 Disconnects the client and image node if the provided node is equal to the client or the image node, and closes the form if not disposed.
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases the unmanaged resources used by the component and optionally releases the managed resources.
 

Private Member Functions

async Task InitializeAsync ()
 Initializes the object asynchronously by creating an image node, adding temporary on disconnect, refreshing cameras, and starting the receive thread.
 
async Task< NodeCreateImageNode ()
 Creates an image node and returns it. If the image node already exists, returns the existing node.
 
void WebCam_Load (object sender, EventArgs e)
 Event handler for the form load event of the WebCam form.
 
async void button2_Click (object sender, EventArgs e)
 Enables the next button and disables the current button, then sends a byte array with value 2 to the client asynchronously.
 
async void button3_Click (object sender, EventArgs e)
 Disables the current button, enables the stop button, and sends a stop signal to the client. If an image is displayed in the picture box, it disposes of the image and sets it to null.
 
async void button1_Click (object sender, EventArgs e)
 Asynchronously refreshes the cameras.
 
async void comboBox1_SelectedIndexChanged (object sender, EventArgs e)
 Handles the SelectedIndexChanged event of comboBox1. Sets the camera based on the selected index of comboBox1.
 
async void comboBox2_SelectedIndexChanged (object sender, EventArgs e)
 Handles the SelectedIndexChanged event of comboBox2. Sets the quality based on the selected index in the comboBox.
 
void InitializeComponent ()
 Initializes the components of the WebCam form.
 

Private Attributes

Node client
 
Node ImageNode
 
bool playing = false
 
string[] Cameras
 
string[] qualitys = new string[] { "100%", "90%", "80%", "70%", "60%", "50%", "40%", "30%", "20%", "10%" }
 
System.ComponentModel.IContainer components = null
 Required designer variable.
 
System.Windows.Forms.Button button1
 
System.Windows.Forms.Button button2
 
System.Windows.Forms.Button button3
 
System.Windows.Forms.ComboBox comboBox1
 
System.Windows.Forms.PictureBox pictureBox1
 
System.Windows.Forms.ComboBox comboBox2
 

Constructor & Destructor Documentation

◆ WebCam()

xeno_rat_server.Forms.WebCam.WebCam ( Node _client)
inline
Here is the call graph for this function:

Member Function Documentation

◆ button1_Click()

async void xeno_rat_server.Forms.WebCam.button1_Click ( object sender,
EventArgs e )
inlineprivate

Asynchronously refreshes the cameras.

This method triggers the asynchronous refresh of the cameras, updating their status and properties.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ button2_Click()

async void xeno_rat_server.Forms.WebCam.button2_Click ( object sender,
EventArgs e )
inlineprivate

Enables the next button and disables the current button, then sends a byte array with value 2 to the client asynchronously.

Parameters
senderThe object that raised the event.
eThe event data.

This method enables the next button (button3) and disables the current button (button2). It also disables another button (button1). The method then sends a byte array with value 2 to the client asynchronously using the client object. The playing flag is set to true after sending the byte array.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ button3_Click()

async void xeno_rat_server.Forms.WebCam.button3_Click ( object sender,
EventArgs e )
inlineprivate

Disables the current button, enables the stop button, and sends a stop signal to the client. If an image is displayed in the picture box, it disposes of the image and sets it to null.

Parameters
senderThe object that raised the event.
eThe event data.

This method disables the current button, enables the stop button, and sends a stop signal to the client. It also disposes of any image displayed in the picture box and sets it to null.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ comboBox1_SelectedIndexChanged()

async void xeno_rat_server.Forms.WebCam.comboBox1_SelectedIndexChanged ( object sender,
EventArgs e )
inlineprivate

Handles the SelectedIndexChanged event of comboBox1. Sets the camera based on the selected index of comboBox1.

Parameters
senderThe source of the event.
eThe EventArgs that contains the event data.

This method asynchronously sets the camera based on the selected index of comboBox1. If the selected index is not -1, it awaits the SetCamera method with the selected index as the parameter.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ comboBox2_SelectedIndexChanged()

async void xeno_rat_server.Forms.WebCam.comboBox2_SelectedIndexChanged ( object sender,
EventArgs e )
inlineprivate

Handles the SelectedIndexChanged event of comboBox2. Sets the quality based on the selected index in the comboBox.

Parameters
senderThe source of the event.
eThe EventArgs that contains the event data.

This method retrieves the selected index from comboBox2 and sets the quality based on the selected index. It first checks if a valid index is selected, then it parses the quality value from the qualitys array and removes the '' symbol. The SetQuality method is then called with the parsed quality value to set the quality.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateImageNode()

async Task< Node > xeno_rat_server.Forms.WebCam.CreateImageNode ( )
inlineprivate

Creates an image node and returns it. If the image node already exists, returns the existing node.

Returns
The created or existing image node.

This method creates an image node if it does not already exist. If the image node already exists, it returns the existing node. The method sends a byte array with a value of 4 to the client asynchronously. It then creates a subnode asynchronously using the parent client and assigns it to the variable SubSubNode. The method sets the type and ID of the subnode using Utils.SetType2setIdAsync method and checks if the ID is not equal to -1. If the ID is not equal to -1, it returns the type and ID asynchronously using Utils.Type2returnAsync method and sends a byte array to the client. The method receives a byte array from the client and checks if it is null or the first element is 0. If so, it disconnects the subnode and returns null. If the ID is equal to -1, it disconnects the subnode and returns null. Finally, it returns the created or existing image node.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispose()

override void xeno_rat_server.Forms.WebCam.Dispose ( bool disposing)
inlineprotected

Releases the unmanaged resources used by the component and optionally releases the managed resources.

Parameters
disposingTrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method releases the unmanaged resources used by the component and optionally releases the managed resources. If disposing is true, this method disposes of all managed resources. If disposing is false, this method releases only the unmanaged resources.

◆ GetCamera()

async Task< string[]> xeno_rat_server.Forms.WebCam.GetCamera ( )
inline

Asynchronously retrieves the list of cameras from the client and returns the result.

Returns
An array of strings containing the list of cameras retrieved from the client.

This method sends a request to the client to retrieve the list of cameras and awaits the response. The response is then parsed to obtain the number of cameras, and individual camera names are received and stored in an array. The array of camera names is then assigned to the 'Cameras' property of the class and returned as the result.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeAsync()

async Task xeno_rat_server.Forms.WebCam.InitializeAsync ( )
inlineprivate

Initializes the object asynchronously by creating an image node, adding temporary on disconnect, refreshing cameras, and starting the receive thread.

This method initializes the object asynchronously by performing the following tasks:

  1. Creates an image node by awaiting the result of the CreateImageNode method.
  2. Adds temporary on disconnect by invoking the AddTempOnDisconnect method on the created ImageNode.
  3. Refreshes cameras by awaiting the result of the RefreshCams method.
  4. Starts the receive thread by invoking the RecvThread method.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeComponent()

void xeno_rat_server.Forms.WebCam.InitializeComponent ( )
inlineprivate

Initializes the components of the WebCam form.

This method initializes and sets up the various components of the WebCam form, including buttons, combo boxes, and picture box. It also sets up event handlers for button clicks and combo box selection changes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecvThread()

async Task xeno_rat_server.Forms.WebCam.RecvThread ( )
inline

Asynchronously receives image data and updates the picture box with the received image.

This method continuously receives image data from the connected ImageNode and updates the picture box with the received image. If the received data is null, the method breaks the loop and stops receiving. If the application is in a playing state, the received image data is converted to an Image object and displayed in the picture box. The method uses asynchronous operations for receiving data to avoid blocking the main thread.

Exceptions
ExceptionThrown if there is an error in receiving or processing the image data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RefreshCams()

async Task xeno_rat_server.Forms.WebCam.RefreshCams ( )
inline

Refreshes the list of cameras and updates the UI accordingly.

This method asynchronously retrieves the list of available cameras using the GetCamera method. It then updates the UI by clearing the existing items in the comboBox1 and adding the new camera names. If no cameras are available, it disables the button2; otherwise, it enables the button and sets the camera to the first available one using the SetCamera method.

Exceptions
ExceptionAn exception may be thrown if there is an error while retrieving the list of cameras or setting the camera.
Returns
A task representing the asynchronous operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCamera()

async Task xeno_rat_server.Forms.WebCam.SetCamera ( int index)
inline

Sets the camera with the specified index.

Parameters
indexThe index of the camera to be set.
Exceptions
ArgumentNullExceptionThrown when the client is null.
Returns
A task representing the asynchronous operation.

This method sends a byte array opcode with value 1 to the client using an asynchronous send operation. Then it sends the index of the camera to the client using an asynchronous send operation after converting it to bytes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetQuality()

async Task xeno_rat_server.Forms.WebCam.SetQuality ( int quality)
inline

Sets the quality of the client and sends the quality value to the server.

Parameters
qualityThe quality value to be set for the client.

This method sends an opcode to the server indicating that the quality is being set, followed by the quality value itself. The quality value is converted to bytes using the client's socket utility method before being sent to the server.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TempOnDisconnect()

void xeno_rat_server.Forms.WebCam.TempOnDisconnect ( Node node)
inline

Disconnects the client and image node if the provided node is equal to the client or the image node, and closes the form if not disposed.

Parameters
nodeThe node to be checked for disconnection.

If the provided node is equal to the client or the image node, this method disconnects the client and image node if it is not null. Additionally, if the form is not disposed, it is closed using Control.BeginInvoke(Delegate).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WebCam_Load()

void xeno_rat_server.Forms.WebCam.WebCam_Load ( object sender,
EventArgs e )
inlineprivate

Event handler for the form load event of the WebCam form.

Parameters
senderThe object that raised the event.
eThe event arguments.

This method is called when the WebCam form is loaded. It can be used to initialize the form or perform any necessary setup.

Here is the caller graph for this function:

Member Data Documentation

◆ button1

System.Windows.Forms.Button xeno_rat_server.Forms.WebCam.button1
private

◆ button2

System.Windows.Forms.Button xeno_rat_server.Forms.WebCam.button2
private

◆ button3

System.Windows.Forms.Button xeno_rat_server.Forms.WebCam.button3
private

◆ Cameras

string [] xeno_rat_server.Forms.WebCam.Cameras
private

◆ client

Node xeno_rat_server.Forms.WebCam.client
private

◆ comboBox1

System.Windows.Forms.ComboBox xeno_rat_server.Forms.WebCam.comboBox1
private

◆ comboBox2

System.Windows.Forms.ComboBox xeno_rat_server.Forms.WebCam.comboBox2
private

◆ components

System.ComponentModel.IContainer xeno_rat_server.Forms.WebCam.components = null
private

Required designer variable.

◆ ImageNode

Node xeno_rat_server.Forms.WebCam.ImageNode
private

◆ pictureBox1

System.Windows.Forms.PictureBox xeno_rat_server.Forms.WebCam.pictureBox1
private

◆ playing

bool xeno_rat_server.Forms.WebCam.playing = false
private

◆ qualitys

string [] xeno_rat_server.Forms.WebCam.qualitys = new string[] { "100%", "90%", "80%", "70%", "60%", "50%", "40%", "30%", "20%", "10%" }
private

The documentation for this class was generated from the following files: