Alignmenttext und Currency

This commit is contained in:
Developer01 2025-12-05 09:22:01 +01:00
parent 4db9b71a29
commit 443242415a
4 changed files with 122 additions and 58 deletions

View File

@ -148,8 +148,6 @@ Public Class ClassControlCreator
ctrl.Location = props.Location ctrl.Location = props.Location
ctrl.Font = props.Font ctrl.Font = props.Font
ctrl.ForeColor = props.Color ctrl.ForeColor = props.Color
If designMode Then If designMode Then
ctrl.Cursor = Cursors.Hand ctrl.Cursor = Cursors.Hand
End If End If
@ -310,6 +308,7 @@ Public Class ClassControlCreator
Dim oFormatString = oControlRow.ItemEx("FORMAT_STRING", String.Empty) Dim oFormatString = oControlRow.ItemEx("FORMAT_STRING", String.Empty)
Dim oBackColorIf = oControlRow.ItemEx("CTRL_BACKCOLOR_IF", String.Empty) Dim oBackColorIf = oControlRow.ItemEx("CTRL_BACKCOLOR_IF", String.Empty)
Dim oIndexname = oControlRow.ItemEx("INDEX_NAME", String.Empty) Dim oIndexname = oControlRow.ItemEx("INDEX_NAME", String.Empty)
Dim oAlignment = oControlRow.ItemEx("TEXT_ALIGNMENT", "Near")
Dim oControl As BaseEdit = Nothing Dim oControl As BaseEdit = Nothing
If oHeight >= 27 Then If oHeight >= 27 Then
oControl = CreateBaseControl(New MemoEdit(), oControlRow, designMode) oControl = CreateBaseControl(New MemoEdit(), oControlRow, designMode)
@ -324,6 +323,13 @@ Public Class ClassControlCreator
oControl.Height = oHeight oControl.Height = oHeight
oControl.Width = oWidth oControl.Width = oWidth
If oAlignment = "Near" Then
oControl.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near
ElseIf oAlignment = "Center" Then
oControl.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center
ElseIf oAlignment = "Far" Then
oControl.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far
End If
If Not designMode Then If Not designMode Then
'oControl.ReadOnly = oReadOnly 'oControl.ReadOnly = oReadOnly
@ -352,17 +358,24 @@ Public Class ClassControlCreator
End Function End Function
Public Function CreateExistingLabel(row As DataRow, designMode As Boolean) As Label Public Function CreateExistingLabel(row As DataRow, designMode As Boolean) As Label
Dim control As Label = CreateBaseControl(New Label(), row, designMode) Dim oControl As Label = CreateBaseControl(New Label(), row, designMode)
Try Try
control.Text = row.Item("CTRL_CAPTION_LANG") oControl.Text = row.Item("CTRL_CAPTION_LANG")
Catch ex As Exception Catch ex As Exception
Logger.Warn("Label [{0}] does not have a translation!", control.Name) Logger.Warn("Label [{0}] does not have a translation!", oControl.Name)
control.Text = row.Item("CTRL_TEXT") oControl.Text = row.Item("CTRL_TEXT")
End Try End Try
Dim oAlignment = oControlRow.ItemEx("TEXT_ALIGNMENT", "Near")
If oAlignment = "Near" Then
oControl.TextAlign = ContentAlignment.MiddleLeft
ElseIf oAlignment = "Center" Then
oControl.TextAlign = ContentAlignment.MiddleCenter
ElseIf oAlignment = "Far" Then
oControl.TextAlign = ContentAlignment.MiddleRight
End If
oControl.AutoSize = True
control.AutoSize = True Return oControl
Return control
End Function End Function
Public Function CreateExistingButton(row As DataRow, designMode As Boolean) As Button Public Function CreateExistingButton(row As DataRow, designMode As Boolean) As Button
@ -394,21 +407,30 @@ Public Class ClassControlCreator
Return oControl Return oControl
End Function End Function
Public Function CreateExistingCombobox(row As DataRow, designMode As Boolean) As Windows.Forms.ComboBox Public Function CreateExistingCombobox(pRow As DataRow, designMode As Boolean) As Windows.Forms.ComboBox
Dim control As Windows.Forms.ComboBox = CreateBaseControl(New Windows.Forms.ComboBox(), row, designMode) Dim oControl As Windows.Forms.ComboBox = CreateBaseControl(New Windows.Forms.ComboBox(), pRow, designMode)
oControl.Size = New Size(pRow.Item("WIDTH"), pRow.Item("HEIGHT"))
control.Size = New Size(row.Item("WIDTH"), row.Item("HEIGHT"))
If Not designMode Then If Not designMode Then
control.Enabled = Not row.Item("READ_ONLY") oControl.Enabled = Not pRow.Item("READ_ONLY")
control.TabStop = Not row.Item("READ_ONLY") oControl.TabStop = Not pRow.Item("READ_ONLY")
control.BackColor = IIf(row.Item("READ_ONLY"), Color.LightGray, Color.White) oControl.BackColor = IIf(pRow.Item("READ_ONLY"), Color.LightGray, Color.White)
control.AutoCompleteMode = AutoCompleteMode.SuggestAppend oControl.AutoCompleteMode = AutoCompleteMode.SuggestAppend
control.AutoCompleteSource = AutoCompleteSource.ListItems oControl.AutoCompleteSource = AutoCompleteSource.ListItems
End If End If
Return control Dim oAlignment = pRow.ItemEx("TEXT_ALIGNMENT", "Near")
If oAlignment = "Near" Then
oControl. = ContentAlignment.MiddleLeft
ElseIf oAlignment = "Center" Then
oControl.TextAlign = ContentAlignment.MiddleCenter
ElseIf oAlignment = "Far" Then
oControl.TextAlign = ContentAlignment.MiddleRight
End If
Return oControl
End Function End Function
Public Function CreateExistingDatepicker(row As DataRow, designMode As Boolean) As DateTimePicker Public Function CreateExistingDatepicker(row As DataRow, designMode As Boolean) As DateTimePicker

View File

@ -69,6 +69,9 @@ Public Module ModuleControlProperties
<Category(ClassConstants.CAT_DISPLAY)> <Category(ClassConstants.CAT_DISPLAY)>
Public Property TextColor As Color Public Property TextColor As Color
<DisplayName("Text Alignement")>
<Category(ClassConstants.CAT_DISPLAY)>
Public Property TextAlignment As String
Class FontConverter Class FontConverter
Inherits TypeConverter Inherits TypeConverter

View File

@ -582,16 +582,17 @@ Public Class frmFormDesigner
obj.ChangedAt = ClassAllgemeineFunktionen.NotNullDate(row.Item("CHANGED_WHEN"), Nothing) obj.ChangedAt = ClassAllgemeineFunktionen.NotNullDate(row.Item("CHANGED_WHEN"), Nothing)
obj.ChangedWho = ClassAllgemeineFunktionen.NotNullString(row.Item("CHANGED_WHO"), "") obj.ChangedWho = ClassAllgemeineFunktionen.NotNullString(row.Item("CHANGED_WHO"), "")
Dim style As FontStyle = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_STYLE"), FontStyle.Regular) Dim oStyle As FontStyle = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_STYLE"), FontStyle.Regular)
Dim size As Single = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_SIZE"), 10) Dim oSize As Single = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_SIZE"), 10)
Dim familyString As String = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_FAMILY"), "Arial") Dim oFamilyString As String = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_FAMILY"), "Arial")
Dim family As FontFamily = New FontFamily(familyString) Dim oFamily As FontFamily = New FontFamily(oFamilyString)
obj.Font = New Font(family, size, style) obj.Font = New Font(oFamily, oSize, oStyle)
Dim color As Integer = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_COLOR"), 0) Dim oColor As Integer = ClassAllgemeineFunktionen.NotNullString(row.Item("FONT_COLOR"), 0)
obj.TextColor = IntToColor(color) obj.TextColor = IntToColor(oColor)
obj.TextAlignment = ClassAllgemeineFunktionen.NotNullString(row.Item("TEXT_ALIGNMENT"), 0)
Return obj Return obj
End Function End Function

View File

@ -1,5 +1,14 @@
Imports DevExpress.DataAccess.Native.Sql Imports System.ComponentModel
'Imports System.Data.SqlClient
Imports System.Globalization
Imports System.IO
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions
Imports System.Threading
Imports DevExpress.DataAccess.Native.Sql
Imports DevExpress.Utils Imports DevExpress.Utils
Imports DevExpress.Utils.Automation
Imports DevExpress.XtraBars Imports DevExpress.XtraBars
Imports DevExpress.XtraEditors Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Mask Imports DevExpress.XtraEditors.Mask
@ -19,14 +28,6 @@ Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.ZooFlow Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.ZooFlow.Constants Imports DigitalData.Modules.ZooFlow.Constants
Imports System.ComponentModel
'Imports System.Data.SqlClient
Imports System.Globalization
Imports System.IO
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions
Imports System.Threading
'Imports System.Windows.Forms.VisualStyles.VisualStyleElement 'Imports System.Windows.Forms.VisualStyles.VisualStyleElement
'Imports System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox 'Imports System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox
Imports WINDREAMLib Imports WINDREAMLib
@ -2739,6 +2740,33 @@ Public Class frmValidator
' oErrorMessage = IDB_GetDocInfo() ' oErrorMessage = IDB_GetDocInfo()
End If End If
Dim oCurrency As String
If PROFIL_CURRENCY_ATTRIBUTE <> "" Then
oCurrency = GetVariableValuefromSource(PROFIL_CURRENCY_ATTRIBUTE, 1, False)
MyValidationLogger.Debug(String.Format("Read oCurrency from Attribute: {0} is {1}", PROFIL_CURRENCY_ATTRIBUTE, oCurrency))
Else
oCurrency = "EUR"
MyValidationLogger.Debug(String.Format("oCurrency by default is {0}", oCurrency))
End If
If Not IsNothing(oCurrency) Then
DocCurrency = oCurrency
Dim oValueType = DocCurrency.GetType.ToString
If IsDBNull(DocCurrency) Then
DocCurrency = "EUR"
Else
Try
DocCurrency = DocCurrency.ToString
Catch ex As Exception
MyValidationLogger.Warn($"Unexpected error in Converting oCurreny to string: " & ex.Message)
DocCurrency = "EUR"
End Try
End If
Else
MyValidationLogger.Warn($"oCurrency is Nothing - Check PROFIL_CURRENCY_ATTRIBUTE! ")
End If
If oErrMsgMissingInput = "" Then If oErrMsgMissingInput = "" Then
@ -2788,26 +2816,9 @@ Public Class frmValidator
End If End If
End If End If
Try Try
Dim oCurrency As String
If PROFIL_CURRENCY_ATTRIBUTE <> "" Then
oCurrency = GetVariableValuefromSource(PROFIL_CURRENCY_ATTRIBUTE, 1, False)
Else
oCurrency = "EUR"
End If
If Not IsNothing(oCurrency) Then
DocCurrency = oCurrency
Dim oValueType = DocCurrency.GetType.ToString
If IsDBNull(DocCurrency) Then
DocCurrency = "EUR"
Else
Try
DocCurrency = DocCurrency.ToString
Catch ex As Exception
MyValidationLogger.Warn($"Unexpected error in Converting oCurreny to string: " & ex.Message)
DocCurrency = "EUR"
End Try
End If
If DocCurrency <> String.Empty Then If DocCurrency <> String.Empty Then
If DocCurrency.ToString.Length <> 3 Then If DocCurrency.ToString.Length <> 3 Then
MyValidationLogger.Info("DocCurrency-Length = 3 - Setting to EUR") MyValidationLogger.Info("DocCurrency-Length = 3 - Setting to EUR")
@ -2861,10 +2872,7 @@ Public Class frmValidator
Else Else
MyValidationLogger.Warn($"DocCurrency is String.empty! ") MyValidationLogger.Warn($"DocCurrency is String.empty! ")
End If End If
Else
MyValidationLogger.Warn($"oCurrency is Nothing - Check PROFIL_CURRENCY_ATTRIBUTE! ")
End If
Catch ex As Exception Catch ex As Exception
MyValidationLogger.Warn($"Unexpected error in display format Currency: " & ex.Message) MyValidationLogger.Warn($"Unexpected error in display format Currency: " & ex.Message)
End Try End Try
@ -3397,6 +3405,9 @@ Public Class frmValidator
oTextBox.EditValue = ObjectEx.NotNull(oValueFromSource, oDefaultValue) oTextBox.EditValue = ObjectEx.NotNull(oValueFromSource, oDefaultValue)
If oControl.GetType = GetType(DevExpress.XtraEditors.TextEdit) And oFormatString = "CURRENCY" Then
ApplyCurrencyMask(oTextBox)
End If
Try Try
Dim oBackColor As String = oControlRow.Item("CTRL_BACKCOLOR_IF") Dim oBackColor As String = oControlRow.Item("CTRL_BACKCOLOR_IF")
If oBackColor <> String.Empty Then If oBackColor <> String.Empty Then
@ -4074,6 +4085,33 @@ Public Class frmValidator
End Sub End Sub
Private Sub ApplyCurrencyMask(pTextEdit As TextEdit)
If pTextEdit Is Nothing Then Return
Try
' Kultur auf Basis der aktuellen UI, aber Währungssymbol aus DocCurrency setzen
Dim culture As New CultureInfo("de-DE")
' Wenn DocCurrency leer/fehlerhaft ist, fallback auf EUR
Dim currencySymbol As String = If(String.IsNullOrWhiteSpace(DocCurrency) OrElse DocCurrency.Length <> 3, "EUR", DocCurrency)
' DevExpress Numeric-Mask "c" mit angepasster Kultur
pTextEdit.Properties.MaskSettings.Configure(Of MaskSettings.Numeric)(
Sub(settings)
settings.MaskExpression = "c"
settings.Culture = DirectCast(culture.Clone(), CultureInfo)
settings.Culture.NumberFormat.CurrencySymbol = currencySymbol
End Sub)
pTextEdit.Properties.UseMaskAsDisplayFormat = True
Catch ex As Exception
MyValidationLogger.Warn(String.Format("Unexpected error while applying CurrencyMaskfor pTextEdit: [{0} - ERROR: {1}", pTextEdit.Name, ex.Message))
End Try
End Sub
Private Sub frmValidation_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown Private Sub frmValidation_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
' Refresh_FileList() ' Refresh_FileList()
Load_Next_Document(True) Load_Next_Document(True)