From 934bbfb06330e749d167ac91285c58f5a486df4b Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 9 Jun 2020 15:49:48 +0200 Subject: [PATCH] ClipboardWatcher: more accurate result text --- GUIs.ClipboardWatcher/frmMatch.Designer.vb | 4 +-- GUIs.ClipboardWatcher/frmMatch.vb | 38 +++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/GUIs.ClipboardWatcher/frmMatch.Designer.vb b/GUIs.ClipboardWatcher/frmMatch.Designer.vb index eac4f7a5..4b816356 100644 --- a/GUIs.ClipboardWatcher/frmMatch.Designer.vb +++ b/GUIs.ClipboardWatcher/frmMatch.Designer.vb @@ -75,9 +75,9 @@ Partial Class frmMatch Me.Label1.ForeColor = System.Drawing.Color.White Me.Label1.Location = New System.Drawing.Point(12, 9) Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(368, 21) + Me.Label1.Size = New System.Drawing.Size(408, 21) Me.Label1.TabIndex = 1 - Me.Label1.Text = "Es wurde(n) {0} für Ihre Suche nach '{1}' gefunden:" + Me.Label1.Text = "Es wurde(n) {0} in {1} für Ihre Suche nach '{2}' gefunden:" ' 'Label2 ' diff --git a/GUIs.ClipboardWatcher/frmMatch.vb b/GUIs.ClipboardWatcher/frmMatch.vb index f9b47583..16ef0fe1 100644 --- a/GUIs.ClipboardWatcher/frmMatch.vb +++ b/GUIs.ClipboardWatcher/frmMatch.vb @@ -56,8 +56,18 @@ Public Class frmMatch _Params = Params End Sub + Private Function GetResultString(CreatedTiles, MatchedProfiles, ClipboardContents) As String + Dim oResultString = IIf(CreatedTiles = 1, "wurde ein Ergebnis", $"wurden {CreatedTiles} Ergebnisse") + Dim oProfileString = IIf(MatchedProfiles = 1, "einem Profil", $"{MatchedProfiles} Profilen") + Dim oBase = "Es {0} in {1} für Ihre Suche nach '{2}' gefunden:" + + Return String.Format(oBase, oResultString, oProfileString, _Params.ClipboardContents) + End Function + Private Async Sub frmMatch_Load(sender As Object, e As EventArgs) Handles MyBase.Load - Dim oCreatedTiles = CreateTiles() + Dim oResult As Tuple(Of Integer, Integer) = CreateTiles() + Dim oCreatedTiles As Integer = oResult.Item1 + Dim oMatchedProfiles As Integer = oResult.Item2 If oCreatedTiles = -1 Then Exit Sub @@ -68,11 +78,11 @@ Public Class frmMatch Close() End If - Dim oMatchString = IIf(oCreatedTiles = 1, "1 Profil", $"{oCreatedTiles} Profile") - Label1.Text = String.Format(Label1.Text, oMatchString, _Params.ClipboardContents) + Label1.Text = GetResultString(oCreatedTiles, oMatchedProfiles, _Params.ClipboardContents) _Logger.Debug($"Created Tiles: {oCreatedTiles} ") - If oCreatedTiles = 1 Then + _Logger.Debug($"Matched Profiles: {oMatchedProfiles}") + If oCreatedTiles = 1 Then Dim oProfile As ProfileData = _Params.MatchingProfiles.First() Dim oProfileSearch As New ProfileSearches(_LogConfig, _Environment, _Params) @@ -97,9 +107,11 @@ Public Class frmMatch TopMost = True End Sub - Function CreateTiles() As Integer + Function CreateTiles() As Tuple(Of Integer, Integer) Try Dim oCreatedTiles As Integer = 0 + Dim oMatchedProfiles As Integer = 0 + Dim oDocumentGroup = TileControlMatch.Groups.Item("TileGroupDocuments") Dim oDataGroup = TileControlMatch.Groups.Item("TileGroupData") Dim oDataDocumentsGroup = TileControlMatch.Groups.Item("TileGroupDocumentsData") @@ -118,12 +130,15 @@ Public Class frmMatch ' End If 'End If + Dim oProfileMatch As Boolean = False + If oProfile.ProfileType = ProfileType.ANY Or oProfile.ProfileType = ProfileType.DOCS_ONLY Then _Logger.Debug("Docs only or ProfileTypeAny") If oProfile.CountDocs > 0 Then Dim oItem = CreateTile(oProfile, $"{oProfile.CountDocs} Dateien") oDocumentGroup.Items.Add(oItem) oCreatedTiles += 1 + oProfileMatch = True Else _Logger.Debug("NO Doc-Results!") End If @@ -134,17 +149,22 @@ Public Class frmMatch Dim oItem = CreateTile(oProfile, $"{oProfile.CountData} Datensätze") oDataGroup.Items.Add(oItem) oCreatedTiles += 1 + oProfileMatch = True Else _Logger.Debug("NO Data-Results!") End If End If + + If oProfileMatch Then + oMatchedProfiles += 1 + End If Next - Return oCreatedTiles + Return New Tuple(Of Integer, Integer)(oCreatedTiles, oMatchedProfiles) Catch ex As Exception _Logger.Error(ex) MsgBox("Error while creating profile tiles!" & vbNewLine & ex.Message) - Return -1 + Return New Tuple(Of Integer, Integer)(-1, -1) End Try End Function @@ -200,7 +220,9 @@ Public Class frmMatch 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 + .StartPosition = FormStartPosition.Manual, + .Left = Left + Width, + .Top = Top } oForm.ShowDialog() End Sub