ClipboardWatcher: Catchall profiles
This commit is contained in:
parent
8907f64bf9
commit
ac71352c24
@ -124,15 +124,17 @@ Public Class ProfileFilter
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oIsMatch = oProcess.ProcessName.ToLower = ProcessName.ToLower
|
Dim oIsMatch = oProcess.ProcessName.ToLower = ProcessName.ToLower
|
||||||
|
Dim oIsCatchAll As Boolean = False
|
||||||
|
|
||||||
' Catch-all processname
|
' Catch-all processname
|
||||||
If oProcess.ProcessName.ToLower = PROCESS_NAME_CATCHALL.ToLower Then
|
If oProcess.ProcessName.ToLower = PROCESS_NAME_CATCHALL.ToLower Then
|
||||||
oIsMatch = True
|
oIsMatch = True
|
||||||
|
oIsCatchAll = True
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oParent = _ProfileMatch.FindNodeByTag(_TreeView.Nodes, oProfile.Name & "-REGEX")
|
Dim oParent = _ProfileMatch.FindNodeByTag(_TreeView.Nodes, oProfile.Name & "-REGEX")
|
||||||
If oParent IsNot Nothing Then
|
If oParent IsNot Nothing Then
|
||||||
Dim oNode = _ProfileMatch.NewProcessNode(oProfile, oProcess, oIsMatch)
|
Dim oNode = _ProfileMatch.NewProcessNode(oProfile, oProcess, oIsMatch, oIsCatchAll)
|
||||||
oParent.Nodes.Add(oNode)
|
oParent.Nodes.Add(oNode)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -143,8 +145,12 @@ Public Class ProfileFilter
|
|||||||
oFilteredProfiles.Add(oProfile)
|
oFilteredProfiles.Add(oProfile)
|
||||||
_Logger.Info("FilterProfilesByProcess: Profile {0} matched!", oProfile.Name)
|
_Logger.Info("FilterProfilesByProcess: Profile {0} matched!", oProfile.Name)
|
||||||
|
|
||||||
|
' Set Process matched
|
||||||
oProcess.IsMatched = True
|
oProcess.IsMatched = True
|
||||||
oProcesses.Add(oProcess)
|
oProcesses.Add(oProcess)
|
||||||
|
|
||||||
|
' Set Profile matched
|
||||||
|
oProfile.IsCatchAll = True
|
||||||
oProfile.IsMatched = True
|
oProfile.IsMatched = True
|
||||||
oProfile.MatchedProcessID = oProcess.Guid
|
oProfile.MatchedProcessID = oProcess.Guid
|
||||||
|
|
||||||
@ -231,13 +237,23 @@ Public Class ProfileFilter
|
|||||||
|
|
||||||
_Logger.Info("FilterWindowsByWindowTitleRegex: Profile {0} matched!", oProfile.Name)
|
_Logger.Info("FilterWindowsByWindowTitleRegex: Profile {0} matched!", oProfile.Name)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If oProfile.IsCatchAll Then
|
||||||
|
oProfile.IsMatched = True
|
||||||
|
oProfiles.Add(oProfile)
|
||||||
|
|
||||||
|
_Logger.Info("FilterWindowsByWindowTitleRegex: Profile {0} is marked catchall!", oProfile.Name)
|
||||||
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
' Add catch-all profiles to the list
|
||||||
|
oProfiles = AddCatchAllProfiles(Profiles, oProfiles)
|
||||||
|
|
||||||
Return oProfiles
|
Return oProfiles
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function FilterProfilesByFocusedControl(Profiles As List(Of ProfileData), ClipboardContents As String, WindowHandle As IntPtr) As List(Of ProfileData)
|
Public Function FilterProfilesByFocusedControl(Profiles As List(Of ProfileData), ClipboardContents As String, WindowHandle As IntPtr) As List(Of ProfileData)
|
||||||
Dim oFilteredProfiles As New List(Of ProfileData)
|
Dim oProfiles As New List(Of ProfileData)
|
||||||
Dim oWindow As New Window(_LogConfig)
|
Dim oWindow As New Window(_LogConfig)
|
||||||
Dim oFocusedWindow As Window.WindowInfo
|
Dim oFocusedWindow As Window.WindowInfo
|
||||||
|
|
||||||
@ -264,7 +280,7 @@ Public Class ProfileFilter
|
|||||||
' If Profile has no controls at all, it automatically matches
|
' If Profile has no controls at all, it automatically matches
|
||||||
If oFilteredControls.Count = 0 Then
|
If oFilteredControls.Count = 0 Then
|
||||||
_Logger.Debug("Profile has no Controls assigned, automatic MATCH")
|
_Logger.Debug("Profile has no Controls assigned, automatic MATCH")
|
||||||
oFilteredProfiles.Add(oProfile)
|
oProfiles.Add(oProfile)
|
||||||
Continue For
|
Continue For
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -335,13 +351,16 @@ Public Class ProfileFilter
|
|||||||
If oMatchingControls.Count > 0 Then
|
If oMatchingControls.Count > 0 Then
|
||||||
_Logger.Debug("Profile has {0} MATCHING Controls", oMatchingControls.Count)
|
_Logger.Debug("Profile has {0} MATCHING Controls", oMatchingControls.Count)
|
||||||
oProfile.Controls = oMatchingControls
|
oProfile.Controls = oMatchingControls
|
||||||
oFilteredProfiles.Add(oProfile)
|
oProfiles.Add(oProfile)
|
||||||
|
|
||||||
_Logger.Info("FilterProfilesByFocusedControl: Profile {0} matched!", oProfile.Name)
|
_Logger.Info("FilterProfilesByFocusedControl: Profile {0} matched!", oProfile.Name)
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
Return oFilteredProfiles
|
' Add catch-all profiles to the list
|
||||||
|
oProfiles = AddCatchAllProfiles(Profiles, oProfiles)
|
||||||
|
|
||||||
|
Return oProfiles
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function FilterProfilesBySearchResults(Profiles As List(Of ProfileData), Database As MSSQLServer, User As UserState, ClipboardContents As String) As List(Of ProfileData)
|
Public Function FilterProfilesBySearchResults(Profiles As List(Of ProfileData), Database As MSSQLServer, User As UserState, ClipboardContents As String) As List(Of ProfileData)
|
||||||
@ -444,6 +463,9 @@ Public Class ProfileFilter
|
|||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
' Add catch-all profiles to the list
|
||||||
|
oProfiles = AddCatchAllProfiles(Profiles, oProfiles)
|
||||||
|
|
||||||
Return oProfiles
|
Return oProfiles
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@ -490,6 +512,9 @@ Public Class ProfileFilter
|
|||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
' Add catch-all profiles to the list
|
||||||
|
oProfiles = AddCatchAllProfiles(Profiles, oProfiles)
|
||||||
|
|
||||||
Return oProfiles
|
Return oProfiles
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@ -510,6 +535,21 @@ Public Class ProfileFilter
|
|||||||
ToList()
|
ToList()
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Function AddCatchAllProfiles(AllProfiles As List(Of ProfileData), FilteredProfiles As List(Of ProfileData)) As List(Of ProfileData)
|
||||||
|
Dim oCatchAllProfiles As New List(Of ProfileData)
|
||||||
|
|
||||||
|
For Each oProfile As ProfileData In AllProfiles
|
||||||
|
If oProfile.IsCatchAll And FilteredProfiles.Contains(oProfile) = False Then
|
||||||
|
oProfile.IsMatched = True
|
||||||
|
oCatchAllProfiles.Add(oProfile)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return FilteredProfiles.
|
||||||
|
Concat(oCatchAllProfiles).
|
||||||
|
ToList()
|
||||||
|
End Function
|
||||||
|
|
||||||
Private Function TransformProfiles() As List(Of ProfileData)
|
Private Function TransformProfiles() As List(Of ProfileData)
|
||||||
Try
|
Try
|
||||||
Dim oList As New List(Of ProfileData)
|
Dim oList As New List(Of ProfileData)
|
||||||
|
|||||||
@ -49,11 +49,16 @@ Public Class ProfileMatch
|
|||||||
|
|
||||||
Return oNode
|
Return oNode
|
||||||
End Function
|
End Function
|
||||||
Public Function NewProcessNode(Profile As ProfileData, Process As ProcessData, IsMatch As Boolean) As TreeNode
|
Public Function NewProcessNode(Profile As ProfileData, Process As ProcessData, IsMatch As Boolean, IsCatchAll As Boolean) As TreeNode
|
||||||
_Logger.Debug("New Process Node for Profile {0} and ProcessName {1}", Profile.Name, Process.ProcessName)
|
_Logger.Debug("New Process Node for Profile {0} and ProcessName {1}", Profile.Name, Process.ProcessName)
|
||||||
|
|
||||||
Dim oMatchText = IIf(IsMatch, "MATCH", "NO MATCH")
|
Dim oText As String
|
||||||
Dim oText = $"{GetMatchText(IsMatch)} on ProcessName {Process.ProcessName}"
|
If IsCatchAll Then
|
||||||
|
oText = $"{GetMatchText(IsMatch)} on Catch-All Process"
|
||||||
|
Else
|
||||||
|
oText = $"{GetMatchText(IsMatch)} on ProcessName {Process.ProcessName}"
|
||||||
|
End If
|
||||||
|
|
||||||
Dim oNode As New TreeNode() With {
|
Dim oNode As New TreeNode() With {
|
||||||
.Text = oText,
|
.Text = oText,
|
||||||
.ImageIndex = ProfileFilter.ImageIndex.Process,
|
.ImageIndex = ProfileFilter.ImageIndex.Process,
|
||||||
|
|||||||
@ -14,6 +14,8 @@
|
|||||||
Public CountData As Integer = 0
|
Public CountData As Integer = 0
|
||||||
|
|
||||||
Public IsMatched As Boolean = False
|
Public IsMatched As Boolean = False
|
||||||
|
Public IsCatchAll As Boolean = False
|
||||||
|
|
||||||
Public MatchedProcessID As Integer = 0
|
Public MatchedProcessID As Integer = 0
|
||||||
Public MatchedWindowID As Integer = 0
|
Public MatchedWindowID As Integer = 0
|
||||||
Public MatchedControlID As Integer = 0
|
Public MatchedControlID As Integer = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user