From 1047f6152aa209f97c2943d04ecbe8ba2179246d Mon Sep 17 00:00:00 2001 From: Developer02 Digital Data Date: Wed, 16 Oct 2019 17:09:40 +0200 Subject: [PATCH] work on resultlists --- GUIs.ClipboardWatcher/frmMatch.vb | 2 +- .../{ClassMessageBox.vb => BaseMessageBox.vb} | 9 +- GUIs.Common/Base/BaseRibbonForm.vb | 83 +++++++++++++++++++ GUIs.Common/Common.vbproj | 5 +- .../DataResultList/frmDataResultList.vb | 6 +- .../frmDocumentResultList.Designer.vb | 2 +- .../frmDocumentResultList.vb | 8 +- GUIs.Common/IResultForm.vb | 2 +- LookupControlGui/Form1.Designer.vb | 54 ++++++++++++ LookupControlGui/Form1.resx | 18 ++++ LookupControlGui/Form1.vb | 14 +++- 11 files changed, 186 insertions(+), 17 deletions(-) rename GUIs.Common/Base/{ClassMessageBox.vb => BaseMessageBox.vb} (85%) create mode 100644 GUIs.Common/Base/BaseRibbonForm.vb diff --git a/GUIs.ClipboardWatcher/frmMatch.vb b/GUIs.ClipboardWatcher/frmMatch.vb index d456f2ae..b28da9db 100644 --- a/GUIs.ClipboardWatcher/frmMatch.vb +++ b/GUIs.ClipboardWatcher/frmMatch.vb @@ -258,7 +258,7 @@ Public Class frmMatch If TypeOf sender Is frmDataResultList Or TypeOf sender Is frmDocumentResultList Then For Each oForm As IResultForm In OpenForms ' Determine if frmProfileMatch should be shown - If oForm.ShouldReturnToMatchForm Then + If oForm.ShouldReturnToPreviousForm Then oShouldOpenAgain = True End If Next diff --git a/GUIs.Common/Base/ClassMessageBox.vb b/GUIs.Common/Base/BaseMessageBox.vb similarity index 85% rename from GUIs.Common/Base/ClassMessageBox.vb rename to GUIs.Common/Base/BaseMessageBox.vb index 287a23de..460394b8 100644 --- a/GUIs.Common/Base/ClassMessageBox.vb +++ b/GUIs.Common/Base/BaseMessageBox.vb @@ -3,7 +3,7 @@ Imports System.Windows.Forms Imports DigitalData.Modules.Logging Namespace Base - Public Class ClassMessageBox + Public Class BaseErrorHandler Private _Logger As Logger Private _Form As Form @@ -17,7 +17,12 @@ Namespace Base Public Sub ShowErrorMessage(Exception As Exception) _Logger.Error(Exception) - MsgBox(GetMessage(Exception), MsgBoxStyle.Critical, _Form.Text) + MessageBox.Show(GetMessage(Exception), _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + End Sub + + Public Sub ShowInfoMessage(Text As String) + _Logger.Info(Text) + MessageBox.Show(Text, _Form.Text, MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub Private Function GetMessage(Exception As Exception) As String diff --git a/GUIs.Common/Base/BaseRibbonForm.vb b/GUIs.Common/Base/BaseRibbonForm.vb new file mode 100644 index 00000000..70364355 --- /dev/null +++ b/GUIs.Common/Base/BaseRibbonForm.vb @@ -0,0 +1,83 @@ +Imports DevExpress.XtraBars.Docking +Imports DevExpress.XtraBars.Ribbon +Imports DigitalData.Modules.Logging + +Namespace Base + ''' + ''' This BaseClass is used to provide common functionality like the Logger or ErrorHandler to all Forms + ''' To use it, create a form and change the `Inherits` statement in FormName.Designer.vb to this form, eg.: + ''' + ''' Partial Class frmExample + ''' Inherits BaseRibbonForm + ''' + ''' ... + ''' End Class + ''' + ''' Only BaseRibbonForms can have panels attached to it! + ''' + Public Class BaseRibbonForm + Inherits RibbonForm + + Private ReadOnly _Logger As Logger + Private ReadOnly _ErrorHandler As BaseErrorHandler + + Protected ReadOnly Property Logger As Logger + Get + Return _Logger + End Get + End Property + + ''' + ''' Sets or gets the ribbon Page that will be shown when the window is visible + ''' + ''' + Public Property DefaultRibbonPage As RibbonPage + + Protected Overrides Sub OnLoad(e As EventArgs) + MyBase.OnLoad(e) + + If DefaultRibbonPage IsNot Nothing Then + Ribbon.SelectPage(DefaultRibbonPage) + End If + End Sub + + Protected Overrides Sub OnVisibleChanged(e As EventArgs) + MyBase.OnVisibleChanged(e) + + If Visible And DefaultRibbonPage IsNot Nothing Then + Ribbon.SelectPage(DefaultRibbonPage) + End If + End Sub + + Protected Overrides Sub OnActivated(e As EventArgs) + MyBase.OnVisibleChanged(e) + + If Visible And DefaultRibbonPage IsNot Nothing Then + Ribbon.SelectPage(DefaultRibbonPage) + End If + End Sub + + + Public Sub New(LogConfig As LogConfig) + ' Get the full name of the inheriting form + ' so the log messages have the right classname + Dim oClassName = [GetType]().FullName + + ' My.LogConfig is undefined in the designer + _Logger = LogConfig?.GetLogger(oClassName) + _ErrorHandler = New BaseErrorHandler(_Logger, Me) + + ' When you add something, be careful if it + ' depends on a global var like My.LogConfig + ' you might need to check for its existence with ? + End Sub + + Public Sub ShowErrorMessage(Exception As Exception) + _ErrorHandler.ShowErrorMessage(Exception) + End Sub + + Public Sub ShowErrorMessage(ErrorMessage As String) + _ErrorHandler.ShowErrorMessage(New Exception(ErrorMessage)) + End Sub + End Class +End Namespace diff --git a/GUIs.Common/Common.vbproj b/GUIs.Common/Common.vbproj index 57312abb..2f717c66 100644 --- a/GUIs.Common/Common.vbproj +++ b/GUIs.Common/Common.vbproj @@ -88,7 +88,10 @@ - + + + Form + diff --git a/GUIs.Common/DataResultList/frmDataResultList.vb b/GUIs.Common/DataResultList/frmDataResultList.vb index 5c2deb7a..97984a3c 100644 --- a/GUIs.Common/DataResultList/frmDataResultList.vb +++ b/GUIs.Common/DataResultList/frmDataResultList.vb @@ -27,7 +27,7 @@ Public Class frmDataResultList Private _ActiveGridBand As GridBand = Nothing Private _ActiveRowHandle As Integer = Constants.NO_ROW_HANDLE - Public Property ShouldReturnToMatchForm As Boolean Implements IResultForm.ShouldReturnToMatchForm + Public Property ShouldReturnToPreviousForm As Boolean Implements IResultForm.ShouldReturnToPreviousForm Public Sub New(LogConfig As LogConfig, Environment As Environment, Params As DataResultParams) ' Dieser Aufruf ist für den Designer erforderlich. @@ -43,7 +43,7 @@ Public Class frmDataResultList _Params = Params _ResultLists = Params.Results - ShouldReturnToMatchForm = False + ShouldReturnToPreviousForm = False End Sub Private Sub frmDataResultList_Load(sender As Object, e As EventArgs) Handles MyBase.Load @@ -234,7 +234,7 @@ Public Class frmDataResultList End Sub Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick - ShouldReturnToMatchForm = True + ShouldReturnToPreviousForm = True Close() End Sub diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb index f06a0191..92b64f24 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb @@ -1,6 +1,6 @@  _ Partial Class frmDocumentResultList - Inherits DevExpress.XtraBars.Ribbon.RibbonForm + Inherits Base.BaseRibbonForm 'Form overrides dispose to clean up the component list. _ diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb index ca530b2d..260772de 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb @@ -35,9 +35,11 @@ Public Class frmDocumentResultList Private _IsLoading As Boolean = True - Public Property ShouldReturnToMatchForm As Boolean Implements IResultForm.ShouldReturnToMatchForm + Public Property ShouldReturnToPreviousForm As Boolean = False Implements IResultForm.ShouldReturnToPreviousForm Public Sub New(LogConfig As LogConfig, Environment As Environment, Params As DocumentResultParams) + MyBase.New(LogConfig) + ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() @@ -50,8 +52,6 @@ Public Class frmDocumentResultList _Environment = Environment _Params = Params _ResultLists = Params.Results - - ShouldReturnToMatchForm = False End Sub Private Sub frmDocumentResultList_Load(sender As Object, e As EventArgs) Handles MyBase.Load @@ -481,7 +481,7 @@ Public Class frmDocumentResultList End Sub Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick - ShouldReturnToMatchForm = True + ShouldReturnToPreviousForm = True Close() End Sub diff --git a/GUIs.Common/IResultForm.vb b/GUIs.Common/IResultForm.vb index d455f8e6..16a73b45 100644 --- a/GUIs.Common/IResultForm.vb +++ b/GUIs.Common/IResultForm.vb @@ -1,3 +1,3 @@ Public Interface IResultForm - Property ShouldReturnToMatchForm As Boolean + Property ShouldReturnToPreviousForm As Boolean End Interface diff --git a/LookupControlGui/Form1.Designer.vb b/LookupControlGui/Form1.Designer.vb index 101e9107..304bb0a4 100644 --- a/LookupControlGui/Form1.Designer.vb +++ b/LookupControlGui/Form1.Designer.vb @@ -53,6 +53,16 @@ Partial Class Form1 Dim SerializableAppearanceObject22 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() Dim SerializableAppearanceObject23 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() Dim SerializableAppearanceObject24 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim EditorButtonImageOptions7 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions() + Dim SerializableAppearanceObject25 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject26 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject27 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject28 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim EditorButtonImageOptions8 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions() + Dim SerializableAppearanceObject29 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject30 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject31 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() + Dim SerializableAppearanceObject32 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject() Me.Button1 = New System.Windows.Forms.Button() Me.LookupControl = New DigitalData.Controls.LookupGrid.LookupControl2() Me.LookupControl21View = New DevExpress.XtraGrid.Views.Grid.GridView() @@ -63,12 +73,17 @@ Partial Class Form1 Me.LookupControl22 = New DigitalData.Controls.LookupGrid.LookupControl2() Me.GridView2 = New DevExpress.XtraGrid.Views.Grid.GridView() Me.Label3 = New System.Windows.Forms.Label() + Me.LookupControl23 = New DigitalData.Controls.LookupGrid.LookupControl2() + Me.GridView3 = New DevExpress.XtraGrid.Views.Grid.GridView() + Me.Label4 = New System.Windows.Forms.Label() CType(Me.LookupControl.Properties, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LookupControl21View, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LookupControl21.Properties, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.GridView1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LookupControl22.Properties, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.GridView2, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.LookupControl23.Properties, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.GridView3, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Button1 @@ -176,13 +191,47 @@ Partial Class Form1 Me.Label3.TabIndex = 4 Me.Label3.Text = "MultiSelect = False" ' + 'LookupControl23 + ' + Me.LookupControl23.AllowAddNewValues = False + Me.LookupControl23.DataSource = Nothing + Me.LookupControl23.Location = New System.Drawing.Point(393, 197) + Me.LookupControl23.MultiSelect = False + Me.LookupControl23.Name = "LookupControl23" + Me.LookupControl23.PreventDuplicates = False + Me.LookupControl23.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo, "", -1, True, True, False, EditorButtonImageOptions7, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject25, SerializableAppearanceObject26, SerializableAppearanceObject27, SerializableAppearanceObject28, "", "openDropdown", Nothing, DevExpress.Utils.ToolTipAnchor.[Default]), New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis, "", -1, True, True, False, EditorButtonImageOptions8, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject29, SerializableAppearanceObject30, SerializableAppearanceObject31, SerializableAppearanceObject32, "", "openLookupForm", Nothing, DevExpress.Utils.ToolTipAnchor.[Default])}) + Me.LookupControl23.Properties.DataSource = CType(resources.GetObject("LookupControl23.Properties.DataSource"), Object) + Me.LookupControl23.Properties.NullText = "" + Me.LookupControl23.Properties.PopupView = Me.GridView3 + Me.LookupControl23.SelectedValues = CType(resources.GetObject("LookupControl23.SelectedValues"), System.Collections.Generic.List(Of String)) + Me.LookupControl23.Size = New System.Drawing.Size(342, 20) + Me.LookupControl23.TabIndex = 3 + ' + 'GridView3 + ' + Me.GridView3.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus + Me.GridView3.Name = "GridView3" + Me.GridView3.OptionsSelection.EnableAppearanceFocusedCell = False + Me.GridView3.OptionsView.ShowGroupPanel = False + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(390, 181) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(89, 13) + Me.Label4.TabIndex = 4 + Me.Label4.Text = "100.000 Records" + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.LookupControl23) Me.Controls.Add(Me.LookupControl22) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.LookupControl21) @@ -196,6 +245,8 @@ Partial Class Form1 CType(Me.GridView1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.LookupControl22.Properties, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.GridView2, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.LookupControl23.Properties, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.GridView3, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() @@ -210,4 +261,7 @@ Partial Class Form1 Friend WithEvents LookupControl22 As DigitalData.Controls.LookupGrid.LookupControl2 Friend WithEvents GridView2 As DevExpress.XtraGrid.Views.Grid.GridView Friend WithEvents Label3 As Label + Friend WithEvents LookupControl23 As DigitalData.Controls.LookupGrid.LookupControl2 + Friend WithEvents GridView3 As DevExpress.XtraGrid.Views.Grid.GridView + Friend WithEvents Label4 As Label End Class diff --git a/LookupControlGui/Form1.resx b/LookupControlGui/Form1.resx index e500039b..c4594ca5 100644 --- a/LookupControlGui/Form1.resx +++ b/LookupControlGui/Form1.resx @@ -169,6 +169,24 @@ PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0 ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs= + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u + ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u + PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB + AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0 + ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs= + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u + ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u + PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB + AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0 + ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs= \ No newline at end of file diff --git a/LookupControlGui/Form1.vb b/LookupControlGui/Form1.vb index 3e3672b3..fb5b1ebe 100644 --- a/LookupControlGui/Form1.vb +++ b/LookupControlGui/Form1.vb @@ -1,8 +1,12 @@ Public Class Form1 - Private _Datasource As New List(Of String) From {"Foo", "bar", "baz", "quux"} + Private _Datasource As New List(Of String) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load - Dim oDatatable = GetDatatable() + For index = 1 To 1000000 + _Datasource.Add($"item-{index}") + Next + + Dim oDatatable = GetDatatable(10) Dim oSelectedValues = _Datasource.Take(1).ToList() LookupControl.DataSource = oDatatable @@ -20,6 +24,8 @@ LookupControl22.SelectedValues = New List(Of String) From {"", Nothing, "LOL", "Foo"} + LookupControl23.DataSource = GetDatatable(100000) + AddHandler LookupControl.SelectedValuesChanged, Sub(_sender As Object, SelectedValues As List(Of String)) MsgBox("Selected Values: " & String.Join(",", SelectedValues.ToArray)) End Sub @@ -33,7 +39,7 @@ End Sub End Sub - Private Function GetDatatable() As DataTable + Private Function GetDatatable(Limit As Integer) As DataTable Dim oDatatable As New DataTable Dim oColumns As New List(Of DataColumn) From { New DataColumn("Col1", GetType(String)), @@ -42,7 +48,7 @@ oDatatable.Columns.AddRange(oColumns.ToArray) - For Each Item In _Datasource + For Each Item In _Datasource.Take(Limit) Dim oRow = oDatatable.NewRow() oRow.Item("Col1") = Item oRow.Item("Col2") = Item & "_" & "SomeLong Random(String) !!!111einself"