diff --git a/GUIs.ZooFlow/ClassConstants.vb b/GUIs.ZooFlow/ClassConstants.vb index 51844642..a96ed8a5 100644 --- a/GUIs.ZooFlow/ClassConstants.vb +++ b/GUIs.ZooFlow/ClassConstants.vb @@ -18,7 +18,12 @@ Public Const ATTR_TYPE_INTEGER = "BIG INTEGER" Public Const ATTR_TYPE_DATE = "DATE" Public Const ATTR_TYPE_BOOLEAN = "BIT" + Public Const VECTORSEPARATOR = "╚" + Public Const SERVICE_ADDRESS_SEPARATOR = ":" + + Public Const HOTKEY_TOGGLE_WATCHER = 354522017 + Public Const HOTKEY_TRIGGER_WATCHER = 354523017 Public Const SQLCMD_FLOW_SEARCH1 = "FLOW_SEARCH1" diff --git a/GUIs.ZooFlow/ClassEnvironment.vb b/GUIs.ZooFlow/ClassEnvironment.vb index ead957b1..506114ae 100644 --- a/GUIs.ZooFlow/ClassEnvironment.vb +++ b/GUIs.ZooFlow/ClassEnvironment.vb @@ -1,3 +1,15 @@ -Public Class ClassEnvironment +Imports DigitalData.Modules.ZooFlow +Public Class ClassEnvironment + Public Shared Function GetEnvironment() As Environment + Dim oEnvironment As New Environment() With { + .DatabaseIDB = My.DatabaseIDB, + .Database = My.Database, + .Modules = My.Application.Modules, + .Service = My.Application.Service, + .Settings = My.Application.Settings, + .User = My.Application.User + } + Return oEnvironment + End Function End Class diff --git a/GUIs.ZooFlow/ClassInit.vb b/GUIs.ZooFlow/ClassInit.vb index 708cc0ce..841220c3 100644 --- a/GUIs.ZooFlow/ClassInit.vb +++ b/GUIs.ZooFlow/ClassInit.vb @@ -14,8 +14,10 @@ Public Class ClassInit Private _MainForm As frmFlowForm Private _Logger As Logger Private _LogConfig As LogConfig - Public Event Completed As EventHandler Private _DataASorDB As ClassDataASorDB + Private _Loader As ClassInitLoader + + Public Event Completed As EventHandler Public Sub New(LogConfig As LogConfig, ParentForm As frmFlowForm) _MainForm = ParentForm @@ -36,22 +38,23 @@ Public Class ClassInit MsgBox("Keine Verbindungs-Informationen hinterlegt. Anwendung wird beendet.", MsgBoxStyle.Critical, _MainForm.Text) Application.Exit() Else - Dim oInit As New ClassInitLoader() + _Loader = New ClassInitLoader() ' === Init Schritte definieren - oInit.AddStep("Checking connectivity..", AddressOf CheckConnectivity, True) - oInit.AddStep("Initializing User..", AddressOf InitializeUser, True) - oInit.AddStep("Initializing IDB Database..", AddressOf InitializeIDBDatabase, True) - oInit.AddStep("Initializing IDB Service..", AddressOf InitializeIDBService, True) - oInit.AddStep("Initializing Language..", AddressOf InitializeLanguage, False) - oInit.AddStep("Loading 3rd-party licenses..", AddressOf Initialize3rdParty, False) - oInit.AddStep("Loading Basic Configs..", AddressOf InitBasicData, False) + _Loader.AddStep("Checking connectivity..", AddressOf CheckConnectivity, True) + _Loader.AddStep("Initializing User..", AddressOf InitializeUser, True) + _Loader.AddStep("Initializing IDB Database..", AddressOf InitializeIDBDatabase, True) + _Loader.AddStep("Initializing IDB Service..", AddressOf InitializeIDBService, True) + _Loader.AddStep("Initializing Language..", AddressOf InitializeLanguage, False) + _Loader.AddStep("Initializing Clipboard Watcher..", AddressOf InitializeClipboardWatcher, False) + _Loader.AddStep("Loading 3rd-party licenses..", AddressOf Initialize3rdParty, False) + _Loader.AddStep("Loading Basic Configs..", AddressOf InitBasicData, False) ' === Init Schritte definieren - AddHandler oInit.ProgressChanged, AddressOf ProgressChanged - AddHandler oInit.InitCompleted, AddressOf InitCompleted + AddHandler _Loader.ProgressChanged, AddressOf ProgressChanged + AddHandler _Loader.InitCompleted, AddressOf InitCompleted - oInit.Run() + _Loader.Run() End If End Sub @@ -96,6 +99,7 @@ Public Class ClassInit My.Application.User = oMyApplication.User My.Application.Modules = oMyApplication.Modules My.Application.ModulesActive = oMyApplication.ModulesActive + My.Application.ClipboardWatcher = oMyApplication.ClipboardWatcher RaiseEvent Completed(sender, Nothing) End If @@ -127,11 +131,9 @@ Public Class ClassInit Dim oRow As DataRow = oDatatable.Rows.Item(0) MyApplication.Settings.GdPictureKey = NotNull(oRow.Item("LICENSE"), String.Empty) - My.Application.Settings.GdPictureKey = NotNull(oRow.Item("LICENSE"), String.Empty) - My.Application.GDPictureLicense = My.Application.Settings.GdPictureKey Catch ex As Exception _Logger.Error(ex) - Throw New InitException("Error initializing3rdParty!") + Throw New InitException("Error initializing3rdParty!", ex) End Try End Sub Private Sub InitBasicData(MyApplication As My.MyApplication) @@ -156,7 +158,7 @@ Public Class ClassInit Next Catch ex As Exception _Logger.Error(ex) - Throw New InitException("Error in InitBasicData") + Throw New InitException("Error in InitBasicData", ex) End Try End Sub @@ -182,7 +184,7 @@ Public Class ClassInit Catch ex As Exception _Logger.Error(ex) - Throw New InitException("Error in InitBasicData") + Throw New InitException("Error in InitBasicData", ex) End Try End Sub @@ -252,7 +254,40 @@ Public Class ClassInit Catch ex As Exception _Logger.Error(ex) - Throw ex + Throw New InitException("Error while initializing user!", ex) + End Try + End Sub + + Private Sub InitializeClipboardWatcher(MyApplication As My.MyApplication) + Try + Dim oUserId = My.Application.User.UserId + Dim oWhereClause = $"T1.USER_ID = {oUserId} OR GROUP_ID IN (SELECT DISTINCT GUID FROM TBDD_GROUPS WHERE GUID IN (SELECT GROUP_ID FROM TBDD_GROUPS_USER WHERE USER_ID = {oUserId}))" + + Dim oProfileSQL As String = $"SELECT DISTINCT GUID, NAME,REGEX_EXPRESSION,COMMENT,PROC_NAME,PROFILE_TYPE FROM VWCW_USER_PROFILE T1 WHERE {oWhereClause}" + Dim oProcessSQL As String = $"SELECT DISTINCT T.GUID, T.PROFILE_ID,T.PROC_NAME FROM TBCW_PROFILE_PROCESS T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})" + Dim oWindowSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_WINDOW T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})" + Dim oControlSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_CONTROL T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})" + + Dim oUserProfiles = My.Database.GetDatatable(oProfileSQL) + + If oUserProfiles Is Nothing OrElse oUserProfiles.Rows.Count = 0 Then + MyApplication.ClipboardWatcher.Status = ClipboardWatcher.State.EnumStatus.NoProfilesConfigured + End If + + Dim oProfileProcesses = My.Database.GetDatatable(oProcessSQL) + Dim oProfileWindows = My.Database.GetDatatable(oWindowSQL) + Dim oProfileControls = My.Database.GetDatatable(oControlSQL) + + MyApplication.ClipboardWatcher.Status = ClipboardWatcher.State.EnumStatus.OK + MyApplication.ClipboardWatcher.UserProfiles = oUserProfiles + MyApplication.ClipboardWatcher.ProfileProcesses = oProfileProcesses + MyApplication.ClipboardWatcher.ProfileWindows = oProfileWindows + MyApplication.ClipboardWatcher.ProfileControls = oProfileControls + MyApplication.ClipboardWatcher.MonitoringActive = True + Catch ex As Exception + MyApplication.ClipboardWatcher.Status = ClipboardWatcher.State.EnumStatus.Exception + _Logger.Error(ex) + Throw New InitException("Error while initializing clipboard watcher!", ex) End Try End Sub @@ -277,7 +312,6 @@ Public Class ClassInit MyApplication.User.Language = NotNull(oValue.ToString, "de-DE") End Select End Sub - Private Sub HandleModuleInfo(MyApplication As My.MyApplication, ModuleName As String, Row As DataRow) Dim oValue As Object = Row.Item("VALUE") Dim oName As String = Row.Item("NAME").ToString diff --git a/GUIs.ZooFlow/ClassInitLoader.vb b/GUIs.ZooFlow/ClassInitLoader.vb index 74fcf30b..86cf520c 100644 --- a/GUIs.ZooFlow/ClassInitLoader.vb +++ b/GUIs.ZooFlow/ClassInitLoader.vb @@ -1,4 +1,5 @@ Imports System.ComponentModel +Imports DigitalData.GUIs.ZooFlow.My Imports DigitalData.Modules.Logging Public Class ClassInitLoader @@ -52,6 +53,13 @@ Public Class ClassInitLoader Try oStep.Action.Invoke(oMyApplication) + + My.Application.Settings = oMyApplication.Settings + My.Application.User = oMyApplication.User + My.Application.Modules = oMyApplication.Modules + My.Application.ModulesActive = oMyApplication.ModulesActive + My.Application.ClipboardWatcher = oMyApplication.ClipboardWatcher + Catch ex As Exception _Logger.Error(ex) _Logger.Warn("Init Step '{0}' failed!", oStep.Name) diff --git a/GUIs.ZooFlow/ClipboardWatcher/State.vb b/GUIs.ZooFlow/ClipboardWatcher/State.vb index 795b4ab1..018f3b63 100644 --- a/GUIs.ZooFlow/ClipboardWatcher/State.vb +++ b/GUIs.ZooFlow/ClipboardWatcher/State.vb @@ -1,8 +1,25 @@ -Namespace ClipboardWatcher +Imports DigitalData.Modules.ZooFlow.Params + +Namespace ClipboardWatcher Public Class State - Public UserProfiles As DataTable - Public ProfileProcesses As DataTable - Public ProfileWindows As DataTable - Public ProfileControls As DataTable + Public Enum EnumStatus + OK + NoProfilesConfigured + Exception + End Enum + + Public UserProfiles As DataTable = Nothing + Public ProfileProcesses As DataTable = Nothing + Public ProfileWindows As DataTable = Nothing + Public ProfileControls As DataTable = Nothing + + Public MatchTreeView As TreeView = New TreeView() + + Public Property CurrentMatchingProfiles As List(Of ProfileData) = New List(Of ProfileData) + Public Property CurrentProfilesWithResults As List(Of ProfileData) = New List(Of ProfileData) + Public Property CurrentClipboardContents As String = String.Empty + + Public Property MonitoringActive As Boolean = False + Public Property Status As EnumStatus End Class End Namespace \ No newline at end of file diff --git a/GUIs.ZooFlow/frmFlowForm.Designer.vb b/GUIs.ZooFlow/frmFlowForm.Designer.vb index a35207e5..98f5e908 100644 --- a/GUIs.ZooFlow/frmFlowForm.Designer.vb +++ b/GUIs.ZooFlow/frmFlowForm.Designer.vb @@ -35,20 +35,21 @@ Partial Class frmFlowForm Me.ZooFlowBeendenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.TimerRefreshData = New System.Windows.Forms.Timer(Me.components) Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) - Me.TimerCheckActiveForms = New System.Windows.Forms.Timer(Me.components) - Me.TimerCheckDroppedFiles = New System.Windows.Forms.Timer(Me.components) Me.PictureBoxAbo = New System.Windows.Forms.PictureBox() Me.PictureBoxDragDrop = New System.Windows.Forms.PictureBox() - Me.PictureBoxGlobix = New System.Windows.Forms.PictureBox() Me.PictureBoxPM = New System.Windows.Forms.PictureBox() Me.PictureBoxSearch = New System.Windows.Forms.PictureBox() + Me.TimerCheckActiveForms = New System.Windows.Forms.Timer(Me.components) + Me.TimerCheckDroppedFiles = New System.Windows.Forms.Timer(Me.components) + Me.PictureBoxGlobix = New System.Windows.Forms.PictureBox() Me.PictureBox1 = New System.Windows.Forms.PictureBox() + Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components) Me.ContextMenuSystray.SuspendLayout() CType(Me.PictureBoxAbo, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.PictureBoxDragDrop, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.PictureBoxGlobix, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.PictureBoxPM, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.PictureBoxSearch, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.PictureBoxGlobix, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' @@ -106,14 +107,6 @@ Partial Class frmFlowForm Me.ZooFlowBeendenToolStripMenuItem.Size = New System.Drawing.Size(173, 22) Me.ZooFlowBeendenToolStripMenuItem.Text = "ZooFlow beenden" ' - 'TimerCheckActiveForms - ' - Me.TimerCheckActiveForms.Interval = 2000 - ' - 'TimerCheckDroppedFiles - ' - Me.TimerCheckDroppedFiles.Interval = 400 - ' 'PictureBoxAbo ' Me.PictureBoxAbo.Cursor = System.Windows.Forms.Cursors.Hand @@ -137,18 +130,6 @@ Partial Class frmFlowForm Me.PictureBoxDragDrop.TabStop = False Me.ToolTip1.SetToolTip(Me.PictureBoxDragDrop, "Drag and Drop files here") ' - 'PictureBoxGlobix - ' - Me.PictureBoxGlobix.BackColor = System.Drawing.Color.Transparent - Me.PictureBoxGlobix.Cursor = System.Windows.Forms.Cursors.Hand - Me.PictureBoxGlobix.Image = CType(resources.GetObject("PictureBoxGlobix.Image"), System.Drawing.Image) - Me.PictureBoxGlobix.Location = New System.Drawing.Point(448, 23) - Me.PictureBoxGlobix.Name = "PictureBoxGlobix" - Me.PictureBoxGlobix.Size = New System.Drawing.Size(90, 101) - Me.PictureBoxGlobix.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom - Me.PictureBoxGlobix.TabIndex = 9 - Me.PictureBoxGlobix.TabStop = False - ' 'PictureBoxPM ' Me.PictureBoxPM.BackColor = System.Drawing.Color.Transparent @@ -175,6 +156,26 @@ Partial Class frmFlowForm Me.PictureBoxSearch.TabStop = False Me.ToolTip1.SetToolTip(Me.PictureBoxSearch, "ZooFlow Suche") ' + 'TimerCheckActiveForms + ' + Me.TimerCheckActiveForms.Interval = 2000 + ' + 'TimerCheckDroppedFiles + ' + Me.TimerCheckDroppedFiles.Interval = 400 + ' + 'PictureBoxGlobix + ' + Me.PictureBoxGlobix.BackColor = System.Drawing.Color.Transparent + Me.PictureBoxGlobix.Cursor = System.Windows.Forms.Cursors.Hand + Me.PictureBoxGlobix.Image = CType(resources.GetObject("PictureBoxGlobix.Image"), System.Drawing.Image) + Me.PictureBoxGlobix.Location = New System.Drawing.Point(448, 23) + Me.PictureBoxGlobix.Name = "PictureBoxGlobix" + Me.PictureBoxGlobix.Size = New System.Drawing.Size(90, 101) + Me.PictureBoxGlobix.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom + Me.PictureBoxGlobix.TabIndex = 9 + Me.PictureBoxGlobix.TabStop = False + ' 'PictureBox1 ' Me.PictureBox1.BackColor = System.Drawing.Color.Transparent @@ -185,6 +186,12 @@ Partial Class frmFlowForm Me.PictureBox1.TabIndex = 12 Me.PictureBox1.TabStop = False ' + 'ImageList1 + ' + Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit + Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16) + Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent + ' 'frmFlowForm ' Me.AllowDrop = True @@ -210,9 +217,9 @@ Partial Class frmFlowForm Me.ContextMenuSystray.ResumeLayout(False) CType(Me.PictureBoxAbo, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.PictureBoxDragDrop, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.PictureBoxGlobix, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.PictureBoxPM, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.PictureBoxSearch, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.PictureBoxGlobix, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) @@ -235,4 +242,5 @@ Partial Class frmFlowForm Friend WithEvents TimerCheckActiveForms As Timer Friend WithEvents TimerCheckDroppedFiles As Timer Friend WithEvents PictureBox1 As PictureBox + Friend WithEvents ImageList1 As ImageList End Class diff --git a/GUIs.ZooFlow/frmFlowForm.resx b/GUIs.ZooFlow/frmFlowForm.resx index 2085a2b1..5105440a 100644 --- a/GUIs.ZooFlow/frmFlowForm.resx +++ b/GUIs.ZooFlow/frmFlowForm.resx @@ -1962,34 +1962,6 @@ 610, 17 - - 709, 17 - - - 891, 17 - - - - iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL - EgAACxIB0t1+/AAAA8pJREFUeF7t3D1uFEEQhmEfwUdwBAIhZG7gI/goPoKP4CP4FAQEyCIgRIgAiQRZ - IiAhcERAstQnjaX26t3dmu7qnlm5giepWXf9aH9me2Z9stlsUgMMJj8MJj8MJj8MJj8MJj8MJj8MJj8M - Jj8MJj8MjvTj/Ytzc2VuzZ3ZHKDH6LH6m3NacyQM9maNX05DeDA0pDm0hta6pFy9YbAHa/DUXJt7Q4OI - oLWV45Rq6AGD0aamIp5tXsp1TbVEw2AUa+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AALdEVYdFRpdGxlAFpvb207zwn+vAAAAKdJREFUOE+1 + ktERREAQRElHLjIQhAgcYrgs1PkWjp+Txuh3hdpadu+c8vHU1HRPzy4SM7vE55G3wxGpKEQnpgVqemjR + AAy1sABoaSyALRjf4iGyBWp6aEUsgKNiYsDX6KF1sQDui4mtvkYPbbo14PIVXgLTGsJWoP76EiuxDocI + fkZ/uBc//0j+cCPc8B1uwFOcGgY3YBSnhsENKAUhnGRnDLEF/I8lMzpgJH6ZZgx9AAAAAElFTkSuQmCC + + + + 1079, 17 + \ No newline at end of file diff --git a/GUIs.ZooFlow/frmFlowForm.vb b/GUIs.ZooFlow/frmFlowForm.vb index 4509343a..721505b2 100644 --- a/GUIs.ZooFlow/frmFlowForm.vb +++ b/GUIs.ZooFlow/frmFlowForm.vb @@ -4,6 +4,8 @@ Imports System.IO Imports DevExpress.XtraSplashScreen Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Messaging +Imports DigitalData.Modules.Windows + Imports DigitalData.GUIs.ClipboardWatcher Imports DigitalData.GUIs.ZooFlow.ClassConstants @@ -21,6 +23,8 @@ Public Class frmFlowForm Private FileDrop As ClassFileDrop Private FileHandle As ClassFilehandle Private ProfileFilter As ProfileFilter + Private WindowClass As Window + ' Runtime Flags Private ApplicationLoading As Boolean = True @@ -33,6 +37,7 @@ Public Class frmFlowForm ' Events Public Event ClipboardChanged As EventHandler(Of IDataObject) + Private WithEvents HotkeyClass As Hotkey Private WithEvents Watcher As ClipboardWatcher.Watcher = ClipboardWatcher.Watcher.Singleton Public Sub New() @@ -89,7 +94,6 @@ Public Class frmFlowForm ' === Register As Event Listener === EventBus.Instance.Register(Me) - ' === Set Form Properties === TopMost = True AllowDrop = True @@ -108,7 +112,6 @@ Public Class frmFlowForm AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged - ' TODO: Clean up Dim oSQL = My.Queries.Common.FNIDB_GET_SEARCH_PROFILES(My.Application.User.UserId, My.Application.User.Language) Dim oDatatable As DataTable = My.DatabaseIDB.GetDatatable(oSQL) @@ -119,17 +122,136 @@ Public Class frmFlowForm DTIDB_SEARCHES = oDatatable PictureBoxSearch.Visible = True End If + + If My.Application.ModulesActive.Contains(MODULE_CLIPBOARDWATCHER) Then + Try + WindowClass = New Window(My.LogConfig) + HotkeyClass = New Hotkey(Me) + + 'Add Toggle Hotkey + HotkeyClass.AddHotKey(Keys.T, Hotkey.ModfierKey.MOD_CONTROL, HOTKEY_TOGGLE_WATCHER) + + ' Add Trigger Hotkey + + 'TODO: Configure Hotkey + Dim oSearchKey As String = "D" + Dim oFunctionKey As String = "CTRL" + + Dim oConverter As New KeysConverter + Dim oObject As Object = oConverter.ConvertFromString(oSearchKey) + Dim oKeyCode As Keys = oObject + + Select Case oFunctionKey + Case "CTRL" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_CONTROL, ClassConstants.HOTKEY_TRIGGER_WATCHER) + Case "SHIFT" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_SHIFT, ClassConstants.HOTKEY_TRIGGER_WATCHER) + Case "ALT" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_ALT, ClassConstants.HOTKEY_TRIGGER_WATCHER) + Case "WIN" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_WIN, ClassConstants.HOTKEY_TRIGGER_WATCHER) + End Select + Catch ex As Exception + Logger.Error(ex) + MsgBox("Error while initializing Hotkeys for Clipboard Watcher!", MsgBoxStyle.Critical, Text) + End Try + Else + My.Application.ClipboardWatcher.MonitoringActive = False + Logger.Info("Clipboard Watcher Module is not active. Hotkey Monitoring will be disabled!") + End If + If My.Application.ModulesActive.Contains(MODULE_GLOBAL_INDEXER) Then FileDrop = New ClassFileDrop(My.LogConfig) FileHandle = New ClassFilehandle(My.LogConfig) Refresh_RegexTable() End If + My.DTAttributes = My.DatabaseIDB.GetDatatable("SELECT * FROM TBIDB_ATTRIBUTE") Me.Cursor = Cursors.Default End Sub Private Sub Watcher_ClipboardChanged(sender As Object, e As IDataObject) - Throw New NotImplementedException() + If My.Application.ClipboardWatcher.MonitoringActive = False Then + Logger.Info("Clipboard Watcher is not active!") + Exit Sub + End If + + If My.Application.ClipboardWatcher.UserProfiles Is Nothing OrElse My.Application.ClipboardWatcher.UserProfiles.Rows.Count = 0 Then + Logger.Warn("User Profiles is empty!") + Exit Sub + End If + + If My.Application.ClipboardWatcher.ProfileProcesses Is Nothing OrElse My.Application.ClipboardWatcher.ProfileProcesses.Rows.Count = 0 Then + Logger.Warn("Profile Processes is empty!") + Exit Sub + End If + + If My.Application.ClipboardWatcher.ProfileWindows Is Nothing OrElse My.Application.ClipboardWatcher.ProfileWindows.Rows.Count = 0 Then + Logger.Warn("Profile Processes is empty!") + Exit Sub + End If + + If My.Application.ClipboardWatcher.ProfileProcesses Is Nothing OrElse My.Application.ClipboardWatcher.ProfileProcesses.Rows.Count = 0 Then + Logger.Warn("Profile Processes is empty!") + Exit Sub + End If + + + Dim oWindowInfo = WindowClass.GetWindowInfo() + Dim ClipboardContents As String = Clipboard.GetText().Trim() + + Try + ' Tree View zurücksetzen + My.Application.ClipboardWatcher.MatchTreeView.Nodes.Clear() + + ProfileFilter = New ProfileFilter(My.LogConfig, + My.Application.ClipboardWatcher.UserProfiles, + My.Application.ClipboardWatcher.ProfileProcesses, + My.Application.ClipboardWatcher.ProfileWindows, + My.Application.ClipboardWatcher.ProfileControls, + My.Application.ClipboardWatcher.MatchTreeView + ) + Catch ex As Exception + Logger.Error(ex) + MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text) + End Try + + Try + Dim oProfiles = ProfileFilter.Profiles.AsEnumerable() + Dim oEnvironment = ClassEnvironment.GetEnvironment() + + ' Filter by Clipboard Contents + oProfiles = ProfileFilter.FilterProfilesByClipboardRegex(oProfiles, ClipboardContents) + oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "FilterProfilesByClipboardRegex") + + ' Filter by Process Name + oProfiles = ProfileFilter.FilterProfilesByProcess(oProfiles, oWindowInfo.ProcessName) + oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "FilterProfilesByProcess") + + ' Filter by Window Title + oProfiles = ProfileFilter.FilterWindowsByWindowTitleRegex(oProfiles, oWindowInfo.WindowTitle) + oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "FilterWindowsByWindowTitleRegex") + + ' Filter by Focused Control + oProfiles = ProfileFilter.FilterProfilesByFocusedControl(oProfiles, ClipboardContents, Handle) + oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "FilterProfilesByFocusedControl") + My.Application.ClipboardWatcher.CurrentMatchingProfiles = oProfiles.ToList() + + ' Filter by Search Results + oProfiles = ProfileFilter.FilterProfilesBySearchResults(oProfiles, oEnvironment.Database, oEnvironment.User, ClipboardContents) + oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "FilterProfilesBySearchResults") + + ' Clean up Profiles + oProfiles = ProfileFilter.ClearNotMatchedProfiles(oProfiles) + oProfiles = ProfileFilter.ClearDuplicateProfiles(oProfiles) + oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "CleanUp") + + My.Application.ClipboardWatcher.CurrentProfilesWithResults = oProfiles.ToList() + My.Application.ClipboardWatcher.CurrentClipboardContents = ClipboardContents + Catch ex As Exception + Logger.Error(ex) + MsgBox("Fehler beim Auswerten der Profile. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text) + End Try End Sub Private Sub TimerRefreshData_Tick(sender As Object, e As EventArgs) @@ -411,7 +533,7 @@ Public Class frmFlowForm My.Application.Globix.CURRENT_WORKFILE_GUID = oFileRow.Item(0) My.Application.Globix.CURRENT_WORKFILE = oFileRow.Item("FILENAME2WORK").ToString Logger.Info(">> CURRENT_WORKFILE: " & My.Application.Globix.CURRENT_WORKFILE) - If File.Exists(My.Application.Globix.CURRENT_WORKFILE) = True And My.Application.Globix.DTACTUAL_FILES.Rows.Count > 0 Then + If IO.File.Exists(My.Application.Globix.CURRENT_WORKFILE) = True And My.Application.Globix.DTACTUAL_FILES.Rows.Count > 0 Then Globix_Open_IndexDialog() End If Next @@ -441,6 +563,13 @@ Public Class frmFlowForm My.UIConfigManager.Save() End Sub - - + Private Sub frmFlowForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing + Try + HotkeyClass.RemoveHotKey(HOTKEY_TOGGLE_WATCHER) + HotkeyClass.RemoveHotKey(HOTKEY_TRIGGER_WATCHER) + Catch ex As Exception + Logger.Error(ex) + Logger.Warn("Hotkeys could not be removed") + End Try + End Sub End Class \ No newline at end of file diff --git a/Windows/Hotkey.vb b/Windows/Hotkey.vb new file mode 100644 index 00000000..970dba1d --- /dev/null +++ b/Windows/Hotkey.vb @@ -0,0 +1,84 @@ +Imports System.Windows.Forms + +Public Class Hotkey + Implements IMessageFilter + + Private _OwnerForm As Form + Private _HotkeyList As New Dictionary(Of Short, HotKeyObject) + Private _HotkeyIDList As New Dictionary(Of String, Short) + + ''' + ''' Diesem Event wird immer die zugewiesene HotKeyID übergeben, wenn eine HotKey Kombination gedrückt wurde. + ''' + Public Event HotKeyPressed(ByVal HotKeyID As String) + + ''' + ''' Definiert verfügbare Modfier Keys + ''' + Public Enum ModfierKey As Integer + MOD_ALT = 1 + MOD_CONTROL = 2 + MOD_SHIFT = 4 + MOD_WIN = 8 + End Enum + + Sub New(ByVal pOwnerForm As Form) + _OwnerForm = pOwnerForm + Application.AddMessageFilter(Me) + End Sub + + ''' + ''' Diese Funktion fügt einen Hotkey hinzu und registriert ihn auch sofort + ''' + ''' Den KeyCode für die Taste + ''' Die Zusatztasten wie z.B. Strg oder Alt, diese können auch mit OR kombiniert werden + ''' Die ID die der Hotkey bekommen soll um diesen zu identifizieren + Public Sub AddHotKey(ByVal pKeyCode As Keys, ByVal pModifiers As ModfierKey, ByVal pHotKeyID As Integer) + If _HotkeyIDList.ContainsKey(pHotKeyID) = True Then + Exit Sub + End If + + Dim oHotkeyId As Short = NativeMethods.GlobalAddAtom(pHotKeyID) + _HotkeyIDList.Add(pHotKeyID, oHotkeyId) + _HotkeyList.Add(oHotkeyId, New HotKeyObject(pKeyCode, pModifiers, pHotKeyID)) + + NativeMethods.RegisterHotKey(_OwnerForm.Handle, oHotkeyId, _HotkeyList(oHotkeyId).Modifier, _HotkeyList(oHotkeyId).HotKey) + End Sub + + ''' + ''' Diese Funktion entfernt einen Hotkey und deregistriert ihn auch sofort + ''' + ''' Gibt die HotkeyID an welche entfernt werden soll + Public Sub RemoveHotKey(ByVal pHotKeyID As Integer) + If _HotkeyIDList.ContainsKey(pHotKeyID) = False Then + Exit Sub + End If + + Dim oHotkeyId As Short = _HotkeyIDList(pHotKeyID) + _HotkeyIDList.Remove(pHotKeyID) + _HotkeyList.Remove(oHotkeyId) + NativeMethods.UnregisterHotKey(_OwnerForm.Handle, CInt(oHotkeyId)) + NativeMethods.GlobalDeleteAtom(oHotkeyId) + End Sub + + Private Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage + If m.Msg = NativeMethods.WM_HOTKEY Then + If Clipboard.GetText().Trim() <> String.Empty Then + RaiseEvent HotKeyPressed(_HotkeyList(CShort(m.WParam)).HotKeyID) + End If + End If + End Function + + Public Class HotKeyObject + Public Property HotKey() As Keys + Public Property Modifier() As ModfierKey + Public Property HotKeyID() As String + Public Property AtomID() As Short + + Sub New(ByVal NewHotKey As Keys, ByVal NewModifier As ModfierKey, ByVal NewHotKeyID As String) + HotKey = NewHotKey + Modifier = NewModifier + HotKeyID = NewHotKeyID + End Sub + End Class +End Class diff --git a/Windows/My Project/AssemblyInfo.vb b/Windows/My Project/AssemblyInfo.vb index 1bbeb8b0..97a103ef 100644 --- a/Windows/My Project/AssemblyInfo.vb +++ b/Windows/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Windows/NativeMethods.vb b/Windows/NativeMethods.vb index d5c328e9..dabda157 100644 --- a/Windows/NativeMethods.vb +++ b/Windows/NativeMethods.vb @@ -79,6 +79,27 @@ Public Class NativeMethods Public Shared Function GetCursorPos(ByRef lpPoint As PointAPI) As Boolean End Function + Public Declare Function RegisterHotKey Lib "user32" ( + ByVal Hwnd As IntPtr, + ByVal ID As Integer, + ByVal Modifiers As Integer, + ByVal Key As Integer + ) As Integer + + Public Declare Function UnregisterHotKey Lib "user32" ( + ByVal Hwnd As IntPtr, + ByVal ID As Integer + ) As Integer + + Public Declare Auto Function GetWindowText Lib "user32" ( + ByVal hWnd As IntPtr, + ByVal lpString As StringBuilder, + ByVal cch As Integer + ) As Integer + + Public Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal IDString As String) As Short + Public Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal Atom As Short) As Short + Public Const STANDARD_RIGHTS_REQUIRED As Integer = &HF0000 Public Const SECTION_QUERY As Short = &H1 Public Const SECTION_MAP_WRITE As Short = &H2 @@ -104,6 +125,7 @@ Public Class NativeMethods Public Const SEE_MASK_INVOKEIDLIST = &HC Public Const SEE_MASK_NOCLOSEPROCESS = &H40 Public Const SEE_MASK_FLAG_NO_UI = &H400 + Public Const WM_HOTKEY As Integer = &H312 Public Enum PageProtection As UInteger NoAccess = &H1 diff --git a/Windows/Windows.vbproj b/Windows/Windows.vbproj index 3bd354be..851b21ec 100644 --- a/Windows/Windows.vbproj +++ b/Windows/Windows.vbproj @@ -76,6 +76,7 @@ +