Compare commits
4 Commits
a856f5f1b3
...
f491d4dd24
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f491d4dd24 | ||
|
|
e65a6fa1a4 | ||
|
|
726bdd1b2d | ||
|
|
fd2ad3f056 |
@@ -52,6 +52,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
@@ -76,10 +77,11 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="BaseClass.vb" />
|
||||
<Compile Include="ECM\ECM.vb" />
|
||||
<Compile Include="GraphicsEx.vb" />
|
||||
<Compile Include="IDB\Attributes.vb" />
|
||||
<Compile Include="IDB\Database.vb" />
|
||||
<Compile Include="IDB\FileStore.vb" />
|
||||
<Compile Include="Language.vb" />
|
||||
<Compile Include="LanguageEx.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -96,7 +98,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Performance.vb" />
|
||||
<Compile Include="PerformanceEx.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
|
||||
16
Base/GraphicsEx.vb
Normal file
16
Base/GraphicsEx.vb
Normal file
@@ -0,0 +1,16 @@
|
||||
Imports System.Drawing
|
||||
|
||||
Public Class GraphicsEx
|
||||
|
||||
Public Shared Function GetBrightness(c As Color) As Single
|
||||
Return (c.R * 0.299F + c.G * 0.587F + c.B * 0.114F) / 256.0F
|
||||
End Function
|
||||
|
||||
Public Shared Function GetContrastedColor(pOtherColor As Color) As Color
|
||||
If GetBrightness(pOtherColor) < 0.55 Then
|
||||
Return Color.White
|
||||
Else
|
||||
Return Color.Black
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
@@ -1,32 +0,0 @@
|
||||
Imports System.Globalization
|
||||
Imports System.Threading
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Language
|
||||
Public Shared Sub SetApplicationLanguage(pLogger As Logger, pUserLanguage As String, Optional pUserDateFormat As String = Nothing)
|
||||
Try
|
||||
pLogger.Debug("Setting application language..")
|
||||
|
||||
'Dim Culture = CultureInfo.CreateSpecificCulture(pUserLanguage)
|
||||
Dim Culture As New CultureInfo(pUserLanguage)
|
||||
Culture.DateTimeFormat.ShortDatePattern = pUserDateFormat
|
||||
|
||||
pLogger.Debug("Culture object for language [{0}] created", pUserLanguage)
|
||||
|
||||
' The following line provides localization for data formats.
|
||||
Thread.CurrentThread.CurrentCulture = Culture
|
||||
' The following line provides localization for the application's user interface.
|
||||
Thread.CurrentThread.CurrentUICulture = Culture
|
||||
|
||||
' Set this culture as the default culture for all threads in this application.
|
||||
' Note: The following properties are supported in the .NET Framework 4.5+
|
||||
CultureInfo.DefaultThreadCurrentCulture = Culture
|
||||
CultureInfo.DefaultThreadCurrentUICulture = Culture
|
||||
|
||||
pLogger.Debug("Application language set to [{0}]", Culture.Name)
|
||||
Catch ex As Exception
|
||||
pLogger.Warn("Could not set application language!")
|
||||
pLogger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
55
Base/LanguageEx.vb
Normal file
55
Base/LanguageEx.vb
Normal file
@@ -0,0 +1,55 @@
|
||||
Imports System.Globalization
|
||||
Imports System.Threading
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
''' <summary>
|
||||
''' Functions relating to i18n, Cultures, Translations
|
||||
''' </summary>
|
||||
Public Class LanguageEx
|
||||
''' <summary>
|
||||
''' Sets the Language of the current thread by setting CurrentCulture and CurrentUICulture
|
||||
''' </summary>
|
||||
''' <param name="pLogger">A Logger instance</param>
|
||||
''' <param name="pUserLanguage">A language code in the form of 'de-DE'</param>
|
||||
''' <param name="pUserDateFormat">A custom date pattern</param>
|
||||
Public Shared Sub SetApplicationLanguage(pLogger As Logger, pUserLanguage As String, Optional pUserDateFormat As String = Nothing)
|
||||
Try
|
||||
pLogger.Debug("Setting application language..")
|
||||
|
||||
Dim Culture As New CultureInfo(pUserLanguage)
|
||||
If String.IsNullOrEmpty(pUserDateFormat) = False Then
|
||||
Culture.DateTimeFormat.ShortDatePattern = pUserDateFormat
|
||||
End If
|
||||
|
||||
pLogger.Debug("Culture object for language [{0}] created", pUserLanguage)
|
||||
|
||||
' The following line provides localization for data formats.
|
||||
Thread.CurrentThread.CurrentCulture = Culture
|
||||
' The following line provides localization for the application's user interface.
|
||||
Thread.CurrentThread.CurrentUICulture = Culture
|
||||
|
||||
' Set this culture as the default culture for all threads in this application.
|
||||
' Note: The following properties are supported in the .NET Framework 4.5+
|
||||
CultureInfo.DefaultThreadCurrentCulture = Culture
|
||||
CultureInfo.DefaultThreadCurrentUICulture = Culture
|
||||
|
||||
pLogger.Debug("Application language set to [{0}]", Culture.Name)
|
||||
Catch ex As Exception
|
||||
pLogger.Warn("Could not set application language!")
|
||||
pLogger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Logs the culture settings of the current thread
|
||||
''' </summary>
|
||||
''' <param name="pLogger">A Logger instance</param>
|
||||
Public Shared Sub LogApplicationLanguage(pLogger As Logger)
|
||||
pLogger.Debug("=== Application Language ===")
|
||||
pLogger.Debug("Thread.CurrentThread.CurrentCulture: [{0}]", Thread.CurrentThread.CurrentCulture)
|
||||
pLogger.Debug("Thread.CurrentThread.CurrentUICulture: [{0}]", Thread.CurrentThread.CurrentUICulture)
|
||||
pLogger.Debug("CultureInfo.DefaultThreadCurrentCulture: [{0}]", CultureInfo.DefaultThreadCurrentCulture)
|
||||
pLogger.Debug("CultureInfo.DefaultThreadCurrentUICulture: [{0}]", CultureInfo.DefaultThreadCurrentUICulture)
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("Base")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2023")>
|
||||
<Assembly: AssemblyTrademark("1.2.0.0")>
|
||||
<Assembly: AssemblyTrademark("1.2.1.0")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' indem Sie "*" wie unten gezeigt eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.2.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.2.0.0")>
|
||||
<Assembly: AssemblyVersion("1.2.1.0")>
|
||||
<Assembly: AssemblyFileVersion("1.2.1.0")>
|
||||
|
||||
@@ -4,7 +4,7 @@ Imports System.Runtime.InteropServices
|
||||
Imports System.Security.Cryptography
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Performance
|
||||
Public Class PerformanceEx
|
||||
Public Sub New(pLogConfig As LogConfig, pAppDataPath As String)
|
||||
Dim savedHash = String.Empty
|
||||
Dim assemblyLocation = Assembly.GetEntryAssembly().Location
|
||||
@@ -103,6 +103,14 @@ Public Class File
|
||||
Return FormatHash(oChecksum)
|
||||
End Function
|
||||
|
||||
Public Function GetHash(FilePath As String) As String
|
||||
Return GetChecksum(FilePath)
|
||||
End Function
|
||||
|
||||
Public Function GetHashFromString(pStringToCheck As String) As String
|
||||
Return GetChecksumFromString(pStringToCheck)
|
||||
End Function
|
||||
|
||||
Private Function FormatHash(pChecksum)
|
||||
Return BitConverter.
|
||||
ToString(pChecksum).
|
||||
|
||||
@@ -42,6 +42,11 @@ Public Class Utils
|
||||
Return [Enum].ToObject(GetType(T), value)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Converts a string to boolean. Accepts true and 1 as truthy values
|
||||
''' </summary>
|
||||
''' <param name="input">The input string</param>
|
||||
''' <returns>True if input is true or 1, otherwise false.</returns>
|
||||
Public Shared Function ToBoolean(input As String) As Boolean
|
||||
If String.IsNullOrEmpty(input) Then Return False
|
||||
Return (input.Trim().ToLower() = "true") OrElse (input.Trim() = "1")
|
||||
@@ -151,6 +156,11 @@ Public Class Utils
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Checks if string contains invalid characters
|
||||
''' </summary>
|
||||
''' <param name="pString"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function TestContainsInvalidCharacters(pString As String) As Boolean
|
||||
Return Not pString.Equals(RemoveInvalidCharacters(pString))
|
||||
End Function
|
||||
|
||||
Reference in New Issue
Block a user