Todas las sugerencias son bienvenidas.
Por lo tanto, mi resultado hasta ahora esto es:
Del lado del servidor
Código:
Dim mRect As Rectangle
Dim d
'=========================== DRAW RECTANGLE IN PICTUREBOX ===================================
Private Sub PictureBoxREMOTO_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBoxREMOTO.MouseDown
mRect = New Rectangle(e.X - d.x, e.Y - d.y, 0, 0)
PictureBoxREMOTO.Invalidate()
End Sub
Private Sub PictureBoxREMOTO_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBoxREMOTO.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim gp As New System.Drawing.Drawing2D.GraphicsPath
mRect = New Rectangle(mRect.Left, mRect.Top, e.X - d.x - mRect.Left, e.Y - d.y - mRect.Top)
PictureBoxREMOTO.Invalidate()
End If
End Sub
Private Sub PictureBoxREMOTO_Paint(sender As Object, e As PaintEventArgs) Handles PictureBoxREMOTO.Paint
Dim mRect2 = New Rectangle(mRect.Location, mRect.Size)
mRect2.Offset(d)
Using pen As New Pen(Color.Red, 3)
e.Graphics.DrawRectangle(pen, mRect2)
End Using
End Sub
Private Sub PictureBoxREMOTO_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBoxREMOTO.MouseUp
Dim MENSAJE As String = "HOLE:" & mRect.Left & ":" & mRect.Top & ":" & e.X - d.x - mRect.Left & ":" & e.Y - d.y - mRect.Top
ENVIO = System.Text.Encoding.UTF7.GetBytes(MENSAJE)
'mRect = New Rectangle(e.X - d.x, e.Y - d.y, 0, 0)
'PictureBoxREMOTO.Invalidate()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
d = PictureBoxREMOTO.PointToClient(PictureBoxREMOTO.Location)
End Sub
'=========================================================================================
Dim d
'=========================== DRAW RECTANGLE IN PICTUREBOX ===================================
Private Sub PictureBoxREMOTO_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBoxREMOTO.MouseDown
mRect = New Rectangle(e.X - d.x, e.Y - d.y, 0, 0)
PictureBoxREMOTO.Invalidate()
End Sub
Private Sub PictureBoxREMOTO_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBoxREMOTO.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim gp As New System.Drawing.Drawing2D.GraphicsPath
mRect = New Rectangle(mRect.Left, mRect.Top, e.X - d.x - mRect.Left, e.Y - d.y - mRect.Top)
PictureBoxREMOTO.Invalidate()
End If
End Sub
Private Sub PictureBoxREMOTO_Paint(sender As Object, e As PaintEventArgs) Handles PictureBoxREMOTO.Paint
Dim mRect2 = New Rectangle(mRect.Location, mRect.Size)
mRect2.Offset(d)
Using pen As New Pen(Color.Red, 3)
e.Graphics.DrawRectangle(pen, mRect2)
End Using
End Sub
Private Sub PictureBoxREMOTO_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBoxREMOTO.MouseUp
Dim MENSAJE As String = "HOLE:" & mRect.Left & ":" & mRect.Top & ":" & e.X - d.x - mRect.Left & ":" & e.Y - d.y - mRect.Top
ENVIO = System.Text.Encoding.UTF7.GetBytes(MENSAJE)
'mRect = New Rectangle(e.X - d.x, e.Y - d.y, 0, 0)
'PictureBoxREMOTO.Invalidate()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
d = PictureBoxREMOTO.PointToClient(PictureBoxREMOTO.Location)
End Sub
'=========================================================================================
Lado del cliente
Código:
Private j As Integer
Private z As Integer
Private l As Integer
Private m As Integer
Private Sub DDMain()
BeginInvoke(New Action(AddressOf Rise_DD))
End Sub
Private Sub Rise_DD()
Form2.m = j
Form2.n = z
Form2.o = l
Form2.p = m
Form2.Button1_Click(Me, Nothing)
End Sub
Public Sub ORDENES(ByVal ORDEN As String)
Dim PARTES As String() = ORDEN.Split(":")
POSICIONX = PARTES(1)
POSICIONY = PARTES(2)
Cursor.Position = New Point(POSICIONX, POSICIONY)
Select Case PARTES(0)
Case "HOLE"
'Coordinates of rectangle drawn on Server
j = PARTES(1)
z = PARTES(2)
l = PARTES(3)
m = PARTES(4)
DDMain()
'MessageBox.Show(PARTES(1) & " - " & PARTES(2) & " - " & PARTES(3) & " - " & PARTES(4)) 'Coordinates of rectangle drawed on Server
End Select
End Sub
Private z As Integer
Private l As Integer
Private m As Integer
Private Sub DDMain()
BeginInvoke(New Action(AddressOf Rise_DD))
End Sub
Private Sub Rise_DD()
Form2.m = j
Form2.n = z
Form2.o = l
Form2.p = m
Form2.Button1_Click(Me, Nothing)
End Sub
Public Sub ORDENES(ByVal ORDEN As String)
Dim PARTES As String() = ORDEN.Split(":")
POSICIONX = PARTES(1)
POSICIONY = PARTES(2)
Cursor.Position = New Point(POSICIONX, POSICIONY)
Select Case PARTES(0)
Case "HOLE"
'Coordinates of rectangle drawn on Server
j = PARTES(1)
z = PARTES(2)
l = PARTES(3)
m = PARTES(4)
DDMain()
'MessageBox.Show(PARTES(1) & " - " & PARTES(2) & " - " & PARTES(3) & " - " & PARTES(4)) 'Coordinates of rectangle drawed on Server
End Select
End Sub
Form2 del lado del cliente
Código:
Public m As Integer
Public n As Integer
Public o As Integer
Public p As Integer
Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim mRect As Rectangle
Dim gp As New System.Drawing.Drawing2D.GraphicsPath
gp.AddRectangle(New Rectangle(0, 0, Me.Width, Me.Height))
mRect = New Rectangle(m, n, o, p)
gp.AddRectangle(mRect)
Me.Region = New Region(gp)
Me.Invalidate()
End Sub
Public n As Integer
Public o As Integer
Public p As Integer
Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim mRect As Rectangle
Dim gp As New System.Drawing.Drawing2D.GraphicsPath
gp.AddRectangle(New Rectangle(0, 0, Me.Width, Me.Height))
mRect = New Rectangle(m, n, o, p)
gp.AddRectangle(mRect)
Me.Region = New Region(gp)
Me.Invalidate()
End Sub