prepare zooflow, add profilefilter
This commit is contained in:
106
ClipboardWatcher/ProfileMatch.vb
Normal file
106
ClipboardWatcher/ProfileMatch.vb
Normal file
@@ -0,0 +1,106 @@
|
||||
Imports System.Drawing
|
||||
Imports System.Windows.Forms
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow.Params
|
||||
|
||||
Public Class ProfileMatch
|
||||
Private _Logger As Logger
|
||||
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
Public Function FindNodeByTag(ByVal nodes As TreeNodeCollection, ByVal Tag As String) As TreeNode
|
||||
For Each node As TreeNode In nodes
|
||||
If (node.Tag.Equals(Tag)) Then
|
||||
Return node
|
||||
End If
|
||||
|
||||
Dim oNext As TreeNode = FindNodeByTag(node.Nodes, Tag)
|
||||
If oNext IsNot Nothing Then
|
||||
Return oNext
|
||||
End If
|
||||
Next
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
Public Function NewProfileNode(Profile As ProfileData) As TreeNode
|
||||
Dim oNode As New TreeNode() With {
|
||||
.Text = $"Profile: {Profile.Name}",
|
||||
.ImageIndex = 0,
|
||||
.Tag = Profile.Name & "-PROFILE"
|
||||
}
|
||||
|
||||
Return oNode
|
||||
End Function
|
||||
|
||||
Public Function NewClipboardRegexNode(Profile As ProfileData, IsMatch As Boolean) As TreeNode
|
||||
Dim oText = $"{GetMatchText(IsMatch)} on Global Clipboard Regex {Profile.Regex}"
|
||||
|
||||
Dim oNode As New TreeNode() With {
|
||||
.Text = oText,
|
||||
.ImageIndex = 1,
|
||||
.Tag = Profile.Name & "-REGEX",
|
||||
.BackColor = GetMatchColor(IsMatch)
|
||||
}
|
||||
|
||||
Return oNode
|
||||
End Function
|
||||
Public Function NewProcessNode(Profile As ProfileData, Process As ProcessData, IsMatch As Boolean) As TreeNode
|
||||
Dim oMatchText = IIf(IsMatch, "MATCH", "NO MATCH")
|
||||
Dim oText = $"{GetMatchText(IsMatch)} on ProcessName {Process.ProcessName}"
|
||||
|
||||
Dim oNode As New TreeNode() With {
|
||||
.Text = oText,
|
||||
.ImageIndex = 4,
|
||||
.Tag = Process.Guid & "-PROCESS",
|
||||
.BackColor = GetMatchColor(IsMatch)
|
||||
}
|
||||
|
||||
Return oNode
|
||||
End Function
|
||||
|
||||
Public Function NewWindowNode(Profile As ProfileData, Window As WindowData, IsMatch As Boolean) As TreeNode
|
||||
Dim oMatchText = IIf(IsMatch, "MATCH", "NO MATCH")
|
||||
Dim oText = $"{GetMatchText(IsMatch)} on WindowTitle {Window.Title}"
|
||||
|
||||
Dim oNode As New TreeNode() With {
|
||||
.Text = oText,
|
||||
.ImageIndex = 3,
|
||||
.Tag = Window.Guid & "-WINDOW",
|
||||
.BackColor = GetMatchColor(IsMatch)
|
||||
}
|
||||
|
||||
Return oNode
|
||||
End Function
|
||||
|
||||
Public Function NewControlNode(Profile As ProfileData, Control As ControlData, IsMatch As Boolean) As TreeNode
|
||||
Dim oMatchText = IIf(IsMatch, "MATCH", "NO MATCH")
|
||||
Dim oText = $"{GetMatchText(IsMatch)} on Control {Control.Description}: {IsMatch.ToString}"
|
||||
|
||||
Dim oNode As New TreeNode() With {
|
||||
.Text = oText,
|
||||
.ImageIndex = 2,
|
||||
.Tag = Control.Guid & "-CONTROL",
|
||||
.BackColor = GetMatchColor(IsMatch)
|
||||
}
|
||||
|
||||
Return oNode
|
||||
End Function
|
||||
|
||||
Private Function GetLowestNode(ByVal Node As TreeNode) As TreeNode
|
||||
If Node.GetNodeCount(False) = 1 Then
|
||||
Return GetLowestNode(Node.Nodes.Item(0))
|
||||
Else
|
||||
Return Node
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function GetMatchText(IsMatch As Boolean)
|
||||
Return IIf(IsMatch, "MATCH", "NO MATCH")
|
||||
End Function
|
||||
|
||||
Private Function GetMatchColor(IsMatch As Boolean)
|
||||
Return IIf(IsMatch, Color.LightGreen, Color.LightCoral)
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user