finish profile filtering (1/?)
This commit is contained in:
parent
54598ab3d4
commit
d55d77a426
@ -101,16 +101,6 @@ Public Class ClassProfileFilter
|
||||
Return _Profiles
|
||||
End Function
|
||||
|
||||
Private Function FindNode(ByVal Node As TreeNode, SearchTerm As String)
|
||||
Dim oNode As TreeNode
|
||||
For Each oNode In Node.Nodes
|
||||
If oNode.Text = SearchTerm Then
|
||||
Return oNode
|
||||
End If
|
||||
Next
|
||||
Return Node
|
||||
End Function
|
||||
|
||||
Private Function GetLowestNode(ByVal Node As TreeNode) As TreeNode
|
||||
If Node.GetNodeCount(False) = 1 Then
|
||||
Return GetLowestNode(Node.Nodes.Item(0))
|
||||
@ -119,11 +109,36 @@ Public Class ClassProfileFilter
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function Node_Get_Lowest_Node(NodeTag As String) As TreeNode
|
||||
Dim oExit = False
|
||||
Dim oParentNode As TreeNode
|
||||
For Each oTreeNode As TreeNode In CurrMatchTreeView.Nodes
|
||||
For Each oNodes As TreeNode In oTreeNode.Nodes
|
||||
If oExit = True Then Exit For
|
||||
If oNodes.Tag = NodeTag Then
|
||||
oParentNode = oNodes
|
||||
oExit = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
Dim olowestNode As TreeNode = GetLowestNode(oParentNode)
|
||||
|
||||
Return olowestNode
|
||||
End Function
|
||||
|
||||
Public Function FilterProfilesByClipboardRegex(Profiles As List(Of ProfileData), ClipboardContents As String) As List(Of ProfileData)
|
||||
Dim oFilteredProfiles As New List(Of ProfileData)
|
||||
For Each oProfile In Profiles
|
||||
Logger.Debug("Current Profile: {0}", oProfile.Name)
|
||||
|
||||
Dim oNode As New TreeNode() With {
|
||||
.Text = $"Profile: {oProfile.Name}",
|
||||
.ImageIndex = 0,
|
||||
.Tag = oProfile.Name & "-PROFILE"
|
||||
}
|
||||
CurrMatchTreeView.Nodes.Add(oNode)
|
||||
|
||||
Try
|
||||
Dim oRegex As New Regex(oProfile.Regex)
|
||||
Dim oMatch = oRegex.Match(ClipboardContents)
|
||||
@ -132,11 +147,7 @@ Public Class ClassProfileFilter
|
||||
'TODO: Add Debug Data
|
||||
oFilteredProfiles.Add(oProfile)
|
||||
oProfile.IsMatched = True
|
||||
Dim oNode As New TreeNode($"Profile: {oProfile.Name}")
|
||||
oNode.ImageIndex = 0
|
||||
Dim f = New Font("Tahoma", 9, FontStyle.Bold)
|
||||
oNode.NodeFont = f
|
||||
CurrMatchTreeView.Nodes.Add(oNode)
|
||||
|
||||
Dim oSubnode As New TreeNode($"MATCH on Global Clipboard Regex: {oProfile.Regex}")
|
||||
oSubnode.ImageIndex = 1
|
||||
oSubnode.Tag = oProfile.Name & "-REGEX"
|
||||
@ -337,8 +348,6 @@ Public Class ClassProfileFilter
|
||||
If oTreeNode.Tag = oProfile.Name & "-REGEX" Then
|
||||
oResult = oTreeNode
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
If Not IsNothing(oResult) Then
|
||||
Dim oNode As New TreeNode($"MATCH on WINDOW Clipboard Regex: [{w.Regex}]")
|
||||
@ -507,23 +516,7 @@ Public Class ClassProfileFilter
|
||||
|
||||
Return oFilteredProfiles
|
||||
End Function
|
||||
Private Function Node_Get_Lowest_Node(NodeTag As String) As TreeNode
|
||||
Dim oExit = False
|
||||
Dim oParentNode As TreeNode
|
||||
For Each oTreeNode As TreeNode In CurrMatchTreeView.Nodes
|
||||
For Each oNodes As TreeNode In oTreeNode.Nodes
|
||||
If oExit = True Then Exit For
|
||||
If oNodes.Tag = NodeTag Then
|
||||
oParentNode = oNodes
|
||||
oExit = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
Dim olowestNode As TreeNode = GetLowestNode(oParentNode)
|
||||
|
||||
Return olowestNode
|
||||
End Function
|
||||
Public Function ClearNotMatchedProfiles(Profiles As List(Of ProfileData)) As List(Of ProfileData)
|
||||
Dim oFilteredProfiles As New List(Of ProfileData)
|
||||
For Each oProfile In Profiles
|
||||
@ -552,7 +545,6 @@ Public Class ClassProfileFilter
|
||||
|
||||
oList.Add(New ProfileData() With {
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.Regex = NotNull(oRow.Item("REGEX_EXPRESSION"), String.Empty),
|
||||
.Name = NotNull(oRow.Item("NAME"), String.Empty),
|
||||
.Comment = NotNull(oRow.Item("COMMENT"), String.Empty),
|
||||
.ProfileType = NotNull(oRow.Item("PROFILE_TYPE"), String.Empty),
|
||||
@ -573,7 +565,6 @@ Public Class ClassProfileFilter
|
||||
oControlList.Add(New ControlData() With {
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.Description = NotNull(oRow.Item("DESCRIPTION"), String.Empty),
|
||||
.Regex = NotNull(oRow.Item("REGEX"), String.Empty),
|
||||
.WindowId = oRow.Item("WINDOW_ID"),
|
||||
.TopLeft = New ControlBounds() With {
|
||||
.Left = oRow.Item("TOPLEFT_LEFT"),
|
||||
@ -609,12 +600,13 @@ Public Class ClassProfileFilter
|
||||
Dim oProcessList As New List(Of ProcessData)
|
||||
|
||||
For Each oRow As DataRow In ProcessDatatable.Rows
|
||||
If oRow.Item("PROFILE_ID") = ProfileId Then
|
||||
oProcessList.Add(New ProcessData() With {
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.PROFILE_ID = oRow.Item("PROFILE_ID"),
|
||||
.ProcessName = NotNull(oRow.Item("PROC_NAME"), String.Empty)
|
||||
})
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
Return oProcessList
|
||||
@ -623,6 +615,7 @@ Public Class ClassProfileFilter
|
||||
Dim oWindowList As New List(Of WindowData)
|
||||
|
||||
For Each oRow As DataRow In WindowDatatable.Rows
|
||||
If oRow.Item("PROFILE_ID") = ProfileId Then
|
||||
oWindowList.Add(New WindowData() With {
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.WindowProcessID = oRow.Item("PROCESS_ID"),
|
||||
@ -630,7 +623,7 @@ Public Class ClassProfileFilter
|
||||
.Regex = NotNull(oRow.Item("REGEX"), String.Empty),
|
||||
.Sequence = NotNull(oRow.Item("SEQUENCE"), 0)
|
||||
})
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
Return oWindowList
|
||||
|
||||
@ -105,6 +105,18 @@ Public Class frmStart
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If DTPROFILE_REL_PROCESS Is Nothing OrElse DTPROFILE_REL_PROCESS.Rows.Count = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If DTPROFILE_REL_WINDOW Is Nothing OrElse DTPROFILE_REL_WINDOW.Rows.Count = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If DTPROFILE_REL_CONTROL Is Nothing OrElse DTPROFILE_REL_CONTROL.Rows.Count = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oWindowInfo = GetWindowInfo()
|
||||
Dim ClipboardContents As String = Clipboard.GetText()
|
||||
Dim oProfileFilter As ClassProfileFilter
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user