From 1b75a4f6311ae825556d6f9be30830ecc3183fd0 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 18 Mar 2021 13:16:48 +0100 Subject: [PATCH] GlobalIndexer: Add New GUI Module --- DDMonorepo.sln | 7 + GUIs.GlobalIndexer/ControlCreator.vb | 217 ++++++++++++++++++ GUIs.GlobalIndexer/ControlMeta.vb | 5 + GUIs.GlobalIndexer/GlobalIndexer.vbproj | 141 ++++++++++++ .../My Project/Application.Designer.vb | 13 ++ .../My Project/Application.myapp | 10 + GUIs.GlobalIndexer/My Project/AssemblyInfo.vb | 35 +++ .../My Project/Resources.Designer.vb | 63 +++++ GUIs.GlobalIndexer/My Project/Resources.resx | 117 ++++++++++ .../My Project/Settings.Designer.vb | 73 ++++++ .../My Project/Settings.settings | 7 + GUIs.GlobalIndexer/packages.config | 4 + 12 files changed, 692 insertions(+) create mode 100644 GUIs.GlobalIndexer/ControlCreator.vb create mode 100644 GUIs.GlobalIndexer/ControlMeta.vb create mode 100644 GUIs.GlobalIndexer/GlobalIndexer.vbproj create mode 100644 GUIs.GlobalIndexer/My Project/Application.Designer.vb create mode 100644 GUIs.GlobalIndexer/My Project/Application.myapp create mode 100644 GUIs.GlobalIndexer/My Project/AssemblyInfo.vb create mode 100644 GUIs.GlobalIndexer/My Project/Resources.Designer.vb create mode 100644 GUIs.GlobalIndexer/My Project/Resources.resx create mode 100644 GUIs.GlobalIndexer/My Project/Settings.Designer.vb create mode 100644 GUIs.GlobalIndexer/My Project/Settings.settings create mode 100644 GUIs.GlobalIndexer/packages.config diff --git a/DDMonorepo.sln b/DDMonorepo.sln index 333ea478..f774b72f 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -124,6 +124,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EDMI.File", "Modules.EDMI.F EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EDMI.File.Test", "Modules.EDMI.File.Test\EDMI.File.Test.vbproj", "{16857A4E-2609-47E6-9C35-7669D64DD040}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GlobalIndexer", "GUIs.GlobalIndexer\GlobalIndexer.vbproj", "{40384B94-1F94-4249-9A5A-D02E0B346738}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -326,6 +328,10 @@ Global {16857A4E-2609-47E6-9C35-7669D64DD040}.Debug|Any CPU.Build.0 = Debug|Any CPU {16857A4E-2609-47E6-9C35-7669D64DD040}.Release|Any CPU.ActiveCfg = Release|Any CPU {16857A4E-2609-47E6-9C35-7669D64DD040}.Release|Any CPU.Build.0 = Release|Any CPU + {40384B94-1F94-4249-9A5A-D02E0B346738}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40384B94-1F94-4249-9A5A-D02E0B346738}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40384B94-1F94-4249-9A5A-D02E0B346738}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40384B94-1F94-4249-9A5A-D02E0B346738}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -380,6 +386,7 @@ Global {3E19C413-3197-4635-944E-558FC04C3475} = {F98C0329-C004-417F-B2AB-7466E88D8220} {1477032D-7A02-4C5F-B026-A7117DA4BC6B} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {16857A4E-2609-47E6-9C35-7669D64DD040} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} + {40384B94-1F94-4249-9A5A-D02E0B346738} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} diff --git a/GUIs.GlobalIndexer/ControlCreator.vb b/GUIs.GlobalIndexer/ControlCreator.vb new file mode 100644 index 00000000..bf7556f9 --- /dev/null +++ b/GUIs.GlobalIndexer/ControlCreator.vb @@ -0,0 +1,217 @@ +Imports System.Windows.Forms +Imports System.Drawing +Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.Language.Utils +Imports DigitalData.Controls.LookupGrid +Imports DevExpress.XtraEditors + +Public Class ControlCreator + Private Form As Form + Private Panel As Panel + Private LogConfig As LogConfig + Private Logger As Logger + + Private Const DEFAULT_HEIGHT = 27 + Private Const DEFAULT_WIDTH = 100 + Private Const DEFAULT_POSITION_X = 11 + + Private Const TYPE_BOOLEAN = "BOOLEAN" + Private Const TYPE_DATE = "DATE" + Private Const TYPE_INTEGER = "INTEGER" + + Private Const PLACEHOLDER_NULL = "$NULL" + Private Const VECTORSEPARATOR = "╚" + + Public Property HightlightColor As Color = Color.FromArgb(255, 214, 49) + Public Property OnControlChanged As Action(Of Control) + + ''' + ''' Callback Function to Return the Lookup Control's Datasource + ''' Receives the following values: + ''' - Control + ''' - SQL Command + ''' - Connection ID + ''' + ''' The Datatable which contains the Control's Data + Public Property OnLookupData As Func(Of Control, String, Integer, DataTable) + + Public Sub New(LogConfig As LogConfig, Panel As Panel, Form As Form) + Me.Form = Form + Me.Panel = Panel + Me.LogConfig = LogConfig + Me.Logger = LogConfig.GetLogger + End Sub + + Public Function AddDateTimePicker(pIndexname As String, pY As Integer, pDefaultValue As String) As DateEdit + Dim oPicker As New DateEdit With { + .Name = "dtp" & pIndexname, + .Size = New Size(DEFAULT_WIDTH, DEFAULT_HEIGHT), + .Location = New Point(DEFAULT_POSITION_X, pY), + .Tag = New ControlMeta() With { + .IndexName = pIndexname, + .IndexType = TYPE_DATE + } + } + + If pDefaultValue.ToUpper = PLACEHOLDER_NULL Then + oPicker.EditValue = Nothing + ElseIf pDefaultValue IsNot Nothing Then + oPicker.EditValue = pDefaultValue + End If + + oPicker.Properties.AppearanceFocused.BackColor = HightlightColor + + Return oPicker + End Function + + Public Function AddTextBox(pIndexname As String, pY As Integer, pDefaultValue As String, pDataType As String) As TextEdit + Dim oEdit As New TextEdit With { + .Name = "txt" & pIndexname, + .Size = New Size(DEFAULT_WIDTH, DEFAULT_HEIGHT), + .Location = New Point(DEFAULT_POSITION_X, pY), + .Tag = New ControlMeta() With { + .IndexName = pIndexname, + .IndexType = pDataType + } + } + + Select Case pDataType + Case TYPE_INTEGER + oEdit.Properties.Mask.MaskType = Mask.MaskType.Numeric + oEdit.Properties.Mask.EditMask = "d" + End Select + + If pDefaultValue IsNot Nothing Then + oEdit.Text = pDefaultValue + oEdit.SelectAll() + End If + + AddHandler oEdit.GotFocus, AddressOf OnTextBoxFocus + AddHandler oEdit.LostFocus, AddressOf OnTextBoxLostFocus + AddHandler oEdit.KeyUp, AddressOf OnTextBoxKeyUp + AddHandler oEdit.TextChanged, AddressOf OnTextBoxTextChanged + + Return oEdit + End Function + + Public Sub OnTextBoxFocus(sender As TextEdit, e As EventArgs) + sender.BackColor = HightlightColor + sender.SelectAll() + End Sub + + Public Sub OnTextBoxTextChanged(sender As TextEdit, e As System.EventArgs) + Using oGraphics As Graphics = sender.CreateGraphics() + Dim oNewWidth = oGraphics.MeasureString(sender.Text, sender.Font).Width + 15 + If oNewWidth >= DEFAULT_WIDTH Then + sender.Width = oNewWidth + End If + End Using + End Sub + + Public Sub OnTextBoxLostFocus(sender As TextEdit, e As EventArgs) + sender.BackColor = Color.White + End Sub + + Public Sub OnTextBoxKeyUp(sender As TextEdit, e As KeyEventArgs) + If sender.Text = String.Empty Then + Exit Sub + End If + + If e.KeyCode = Keys.Return Or e.KeyCode = Keys.Enter Or e.KeyCode = Keys.Tab Then + OnControlChanged.Invoke(sender) + End If + + If e.KeyCode = Keys.Return Then + SendKeys.Send("{TAB}") + End If + End Sub + + Public Function AddCheckBox(pIndexname As String, pY As Integer, pDefaultValue As String, pCaption As String) + Try + Dim oValue As Boolean = False + Dim oCheckBox As New CheckBox With { + .Name = "chk" & pIndexname, + .AutoSize = False, + .Size = New Size(DEFAULT_WIDTH, DEFAULT_HEIGHT), + .Location = New Point(DEFAULT_POSITION_X, pY), + .Tag = New ControlMeta() With { + .IndexName = pIndexname, + .IndexType = TYPE_BOOLEAN + } + } + + If pCaption <> "" Then + oCheckBox.Text = pCaption + oCheckBox.Size = New Size(CInt(pCaption.Length * 15), 27) + End If + + If Boolean.TryParse(pDefaultValue, oValue) = False Then + If pDefaultValue = "1" Or pDefaultValue = "0" Then + oCheckBox.Checked = CBool(pDefaultValue) + Else + oCheckBox.Checked = False + End If + Else + oCheckBox.Checked = oValue + End If + + AddHandler oCheckBox.CheckedChanged, Sub(sender As CheckBox, e As EventArgs) + OnControlChanged.Invoke(sender) + End Sub + + Return oCheckBox + Catch ex As Exception + Logger.Warn("Unhandled Exception in AddCheckBox: " & ex.Message) + Logger.Error(ex) + Return Nothing + End Try + End Function + + Public Function AddLookupControl(pIndexname As String, pY As Integer, pMultiselect As Boolean, pDataType As String, pSQLCommand As String, pConnectionId As Integer, Optional pDefaultValue As String = "", Optional pAddNewValues As Boolean = False, Optional pPreventDuplicateValues As Boolean = False) + Dim oControl As New LookupControl2 With { + .MultiSelect = pMultiselect, + .AllowAddNewValues = pAddNewValues, + .PreventDuplicates = pPreventDuplicateValues, + .Location = New Point(DEFAULT_POSITION_X, pY), + .Size = New Size(DEFAULT_WIDTH, DEFAULT_HEIGHT), + .Name = "cmbMulti" & pIndexname, + .Tag = New ControlMeta() With { + .IndexName = pIndexname, + .IndexType = pDataType + } + } + oControl.Properties.AppearanceFocused.BackColor = HightlightColor + + If Not String.IsNullOrEmpty(pDefaultValue) Then + Dim oDefaultValues As New List(Of String) + + If pDefaultValue.Contains(",") Then + oDefaultValues = pDefaultValue. + Split(",").ToList(). + Select(Function(item) item.Trim()). + ToList() + Else + oDefaultValues = pDefaultValue. + Split(VECTORSEPARATOR).ToList(). + Select(Function(item) item.Trim()). + ToList() + End If + oControl.SelectedValues = oDefaultValues + End If + + AddHandler oControl.SelectedValuesChanged, Sub() OnControlChanged.Invoke(oControl) + + If OnLookupData Is Nothing Then + Logger.Warn("LookupGrid Datasource could not be set, OnLookupData Function is not defined!") + End If + + Try + Dim oDataSource = OnLookupData.Invoke(oControl, pSQLCommand, pConnectionId) + oControl.DataSource = oDataSource + Catch ex As Exception + Logger.Error(ex) + End Try + + Return oControl + End Function +End Class diff --git a/GUIs.GlobalIndexer/ControlMeta.vb b/GUIs.GlobalIndexer/ControlMeta.vb new file mode 100644 index 00000000..0a19a6e6 --- /dev/null +++ b/GUIs.GlobalIndexer/ControlMeta.vb @@ -0,0 +1,5 @@ +Public Class ControlMeta + Public Property IndexName As String + Public Property IndexType As String + Public Property MultipleValues As Boolean = False +End Class \ No newline at end of file diff --git a/GUIs.GlobalIndexer/GlobalIndexer.vbproj b/GUIs.GlobalIndexer/GlobalIndexer.vbproj new file mode 100644 index 00000000..86364acf --- /dev/null +++ b/GUIs.GlobalIndexer/GlobalIndexer.vbproj @@ -0,0 +1,141 @@ + + + + + Debug + AnyCPU + {40384B94-1F94-4249-9A5A-D02E0B346738} + Library + DigitalData.GUIs.GlobalIndexer + DigitalData.GUIs.GlobalIndexer + 512 + Windows + v4.6.1 + true + + + true + full + true + true + bin\Debug\ + DigitalData.GUIs.GlobalIndexer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + DigitalData.GUIs.GlobalIndexer.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + False + D:\ProgramFiles\DevExpress 19.2\Components\Bin\Framework\DevExpress.Utils.v19.2.dll + + + False + D:\ProgramFiles\DevExpress 19.2\Components\Bin\Framework\DevExpress.XtraEditors.v19.2.dll + + + + + ..\..\packages\NLog.4.7.5\lib\net45\NLog.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + True + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + {3dcd6d1a-c830-4241-b7e4-27430e7ea483} + LookupControl + + + {d3c8cfed-d6f6-43a8-9bdf-454145d0352f} + Language + + + {903b2d7d-3b80-4be9-8713-7447b704e1b0} + Logging + + + + \ No newline at end of file diff --git a/GUIs.GlobalIndexer/My Project/Application.Designer.vb b/GUIs.GlobalIndexer/My Project/Application.Designer.vb new file mode 100644 index 00000000..8ab460ba --- /dev/null +++ b/GUIs.GlobalIndexer/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/GUIs.GlobalIndexer/My Project/Application.myapp b/GUIs.GlobalIndexer/My Project/Application.myapp new file mode 100644 index 00000000..758895de --- /dev/null +++ b/GUIs.GlobalIndexer/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/GUIs.GlobalIndexer/My Project/AssemblyInfo.vb b/GUIs.GlobalIndexer/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..c0b3cbdf --- /dev/null +++ b/GUIs.GlobalIndexer/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID wird für die typelib-ID verwendet, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' indem Sie "*" wie unten gezeigt eingeben: +' + + + diff --git a/GUIs.GlobalIndexer/My Project/Resources.Designer.vb b/GUIs.GlobalIndexer/My Project/Resources.Designer.vb new file mode 100644 index 00000000..349910b1 --- /dev/null +++ b/GUIs.GlobalIndexer/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.GUIs.GlobalIndexer.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/GUIs.GlobalIndexer/My Project/Resources.resx b/GUIs.GlobalIndexer/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/GUIs.GlobalIndexer/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GUIs.GlobalIndexer/My Project/Settings.Designer.vb b/GUIs.GlobalIndexer/My Project/Settings.Designer.vb new file mode 100644 index 00000000..d5a79e89 --- /dev/null +++ b/GUIs.GlobalIndexer/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.DigitalData.GUIs.GlobalIndexer.My.MySettings + Get + Return Global.DigitalData.GUIs.GlobalIndexer.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/GUIs.GlobalIndexer/My Project/Settings.settings b/GUIs.GlobalIndexer/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/GUIs.GlobalIndexer/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/GUIs.GlobalIndexer/packages.config b/GUIs.GlobalIndexer/packages.config new file mode 100644 index 00000000..6f6bc401 --- /dev/null +++ b/GUIs.GlobalIndexer/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file