Imports System.Runtime.InteropServices
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Windows

Public Class Form1
    Private Logger As Logger
    Private LogConfig As LogConfig

    Private Watcher As ClassClipboardWatcher
    Private Window As Window

    Private CurrentAnchor As Window.Anchor = Window.Anchor.TopLeft

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Interval = 1000
        Timer1.Enabled = True

        LogConfig = New LogConfig(LogConfig.PathType.AppData)
        Logger = LogConfig.GetLogger()
        Window = New Window(LogConfig)

        Watcher = ClassClipboardWatcher.Singleton
        AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged
    End Sub

    Private Sub Watcher_ClipboardChanged(sender As Object, e As IDataObject)
        Dim oControl As Window.RectangleInfo = Window.GetFocusedControlLocation(Handle, CurrentAnchor)

        TextBox9.Text = oControl.Left
        TextBox12.Text = oControl.Right
        TextBox11.Text = oControl.Top
        TextBox10.Text = oControl.Bottom
        TextBox3.Text = ComboBox1.Text.ToUpper
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.Text
            Case "TopLeft"
                CurrentAnchor = Window.Anchor.TopLeft
            Case "TopRight"
                CurrentAnchor = Window.Anchor.TopRight
            Case "BottomLeft"
                CurrentAnchor = Window.Anchor.BottomLeft
            Case "BottomRight"
                CurrentAnchor = Window.Anchor.BottomRight
        End Select
    End Sub
End Class
