Prepare for Version 2.0.0.0

This commit is contained in:
Jonathan Jenne
2019-07-31 15:37:48 +02:00
parent 257ed65246
commit 71559c9ca5
44 changed files with 13768 additions and 7629 deletions

View File

@@ -1,9 +1,14 @@
Imports DevExpress.XtraEditors
Imports DD_Clipboard_Watcher.ClassProfileFilter
Imports DevExpress.XtraEditors
Imports ClassConstants
Public Class frmProfileMatch
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 Sub frmProfileMatch_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not ConfigManager.Config.MatchWindowLocation.IsEmpty Then
Location = ConfigManager.Config.MatchWindowLocation
@@ -14,17 +19,30 @@ Public Class frmProfileMatch
End If
If USER_LANGUAGE = "de-DE" Then
Label1.Text = $"Clipboard Watcher hat mehr als einen Match für Ihre Suche nach ""{CURR_MATCH_RESULT}"" gefunden:"
Label1.Text = $"Clipboard Watcher hat mehr als einen Match für Ihre Suche nach ""{CURRENT_CLIPBOARD_CONTENTS}"" gefunden:"
Else
Label1.Text = $"Clipboard Watcher found more than on match for your search for ""{CURR_MATCH_RESULT}"":"
Label1.Text = $"Clipboard Watcher found more than on match for your search for ""{CURRENT_CLIPBOARD_CONTENTS}"":"
End If
CreateTiles()
CurrDocSearch2Load = Nothing
Dim oCreatedTiles = CreateTiles()
' 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)
ShouldHideInitially = True
End If
End Sub
Sub CreateTiles()
Private Sub frmProfileMatch_Shown(sender As Object, e As EventArgs) Handles Me.Shown
If ShouldHideInitially Then
Hide()
End If
End Sub
Function CreateTiles() As Integer
Try
Dim oCreatedTiles As Integer = 0
Dim oDocumentGroup = TileControlMatch.Groups.Item("TileGroupDocuments")
Dim oDataGroup = TileControlMatch.Groups.Item("TileGroupData")
Dim oDataDocumentsGroup = TileControlMatch.Groups.Item("TileGroupDocumentsData")
@@ -32,30 +50,42 @@ Public Class frmProfileMatch
oDocumentGroup.Items.Clear()
oDataGroup.Items.Clear()
For Each oProfile As ClassProfileFilter.ProfileData In CURRENT_MATCHING_PROFILES
If oProfile.CountData > 0 And oProfile.CountDocs > 0 Then
Dim oCountText = oProfile.CountData + oProfile.CountDocs
Dim oItem = CreateTile(oProfile, $"{oCountText} Ergebnisse")
oDataDocumentsGroup.Items.Add(oItem)
For Each oProfile As ProfileData In CURRENT_MATCHING_PROFILES
If oProfile.ProfileType = ClassConstants.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")
oDataDocumentsGroup.Items.Add(oItem)
oCreatedTiles += 1
End If
End If
If oProfile.CountDocs > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountDocs} Dokumente")
oDocumentGroup.Items.Add(oItem)
If oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DOCS_ONLY Then
If oProfile.CountDocs > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountDocs} Dokumente")
oDocumentGroup.Items.Add(oItem)
oCreatedTiles += 1
End If
End If
If oProfile.CountData > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountData} Datensätze")
oDataGroup.Items.Add(oItem)
If oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_DOCS Or oProfile.ProfileType = ClassConstants.PROFILE_TYPE_DATA_ONLY Then
If oProfile.CountData > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountData} Datensätze")
oDataGroup.Items.Add(oItem)
oCreatedTiles += 1
End If
End If
Next
Return oCreatedTiles
Catch ex As Exception
Logger.Error(ex)
MsgBox("Error while creating profile tiles!" & vbNewLine & ex.Message)
Return -1
End Try
End Sub
End Function
Private Function CreateTile(Profile As ClassProfileFilter.ProfileData, CountText As String) As TileItem
Private Function CreateTile(Profile As ProfileData, CountText As String) As TileItem
Dim oItem As New TileItem() With {.Tag = Profile.Guid}
oItem.Elements.Clear()
@@ -113,35 +143,77 @@ Public Class frmProfileMatch
End Try
End Sub
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs)
Close()
End Sub
Private Sub TileControl1_ItemClick(sender As Object, e As TileItemEventArgs) Handles TileControlMatch.ItemClick
Private Sub TileControlMatch_ItemClick(sender As Object, e As TileItemEventArgs) Handles TileControlMatch.ItemClick
Dim oItem As TileItem = e.Item
Dim oProfileId = oItem.Tag
Dim oProfileId As Integer = oItem.Tag
If oProfileId Is Nothing Then
Dim oResult As String = ""
For Each oProfile As ClassProfileFilter.ProfileData In CURRENT_MATCHING_PROFILES
If oResult = "" Then
oResult = oProfile.Guid
Else
oResult &= "," & oProfile.Guid
End If
Next
CurrDocSearch2Load = oResult
CurrDataSearch2Load = oResult
Else
CurrDocSearch2Load = oProfileId
CurrDataSearch2Load = oProfileId
End If
OpenResultForms(oProfileId)
' Show Result Document Form
Dim oFrmResultDoc As Form = New frmResultDoc(Me)
oFrmResultDoc.Show()
' ..and hide myself
Hide()
End Sub
Private Sub OpenResultForms(ProfileId As Integer)
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.
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)
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)
oForm.Show()
End If
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 frmResultSQL 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)
RemoveHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
oForm.Close()
Next
Show()
End If
End Sub
End Class