clipboard watcher migration

This commit is contained in:
Jonathan Jenne
2019-09-25 16:30:35 +02:00
parent cc2d8cbe33
commit f5d43edeef
40 changed files with 1637 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraEditors
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Windows
Imports DigitalData.Modules.ZooFlow
@@ -30,6 +31,9 @@ Public Class frmMatch
Private PrimaryFont As New Font("Segoe UI", 12, FontStyle.Bold)
Private SecondaryFont As New Font("Segoe UI", 10)
Private OpenForms As New List(Of IResultForm)
Private ShouldHideInitially As Boolean = False
Private Const NO_COUNT_SQL As Integer = 99998
Private Const INVALID_COUNT_SQL As Integer = 99999
@@ -56,6 +60,19 @@ Public Class frmMatch
If oCreatedTiles = -1 Then
Exit Sub
End If
If oCreatedTiles = 0 Then
_Logger.Warn("No Results found for ""{0}""", _Params.ClipboardContents)
Close()
End If
Dim oMatchString = IIf(oCreatedTiles = 1, "1 Match", $"{oCreatedTiles} Matches")
Label1.Text = String.Format(Label1.Text, oMatchString, _Params.ClipboardContents)
If oCreatedTiles = 1 Then
Dim oProfile As ProfileData = _Params.MatchingProfiles.First()
' TODO Open Result Forms
End If
End Sub
Function CreateTiles() As Integer
@@ -152,4 +169,84 @@ Public Class frmMatch
Return oText
End Function
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
Dim oForm As New frmTreeView(_Params.MatchTreeView.Nodes) With {
.StartPosition = FormStartPosition.CenterScreen
}
oForm.ShowDialog()
End Sub
Private Sub TileControlMatch_ItemClick(sender As Object, e As TileItemEventArgs) Handles TileControlMatch.ItemClick
Dim oItem As TileItem = e.Item
Dim oProfileId As Integer = oItem.Tag
Select Case oItem.Group.Name
Case TileGroupData.Name
OpenResultForms(oProfileId, ProfileType.DATA_ONLY)
Case TileGroupDocuments.Name
OpenResultForms(oProfileId, ProfileType.DOCS_ONLY)
Case Else
OpenResultForms(oProfileId, ProfileType.ANY)
End Select
Hide()
End Sub
Private Sub OpenResultForms(ProfileId As Integer, OpenType As ProfileType)
Dim oMatchingProfiles As New List(Of ProfileData)
' TODO: Implement Show All
' Click on specific profile
Dim oProfile As ProfileData = _Params.MatchingProfiles.
Where(Function(p) p.Guid = ProfileId).
First()
oMatchingProfiles.Add(oProfile)
If OpenType = ProfileType.ANY Or OpenType = ProfileType.DOCS_ONLY Then
' Show Result Document Form
Dim oForm As New frmDocumentResult(_LogConfig, _Environment, _Params)
AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
OpenForms.Add(oForm)
oForm.Show()
End If
'If OpenType = ProfileType.ANY Or OpenType = ProfileType.DATA_ONLY Then
' ' Show Result Data Form
' Dim oForm As New frmResultSQL(Me, oMatchingProfiles)
' AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
' OpenForms.Add(oForm)
' oForm.Show()
'End If
End Sub
Private Sub ProfileResultForm_Closed(sender As Object, e As FormClosedEventArgs)
Dim oShouldOpenAgain As Boolean = False
Dim oThisForm = New List(Of IResultForm) From {sender}
If TypeOf sender Is frmResultDoc Or TypeOf sender Is frmDocumentResult Then
For Each oForm As IResultForm In OpenForms
' Determine if frmProfileMatch should be shown
If oForm.ShouldReturnToMatchForm Then
oShouldOpenAgain = True
End If
Next
End If
' If frmProfileMatch should be shown, close all windows of this profile
If oShouldOpenAgain Then
For Each oForm As Form In OpenForms.Except(oThisForm)
' Remove the Handler to prevent a loop
RemoveHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
oForm.Close()
Next
Show()
End If
End Sub
End Class