This commit is contained in:
Jonathan Jenne
2019-09-20 16:20:09 +02:00
parent a765fe4cce
commit 54598ab3d4
11 changed files with 611 additions and 1051 deletions

View File

@@ -7,60 +7,112 @@ Public Class frmControlCapture
Public Property BottomLeft As RectangleInfo
Public Property BottomRight As RectangleInfo
Public Property ControlName As String
Private WithEvents Watcher As ClipboardWatcher = ClipboardWatcher.Singleton
Private Window As Window
Private EditMode As Boolean = False
Public Sub New(EditMode As Boolean)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
EditMode = EditMode
End Sub
Private Sub frmControlCapture_Load(sender As Object, e As EventArgs) Handles Me.Load
Window = New Window(LogConfig)
rbControlName.Checked = True
AddHandler Watcher.Changed, AddressOf Watcher_Changed
End Sub
Private Sub Watcher_Changed(sender As Object, e As EventArgs)
' === CONTROL NAME ===
Dim oControl As WindowInfo = Window.GetFocusedControl(Handle)
If oControl IsNot Nothing Then
TextBox1.Text = oControl.ControlName
ControlName = oControl.ControlName
End If
' === CONTROL POSITION ===
For Each oAnchor As Anchor In [Enum].GetValues(GetType(Anchor))
Dim oRect = Window.GetFocusedControlLocation(Handle, oAnchor)
Dim oRect As RectangleInfo = Window.GetFocusedControlLocation(Handle, oAnchor)
Select Case oAnchor
Case Window.Anchor.TopLeft
If oRect IsNot Nothing Then
TopLeft = oRect
txtTLLeft.Text = oRect.Left
txtTLRight.Text = oRect.Right
txtTLTop.Text = oRect.Top
txtTLBottom.Text = oRect.Bottom
End If
Case Window.Anchor.TopRight
If oRect IsNot Nothing Then
TopRight = oRect
txtTRLeft.Text = oRect.Left
txtTRRight.Text = oRect.Right
txtTRTop.Text = oRect.Top
txtTRBottom.Text = oRect.Bottom
End If
Case Window.Anchor.BottomLeft
If oRect IsNot Nothing Then
BottomLeft = oRect
txtBLLeft.Text = oRect.Left
txtBLRight.Text = oRect.Right
txtBLTop.Text = oRect.Top
txtBLBottom.Text = oRect.Bottom
End If
Case Window.Anchor.BottomRight
If oRect IsNot Nothing Then
BottomRight = oRect
txtBRLeft.Text = oRect.Left
txtBRRight.Text = oRect.Right
txtBRTop.Text = oRect.Top
txtBRBottom.Text = oRect.Bottom
End If
End Select
TextBox2.Text = GetBoundsString()
Next
End Sub
Private Function GetBoundsString()
Dim oResult As String = String.Empty
If TopLeft IsNot Nothing Then
oResult &= TopLeft.ToString & vbNewLine
End If
If TopRight IsNot Nothing Then
oResult &= TopRight.ToString & vbNewLine
End If
If BottomLeft IsNot Nothing Then
oResult &= BottomLeft.ToString & vbNewLine
End If
If BottomRight IsNot Nothing Then
oResult &= BottomRight.ToString & vbNewLine
End If
Return oResult
End Function
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlName.CheckedChanged
gbControlName.Enabled = rbControlName.Checked
gbControlPosition.Enabled = Not rbControlName.Checked
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlPosition.CheckedChanged
gbControlName.Enabled = Not rbControlPosition.Checked
gbControlPosition.Enabled = rbControlPosition.Checked
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = String.Empty And TextBox2.Text = String.Empty Then
MsgBox("Kein Control gefunden!")
DialogResult = DialogResult.Cancel
End If
If rbControlPosition.Checked Then
ControlName = String.Empty
Else
TopLeft = New RectangleInfo()
TopRight = New RectangleInfo()
BottomLeft = New RectangleInfo()
BottomRight = New RectangleInfo()
End If
End Sub
End Class