This commit is contained in:
Jonathan Jenne
2019-08-02 16:27:35 +02:00
parent 28d5e590b4
commit 926801f7ba
29 changed files with 6191 additions and 2821 deletions

View File

@@ -1,66 +1,61 @@
Imports System.Threading
Imports System.IO
Imports System.Globalization
Imports DD_LIB_Standards
Imports DD_Clipboard_Watcher.ClassConstants
Public Class frmStart
Dim WithEvents Hotkey As New clsHotkey(Me)
Dim WithEvents Hotkey As New ClassHotkey(Me)
Private WithEvents _Watcher As ClipboardWatcher = ClipboardWatcher.Singleton
Private Sub frmClipboardWatch_Disposed(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Disposed
_Watcher.Dispose()
End Sub
Private Sub WatcherChanged_New(ByVal sender As Object, ByVal e As EventArgs) Handles _Watcher.Changed
If MONITORING_ACTIVE = False Then
NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Clipboard-watcher is inactive.", ToolTipIcon.Info)
Exit Sub
End If
If DT_USER_PROFILES Is Nothing OrElse DT_USER_PROFILES.Rows.Count = 0 Then
Exit Sub
End If
Dim ClipboardContents As String = Clipboard.GetText()
Dim WindowTitle As String = clsHotkey.GetCaption()
Dim oProfileFilter As ClassProfileFilter
Try
oProfileFilter = New ClassProfileFilter(DT_USER_PROFILES, DTPROFILE_REL_WINDOW)
Catch ex As Exception
MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor.")
Exit Sub
End Try
Dim oProfiles = oProfileFilter.Profiles.AsEnumerable()
oProfiles = oProfileFilter.FilterProfilesByProcess(oProfiles, CurrPROC_Name)
oProfiles = oProfileFilter.FilterProfilesByClipboardRegex(oProfiles, ClipboardContents)
oProfiles = oProfileFilter.FilterWindowsByWindowTitleRegex(oProfiles, WindowTitle)
oProfiles = oProfileFilter.FilterProfilesByWindowClipboardRegex(oProfiles, ClipboardContents)
oProfiles = oProfileFilter.RemoveDuplicateProfiles()
oProfiles = oProfiles.ToList()
CURRENT_MATCHING_PROFILES = oProfiles
CURRENT_CLIPBOARD_CONTENTS = ClipboardContents
End Sub
Public Sub New()
Dim splash As New frmSplash()
splash.ShowDialog()
If ERROR_INIT <> "INVALID USER" Then
Dim cultureInfo As System.Globalization.CultureInfo
cultureInfo = New System.Globalization.CultureInfo(USER_LANGUAGE)
'cultureInfo.DateTimeFormat.ShortDatePattern = USER_DATE_FORMAT
Thread.CurrentThread.CurrentCulture = cultureInfo
Thread.CurrentThread.CurrentUICulture = cultureInfo
Globalization.CultureInfo.DefaultThreadCurrentCulture = cultureInfo
Globalization.CultureInfo.DefaultThreadCurrentUICulture = cultureInfo
End If
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
Dim splash As New frmSplash()
splash.ShowDialog()
If ERROR_INIT <> "INVALID USER" Then
Dim cultureInfo As New CultureInfo(USER_LANGUAGE)
Thread.CurrentThread.CurrentCulture = cultureInfo
Thread.CurrentThread.CurrentUICulture = cultureInfo
CultureInfo.DefaultThreadCurrentCulture = cultureInfo
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo
End If
End Sub
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
ClassWindowLocation.LoadFormLocationSize(Me)
If ERROR_INIT = "FAILED DBCONNECTION" Or ERROR_INIT = "DATABASE" Then
frmConfig_Basic.ShowDialog()
End If
If clsDatabase.DB_DEFAULT_INITIALIZED = True Then
If ERROR_INIT <> "" Then
If ERROR_INIT = "NO CLIENT" Then
MsgBox("You are not related to a client!" & vbNewLine & "Please contact the system administrator!", MsgBoxStyle.Exclamation)
Else
MsgBox("Sorry Something went wrong in user configuration!" & vbNewLine & "Reason: " & ERROR_INIT & vbNewLine & "Please contact the system administrator!", MsgBoxStyle.Exclamation)
End If
Exit Sub
End If
NotifyIconMain.Visible = True
ClassInit.Refresh_Profile_Links()
Hotkey.AddHotKey(Keys.T, ClassHotkey.ModfierKey.MOD_CONTROL, HOTKEY_TOGGLE_WATCHER)
Dim oKeyCode As Keys
Dim oConverter As New KeysConverter
Dim oObject As Object = oConverter.ConvertFromString(HotkeySearchKey.ToUpper)
oKeyCode = CType(oObject, Keys)
If HotkeyFunctionKey = HOTKEY_CTRL Then
Hotkey.AddHotKey(oKeyCode, ClassHotkey.ModfierKey.MOD_CONTROL, ClassConstants.HOTKEY_TRIGGER_WATCHER)
ElseIf HotkeyFunctionKey = HOTKEY_SHIFT Then
Hotkey.AddHotKey(oKeyCode, ClassHotkey.ModfierKey.MOD_SHIFT, ClassConstants.HOTKEY_TRIGGER_WATCHER)
End If
End If
tslblUser.Text = USER_USERNAME
labelHotkey.Text = $"STRG+C {HotkeyFunctionKey.ToUpper}+{HotkeySearchKey.ToUpper}"
End Sub
Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
@@ -95,45 +90,50 @@ Public Class frmStart
Next
End Sub
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
ClassWindowLocation.LoadFormLocationSize(Me)
If ERROR_INIT = "FAILED DBCONNECTION" Or ERROR_INIT = "DATABASE" Then
frmConfig_Basic.ShowDialog()
End If
If clsDatabase.DB_DEFAULT_INITIALIZED = True Then
If ERROR_INIT <> "" Then
If ERROR_INIT = "NO CLIENT" Then
MsgBox("You are not related to a client!" & vbNewLine & "Please contact the system administrator!", MsgBoxStyle.Exclamation)
Else
MsgBox("Sorry Something went wrong in user configuration!" & vbNewLine & "Reason: " & ERROR_INIT & vbNewLine & "Please contact the system administrator!", MsgBoxStyle.Exclamation)
End If
Exit Sub
End If
NotifyIconMain.Visible = True
clsHotkey.Refresh_Profile_Links()
Hotkey.AddHotKey(Keys.T, clsHotkey.MODKEY.MOD_CONTROL, ClassConstants.HOTKEY_TOGGLE_WATCHER)
Dim oKeyCode As Keys
Dim oConverter As New KeysConverter
Dim oObject As Object = oConverter.ConvertFromString(HotkeySearchKey.ToUpper)
oKeyCode = CType(oObject, Keys)
If HotkeyFunctionKey = ClassConstants.HOTKEY_CTRL Then
Hotkey.AddHotKey(oKeyCode, clsHotkey.MODKEY.MOD_CONTROL, ClassConstants.HOTKEY_TRIGGER_WATCHER)
ElseIf HotkeyFunctionKey = "SHIFT" Then
Hotkey.AddHotKey(oKeyCode, clsHotkey.MODKEY.MOD_SHIFT, ClassConstants.HOTKEY_TRIGGER_WATCHER)
End If
End If
tslblUser.Text = USER_USERNAME
labelHotkey.Text = $"STRG+C {HotkeyFunctionKey.ToUpper}+{HotkeySearchKey.ToUpper}"
Private Sub frmClipboardWatch_Disposed(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Disposed
_Watcher.Dispose()
End Sub
Private Sub WatcherChanged_New(ByVal sender As Object, ByVal e As EventArgs) Handles _Watcher.Changed
If MONITORING_ACTIVE = False Then
NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Clipboard-watcher is inactive.", ToolTipIcon.Info)
Exit Sub
End If
If DT_USER_PROFILES Is Nothing OrElse DT_USER_PROFILES.Rows.Count = 0 Then
Exit Sub
End If
Dim ClipboardContents As String = Clipboard.GetText()
Dim WindowTitle As String = ClassHotkey.GetCaption()
Dim oProfileFilter As ClassProfileFilter
Try
oProfileFilter = New ClassProfileFilter(DT_USER_PROFILES, DTPROFILE_REL_WINDOW)
Catch ex As Exception
MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor.")
Exit Sub
End Try
Dim oProfiles = oProfileFilter.Profiles.AsEnumerable()
oProfiles = oProfileFilter.FilterProfilesByProcess(oProfiles, CurrPROC_Name)
oProfiles = oProfileFilter.FilterProfilesByClipboardRegex(oProfiles, ClipboardContents)
oProfiles = oProfileFilter.FilterWindowsByWindowTitleRegex(oProfiles, WindowTitle)
oProfiles = oProfileFilter.FilterProfilesByWindowClipboardRegex(oProfiles, ClipboardContents)
oProfiles = oProfileFilter.RemoveDuplicateProfiles()
oProfiles = oProfiles.ToList()
CURRENT_MATCHING_PROFILES = oProfiles
CURRENT_CLIPBOARD_CONTENTS = ClipboardContents
End Sub
Private Sub ReceiveHotKey(ByVal HotKeyID As String) Handles Hotkey.HotKeyPressed
If HotKeyID = ClassConstants.HOTKEY_TRIGGER_WATCHER Then
If HotKeyID = HOTKEY_TRIGGER_WATCHER Then
If CURRENT_MATCHING_PROFILES.Count > 0 And MONITORING_ACTIVE = True Then
CHECK_PROFILE_MATCH()
End If
ElseIf HotKeyID = ClassConstants.HOTKEY_TOGGLE_WATCHER Then
ElseIf HotKeyID = HOTKEY_TOGGLE_WATCHER Then
Change_Monitoring_State()
End If
@@ -197,7 +197,7 @@ Public Class frmStart
End Sub
Sub Change_Monitoring_State()
If MONITORING_ACTIVE = True Then
NotifyIconMain.ShowBalloonTip(30000, "Clipboard Watcher", "Clipboard-Watcher wurde inaktiviert!", ToolTipIcon.Info)
NotifyIconMain.ShowBalloonTip(30000, "Clipboard Watcher", "Clipboard-Watcher wurde deaktiviert!", ToolTipIcon.Info)
MONITORING_ACTIVE = False
Else
MONITORING_ACTIVE = True
@@ -229,12 +229,12 @@ Public Class frmStart
OpenClose()
End Sub
Sub OpenClose()
If Me.Visible = False Then
Me.BringToFront()
Me.Visible = True
If Visible = False Then
BringToFront()
Visible = True
TimerClose.Start()
Else
Me.Hide()
Hide()
NotifyIconMain.Visible = True
End If
End Sub
@@ -290,5 +290,4 @@ Public Class frmStart
TimerClose.Start()
MONITORING_ACTIVE = True
End Sub
End Class