This commit is contained in:
Jonathan Jenne
2019-08-02 16:27:35 +02:00
parent 28d5e590b4
commit 926801f7ba
29 changed files with 6191 additions and 2821 deletions

View File

@@ -1,6 +1,6 @@
Imports DD_Clipboard_Watcher.ClassProfileFilter
Imports DD_Clipboard_Watcher.ClassConstants
Imports DevExpress.XtraEditors
Imports ClassConstants
Public Class frmProfileMatch
Private PrimaryFont As New Font("Segoe UI", 12, FontStyle.Bold)
@@ -9,6 +9,12 @@ Public Class frmProfileMatch
Private OpenForms As New List(Of IResultForm)
Private ShouldHideInitially As Boolean = False
Private Enum ProfileType
ANY = 0
DOCS_ONLY = 1
DATA_ONLY = 2
End Enum
Private Sub frmProfileMatch_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not ConfigManager.Config.MatchWindowLocation.IsEmpty Then
Location = ConfigManager.Config.MatchWindowLocation
@@ -26,10 +32,14 @@ Public Class frmProfileMatch
Dim oCreatedTiles = CreateTiles()
If oCreatedTiles = -1 Then
Exit Sub
End If
' Open Result Forms directly if only one match found
If oCreatedTiles = 1 Then
Dim oProfileId As Integer = CURRENT_MATCHING_PROFILES.Select(Function(p) p.Guid).First()
OpenResultForms(oProfileId)
OpenResultForms(oProfileId, ProfileType.ANY)
ShouldHideInitially = True
End If
End Sub
@@ -51,7 +61,7 @@ Public Class frmProfileMatch
oDataGroup.Items.Clear()
For Each oProfile As ProfileData In CURRENT_MATCHING_PROFILES
If oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_DOCS Then
If oProfile.ProfileType = PROFILE_TYPE_DATA_DOCS Then
If oProfile.CountData > 0 And oProfile.CountDocs > 0 Then
Dim oCountText = oProfile.CountData + oProfile.CountDocs
Dim oItem = CreateTile(oProfile, $"{oCountText} Ergebnisse")
@@ -60,7 +70,7 @@ Public Class frmProfileMatch
End If
End If
If oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DOCS_ONLY Then
If oProfile.ProfileType = PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = PROFILE_TYPE_DOCS_ONLY Then
If oProfile.CountDocs > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountDocs} Dokumente")
oDocumentGroup.Items.Add(oItem)
@@ -68,7 +78,7 @@ Public Class frmProfileMatch
End If
End If
If oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_ONLY Then
If oProfile.ProfileType = PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = PROFILE_TYPE_DATA_ONLY Then
If oProfile.CountData > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountData} Datensätze")
oDataGroup.Items.Add(oItem)
@@ -89,41 +99,44 @@ Public Class frmProfileMatch
Dim oItem As New TileItem() With {.Tag = Profile.Guid}
oItem.Elements.Clear()
Dim oNameElement = New TileItemElement()
oNameElement.Text = Profile.Name
oNameElement.TextAlignment = TileItemContentAlignment.TopLeft
Dim oNameElement = New TileItemElement With {
.Text = Profile.Name,
.TextAlignment = TileItemContentAlignment.TopLeft
}
oNameElement.Appearance.Normal.Font = PrimaryFont
oItem.Elements.Add(oNameElement)
Dim oCommentElement = New TileItemElement()
oCommentElement.Text = Profile.Comment
oCommentElement.TextAlignment = TileItemContentAlignment.MiddleLeft
Dim oCommentElement = New TileItemElement With {
.Text = Profile.Comment,
.TextAlignment = TileItemContentAlignment.MiddleLeft
}
oCommentElement.Appearance.Normal.Font = SecondaryFont
oItem.Elements.Add(oCommentElement)
Dim oCountElement = New TileItemElement()
oCountElement.Text = GetCountText(Profile, CountText)
oCountElement.TextAlignment = TileItemContentAlignment.BottomRight
Dim oCountElement = New TileItemElement With {
.Text = GetCountText(Profile, CountText),
.TextAlignment = TileItemContentAlignment.BottomRight
}
oCountElement.Appearance.Normal.Font = SecondaryFont
oItem.Elements.Add(oCountElement)
Return oItem
End Function
Private Function GetCountText(Profile As ClassProfileFilter.ProfileData, CountText As String) As String
Private Function GetCountText(Profile As ProfileData, CountText As String) As String
Dim oText As String = "No implemented"
If Profile.CountData = ClassConstants.INVALID_COUNT_SQL Then
If Profile.CountData = INVALID_COUNT_SQL Then
oText = "Invalid SQL!"
ElseIf Profile.CountData = ClassConstants.NO_COUNT_SQL Then
ElseIf Profile.CountData = NO_COUNT_SQL Then
oText = "No SQL!"
Else
oText = CountText
End If
If Profile.CountDocs = ClassConstants.INVALID_COUNT_SQL Then
If Profile.CountDocs = INVALID_COUNT_SQL Then
oText = "Invalid SQL!"
ElseIf Profile.CountDocs = ClassConstants.NO_COUNT_SQL Then
ElseIf Profile.CountDocs = NO_COUNT_SQL Then
oText = "No SQL!"
Else
oText = CountText
@@ -143,51 +156,51 @@ Public Class frmProfileMatch
End Try
End Sub
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs)
Close()
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
OpenResultForms(oProfileId)
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)
Private Sub OpenResultForms(ProfileId As Integer, OpenType As ProfileType)
Dim oMatchingProfiles As New List(Of ProfileData)
If ProfileId = -1 Then
' Click on Show all, add all matching profiles
oMatchingProfiles = CURRENT_MATCHING_PROFILES.
Select(Function(p) p).
ToList()
Else
' Click on specific profile
Dim oProfile As ProfileData = CURRENT_MATCHING_PROFILES.
' TODO: Implement Show All
' Click on specific profile
Dim oProfile As ProfileData = CURRENT_MATCHING_PROFILES.
Where(Function(p) p.Guid = ProfileId).
First()
oMatchingProfiles.Add(oProfile)
If (oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DOCS_ONLY) And oProfile.CountDocs > 0 Then
' Show Result Document Form
Dim oForm As New frmResultDoc(Me, oMatchingProfiles)
AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
OpenForms.Add(oForm)
If OpenType = ProfileType.ANY Or OpenType = ProfileType.DOCS_ONLY Then
' Show Result Document Form
Dim oForm As New frmResultDoc(Me, oMatchingProfiles)
AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
OpenForms.Add(oForm)
oForm.Show()
End If
oForm.Show()
End If
If oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_ONLY And oProfile.CountData > 0 Then
' Show Result Data Form
Dim oForm As New frmResultSQL(Me, oMatchingProfiles)
AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
OpenForms.Add(oForm)
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
oForm.Show()
End If
End Sub
@@ -207,6 +220,7 @@ Public Class frmProfileMatch
' 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