This commit is contained in:
Jonathan Jenne
2019-09-13 16:05:20 +02:00
parent 6b955569f6
commit 8a8b286c77
19 changed files with 621 additions and 527 deletions

View File

@@ -51,6 +51,9 @@ Class Win32
Public Const AC_SRC_OVER As Byte = &H0
Public Const AC_SRC_ALPHA As Byte = &H1
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HTCAPTION As Integer = &H2
<DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function UpdateLayeredWindow(ByVal hwnd As IntPtr, ByVal hdcDst As IntPtr, ByRef pptDst As Point, ByRef psize As Size, ByVal hdcSrc As IntPtr, ByRef pprSrc As Point, ByVal crKey As Int32, ByRef pblend As BLENDFUNCTION, ByVal dwFlags As Int32) As Bool
End Function
@@ -72,6 +75,13 @@ Class Win32
<DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function DeleteObject(ByVal hObject As IntPtr) As Bool
End Function
<DllImport("User32.dll")>
Public Shared Function ReleaseCapture() As Boolean
End Function
<DllImport("User32.dll")>
Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
End Class
Public Class ClassFlowForm
@@ -81,6 +91,23 @@ Public Class ClassFlowForm
TopMost = True
End Sub
Private Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs)
AddHandler MouseDown, New MouseEventHandler(AddressOf Form_MouseDown)
End Sub
Private Sub Form_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then
Win32.ReleaseCapture()
Win32.SendMessage(Handle, Win32.WM_NCLBUTTONDOWN, Win32.HTCAPTION, 0)
End If
End Sub
Private Sub Form_click(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Click
MsgBox("LOL")
End Sub
Public Sub SetBitmap(ByVal bitmap As Bitmap)
SetBitmap(bitmap, 255, bitmap.Width, bitmap.Height)
End Sub

302
ZooFlow/ClassPatterns.vb Normal file
View File

@@ -0,0 +1,302 @@
Imports System.Text.RegularExpressions
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.ZooFlow
''' <summary>
''' Defines common Functions for Checking for and replacing placeholders.
''' This Class also includes a child class `Pattern` for passing around Patterns.
'''
''' The format of all placeholders is:
''' {#TYPE#VALUE}
'''
''' Some Examples:
''' {#INT#USERNAME}
''' {#CTRL#CMB_2}
''' {#WMI#String 39}
''' </summary>
Public Class ClassPatterns
' Complex patterns that rely on a datasource like a Database or Windream
Public Const PATTERN_WMI = "WMI"
Public Const PATTERN_CTRL = "CTRL"
' Simple patterns that only rely on .NET functions
Public Const PATTERN_INT = "INT"
' Simple patterns that rely on Data from the TBDD_USER table
Public Const PATTERN_USER = "USER"
Public Const USER_VALUE_PRENAME = "PRENAME"
Public Const USER_VALUE_SURNAME = "SURNAME"
Public Const USER_VALUE_EMAIL = "EMAIL"
Public Const USER_VALUE_SHORTNAME = "SHORTNAME"
Public Const USER_VALUE_USER_ID = "USER_ID"
Public Const USER_VALUE_PROFILE_ID = "PROFILE_ID"
Public Const INT_VALUE_USERNAME = "USERNAME"
Public Const INT_VALUE_MACHINE = "MACHINE"
Public Const INT_VALUE_DOMAIN = "DOMAIN"
Public Const INT_VALUE_DATE = "DATE"
Public Const CLIPBOARD_VALUE_DE = "@Zwischenablage"
Public Const CLIPBOARD_VALUE_EN = "@Clipboard"
Public Const MAX_TRY_COUNT = 100
Private _Logger As Logger
Private _LogConfig As LogConfig
Private _Regex As Regex = New Regex("{#(\w+)#([\w\s_-]+)}+")
Private _AllPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL, PATTERN_USER, PATTERN_INT}
Private _ComplexPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL}
Private _SimplePatterns As New List(Of String) From {PATTERN_USER, PATTERN_INT}
''' <summary>
''' Wraps a pattern-type and -value in the common format: {#type#value}
''' </summary>
Public Function WrapPatternValue(type As String, value As String) As String
Return New Pattern(type, value).ToString
End Function
Public Sub New(LogConfig As LogConfig)
_LogConfig = LogConfig
_Logger = LogConfig.GetLogger
End Sub
Public Function ReplaceAllValues(input As String, User As State.UserState) As String
Try
Dim result = input
result = ReplaceInternalValues(result)
result = ReplaceUserValues(result, User)
Return result
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("Error in ReplaceAllValues:" & ex.Message)
Return input
End Try
End Function
Public Function ReplaceClipboardContents(Input As String, ClipboardContents As String) As String
Dim oResult = Input
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToLower, ClipboardContents)
oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToUpper, ClipboardContents)
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToLower, ClipboardContents)
oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToUpper, ClipboardContents)
Return oResult
End Function
Public Function ReplaceInternalValues(Input As String) As String
Try
Dim oResult = Input
' Replace Username(s)
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_USERNAME)
oResult = ReplacePattern(oResult, PATTERN_INT, System.Environment.UserName)
End While
' Replace Machinename(s)
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_MACHINE)
oResult = ReplacePattern(oResult, PATTERN_INT, System.Environment.MachineName)
End While
' Replace Domainname(s)
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_DOMAIN)
oResult = ReplacePattern(oResult, PATTERN_INT, System.Environment.UserDomainName)
End While
' Replace CurrentDate(s)
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_DATE)
oResult = ReplacePattern(oResult, PATTERN_INT, Now.ToShortDateString)
End While
Return oResult
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("Error in ReplaceInternalValues:" & ex.Message)
Return Input
End Try
End Function
Public Function ReplaceUserValues(Input As String, User As State.UserState) As String
Try
Dim oResult = Input
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_PRENAME)
oResult = ReplacePattern(Input, PATTERN_USER, User.GivenName)
End While
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_USER_ID)
oResult = ReplacePattern(Input, PATTERN_USER, User.UserId.ToString)
End While
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_SURNAME)
oResult = ReplacePattern(Input, PATTERN_USER, User.Surname)
End While
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_SHORTNAME)
oResult = ReplacePattern(Input, PATTERN_USER, User.ShortName)
End While
While ContainsPatternAndValue(oResult, PATTERN_USER, USER_VALUE_EMAIL)
oResult = ReplacePattern(Input, PATTERN_USER, User.Email)
End While
Return oResult
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("Error in ReplaceUserValues:" & ex.Message)
Return Input
End Try
End Function
Public Function ReplaceControlValues(Input As String, Panel As Panel) As String
Try
Dim oResult = Input
Dim oTryCounter = 0
While ContainsPattern(oResult, PATTERN_CTRL)
If oTryCounter > MAX_TRY_COUNT Then
Throw New Exception("Max tries in ReplaceControlValues exceeded.")
End If
Dim controlName As String = GetNextPattern(oResult, PATTERN_CTRL).Value
Dim control As Control = Panel.Controls.Find(controlName, False).FirstOrDefault()
If control IsNot Nothing Then
Dim value As String = control.Text
oResult = ReplacePattern(oResult, PATTERN_CTRL, value)
End If
oTryCounter += 1
End While
Return oResult
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("Error in ReplaceControlValues:" & ex.Message)
Return Input
End Try
End Function
Private Function ContainsPattern(input As String, type As String) As Boolean
Dim elements As MatchCollection = _Regex.Matches(input)
For Each element As Match In elements
Dim t As String = element.Groups(1).Value
If t = type Then
Return True
End If
Next
Return False
End Function
Public Function GetNextPattern(Input As String, Type As String) As Pattern
Dim oElements As MatchCollection = _Regex.Matches(Input)
For Each oElement As Match In oElements
' Pattern in input
Dim oType As String = oElement.Groups(1).Value
Dim oValue As String = oElement.Groups(2).Value
If oType = Type Then
Return New Pattern(oType, oValue)
End If
Next
Return Nothing
End Function
Public Function GetAllPatterns(Input As String) As List(Of Pattern)
Dim elements As MatchCollection = _Regex.Matches(Input)
Dim results As New List(Of Pattern)
For Each element As Match In elements
' Pattern in input
Dim t As String = element.Groups(1).Value
Dim v As String = element.Groups(2).Value
results.Add(New Pattern(t, v))
Next
Return results
End Function
Public Function ReplacePattern(Input As String, Type As String, Replacement As String) As String
Dim oElements As MatchCollection = _Regex.Matches(Input)
If IsNothing(Replacement) Or Replacement = String.Empty Then
Return Input
End If
For Each element As Match In oElements
' if group 1 contains the 'pattern' the replace whole group with 'replacement'
' and return it
If element.Groups(1).Value = Type Then
Return Regex.Replace(Input, element.Groups(0).Value, Replacement)
End If
Next
' no replacement made
Return Input
End Function
Private Function ContainsPatternAndValue(Input As String, Type As String, Value As String) As Boolean
Dim oElements As MatchCollection = _Regex.Matches(Input)
For Each oElement As Match In oElements
' Pattern in input
Dim oType As String = oElement.Groups(1).Value
Dim oValue As String = oElement.Groups(2).Value
If oType = Type And oValue = Value Then
Return True
End If
Next
Return False
End Function
Public Function HasAnyPatterns(Input As String) As Boolean
Return _AllPatterns.Any(Function(p)
Return HasPattern(Input, p)
End Function)
End Function
Public Function HasOnlySimplePatterns(Input As String) As Boolean
Return Not HasComplexPatterns(Input)
End Function
Public Function HasComplexPatterns(Input As String) As Boolean
Return _ComplexPatterns.Any(Function(oPattern)
Return HasPattern(Input, oPattern)
End Function)
End Function
Public Function HasPattern(Input As String, Type As String) As Boolean
Dim oMatches = _Regex.Matches(Input)
For Each oMatch As Match In oMatches
For Each oGroup As Group In oMatch.Groups
If oGroup.Value = Type Then
Return True
End If
Next
Next
Return False
End Function
Public Class Pattern
Public ReadOnly Property Type As String
Public ReadOnly Property Value As String
Public Sub New(Type As String, Value As String)
Me.Type = Type
Me.Value = Value
End Sub
Public Overrides Function ToString() As String
Return $"{{#{Type}#{Value}}}"
End Function
End Class
End Class

View File

@@ -217,7 +217,6 @@ Public Class ClassProfileFilter
Return oProfiles
End Function
Public Function FilterWindowsByWindowClipboardRegex(Profiles As List(Of ProfileData), ClipboardContents As String) As List(Of ProfileData)
Dim oProfiles As New List(Of ProfileData)
@@ -272,7 +271,6 @@ Public Class ClassProfileFilter
Return oProfiles
End Function
Public Function FilterProfilesByFocusedControl(Profiles As List(Of ProfileData), ClipboardContents As String, ControlFocusresult As String) As List(Of ProfileData)
Dim oWindow As Window.WindowInfo
Dim oFocusedControl As Window.WindowInfo
@@ -396,6 +394,59 @@ Public Class ClassProfileFilter
Return oFilteredProfiles
End Function
Public Function FilterProfilesBySearchResults(Profiles As List(Of ProfileData)) As List(Of ProfileData)
Dim oProfiles As New List(Of ProfileData)
For Each oProfile In Profiles
Dim oResultDocs As Integer = 0
Dim oResultData As Integer = 0
Dim oPatterns As New ClassPatterns(My.LogConfig)
Dim oDataSearches As DataTable = My.Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
Dim oDocSearches As DataTable = My.Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
For Each oRow As DataRow In oDataSearches.Rows
Dim oCountCommand = String.Empty
Try
oCountCommand = NotNull(oRow.Item("COUNT_COMMAND"), String.Empty)
If oCountCommand = String.Empty Then
Continue For
End If
oCountCommand = oPatterns.ReplaceAllValues(oCountCommand, My.Application.User)
oResultData += NotNull(Of Integer)(My.Database.GetScalarValue(oCountCommand), 0)
Catch ex As Exception
_Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
End Try
Next
For Each oRow As DataRow In oDocSearches.Rows
Dim oCountCommand = String.Empty
Try
oCountCommand = NotNull(oRow.Item("COUNT_COMMAND"), String.Empty)
If oCountCommand = String.Empty Then
Continue For
End If
oCountCommand = oPatterns.ReplaceAllValues(oCountCommand, My.Application.User)
oResultDocs += NotNull(Of Integer)(My.Database.GetScalarValue(oCountCommand), 0)
Catch ex As Exception
_Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
End Try
Next
If oResultData > 0 Or oResultDocs > 0 Then
oProfile.CountData = oResultData
oProfile.CountDocs = oResultDocs
oProfiles.Add(oProfile)
End If
Next
Return oProfiles
End Function
Private Function Node_Get_Lowest_Node(NodeTag As String) As TreeNode
Dim oExit = False
Dim oParentNode As TreeNode
@@ -445,7 +496,6 @@ Public Class ClassProfileFilter
Return oList
End Function
Private Function TransformControls(ProfileId As Integer, ControlDatatable As DataTable) As List(Of ProfileData.ControlData)
Dim oControlList As New List(Of ProfileData.ControlData)
@@ -492,4 +542,6 @@ Public Class ClassProfileFilter
Return oWindowList
End Function
End Class

View File

@@ -0,0 +1,11 @@
Public Class OnFlowFormInteractionEvent
Public Enum FlowFormInteraction
Click
End Enum
Public ReadOnly Property Interaction As FlowFormInteraction
Public Sub New(Interaction As FlowFormInteraction)
_Interaction = Interaction
End Sub
End Class

View File

@@ -0,0 +1,12 @@
Public Class OnFlowFormStateChangedEvent
Public Enum FlowFormState
[Default]
HasSearchResults
End Enum
Public ReadOnly Property State As FlowFormState
Public Sub New(State As FlowFormState)
_State = State
End Sub
End Class

View File

@@ -63,9 +63,9 @@ Namespace My.Resources
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Friend ReadOnly Property CW_hatwas_klein() As System.Drawing.Bitmap
Friend ReadOnly Property CW_GEFUNDEN_klein() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("CW_hatwas_klein", resourceCulture)
Dim obj As Object = ResourceManager.GetObject("CW_GEFUNDEN_klein", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
@@ -73,9 +73,39 @@ Namespace My.Resources
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Friend ReadOnly Property CW_wartet_klein() As System.Drawing.Bitmap
Friend ReadOnly Property CW_klein() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("CW_wartet_klein", resourceCulture)
Dim obj As Object = ResourceManager.GetObject("CW_klein", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Friend ReadOnly Property GLOBIX_GEFUNDEN_klein() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("GLOBIX_GEFUNDEN_klein", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Friend ReadOnly Property GLOBIX_klein() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("GLOBIX_klein", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Friend ReadOnly Property ZOOFLOW_Home_klein() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("ZOOFLOW_Home_klein", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property

View File

@@ -118,10 +118,19 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="CW_hatwas_klein" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CW_hatwas_klein.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="CW_GEFUNDEN_klein" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CW_GEFUNDEN_klein.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="CW_wartet_klein" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CW_wartet_klein.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="CW_klein" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CW_klein.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="GLOBIX_GEFUNDEN_klein" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GLOBIX_GEFUNDEN_klein.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="GLOBIX_klein" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GLOBIX_klein.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ZOOFLOW_Home_klein" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ZOOFLOW_Home_klein.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -89,8 +89,11 @@
<Compile Include="Base\BaseClass.vb" />
<Compile Include="ClassClipboardWatcher.vb" />
<Compile Include="ClassInit.vb" />
<Compile Include="ClassPatterns.vb" />
<Compile Include="ClassProfileFilter.vb" />
<Compile Include="ClipboardWatcher\State.vb" />
<Compile Include="Events\OnFlowFormInteractionEvent.vb" />
<Compile Include="Events\OnFlowFormStateChangedEvent.vb" />
<Compile Include="Queries\ClassClipboardWatcherQueries.vb" />
<Compile Include="Queries\ClassCommonQueries.vb" />
<Compile Include="Config\ClassConfig.vb" />
@@ -183,16 +186,16 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\CW_hatwas_klein.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\CW_wartet_klein.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filesystem\Filesystem.vbproj">
<Project>{991d0231-4623-496d-8bd0-9ca906029cbc}</Project>
<Name>Filesystem</Name>
</ProjectReference>
<ProjectReference Include="..\Message\Messaging.vbproj">
<Project>{af664d85-0a4b-4bab-a2f8-83110c06553a}</Project>
<Name>Messaging</Name>
</ProjectReference>
<ProjectReference Include="..\Modules.Config\Config.vbproj">
<Project>{44982F9B-6116-44E2-85D0-F39650B1EF99}</Project>
<Name>Config</Name>
@@ -223,6 +226,21 @@
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="Resources\CW_GEFUNDEN_klein.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\CW_klein.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\GLOBIX_GEFUNDEN_klein.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\GLOBIX_klein.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ZOOFLOW_Home_klein.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -1,4 +1,6 @@
Public Class frmFlowForm
Imports DigitalData.Modules.Messaging
Public Class frmFlowForm
Private WithEvents Watcher As ClassClipboardWatcher = ClassClipboardWatcher.Singleton
Private ActiveModules As List(Of String)
@@ -13,10 +15,33 @@
End Sub
Private Sub frmFlowForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' === Set Form Properties ===
AllowDrop = True
ShowInTaskbar = False
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
SetBitmap(My.Resources.CW_wartet_klein)
' === Register As Event Listener ===
EventBus.Instance.Register(Me)
End Sub
Private Sub frmFlowForm_Closed(sender As Object, e As EventArgs) Handles Me.Closed
EventBus.Instance.Unregister(Me)
End Sub
Private Sub frmFlowForm_Click(sender As Object, e As EventArgs) Handles Me.MouseClick
EventBus.Instance.PostEvent(New OnFlowFormInteractionEvent(OnFlowFormInteractionEvent.FlowFormInteraction.Click))
End Sub
Public Sub OnEvent(e As OnFlowFormStateChangedEvent)
SetFlowFormState(e.State)
End Sub
Public Sub SetFlowFormState(State As OnFlowFormStateChangedEvent.FlowFormState)
Select Case State
Case OnFlowFormStateChangedEvent.FlowFormState.HasSearchResults
SetBitmap(My.Resources.CW_GEFUNDEN_klein)
Case Else
SetBitmap(My.Resources.ZOOFLOW_Home_klein)
End Select
End Sub
Private Sub frmFlowForm_DragOver(sender As Object, e As DragEventArgs) Handles Me.DragOver
@@ -26,15 +51,15 @@
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
' Handle file dragged from Windows
e.Effect = DragDropEffects.Copy
SetBitmap(My.Resources.CW_hatwas_klein)
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.HasSearchResults)
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then
' Handle a message dragged from Outlook
e.Effect = DragDropEffects.Copy
SetBitmap(My.Resources.CW_hatwas_klein)
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.HasSearchResults)
ElseIf e.Data.GetDataPresent("aryFileGroupDescriptor") AndAlso (e.Data.GetDataPresent("FileContents")) Then
' Handle a message dragged from Thunderbird?
e.Effect = DragDropEffects.Copy
SetBitmap(My.Resources.CW_hatwas_klein)
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.HasSearchResults)
Else
' Otherwise, do not handle
e.Effect = DragDropEffects.None
@@ -43,7 +68,7 @@
End Sub
Private Sub frmFlowForm_DragLeave(sender As Object, e As EventArgs) Handles Me.DragLeave
SetBitmap(My.Resources.CW_wartet_klein)
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
End Sub
Private Sub Watcher_ClipboardChanged(sender As Object, e As IDataObject) Handles Watcher.ClipboardChanged
@@ -52,15 +77,15 @@
End If
End Sub
''' <summary>
''' DragDrop Support
''' </summary>
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = &H84 Then
m.Result = CType(2, IntPtr)
Return
End If
'''' <summary>
'''' DragDrop Support
'''' </summary>
'Protected Overrides Sub WndProc(ByRef m As Message)
' If m.Msg = &H84 Then
' m.Result = CType(2, IntPtr)
' Return
' End If
MyBase.WndProc(m)
End Sub
' MyBase.WndProc(m)
'End Sub
End Class

View File

@@ -5,12 +5,16 @@ Imports DigitalData.Modules.ZooFlow
Imports DevExpress.LookAndFeel
Imports DigitalData.Products.ClipboardWatcher
Imports DigitalData.Modules.ZooFlow.Params
Imports System.Threading.Tasks
Imports DigitalData.Modules.Messaging
Partial Public Class frmMain
Private WithEvents FlowForm As frmFlowForm
Private Init As ClassInit
Private Loading As Boolean = True
Private Logger As Logger = My.LogConfig.GetLogger
Private MatchingProfiles As List(Of ProfileData)
Public Sub New()
InitializeComponent()
@@ -24,6 +28,28 @@ Partial Public Class frmMain
' === Layout and Skin ===
UserLookAndFeel.Default.SetSkinStyle(My.UIConfig.SkinName)
' === Register As Event Listener ===
EventBus.Instance.Register(Me)
End Sub
Private Sub frmMain_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
EventBus.Instance.Unregister(Me)
End Sub
Public Sub OnEvent(e As OnFlowFormInteractionEvent)
Select Case e.Interaction
Case OnFlowFormInteractionEvent.FlowFormInteraction.Click
Dim oEnvironment As New Environment() With {
.User = My.Application.User,
.Modules = My.Application.Modules
}
Dim oParams As New ClipboardWatcherParams() With {
.MatchingProfiles = MatchingProfiles
}
Dim oForm As New frmMatch(My.LogConfig, oEnvironment, oParams)
oForm.Show()
End Select
End Sub
Private Sub Init_Completed(sender As Object, e As EventArgs)
@@ -41,7 +67,6 @@ Partial Public Class frmMain
' === Load Data ===
RefreshData()
End Sub
Private Sub TimerRefreshData_Tick(sender As Object, e As EventArgs)
@@ -52,7 +77,7 @@ Partial Public Class frmMain
Hide()
End Sub
Private Sub FlowForm_ClipboardChanged(sender As Object, e As IDataObject) Handles FlowForm.ClipboardChanged
Private Async Sub FlowForm_ClipboardChangedAsync(sender As Object, e As IDataObject) Handles FlowForm.ClipboardChanged
If My.Application.ClipboardWatcher.UserProfiles.Rows.Count = 0 Then
Logger.Warn("Clipboard Changed but no profiles configured!")
Exit Sub
@@ -66,7 +91,11 @@ Partial Public Class frmMain
Dim oClipboardContents As String = Clipboard.GetText()
Try
oProfileFilter = New ClassProfileFilter(My.LogConfig, My.Application.ClipboardWatcher.UserProfiles, My.Application.ClipboardWatcher.ProfileProcesses, My.Application.ClipboardWatcher.ProfileWindows, My.Application.ClipboardWatcher.ProfileControls)
oProfileFilter = New ClassProfileFilter(My.LogConfig,
My.Application.ClipboardWatcher.UserProfiles,
My.Application.ClipboardWatcher.ProfileProcesses,
My.Application.ClipboardWatcher.ProfileWindows,
My.Application.ClipboardWatcher.ProfileControls)
oMatchingProfiles = oProfileFilter.Profiles
Logger.Debug("Profiles before filtering: {0}", oMatchingProfiles.Count)
@@ -78,8 +107,11 @@ Partial Public Class frmMain
Logger.Debug("Profiles after FilterWindowsByWindowTitleRegex: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oProfileFilter.FilterProfilesByFocusedControl(oMatchingProfiles, oClipboardContents, oFocusedControl.ToString)
Logger.Debug("Profiles after FilterProfilesByFocusedControl: {0}", oMatchingProfiles.Count)
oMatchingProfiles = Await Task.Run(Function() oProfileFilter.FilterProfilesBySearchResults(oMatchingProfiles))
Logger.Debug("Profiles after FilterProfilesBySearchResults: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oProfileFilter.ClearNotMatchedProfiles(oMatchingProfiles)
Logger.Debug("Profiles after ClearNotMatchedProfiles: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oMatchingProfiles.ToList()
Catch ex As Exception
MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor.", MsgBoxStyle.Critical, Text)
@@ -91,15 +123,9 @@ Partial Public Class frmMain
Exit Sub
End If
Dim oEnvironment As New Environment() With {
.User = My.Application.User,
.Modules = My.Application.Modules
}
Dim oParams As New ClipboardWatcherParams() With {
.MatchingProfiles = oMatchingProfiles
}
Dim oForm As New frmMatch(My.LogConfig, oEnvironment, oParams)
oForm.Show()
MatchingProfiles = oMatchingProfiles
EventBus.Instance.PostEvent(New OnFlowFormStateChangedEvent(OnFlowFormStateChangedEvent.FlowFormState.HasSearchResults))
End Sub
#Region "Notify Icon Menu"
@@ -166,4 +192,6 @@ Partial Public Class frmMain
Logger.Error(ex)
End Try
End Sub
End Class