diff --git a/src/DevCase/CultureUtil.vb b/src/DevCase/CultureUtil.vb new file mode 100644 index 0000000..04b10af --- /dev/null +++ b/src/DevCase/CultureUtil.vb @@ -0,0 +1,129 @@ +' This source-code is freely distributed as part of "DevCase for .NET Framework". +' +' Maybe you would like to consider to buy this powerful set of libraries to support me. +' You can do loads of things with my apis for a big amount of diverse thematics. +' +' Here is a link to the purchase page: +' https://codecanyon.net/item/elektrokit-class-library-for-net/19260282 +' +' Thank you. + +#Region " Option Statements " + +Option Strict On +Option Explicit On +Option Infer Off + +#End Region + +#Region " Imports " + +Imports System.Collections.ObjectModel +Imports System.Globalization +Imports System.Runtime.InteropServices +Imports System.Security + +Imports DevCase.Interop.Unmanaged.Win32 +Imports DevCase.Interop.Unmanaged.Win32.Enums + +#End Region + +#Region " Culture Util " + +Namespace DevCase.Core.Application.Tools + + Friend NotInheritable Class CultureUtil + +#Region " Public Methods " + + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Sets the preferred UI languages for the current process. + ''' + ''' To retrieve the preferred UI languages for the current process, + ''' call function. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' This is a code example. + ''' + ''' Dim langNames As String() = {"en-US", "es-ES", "it-IT", "de-DE", "fr-FR"} + ''' Dim successfulLangs As Integer = SetProcessPreferredUILanguages(langNames) + ''' Console.WriteLine($"{NameOf(successfulLangs)}: {successfulLangs}") + ''' + ''' Dim currentPreferredLangs As ReadOnlyCollection(Of CultureInfo) = GetProcessPreferredUILanguages() + ''' Console.WriteLine($"{NameOf(currentPreferredLangs)}: {String.Join(", ", currentPreferredLangs.Select(Function(ci) ci.Name))}") + ''' + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' The name of the languages, in the format languagecode2-country/regioncode2 (eg. "en-US") + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Returns the amount of languages that were successfully set. + ''' + ''' ---------------------------------------------------------------------------------------------------- + + Public Shared Function SetProcessPreferredUILanguages(ParamArray langNames As String()) As Integer + + If (langNames Is Nothing) Then + Throw New ArgumentNullException(paramName:=NameOf(langNames)) + End If + + Dim languages As String = String.Join(ControlChars.NullChar, langNames) + Dim numLangs As UInteger + Dim result As Boolean = NativeMethods.SetProcessPreferredUILanguages(MuiLanguageMode.Name, languages, numLangs) + If Not (result) Then + Return 0 + End If + + Return CType(numLangs, Integer) + + End Function + + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Sets the preferred UI languages for the current process. + ''' + ''' To retrieve the preferred UI languages for the current process, + ''' call function. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' This is a code example. + ''' + ''' Dim cultures As CultureInfo() = { + ''' CultureInfo.CreateSpecificCulture("en-US"), + ''' CultureInfo.CreateSpecificCulture("es-ES"), + ''' CultureInfo.CreateSpecificCulture("it-IT"), + ''' CultureInfo.CreateSpecificCulture("de-DE"), + ''' CultureInfo.CreateSpecificCulture("fr-FR") + ''' } + ''' + ''' Dim successfulLangs As Integer = SetProcessPreferredUILanguages(cultures) + ''' Console.WriteLine($"{NameOf(successfulLangs)}: {successfulLangs}") + ''' + ''' Dim currentPreferredLangs As ReadOnlyCollection(Of CultureInfo) = GetProcessPreferredUILanguages() + ''' Console.WriteLine($"{NameOf(currentPreferredLangs)}: {String.Join(", ", currentPreferredLangs.Select(Function(ci) ci.Name))}") + ''' + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' An array of representing each language. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Returns the amount of languages that were successfully set. + ''' + ''' ---------------------------------------------------------------------------------------------------- + + Public Shared Function SetProcessPreferredUILanguages(ParamArray cultures As CultureInfo()) As Integer + Return SetProcessPreferredUILanguages(cultures.Select(Function(ci) ci.Name).ToArray()) + End Function + +#End Region + + End Class + +End Namespace + +#End Region diff --git a/src/DevCase/Extensions/ControlExtensions.vb b/src/DevCase/Extensions/ControlExtensions.vb index 6b95ef6..686cd2b 100644 --- a/src/DevCase/Extensions/ControlExtensions.vb +++ b/src/DevCase/Extensions/ControlExtensions.vb @@ -33,7 +33,7 @@ Namespace DevCase.Core.Extensions ''' ''' ---------------------------------------------------------------------------------------------------- - Public Module ControlExtensions + Friend Module ControlExtensions #Region " Public Extension Methods " @@ -188,7 +188,7 @@ Namespace DevCase.Core.Extensions ctrl.BackColor = NumericUpDown.DefaultBackColor ctrl.ForeColor = NumericUpDown.DefaultForeColor - ElseIf ctrl.GetType() = GetType(panel) Then + ElseIf ctrl.GetType() = GetType(Panel) Then ctrl.BackColor = Panel.DefaultBackColor ctrl.ForeColor = Panel.DefaultForeColor diff --git a/src/DevCase/Extensions/FormExtensions.vb b/src/DevCase/Extensions/FormExtensions.vb index 17cad86..49e0e01 100644 --- a/src/DevCase/Extensions/FormExtensions.vb +++ b/src/DevCase/Extensions/FormExtensions.vb @@ -33,7 +33,7 @@ Namespace DevCase.Core.Extensions ''' ''' ---------------------------------------------------------------------------------------------------- - Public Module FormExtensions + Friend Module FormExtensions #Region " Public Extension Methods " diff --git a/src/DevCase/Extensions/PropertyGridExtensions.vb b/src/DevCase/Extensions/PropertyGridExtensions.vb index ce19c73..55572ef 100644 --- a/src/DevCase/Extensions/PropertyGridExtensions.vb +++ b/src/DevCase/Extensions/PropertyGridExtensions.vb @@ -34,7 +34,7 @@ Namespace DevCase.Core.Extensions ''' ''' ---------------------------------------------------------------------------------------------------- - Public Module PropertyGridExtensions + Friend Module PropertyGridExtensions #Region " Public Extension Methods " diff --git a/src/DevCase/FileSizeConverter.vb b/src/DevCase/FileSizeConverter.vb index 30bc727..cf6dec9 100644 --- a/src/DevCase/FileSizeConverter.vb +++ b/src/DevCase/FileSizeConverter.vb @@ -33,8 +33,10 @@ Option Infer Off Imports System.ComponentModel Imports System.ComponentModel.Design.Serialization Imports System.Globalization - +Imports System.Runtime.InteropServices +Imports System.Text Imports DevCase.Core.IO +Imports DevCase.Interop.Unmanaged.Win32 #End Region @@ -44,8 +46,9 @@ Namespace DevCase.Core.Design ''' ---------------------------------------------------------------------------------------------------- ''' - ''' Provides a type converter to convert from a file size specified in bytes, - ''' to a rounded file size string using the most approximated unit of size. + ''' Provides a type converter to converts a numeric value + ''' into a string that represents the number expressed as a size value in bytes, + ''' kilobytes, megabytes, gigabytes, petabytes or exabytes, depending on the size. ''' ''' Conversion examples: ''' @@ -60,13 +63,23 @@ Namespace DevCase.Core.Design ''' ---------------------------------------------------------------------------------------------------- ''' This is a code example. ''' - ''' <TypeConverter(GetType(FileSizeConverter))> - ''' <Browsable(True)> - ''' Public ReadOnly Property FileSize As Long = 2048 ' Bytes + ''' Public Class Form1 + ''' + ''' Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load + ''' Me.PropertyGrid1.SelectedObject = New TestClass + ''' End Sub + ''' + ''' End Class + ''' + ''' Public Class TestClass + ''' + ''' <TypeConverter(GetType(FileSizeConverter))> + ''' Public ReadOnly Property FileSize1 As Long = 1024 ' Bytes ''' - ''' <TypeConverter(GetType(FileSizeConverter))> - ''' <Browsable(True)> - ''' Public ReadOnly Property FileSize As New Filesize(2048, SizeUnits.Byte) + ''' <TypeConverter(GetType(FileSizeConverter))> + ''' Public ReadOnly Property FileSize2 As New Filesize(1024, SizeUnits.Byte) + ''' + ''' End Class ''' ''' ''' ---------------------------------------------------------------------------------------------------- @@ -169,11 +182,25 @@ Namespace DevCase.Core.Design End If If (destinationType Is GetType(String)) Then - If (TypeOf value Is Filesize) Then - Return DirectCast(value, Filesize).ToString() + 'If (TypeOf value Is DevCase.Core.IO.Filesize) Then ' Return 'Filesize' string format. + ' Return DirectCast(value, DevCase.Core.IO.Filesize).ToString() + 'Else + Dim sb As New StringBuilder(16) + Dim longValue As ULong + If ULong.TryParse(value.ToString(), longValue) Then ' Return native string format. + Dim result As IntPtr = NativeMethods.StrFormatByteSize64A(longValue, sb, CUInt(sb.Capacity)) + Dim win32Err As Integer = Marshal.GetLastWin32Error() + + If (result <> IntPtr.Zero) Then + Return sb.ToString() + Else + Return New Win32Exception(win32Err).Message + End If + Else ' Return original value. + Return value End If - Return New Filesize(CType(value, Double), SizeUnits.Byte).ToString() + 'End If End If Return MyBase.ConvertTo(context, culture, value, destinationType) diff --git a/src/DevCase/Filesize.vb b/src/DevCase/Filesize.vb deleted file mode 100644 index 1a93774..0000000 --- a/src/DevCase/Filesize.vb +++ /dev/null @@ -1,474 +0,0 @@ -' This source-code is freely distributed as part of "DevCase for .NET Framework". -' -' Maybe you would like to consider to buy this powerful set of libraries to support me. -' You can do loads of things with my apis for a big amount of diverse thematics. -' -' Here is a link to the purchase page: -' https://codecanyon.net/item/elektrokit-class-library-for-net/19260282 -' -' Thank you. - -#Region " Public Members Summary " - -#Region " Constructors " - -' New(Double, SizeUnits) - -#End Region - -#Region " Properties " - -' Size(SizeUnits) As Double -' Size(SizeUnits, Integer, Opt: NumberFormatInfo) As String -' SizeRounded As Double -' SizeRounded(Integer, Opt: NumberFormatInfo) As String -' SizeUnit As SizeUnits -' SizeUnitNameShort As String -' SizeUnitNameLong As String - -#End Region - -#Region " Functions " - -' ToString() As String - -#End Region - -#End Region - -#Region " Option Statements " - -Option Strict On -Option Explicit On -Option Infer Off - -#End Region - -#Region " Imports " - -Imports System.ComponentModel -Imports System.Globalization -Imports System.Xml.Serialization - -Imports DevCase.Core.IO -Imports DevCase.Core.Design - -#End Region - -#Region " Filesize " - -Namespace DevCase.Core.IO - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Defines a filesize. - ''' - ''' Provides methods to round or convert a filesize between different units of size. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' This is a code example that performs a simple conversion between units of size. - ''' - ''' Dim fs As New Filesize(1073741824, Filesize.SizeUnits.Byte) - ''' - ''' Dim b As Double = fs.Size(Filesize.SizeUnits.Byte) - ''' Dim kb As Double = fs.Size(Filesize.SizeUnits.KiloByte) - ''' Dim mb As Double = fs.Size(Filesize.SizeUnits.MegaByte) - ''' Dim gb As Double = fs.Size(Filesize.SizeUnits.GigaByte) - ''' Dim tb As Double = fs.Size(Filesize.SizeUnits.TeraByte) - ''' Dim pb As Double = fs.Size(Filesize.SizeUnits.PetaByte) - ''' - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' This is a code example that rounds a filesize in bytes, to its most approximated unit of size. - ''' - ''' For Each sizeUnit As Filesize.SizeUnits In [Enum].GetValues(GetType(Filesize.SizeUnits)) - ''' - ''' Dim fsize As New Filesize(sizeUnit, Filesize.SizeUnits.Byte) - ''' - ''' Dim stringFormat As String = - ''' String.Format("{0} Bytes rounded to {1} {2}.", - ''' fsize.Size(Filesize.SizeUnits.Byte, CultureInfo.CurrentCulture.NumberFormat), - ''' fsize.SizeRounded(decimalPrecision:=2, numberFormatInfo:=Nothing), - ''' fsize.SizeUnitNameLong) - ''' - ''' Console.WriteLine(stringFormat) - ''' - ''' Next sizeUnit - ''' - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' This is a code example that converts a Terabyte (1099511627776 Bytes) to other units of size. - ''' - ''' Dim fsize As New Filesize(Filesize.SizeUnits.TeraByte, Filesize.SizeUnits.Byte) - ''' - ''' For Each sizeUnit As Filesize.SizeUnits In [Enum].GetValues(GetType(Filesize.SizeUnits)) - ''' - ''' Dim stringFormat As String = - ''' String.Format("{0} Bytes equals to {1} {2}.", - ''' fsize.Size(Filesize.SizeUnits.Byte, Nothing, CultureInfo.CurrentCulture.NumberFormat), - ''' fsize.Size(sizeUnit, 2, CultureInfo.CurrentCulture.NumberFormat), - ''' sizeUnit.ToString()) - ''' - ''' Console.WriteLine(stringFormat) - ''' - ''' Next sizeUnit - ''' - ''' - ''' ---------------------------------------------------------------------------------------------------- - - - Friend NotInheritable Class Filesize - -#Region " Private Fields " - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The filesize, in Bytes. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Private ReadOnly bytesB As Double - -#End Region - -#Region " Properties " - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Gets the filesize, in the specified unit of size. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The unit of size. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The filesize. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public ReadOnly Property Size(ByVal sizeUnit As SizeUnits) As Double - - Get - Return Me.Convert(size:=Me.bytesB, fromUnit:=SizeUnits.Byte, toUnit:=sizeUnit) - End Get - End Property - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Gets the filesize, in the specified unit of size, using the specified numeric format. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The unit of size. - ''' - ''' - ''' - ''' A custom format provider. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The filesize. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public ReadOnly Property Size(ByVal sizeUnit As SizeUnits, - ByVal decimalPrecision As Integer, - Optional ByVal numberFormatInfo As NumberFormatInfo = Nothing) As String - - Get - If (numberFormatInfo Is Nothing) Then - numberFormatInfo = CultureInfo.CurrentCulture.NumberFormat - End If - Return Me.Size(sizeUnit).ToString(String.Format("N{0}", decimalPrecision), numberFormatInfo) - End Get - End Property - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Gets the filesize, rounded using the most approximated unit of size. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The rounded filesize. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public ReadOnly Property SizeRounded As Double - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Gets the filesize, rounded using the most approximated unit of size, with the specified decimal precision. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The decimal precision. - ''' - ''' - ''' - ''' A format provider. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The rounded value, with the specified decimal precision. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public ReadOnly Property SizeRounded(ByVal decimalPrecision As Integer, - Optional ByVal numberFormatInfo As NumberFormatInfo = Nothing) As String - - Get - If numberFormatInfo Is Nothing Then - numberFormatInfo = CultureInfo.CurrentCulture.NumberFormat - End If - Return Me.SizeRounded.ToString(String.Format("N{0}", decimalPrecision), numberFormatInfo) - End Get - End Property - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Gets the used to round the . - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The . - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public ReadOnly Property SizeUnit As SizeUnits - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Gets the short name of the used to round the . - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The short name of the . - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public ReadOnly Property SizeUnitNameShort As String - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Gets the long name of the used to round the . - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The short long of the . - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public ReadOnly Property SizeUnitNameLong As String - -#End Region - -#Region " Constructors " - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Prevents a default instance of the class from being created. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Private Sub New() - End Sub - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Initializes a new instance of the class. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The filesize. - ''' - ''' - ''' - ''' The unit of size. - ''' - ''' ---------------------------------------------------------------------------------------------------- - - Public Sub New(ByVal size As Double, ByVal sizeUnit As SizeUnits) - - Me.bytesB = Global.System.Convert.ToDouble(size * sizeUnit) - - Select Case Math.Abs(Me.bytesB) - - Case Is >= SizeUnits.Petabyte - Me.SizeRounded = (Me.bytesB / SizeUnits.Petabyte) - Me.SizeUnit = SizeUnits.Petabyte - Me.SizeUnitNameShort = "PB" - Me.SizeUnitNameLong = "PetaBytes" - - Case Is >= SizeUnits.Terabyte - Me.SizeRounded = (Me.bytesB / SizeUnits.Terabyte) - Me.SizeUnit = SizeUnits.Terabyte - Me.SizeUnitNameShort = "TB" - Me.SizeUnitNameLong = "TeraBytes" - - Case Is >= SizeUnits.Gigabyte - Me.SizeRounded = (Me.bytesB / SizeUnits.Gigabyte) - Me.SizeUnit = SizeUnits.Gigabyte - Me.SizeUnitNameShort = "GB" - Me.SizeUnitNameLong = "GigaBytes" - - Case Is >= SizeUnits.Megabyte - Me.SizeRounded = (Me.bytesB / SizeUnits.Megabyte) - Me.SizeUnit = SizeUnits.Megabyte - Me.SizeUnitNameShort = "MB" - Me.SizeUnitNameLong = "MegaBytes" - - Case Is >= SizeUnits.Kilobyte - Me.SizeRounded = (Me.bytesB / SizeUnits.Kilobyte) - Me.SizeUnit = SizeUnits.Kilobyte - Me.SizeUnitNameShort = "KB" - Me.SizeUnitNameLong = "KiloBytes" - - Case Is >= SizeUnits.Byte, Is = 0 - Me.SizeRounded = (Me.bytesB / SizeUnits.Byte) - Me.SizeUnit = SizeUnits.Byte - Me.SizeUnitNameShort = "Bytes" - Me.SizeUnitNameLong = "Bytes" - - End Select - - End Sub - -#End Region - -#Region " Public Methods " - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Returns a that represents this filesize. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' A that represents this filesize. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public Overrides Function ToString() As String - Return Me.ToString(CultureInfo.InvariantCulture.NumberFormat) - End Function - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Returns a that represents this filesize. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' A that represents this filesize. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Public Overloads Function ToString(ByVal provider As IFormatProvider) As String - If Me.SizeUnit = SizeUnits.Byte Then - Return String.Format(provider, "{0:0.##} {1}", Math.Floor(Me.SizeRounded * 100) / 100, Me.SizeUnitNameShort) - Else - Return String.Format(provider, "{0:0.00} {1}", Math.Floor(Me.SizeRounded * 100) / 100, Me.SizeUnitNameShort) - End If - End Function - -#End Region - -#Region " Private Methods " - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Converts the specified filesize to a different unit of size. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The filesize. - ''' - ''' - ''' - ''' The unit size to convert from. - ''' - ''' - ''' - ''' The unit size to convert to. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' The resulting value of the unit conversion. - ''' - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' - ''' ---------------------------------------------------------------------------------------------------- - - Private Function Convert(ByVal size As Double, - ByVal fromUnit As SizeUnits, - ByVal toUnit As SizeUnits) As Double - - Dim bytes As Double - - If fromUnit = SizeUnits.Byte Then - bytes = size - - Else - bytes = Global.System.Convert.ToDouble(size * fromUnit) - - End If - - If (toUnit < fromUnit) Then - - Select Case toUnit - - Case SizeUnits.Byte - Return bytes - - Case SizeUnits.Kilobyte - Return (bytes / SizeUnits.Kilobyte) - - Case SizeUnits.Megabyte - Return (bytes / SizeUnits.Megabyte) - - Case SizeUnits.Gigabyte - Return (bytes / SizeUnits.Gigabyte) - - Case SizeUnits.Terabyte - Return (bytes / SizeUnits.Terabyte) - - Case SizeUnits.Petabyte - Return (bytes / SizeUnits.Petabyte) - - Case Else - Throw New InvalidEnumArgumentException(argumentName:=NameOf(toUnit), invalidValue:=CInt(toUnit), - enumClass:=GetType(SizeUnits)) - - End Select - - ElseIf (toUnit > fromUnit) Then - - Select Case toUnit - - Case SizeUnits.Byte - Return bytes - - Case SizeUnits.Kilobyte - Return (bytes * SizeUnits.Kilobyte / SizeUnits.Kilobyte ^ 2) - - Case SizeUnits.Megabyte - Return (bytes * SizeUnits.Megabyte / SizeUnits.Megabyte ^ 2) - - Case SizeUnits.Gigabyte - Return (bytes * SizeUnits.Gigabyte / SizeUnits.Gigabyte ^ 2) - - Case SizeUnits.Terabyte - Return (bytes * SizeUnits.Terabyte / SizeUnits.Terabyte ^ 2) - - Case SizeUnits.Petabyte - Return (bytes * SizeUnits.Petabyte / SizeUnits.Petabyte ^ 2) - - Case Else - Throw New InvalidEnumArgumentException(argumentName:=NameOf(toUnit), invalidValue:=CInt(toUnit), - enumClass:=GetType(SizeUnits)) - - End Select - - Else ' If toUnit = fromUnit - Return bytes - - End If - - End Function - -#End Region - - End Class - -End Namespace - -#End Region diff --git a/src/DevCase/ShortcutFileInfoIconIndexEditor.vb b/src/DevCase/ShortcutFileInfoIconIndexEditor.vb index 4510fc1..d2cd871 100644 --- a/src/DevCase/ShortcutFileInfoIconIndexEditor.vb +++ b/src/DevCase/ShortcutFileInfoIconIndexEditor.vb @@ -24,6 +24,7 @@ Imports System.IO Imports DevCase.Core.Imaging.Tools Imports DevCase.Core.IO +Imports DevCase.Interop.Unmanaged.Win32 #End Region @@ -70,7 +71,6 @@ Namespace DevCase.Core.Design ''' ''' ---------------------------------------------------------------------------------------------------- Public Overrides Sub PaintValue(ByVal e As PaintValueEventArgs) - Dim ico As Icon = Nothing Dim index As Integer = CInt(e.Value) @@ -155,8 +155,29 @@ Namespace DevCase.Core.Design ''' ''' ---------------------------------------------------------------------------------------------------- Public Overrides Function EditValue(ByVal context As ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value As Object) As Object + Me.UpdateFields(context) - Return MyBase.EditValue(context, provider, value) + + Dim path As String = Me.iconPath + If String.IsNullOrEmpty(path) Then + path = Me.target + End If + + If File.Exists(path) Then + If path.EndsWith(".ico", StringComparison.OrdinalIgnoreCase) OrElse + path.EndsWith(".icl", StringComparison.OrdinalIgnoreCase) OrElse + path.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) OrElse + path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) Then + + Dim iconIndex As Integer + If NativeMethods.PickIconDlg(Process.GetCurrentProcess.MainWindowHandle(), path, 0, iconIndex) Then + value = iconIndex + End If + End If + End If + + Return value + End Function ''' ---------------------------------------------------------------------------------------------------- @@ -174,7 +195,7 @@ Namespace DevCase.Core.Design ''' ---------------------------------------------------------------------------------------------------- Public Overrides Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle Me.UpdateFields(context) - Return UITypeEditorEditStyle.None + Return UITypeEditorEditStyle.Modal End Function #End Region diff --git a/src/DevCase/SizeUnits.vb b/src/DevCase/SizeUnits.vb deleted file mode 100644 index 6d3ed51..0000000 --- a/src/DevCase/SizeUnits.vb +++ /dev/null @@ -1,83 +0,0 @@ -' This source-code is freely distributed as part of "DevCase for .NET Framework". -' -' Maybe you would like to consider to buy this powerful set of libraries to support me. -' You can do loads of things with my apis for a big amount of diverse thematics. -' -' Here is a link to the purchase page: -' https://codecanyon.net/item/elektrokit-class-library-for-net/19260282 -' -' Thank you. - -#Region " Option Statements " - -Option Strict On -Option Explicit On -Option Infer Off - -#End Region - -#Region " Size Units " - -Namespace DevCase.Core.IO - - ''' ---------------------------------------------------------------------------------------------------- - ''' - ''' Specifies a size unit. - ''' - ''' ---------------------------------------------------------------------------------------------------- - Friend Enum SizeUnits As Long - - ''' - ''' Represents 1 Byte. - ''' - ''' (8 Bits) - ''' - [Byte] = CLng(2 ^ 0) - - ''' - ''' Represents 1 Kilobyte. - ''' - ''' (1.024 Bytes) - ''' - Kilobyte = CLng(2 ^ 10) - - ''' - ''' Represents 1 MegaByte. - ''' - ''' (1.048.576 Bytes) - ''' - Megabyte = CLng(2 ^ 20) - - ''' - ''' Represents 1 Gigabyte. - ''' - ''' (1.073.741.824 Bytes) - ''' - Gigabyte = CLng(2 ^ 30) - - ''' - ''' Represents 1 Terabyte. - ''' - ''' (1.099.511.627.776 Bytes) - ''' - Terabyte = CLng(2 ^ 40) - - ''' - ''' Represents 1 Petabyte. - ''' - ''' (1.125.899.906.842.624 Bytes) - ''' - Petabyte = CLng(2 ^ 50) - - ''' - ''' Represents 1 Exabyte. - ''' - ''' (1.152.921.504.606.846.976 Bytes) - ''' - Exabyte = CLng(2 ^ 60) - - End Enum - -End Namespace - -#End Region diff --git a/src/DevCase/Win32/HResult.vb b/src/DevCase/Win32/HResult.vb index 57d4f2d..5dda3a4 100644 --- a/src/DevCase/Win32/HResult.vb +++ b/src/DevCase/Win32/HResult.vb @@ -33,7 +33,7 @@ Namespace DevCase.Interop.Unmanaged.Win32.Enums ''' List of HRESULT codes: class. ''' ''' ---------------------------------------------------------------------------------------------------- - Public Enum HResult As Integer + Friend Enum HResult As Integer ' ***************************************************************************** ' WARNING!, NEED TO KNOW... diff --git a/src/DevCase/Win32/IShellItem.vb b/src/DevCase/Win32/IShellItem.vb index 6100dc2..b0455ff 100644 --- a/src/DevCase/Win32/IShellItem.vb +++ b/src/DevCase/Win32/IShellItem.vb @@ -47,7 +47,7 @@ Namespace DevCase.Interop.Unmanaged.Win32.Interfaces - Public Interface IShellItem + Friend Interface IShellItem Function NotImplemented_BindToHandler() As Object diff --git a/src/DevCase/Win32/MuiLanguageMode.vb b/src/DevCase/Win32/MuiLanguageMode.vb new file mode 100644 index 0000000..6818310 --- /dev/null +++ b/src/DevCase/Win32/MuiLanguageMode.vb @@ -0,0 +1,52 @@ +' This source-code is freely distributed as part of "DevCase for .NET Framework". +' +' Maybe you would like to consider to buy this powerful set of libraries to support me. +' You can do loads of things with my apis for a big amount of diverse thematics. +' +' Here is a link to the purchase page: +' https://codecanyon.net/item/elektrokit-class-library-for-net/19260282 +' +' Thank you. + +#Region " Option Statements " + +Option Strict On +Option Explicit On +Option Infer Off + +#End Region + +#Region " Imports " + +#End Region + +#Region " ActiveDesktopApplyMode " + +Namespace DevCase.Interop.Unmanaged.Win32.Enums + + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Specifies the language format to use for Multilingual User Interface (MUI) functions. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' + ''' + ''' ---------------------------------------------------------------------------------------------------- + Friend Enum MuiLanguageMode As Integer + + ''' + ''' The input parameter language strings are in language identifier format. + ''' + Id = 4 + + ''' + ''' The input parameter language strings are in language name format. + ''' + Name = 8 + + End Enum + +End Namespace + +#End Region diff --git a/src/DevCase/Win32/NativeMethods.vb b/src/DevCase/Win32/NativeMethods.vb index 9f30b2a..c636a13 100644 --- a/src/DevCase/Win32/NativeMethods.vb +++ b/src/DevCase/Win32/NativeMethods.vb @@ -62,6 +62,52 @@ Namespace DevCase.Interop.Unmanaged.Win32 #End Region +#Region " Kernel32.dll " + + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Sets the process preferred UI languages for the current process. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Flags identifying the language format to use for the process preferred UI languages. + ''' + ''' + ''' + ''' Pointer to a double null-terminated multi-string buffer that contains an ordered, + ''' null-delimited list in decreasing order of preference. + ''' + ''' If there are more than five languages in the buffer, the function only sets the first five valid languages. + ''' + ''' Alternatively, this parameter can contain NULL if no language list is required. + ''' In this case, the function clears the preferred UI languages for the process. + ''' + ''' + ''' + ''' Pointer to the number of languages that has been set in the process language list from the input buffer, + ''' up to a maximum of five. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' If the function succeeds, the return value is . + ''' If the function fails, the return value is . + ''' + ''' To get extended error information, call . + ''' + ''' ---------------------------------------------------------------------------------------------------- + + Friend Shared Function SetProcessPreferredUILanguages(ByVal flags As MuiLanguageMode, + ByVal languagesBuffer As String, + ByRef refNumLanguages As UInteger + ) As Boolean + End Function + +#End Region + #Region " Shell32.dll " ''' ---------------------------------------------------------------------------------------------------- @@ -159,7 +205,7 @@ Namespace DevCase.Interop.Unmanaged.Win32 ''' ''' ---------------------------------------------------------------------------------------------------- - Public Shared Function SHGetNameFromIDList(ByVal pidl As IntPtr, + Friend Shared Function SHGetNameFromIDList(ByVal pidl As IntPtr, ByVal sigdn As ShellItemGetDisplayName, ByRef refName As StringBuilder ) As HResult @@ -202,7 +248,7 @@ Namespace DevCase.Interop.Unmanaged.Win32 ''' ''' ---------------------------------------------------------------------------------------------------- - Public Shared Function SHCreateItemFromParsingName(ByVal path As String, + Friend Shared Function SHCreateItemFromParsingName(ByVal path As String, ByVal pbc As IntPtr, ByRef refIID As Guid, ByRef refShellItem As IShellItem @@ -265,7 +311,7 @@ Namespace DevCase.Interop.Unmanaged.Win32 ''' ---------------------------------------------------------------------------------------------------- - Public Shared Function SHDefExtractIcon(ByVal iconFile As String, + Friend Shared Function SHDefExtractIcon(ByVal iconFile As String, ByVal iconIndex As Integer, ByVal flags As UInteger, ByRef refHiconLarge As IntPtr, @@ -274,6 +320,90 @@ Namespace DevCase.Interop.Unmanaged.Win32 ) As HResult End Function + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Displays a dialog box that allows the user to choose an icon from the + ''' selection available embedded in a resource such as an executable or DLL file. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' The handle of the parent window. This value can be . + ''' + ''' + ''' + ''' A pointer to a string that contains the null-terminated, + ''' fully qualified path of the default resource that contains the icons. + ''' + ''' If the user chooses a different resource in the dialog, + ''' this buffer contains the path of that file when the function returns. + ''' + ''' This buffer should be at least MAX_PATH characters in length, or the returned path may be truncated. + ''' + ''' You should verify that the path is valid before using it. + ''' + ''' + ''' + ''' The number of characters in , including the terminating NULL character. + ''' + ''' + ''' + ''' A pointer to an integer that on entry specifies the index of the initial selection and, + ''' when this function returns successfully, receives the index of the icon that was selected. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Returns if successful; otherwise, . + ''' + ''' ---------------------------------------------------------------------------------------------------- + + Friend Shared Function PickIconDlg(ByVal hWnd As IntPtr, + ByVal iconPath As String, + ByVal iconPathSize As Integer, + ByRef refIconIndex As Integer + ) As Boolean + End Function + +#End Region + +#Region " ShlwApi.dll " + + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Converts a numeric value into a string that represents the number expressed as a size value in bytes, + ''' kilobytes, megabytes, gigabytes, petabytes or exabytes, depending on the size. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' The numeric value to be converted. + ''' + ''' + ''' + ''' A pointer to a buffer that, when this function returns successfully, receives the converted number. + ''' + ''' + ''' + ''' The size of , in characters. + ''' + ''' ---------------------------------------------------------------------------------------------------- + ''' + ''' Returns a pointer to the converted string, or NULL if the conversion fails. + ''' + ''' ---------------------------------------------------------------------------------------------------- + + Friend Shared Function StrFormatByteSize64A(ByVal number As ULong, + ByVal buffer As StringBuilder, + ByVal bufferSize As UInteger + ) As IntPtr + End Function + #End Region #Region " User32.dll " diff --git a/src/DevCase/Win32/NativeWindowState.vb b/src/DevCase/Win32/NativeWindowState.vb index dc00b9c..f227dd9 100644 --- a/src/DevCase/Win32/NativeWindowState.vb +++ b/src/DevCase/Win32/NativeWindowState.vb @@ -29,7 +29,7 @@ Namespace DevCase.Interop.Unmanaged.Win32.Enums ''' ''' ''' ---------------------------------------------------------------------------------------------------- - Public Enum NativeWindowState As Integer + Friend Enum NativeWindowState As Integer ''' ''' Hides the window and activates another window. diff --git a/src/DevCase/Win32/ShellItemGetDisplayName.vb b/src/DevCase/Win32/ShellItemGetDisplayName.vb index 5ac2025..4d00504 100644 --- a/src/DevCase/Win32/ShellItemGetDisplayName.vb +++ b/src/DevCase/Win32/ShellItemGetDisplayName.vb @@ -30,7 +30,7 @@ Namespace DevCase.Interop.Unmanaged.Win32.Enums ''' ''' ''' ---------------------------------------------------------------------------------------------------- - Public Enum ShellItemGetDisplayName As UInteger ' SIGDN + Friend Enum ShellItemGetDisplayName As UInteger ' SIGDN ''' ''' Returns the editing name relative to the desktop. In UI this name is suitable for display to the user. diff --git a/src/Easy Link File Viewer.vbproj b/src/Easy Link File Viewer.vbproj index e29fe94..27f1129 100644 --- a/src/Easy Link File Viewer.vbproj +++ b/src/Easy Link File Viewer.vbproj @@ -80,19 +80,19 @@ + + - Component - AboutBox1.vb diff --git a/src/My Project/AssemblyInfo.vb b/src/My Project/AssemblyInfo.vb index debc8d0..1556cd3 100644 --- a/src/My Project/AssemblyInfo.vb +++ b/src/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/src/UI/Form1.Designer.vb b/src/UI/Form1.Designer.vb index 3ff4aa5..1248bc0 100644 --- a/src/UI/Form1.Designer.vb +++ b/src/UI/Form1.Designer.vb @@ -25,14 +25,8 @@ Partial Friend Class Form1 Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) Me.MenuStrip1 = New System.Windows.Forms.MenuStrip() - Me.PropertyGrid1 = New System.Windows.Forms.PropertyGrid() - Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) - Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() - Me.ToolStripStatusLabelIcon = New System.Windows.Forms.ToolStripStatusLabel() - Me.ToolStripStatusLabelFileName = New System.Windows.Forms.ToolStripStatusLabel() Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.NewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() - Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator() Me.RecentToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator() Me.OpenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() @@ -48,6 +42,8 @@ Partial Friend Class Form1 Me.DefaultToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.DarkToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.PropertyGrid1 = New System.Windows.Forms.PropertyGrid() + Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.OpenShortcutMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.OpenTargetMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.OpenTargetWithArgsMenuItem = New System.Windows.Forms.ToolStripMenuItem() @@ -55,6 +51,9 @@ Partial Friend Class Form1 Me.ViewTargetMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ViewWorkingDirectoryMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ViewIconMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() + Me.ToolStripStatusLabelIcon = New System.Windows.Forms.ToolStripStatusLabel() + Me.ToolStripStatusLabelFileName = New System.Windows.Forms.ToolStripStatusLabel() Me.MenuStrip1.SuspendLayout() Me.ContextMenuStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() @@ -70,56 +69,9 @@ Partial Friend Class Form1 Me.MenuStrip1.TabIndex = 0 Me.MenuStrip1.Text = "MenuStrip1" ' - 'PropertyGrid1 - ' - Me.PropertyGrid1.AllowDrop = True - Me.PropertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill - Me.PropertyGrid1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!) - Me.PropertyGrid1.Location = New System.Drawing.Point(0, 27) - Me.PropertyGrid1.Name = "PropertyGrid1" - Me.PropertyGrid1.Size = New System.Drawing.Size(684, 360) - Me.PropertyGrid1.TabIndex = 1 - ' - 'ContextMenuStrip1 - ' - Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OpenShortcutMenuItem, Me.OpenTargetMenuItem, Me.OpenTargetWithArgsMenuItem, Me.ViewShortcutMenuItem, Me.ViewTargetMenuItem, Me.ViewWorkingDirectoryMenuItem, Me.ViewIconMenuItem}) - Me.ContextMenuStrip1.Name = "ContextMenuStrip1" - Me.ContextMenuStrip1.Size = New System.Drawing.Size(257, 158) - ' - 'StatusStrip1 - ' - Me.StatusStrip1.BackColor = System.Drawing.SystemColors.Control - Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabelIcon, Me.ToolStripStatusLabelFileName}) - Me.StatusStrip1.Location = New System.Drawing.Point(0, 387) - Me.StatusStrip1.Name = "StatusStrip1" - Me.StatusStrip1.Size = New System.Drawing.Size(684, 24) - Me.StatusStrip1.TabIndex = 2 - Me.StatusStrip1.Text = "StatusStrip1" - ' - 'ToolStripStatusLabelIcon - ' - Me.ToolStripStatusLabelIcon.Font = New System.Drawing.Font("Segoe UI", 10.0!) - Me.ToolStripStatusLabelIcon.ImageAlign = System.Drawing.ContentAlignment.MiddleRight - Me.ToolStripStatusLabelIcon.Name = "ToolStripStatusLabelIcon" - Me.ToolStripStatusLabelIcon.Size = New System.Drawing.Size(42, 19) - Me.ToolStripStatusLabelIcon.Text = "{icon}" - Me.ToolStripStatusLabelIcon.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay - ' - 'ToolStripStatusLabelFileName - ' - Me.ToolStripStatusLabelFileName.AutoToolTip = True - Me.ToolStripStatusLabelFileName.Font = New System.Drawing.Font("Segoe UI", 10.0!) - Me.ToolStripStatusLabelFileName.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft - Me.ToolStripStatusLabelFileName.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline - Me.ToolStripStatusLabelFileName.Name = "ToolStripStatusLabelFileName" - Me.ToolStripStatusLabelFileName.Size = New System.Drawing.Size(627, 19) - Me.ToolStripStatusLabelFileName.Spring = True - Me.ToolStripStatusLabelFileName.Text = "{fullpath} " - Me.ToolStripStatusLabelFileName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft - ' 'FileToolStripMenuItem ' - Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.NewToolStripMenuItem, Me.ToolStripSeparator3, Me.RecentToolStripMenuItem, Me.ToolStripSeparator1, Me.OpenToolStripMenuItem, Me.SaveToolStripMenuItem, Me.SaveAsToolStripMenuItem, Me.CloseToolStripMenuItem, Me.ToolStripSeparator2, Me.ExitToolStripMenuItem}) + Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.NewToolStripMenuItem, Me.OpenToolStripMenuItem, Me.SaveToolStripMenuItem, Me.SaveAsToolStripMenuItem, Me.CloseToolStripMenuItem, Me.ToolStripSeparator1, Me.RecentToolStripMenuItem, Me.ToolStripSeparator2, Me.ExitToolStripMenuItem}) Me.FileToolStripMenuItem.Image = Global.My.Resources.Resources.FSFile_16x Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" Me.FileToolStripMenuItem.Size = New System.Drawing.Size(57, 23) @@ -132,11 +84,6 @@ Partial Friend Class Form1 Me.NewToolStripMenuItem.Size = New System.Drawing.Size(180, 24) Me.NewToolStripMenuItem.Text = "New" ' - 'ToolStripSeparator3 - ' - Me.ToolStripSeparator3.Name = "ToolStripSeparator3" - Me.ToolStripSeparator3.Size = New System.Drawing.Size(177, 6) - ' 'RecentToolStripMenuItem ' Me.RecentToolStripMenuItem.Enabled = False @@ -245,6 +192,22 @@ Partial Friend Class Form1 Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(84, 23) Me.AboutToolStripMenuItem.Text = "About..." ' + 'PropertyGrid1 + ' + Me.PropertyGrid1.AllowDrop = True + Me.PropertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill + Me.PropertyGrid1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!) + Me.PropertyGrid1.Location = New System.Drawing.Point(0, 27) + Me.PropertyGrid1.Name = "PropertyGrid1" + Me.PropertyGrid1.Size = New System.Drawing.Size(684, 360) + Me.PropertyGrid1.TabIndex = 1 + ' + 'ContextMenuStrip1 + ' + Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OpenShortcutMenuItem, Me.OpenTargetMenuItem, Me.OpenTargetWithArgsMenuItem, Me.ViewShortcutMenuItem, Me.ViewTargetMenuItem, Me.ViewWorkingDirectoryMenuItem, Me.ViewIconMenuItem}) + Me.ContextMenuStrip1.Name = "ContextMenuStrip1" + Me.ContextMenuStrip1.Size = New System.Drawing.Size(257, 158) + ' 'OpenShortcutMenuItem ' Me.OpenShortcutMenuItem.Image = Global.My.Resources.Resources.Open_16x @@ -294,6 +257,38 @@ Partial Friend Class Form1 Me.ViewIconMenuItem.Size = New System.Drawing.Size(256, 22) Me.ViewIconMenuItem.Text = "View Icon in Explorer" ' + 'StatusStrip1 + ' + Me.StatusStrip1.BackColor = System.Drawing.SystemColors.Control + Me.StatusStrip1.ContextMenuStrip = Me.ContextMenuStrip1 + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabelIcon, Me.ToolStripStatusLabelFileName}) + Me.StatusStrip1.Location = New System.Drawing.Point(0, 387) + Me.StatusStrip1.Name = "StatusStrip1" + Me.StatusStrip1.Size = New System.Drawing.Size(684, 24) + Me.StatusStrip1.TabIndex = 2 + Me.StatusStrip1.Text = "StatusStrip1" + ' + 'ToolStripStatusLabelIcon + ' + Me.ToolStripStatusLabelIcon.Font = New System.Drawing.Font("Segoe UI", 10.0!) + Me.ToolStripStatusLabelIcon.ImageAlign = System.Drawing.ContentAlignment.MiddleRight + Me.ToolStripStatusLabelIcon.Name = "ToolStripStatusLabelIcon" + Me.ToolStripStatusLabelIcon.Size = New System.Drawing.Size(42, 19) + Me.ToolStripStatusLabelIcon.Text = "{icon}" + Me.ToolStripStatusLabelIcon.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay + ' + 'ToolStripStatusLabelFileName + ' + Me.ToolStripStatusLabelFileName.AutoToolTip = True + Me.ToolStripStatusLabelFileName.Font = New System.Drawing.Font("Segoe UI", 10.0!) + Me.ToolStripStatusLabelFileName.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.ToolStripStatusLabelFileName.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline + Me.ToolStripStatusLabelFileName.Name = "ToolStripStatusLabelFileName" + Me.ToolStripStatusLabelFileName.Size = New System.Drawing.Size(596, 19) + Me.ToolStripStatusLabelFileName.Spring = True + Me.ToolStripStatusLabelFileName.Text = "{fullpath} " + Me.ToolStripStatusLabelFileName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -347,5 +342,4 @@ Partial Friend Class Form1 Friend WithEvents ToolStripComboBoxFontSize As ToolStripComboBox Friend WithEvents ToolStripStatusLabelIcon As ToolStripStatusLabel Friend WithEvents NewToolStripMenuItem As ToolStripMenuItem - Friend WithEvents ToolStripSeparator3 As ToolStripSeparator End Class diff --git a/src/UI/Form1.vb b/src/UI/Form1.vb index 4173be8..fd59905 100644 --- a/src/UI/Form1.vb +++ b/src/UI/Form1.vb @@ -1,6 +1,6 @@ ' *********************************************************************** ' Author : ElektroStudios -' Modified : 30-May-2019 +' Modified : 04-June-2019 ' *********************************************************************** #Region " Option Statements " @@ -14,8 +14,11 @@ Option Infer Off #Region " Imports " Imports System.ComponentModel +Imports System.Globalization Imports System.IO +Imports System.Threading +Imports DevCase.Core.Application.Tools Imports DevCase.Core.Extensions Imports DevCase.Core.IO Imports DevCase.Core.IO.Tools @@ -52,6 +55,12 @@ Friend NotInheritable Class Form1 : Inherits Form ''' ---------------------------------------------------------------------------------------------------- Public Sub New() MyClass.InitializeComponent() + + Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("en-US") + Thread.CurrentThread.CurrentCulture = ci + Thread.CurrentThread.CurrentUICulture = ci + ' Set file dialogs language too. + CultureUtil.SetProcessPreferredUILanguages(ci.Name) End Sub #End Region @@ -360,6 +369,7 @@ Friend NotInheritable Class Form1 : Inherits Form Me.CloseToolStripMenuItem.Enabled = False Me.PropertyGrid1.ContextMenuStrip = Nothing + Me.StatusStrip1.ContextMenuStrip = Nothing End Sub ''' ---------------------------------------------------------------------------------------------------- @@ -814,6 +824,7 @@ Friend NotInheritable Class Form1 : Inherits Form Me.ToolStripStatusLabelIcon.Image = Me.RecentToolStripMenuItem.DropDown.Items(0).Image Me.PropertyGrid1.ContextMenuStrip = Me.ContextMenuStrip1 + Me.StatusStrip1.ContextMenuStrip = Me.ContextMenuStrip1 End Sub