-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
30 changed files
with
2,905 additions
and
142 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
' 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.ComponentModel | ||
Imports System.Drawing.Design | ||
Imports System.IO | ||
Imports System.Text | ||
Imports System.Windows.Forms.Design | ||
Imports DevCase.UserControls.Controls | ||
|
||
#End Region | ||
|
||
#Region " FileOrFolderNameEditor " | ||
|
||
Namespace DevCase.Core.Design | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Provides a user interface for selecting a file or folder name. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <seealso cref="UITypeEditor"/> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Friend Class FileOrFolderNameEditor : Inherits UITypeEditor | ||
|
||
#Region " Constructors " | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Initializes a new instance of the <see cref="FileOrFolderNameEditor"/> class. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Public Sub New() | ||
MyBase.New() | ||
End Sub | ||
|
||
#End Region | ||
|
||
#Region " Public Methods " | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Gets the editor style used by the <see cref="UITypeEditor.EditValue(IServiceProvider, Object)"/> method. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <param name="context"> | ||
''' An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information. | ||
''' </param> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <returns> | ||
''' A <see cref="UITypeEditorEditStyle"/> value that indicates the style of editor used | ||
''' by the <see cref="UITypeEditor.EditValue(IServiceProvider, Object)"/> method. | ||
''' <para></para> | ||
''' If the <see cref="UITypeEditor"/> does not support this method, | ||
''' then <see cref="UITypeEditor.GetEditStyle"/> will return <see cref="UITypeEditorEditStyle.None"/>. | ||
''' </returns> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Public Overrides Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle | ||
Return UITypeEditorEditStyle.Modal | ||
End Function | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Edits the specified object's value using the editor style indicated by the <see cref="UITypeEditor.GetEditStyle"/> method. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <param name="context"> | ||
''' An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information. | ||
''' </param> | ||
''' | ||
''' <param name="provider"> | ||
''' An <see cref="IServiceProvider"/> that this editor can use to obtain services. | ||
''' </param> | ||
''' | ||
''' <param name="value"> | ||
''' The object to edit. | ||
''' </param> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <returns> | ||
''' The new value of the object. | ||
''' <para></para> | ||
''' If the value of the object has not changed, this should return the same object it was passed. | ||
''' </returns> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Public Overrides Function EditValue(ByVal context As ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value As Object) As Object | ||
|
||
Using dlg As New OpenFileOrFolderDialog() With { | ||
.Title = "Select a file or folder...", | ||
.AutoUpgradeEnabled = True, | ||
.DereferenceLinks = True, | ||
.RestoreDirectory = True, | ||
.ShowHelp = False | ||
} | ||
|
||
If (dlg.ShowDialog = DialogResult.OK) Then | ||
Return dlg.ItemName | ||
End If | ||
End Using | ||
|
||
Return MyBase.EditValue(context, provider, value) | ||
|
||
End Function | ||
|
||
#End Region | ||
|
||
End Class | ||
|
||
End Namespace | ||
|
||
#End Region |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
' 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 " Usage Examples " | ||
|
||
'<TypeConverter(GetType(FileSizeConverter))> | ||
'<Browsable(True)> | ||
'Public ReadOnly Property FileSize As Long = 2048 ' Bytes | ||
|
||
'<TypeConverter(GetType(FileSizeConverter))> | ||
'<Browsable(True)> | ||
'Public ReadOnly Property FileSize As New Filesize(2048, SizeUnits.Byte) | ||
|
||
#End Region | ||
|
||
#Region " Option Statements " | ||
|
||
Option Strict On | ||
Option Explicit On | ||
Option Infer Off | ||
|
||
#End Region | ||
|
||
#Region " Imports " | ||
|
||
Imports System.ComponentModel | ||
Imports System.ComponentModel.Design.Serialization | ||
Imports System.Globalization | ||
|
||
Imports DevCase.Core.IO | ||
|
||
#End Region | ||
|
||
#Region " FileSizeConverter " | ||
|
||
Namespace DevCase.Core.Design | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' 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. | ||
''' <para></para> | ||
''' Conversion examples: | ||
''' <para></para> | ||
''' Input value -> Result string | ||
''' <para></para> | ||
''' 793 -> 793 Bytes | ||
''' <para></para> | ||
''' 1533 -> 1,49 KB | ||
''' <para></para> | ||
''' 2049 -> 2,00 KB | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <example> This is a code example. | ||
''' <code> | ||
''' <TypeConverter(GetType(FileSizeConverter))> | ||
''' <Browsable(True)> | ||
''' Public ReadOnly Property FileSize As Long = 2048 ' Bytes | ||
''' | ||
''' <TypeConverter(GetType(FileSizeConverter))> | ||
''' <Browsable(True)> | ||
''' Public ReadOnly Property FileSize As New Filesize(2048, SizeUnits.Byte) | ||
''' </code> | ||
''' </example> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Friend Class FileSizeConverter : Inherits TypeConverter | ||
|
||
#Region " Constructors " | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Initializes a new instance of the <see cref="FileSizeConverter"/> class. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Public Sub New() | ||
MyBase.New() | ||
End Sub | ||
|
||
#End Region | ||
|
||
#Region " Public Methods " | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Determines if this converter can convert an object in the given source type to the native type of the converter. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <param name="context"> | ||
''' An <see cref="ITypeDescriptorContext" /> that provides a format context. | ||
''' </param> | ||
''' | ||
''' <param name="sourceType"> | ||
''' A <see cref="Type" /> that represents the type from which you want to convert. | ||
''' </param> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <returns> | ||
''' <see langword="true" /> if this converter can perform the operation; otherwise, <see langword="false" />. | ||
''' </returns> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Public Overrides Function CanConvertFrom(ByVal context As ITypeDescriptorContext, ByVal sourceType As Type) As Boolean | ||
|
||
Return False | ||
|
||
End Function | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Returns whether this converter can convert the object to the specified type, using the specified context. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <param name="context"> | ||
''' An <see cref="ITypeDescriptorContext"/> that provides a format context. | ||
''' </param> | ||
''' | ||
''' <param name="destinationType"> | ||
''' A <see cref="Type"/> that represents the type you want to convert to. | ||
''' </param> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <returns> | ||
''' <see langword="True"/> if this converter can perform the conversion; otherwise, <see langword="False"/>. | ||
''' </returns> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Public Overloads Overrides Function CanConvertTo(ByVal context As ITypeDescriptorContext, ByVal destinationType As Type) As Boolean | ||
|
||
If (destinationType = GetType(InstanceDescriptor)) Then | ||
Return True | ||
End If | ||
|
||
Return MyBase.CanConvertTo(context, destinationType) | ||
|
||
End Function | ||
|
||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <summary> | ||
''' Converts the specified object to another type. | ||
''' </summary> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <param name="context"> | ||
''' An <see cref="ITypeDescriptorContext"/> that provides a format context. | ||
''' </param> | ||
''' | ||
''' <param name="culture"> | ||
''' A <see cref="CultureInfo"/> that specifies the culture to represent the number. | ||
''' </param> | ||
''' | ||
''' <param name="value"> | ||
''' The object to convert. | ||
''' </param> | ||
''' | ||
''' <param name="destinationType"> | ||
''' The type to convert the object to. | ||
''' </param> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
''' <returns> | ||
''' An <see cref="Object"/> that represents the converted value. | ||
''' </returns> | ||
''' ---------------------------------------------------------------------------------------------------- | ||
Public Overrides Function ConvertTo(ByVal context As ITypeDescriptorContext, ByVal culture As CultureInfo, ByVal value As Object, ByVal destinationType As Type) As Object | ||
|
||
If (destinationType Is Nothing) Then | ||
Throw New ArgumentNullException("destinationType") | ||
End If | ||
|
||
If (destinationType Is GetType(String)) Then | ||
If (TypeOf value Is Filesize) Then | ||
Return DirectCast(value, Filesize).ToString() | ||
End If | ||
|
||
Return New Filesize(CType(value, Double), SizeUnits.Byte).ToString() | ||
End If | ||
|
||
Return MyBase.ConvertTo(context, culture, value, destinationType) | ||
|
||
End Function | ||
|
||
#End Region | ||
|
||
End Class | ||
|
||
End Namespace | ||
|
||
#End Region |
Oops, something went wrong.