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

Public Member Functions

 ScreenControl (Node _client)
 
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.
 
async Task RefreshMons ()
 Refreshes the list of monitors in the combo box and enables/disables a button based on the number of monitors.
 
async Task start ()
 Starts the asynchronous operation.
 
async Task stop ()
 Sends a stop signal to the client asynchronously.
 
async Task< string[]> GetMonitors ()
 Asynchronously retrieves the list of monitors from the client and returns it as an array of strings.
 
async Task SetQuality (int quality)
 Sets the quality of the client and sends the quality value to the server.
 
async Task SetMonitor (int monitorIndex)
 Sets the monitor index and updates the scale size.
 
async Task UpdateScaleSize ()
 Updates the scale size of the picture box based on the current monitor size.
 
async Task RecvThread ()
 Asynchronously receives data from the ImageNode and updates the PictureBox with the received image.
 
Point TranslateCoordinates (Point originalCoords, Size originalScreenSize, PictureBox targetControl)
 Translates the original coordinates from one screen size to another based on the target control's image size.
 

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 the mons, and receiving thread.
 
async Task< NodeCreateImageNode ()
 Creates an image node and returns it. If the image node already exists, returns the existing node.
 
Point UnzoomedAndAdjusted (PictureBox pictureBox, Point scaledPoint)
 Translates a point from scaled coordinates to unscaled coordinates and adjusts for the zoom factor.
 
Point Unzoomed (PictureBox pictureBox, Point zoomedPoint)
 Calculates the position on the original image from the zoomed point on the PictureBox.
 
Rectangle GetImageDisplayRectangle (PictureBox pictureBox)
 Gets the display rectangle for the image in the specified PictureBox.
 
void ScreenControl_Load (object sender, EventArgs e)
 Called when the screen control is loaded.
 
async void button2_Click (object sender, EventArgs e)
 Initiates the start method asynchronously and sets the 'playing' flag to true.
 
async void button3_Click (object sender, EventArgs e)
 Stops the current operation and sets the 'playing' flag to false.
 
async void button1_Click (object sender, EventArgs e)
 Asynchronously refreshes the monsters.
 
async void comboBox1_SelectedIndexChanged (object sender, EventArgs e)
 Handles the SelectedIndexChanged event 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.
 
async void pictureBox1_MouseClick (object sender, MouseEventArgs e)
 Handles the mouse click event on pictureBox1 by sending the coordinates and opcode to the server.
 
async void pictureBox1_MouseDoubleClick (object sender, MouseEventArgs e)
 Handles the double-click event on the picture box.
 
async void pictureBox1_MouseUp (object sender, MouseEventArgs e)
 Handles the mouse up event for pictureBox1.
 
async void pictureBox1_MouseMove (object sender, MouseEventArgs e)
 Handles the mouse movement event for pictureBox1.
 
async void pictureBox1_MouseDown (object sender, MouseEventArgs e)
 Handles the mouse down event for pictureBox1.
 
void pictureBox1_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e)
 Handles the PreviewKeyDown event for the pictureBox1 control.
 
void pictureBox1_Click (object sender, EventArgs e)
 Event handler for the Click event of pictureBox1.
 
void ScreenControl_KeyPress (object sender, KeyPressEventArgs e)
 Handles the KeyPress event for the screen control.
 
void ScreenControl_KeyDown (object sender, KeyEventArgs e)
 Handles the KeyDown event for the screen control.
 
async void ScreenControl_KeyUp (object sender, KeyEventArgs e)
 Handles the KeyUp event for screen control.
 
void checkBox1_CheckedChanged (object sender, EventArgs e)
 Handles the CheckedChanged event of checkBox1 and updates the text based on the checked state.
 
void pictureBox1_SizeChanged (object sender, EventArgs e)
 Updates the scale size when the size of the picture box changes.
 
void InitializeComponent ()
 Initializes the components of the form including picture box, combo boxes, buttons, labels, and checkbox.
 

Private Attributes

Node client
 
Node ImageNode
 
bool playing = false
 
int monitor_index = 0
 
double scaling_factor = 1
 
Size? current_mon_size = null
 
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.PictureBox pictureBox1
 
System.Windows.Forms.ComboBox comboBox1
 
System.Windows.Forms.ComboBox comboBox2
 
System.Windows.Forms.Button button1
 
System.Windows.Forms.Button button2
 
System.Windows.Forms.Button button3
 
System.Windows.Forms.Label label1
 
System.Windows.Forms.CheckBox checkBox1
 

Constructor & Destructor Documentation

◆ ScreenControl()

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

Member Function Documentation

◆ button1_Click()

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

Asynchronously refreshes the monsters.

This method triggers an asynchronous refresh of the monsters, updating the monster data and UI display accordingly.

Here is the caller graph for this function:

◆ button2_Click()

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

Initiates the start method asynchronously and sets the 'playing' flag to true.

This method asynchronously initiates the start method, which may involve asynchronous operations such as network requests or file I/O. Once the start method is initiated, the 'playing' flag is set to true, indicating that the application is in a playing state.

Here is the caller graph for this function:

◆ button3_Click()

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

Stops the current operation and sets the 'playing' flag to false.

This method asynchronously stops the current operation and sets the 'playing' flag to false.

Here is the caller graph for this function:

◆ checkBox1_CheckedChanged()

void xeno_rat_server.Forms.ScreenControl.checkBox1_CheckedChanged ( object sender,
EventArgs e )
inlineprivate

Handles the CheckedChanged event of checkBox1 and updates the text based on the checked state.

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

This method updates the text of checkBox1 based on its checked state. If checkBox1 is checked, the text is set to "Enabled"; otherwise, it is set to "Disabled".

Here is the caller graph for this function:

◆ comboBox1_SelectedIndexChanged()

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

Handles the SelectedIndexChanged event of comboBox1.

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

This method asynchronously sets the monitor based on the selected index in comboBox1. If the selected index is not -1, it awaits the SetMonitor method passing the selected index as a parameter.

Here is the caller graph for this function:

◆ comboBox2_SelectedIndexChanged()

async void xeno_rat_server.Forms.ScreenControl.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.
eAn 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 calls the SetQuality method with the parsed quality value from the qualitys array.

Here is the caller graph for this function:

◆ CreateImageNode()

async Task< Node > xeno_rat_server.Forms.ScreenControl.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 first checks if the image node already exists. If it does, it returns the existing node. If the image node does not exist, it creates a new sub-node using the client and sets its type to 2. It then sends the type 2 ID to the server and waits for a response. If the ID is found, it sets the type 2 ID and returns the sub-node. If the ID is not found, it disconnects the sub-node and returns null. If the type 2 ID cannot be set, it disconnects the sub-node and returns null.

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

◆ Dispose()

override void xeno_rat_server.Forms.ScreenControl.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 the managed resources.

◆ GetImageDisplayRectangle()

Rectangle xeno_rat_server.Forms.ScreenControl.GetImageDisplayRectangle ( PictureBox pictureBox)
inlineprivate

Gets the display rectangle for the image in the specified PictureBox.

Parameters
pictureBoxThe PictureBox control containing the image.
Returns
The display rectangle for the image based on the PictureBox's SizeMode property. If SizeMode is Normal, the rectangle is positioned at (0, 0) with dimensions equal to the image size. If SizeMode is StretchImage, the rectangle matches the client area of the PictureBox. If SizeMode is Zoom, the rectangle is calculated to fit the image within the client area while maintaining aspect ratio.

◆ GetMonitors()

async Task< string[]> xeno_rat_server.Forms.ScreenControl.GetMonitors ( )
inline

Asynchronously retrieves the list of monitors from the client and returns it as an array of strings.

Returns
An array of strings containing the list of monitors.

This method sends a byte array with a value of 2 to the client asynchronously and then receives a string from the client, which is then split into an array of strings using the newline character as the delimiter.

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

◆ InitializeAsync()

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

Initializes the object asynchronously by creating an image node, adding temporary on disconnect, refreshing the mons, and receiving thread.

Returns
A Task representing the asynchronous operation.

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

  1. Creates an image node by awaiting the CreateImageNode method.
  2. Adds temporary on disconnect by calling the ImageNode.AddTempOnDisconnect method.
  3. Refreshes the mons by awaiting the RefreshMons method.
  4. Receives thread by awaiting 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.ScreenControl.InitializeComponent ( )
inlineprivate

Initializes the components of the form including picture box, combo boxes, buttons, labels, and checkbox.

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

◆ pictureBox1_Click()

void xeno_rat_server.Forms.ScreenControl.pictureBox1_Click ( object sender,
EventArgs e )
inlineprivate

Event handler for the Click event of pictureBox1.

Parameters
senderThe object that raised the event.
eThe event data.
Here is the caller graph for this function:

◆ pictureBox1_MouseClick()

async void xeno_rat_server.Forms.ScreenControl.pictureBox1_MouseClick ( object sender,
MouseEventArgs e )
inlineprivate

Handles the mouse click event on pictureBox1 by sending the coordinates and opcode to the server.

Parameters
senderThe object that raised the event.
eA MouseEventArgs that contains the event data.

This method checks if the pictureBox1 has an image, if the application is in playing mode, and if checkBox1 is checked. If any of these conditions are not met, the method returns without performing any further actions. The method then translates the mouse coordinates to match the current monitor size and pictureBox1, and determines the opcode based on the mouse button clicked. The coordinates and opcode are then sent to the server using the client's SendAsync method.

Here is the caller graph for this function:

◆ pictureBox1_MouseDoubleClick()

async void xeno_rat_server.Forms.ScreenControl.pictureBox1_MouseDoubleClick ( object sender,
MouseEventArgs e )
inlineprivate

Handles the double-click event on the picture box.

Parameters
senderThe object that raised the event.
eA MouseEventArgs that contains the event data.

This method checks if the current monitor size is null, if the picture box image is null, if the application is not in playing mode, if the right mouse button or middle mouse button is clicked, or if the checkbox is not checked. If any of these conditions are met, the method returns without performing any further actions. If all conditions are met, the method translates the coordinates of the mouse click to the current monitor size and sends the coordinates to the client asynchronously.

Here is the caller graph for this function:

◆ pictureBox1_MouseDown()

async void xeno_rat_server.Forms.ScreenControl.pictureBox1_MouseDown ( object sender,
MouseEventArgs e )
inlineprivate

Handles the mouse down event for pictureBox1.

Parameters
senderThe object that raised the event.
eA MouseEventArgs that contains the event data.

This method sends the coordinates of the mouse click to the server using the client's socket connection. It translates the coordinates relative to the pictureBox1 and sends the payload asynchronously to the server.

Here is the caller graph for this function:

◆ pictureBox1_MouseMove()

async void xeno_rat_server.Forms.ScreenControl.pictureBox1_MouseMove ( object sender,
MouseEventArgs e )
inlineprivate

Handles the mouse movement event for pictureBox1.

Parameters
senderThe object that raised the event.
eA MouseEventArgs that contains the event data.

This method translates the mouse coordinates to the corresponding coordinates on the pictureBox1 image, and sends the translated coordinates to the client asynchronously.

Here is the caller graph for this function:

◆ pictureBox1_MouseUp()

async void xeno_rat_server.Forms.ScreenControl.pictureBox1_MouseUp ( object sender,
MouseEventArgs e )
inlineprivate

Handles the mouse up event for pictureBox1.

Parameters
senderThe object that raised the event.
eA MouseEventArgs that contains the event data.

This method checks if the current monitor size and pictureBox1.Image are not null, if the application is in playing state, if the right or middle mouse button is not clicked, and if checkBox1 is checked. If all conditions are met, it translates the mouse coordinates to the pictureBox1 and sends the payload to the client asynchronously.

Here is the caller graph for this function:

◆ pictureBox1_PreviewKeyDown()

void xeno_rat_server.Forms.ScreenControl.pictureBox1_PreviewKeyDown ( object sender,
PreviewKeyDownEventArgs e )
inlineprivate

Handles the PreviewKeyDown event for the pictureBox1 control.

Parameters
senderThe source of the event.
eA PreviewKeyDownEventArgs that contains the event data.

This method checks if the current_mon_size is null, if the pictureBox1.Image is null, if the application is not in a playing state, or if checkBox1 is not checked, and returns if any of these conditions are met.

Here is the caller graph for this function:

◆ pictureBox1_SizeChanged()

void xeno_rat_server.Forms.ScreenControl.pictureBox1_SizeChanged ( object sender,
EventArgs e )
inlineprivate

Updates the scale size when the size of the picture box changes.

Parameters
senderThe object that raised the event.
eThe event data.
Here is the caller graph for this function:

◆ RecvThread()

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

Asynchronously receives data from the ImageNode and updates the PictureBox with the received image.

This method continuously receives data from the ImageNode while it is connected. Upon receiving data, it checks if the application is in a playing state. If so, it attempts to convert the received data into a System.Drawing.Image and updates the PictureBox with the new image using BeginInvoke to ensure thread safety. If an exception occurs during the image processing or updating the PictureBox, it is caught and ignored.

Here is the caller graph for this function:

◆ RefreshMons()

async Task xeno_rat_server.Forms.ScreenControl.RefreshMons ( )
inline

Refreshes the list of monitors in the combo box and enables/disables a button based on the number of monitors.

This method asynchronously retrieves the list of monitors and updates the combo box with the new list. If the list of monitors is empty, the associated button is disabled. Otherwise, the button is enabled and the monitor is set to the first item in the list.

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

◆ ScreenControl_KeyDown()

void xeno_rat_server.Forms.ScreenControl.ScreenControl_KeyDown ( object sender,
KeyEventArgs e )
inlineprivate

Handles the KeyDown event for the screen control.

Parameters
senderThe source of the event.
eA KeyEventArgs that contains the event data.
Here is the caller graph for this function:

◆ ScreenControl_KeyPress()

void xeno_rat_server.Forms.ScreenControl.ScreenControl_KeyPress ( object sender,
KeyPressEventArgs e )
inlineprivate

Handles the KeyPress event for the screen control.

Parameters
senderThe source of the event.
eA KeyPressEventArgs that contains the event data.
Here is the caller graph for this function:

◆ ScreenControl_KeyUp()

async void xeno_rat_server.Forms.ScreenControl.ScreenControl_KeyUp ( object sender,
KeyEventArgs e )
inlineprivate

Handles the KeyUp event for screen control.

Parameters
senderThe object that raised the event.
eA KeyEventArgs that contains the event data.

This method checks if the current monitor size is null, if the picture box image is null, if the application is not playing, or if the checkbox is not checked, and then returns without performing any further action. If the conditions are met, it sends an asynchronous message to the client with the concatenated byte array consisting of 12 and the key value from the KeyEventArgs.

Here is the caller graph for this function:

◆ ScreenControl_Load()

void xeno_rat_server.Forms.ScreenControl.ScreenControl_Load ( object sender,
EventArgs e )
inlineprivate

Called when the screen control is loaded.

Parameters
senderThe source of the event.
eAn EventArgs that contains the event data.
Here is the caller graph for this function:

◆ SetMonitor()

async Task xeno_rat_server.Forms.ScreenControl.SetMonitor ( int monitorIndex)
inline

Sets the monitor index and updates the scale size.

Parameters
monitorIndexThe index of the monitor to be set.
Returns
Task representing the asynchronous operation.

This method sets the monitor index to the specified value and updates the scale size accordingly. It sends the monitor index to the client and receives hardware data, including width and height, from the client. The received data is used to update the current monitor size, and then the scale size is updated accordingly.

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

◆ SetQuality()

async Task xeno_rat_server.Forms.ScreenControl.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 sets the quality of the client and sends the quality value to the server using the SendAsync method of the client. The quality value is sent to the server after concatenating it with a byte array containing the value 3 using the Concat method. The method is asynchronous and returns a Task representing the asynchronous operation.

Here is the call graph for this function:

◆ start()

async Task xeno_rat_server.Forms.ScreenControl.start ( )
inline

Starts the asynchronous operation.

Returns
A task representing the asynchronous operation.

This method initiates an asynchronous operation using the client to send a byte array with a single element of value 0.

Here is the call graph for this function:

◆ stop()

async Task xeno_rat_server.Forms.ScreenControl.stop ( )
inline

Sends a stop signal to the client asynchronously.

Returns
A task representing the asynchronous operation.
Exceptions
ExceptionThrown when an error occurs while sending the stop signal.
Here is the call graph for this function:

◆ TempOnDisconnect()

void xeno_rat_server.Forms.ScreenControl.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.
Exceptions
InvalidOperationExceptionThrown when attempting to disconnect the client or image node while they are null.

If the provided node is equal to the client or the image node, this method disconnects the client and image node if they are not null, and closes the form if it is not disposed.

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

◆ TranslateCoordinates()

Point xeno_rat_server.Forms.ScreenControl.TranslateCoordinates ( Point originalCoords,
Size originalScreenSize,
PictureBox targetControl )
inline

Translates the original coordinates from one screen size to another based on the target control's image size.

Parameters
originalCoordsThe original coordinates to be translated.
originalScreenSizeThe original screen size.
targetControlThe target control to which the coordinates will be translated.
Returns
The translated coordinates based on the target control's image size.

This method calculates the scaling factors based on the target control's image size and the original screen size. It then applies the scaling factors to the original coordinates to obtain the scaled coordinates. The method further adjusts the scaled coordinates based on the unzoomed and offset-adjusted coordinates of the target control.

◆ Unzoomed()

Point xeno_rat_server.Forms.ScreenControl.Unzoomed ( PictureBox pictureBox,
Point zoomedPoint )
inlineprivate

Calculates the position on the original image from the zoomed point on the PictureBox.

Parameters
pictureBoxThe PictureBox control where the image is displayed.
zoomedPointThe point on the PictureBox after zooming.
Returns
The position on the original image corresponding to the zoomed point.

This method calculates the position on the original image based on the zoomed point and the scaling factor of the PictureBox. It first determines the scaling factor by comparing the client size of the PictureBox with the dimensions of the image. Then, it calculates the bounding rectangle of the displayed image and uses it to find the corresponding position on the original image.

◆ UnzoomedAndAdjusted()

Point xeno_rat_server.Forms.ScreenControl.UnzoomedAndAdjusted ( PictureBox pictureBox,
Point scaledPoint )
inlineprivate

Translates a point from scaled coordinates to unscaled coordinates and adjusts for the zoom factor.

Parameters
pictureBoxThe PictureBox control used for displaying the image.
scaledPointThe point in scaled coordinates to be translated and adjusted.
Returns
The translated and adjusted Point in unscaled coordinates.

This method calculates the zoom factor based on the size of the PictureBox control and the size of the image being displayed. It then determines the displayed rectangle of the image within the PictureBox. The method finally offsets and unzooms the input coordinates to obtain the corresponding unscaled coordinates, taking into account the zoom factor and the displayed rectangle.

◆ UpdateScaleSize()

async Task xeno_rat_server.Forms.ScreenControl.UpdateScaleSize ( )
inline

Updates the scale size of the picture box based on the current monitor size.

This method compares the width and height of the picture box with the current monitor size. If the picture box dimensions exceed the monitor size, it sends a scaling factor of 10000 to the client. If the picture box dimensions are within the monitor size, it calculates the scaling factor based on the width and height ratios, and sends the scaled factor to the client.

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

Member Data Documentation

◆ button1

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

◆ button2

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

◆ button3

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

◆ checkBox1

System.Windows.Forms.CheckBox xeno_rat_server.Forms.ScreenControl.checkBox1
private

◆ client

Node xeno_rat_server.Forms.ScreenControl.client
private

◆ comboBox1

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

◆ comboBox2

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

◆ components

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

Required designer variable.

◆ current_mon_size

Size? xeno_rat_server.Forms.ScreenControl.current_mon_size = null
private

◆ ImageNode

Node xeno_rat_server.Forms.ScreenControl.ImageNode
private

◆ label1

System.Windows.Forms.Label xeno_rat_server.Forms.ScreenControl.label1
private

◆ monitor_index

int xeno_rat_server.Forms.ScreenControl.monitor_index = 0
private

◆ pictureBox1

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

◆ playing

bool xeno_rat_server.Forms.ScreenControl.playing = false
private

◆ qualitys

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

◆ scaling_factor

double xeno_rat_server.Forms.ScreenControl.scaling_factor = 1
private

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