@@ -15,6 +15,7 @@ Imports PersonalUtilities.Forms
1515Imports PersonalUtilities.Functions.XML
1616Imports PersonalUtilities.Functions.XML.Base
1717Imports PersonalUtilities.Functions.XML.Objects
18+ Imports PersonalUtilities.Functions.XML.Attributes
1819Imports PersonalUtilities.Functions.XML.Attributes.Specialized
1920Imports PersonalUtilities.Tools
2021Imports PersonalUtilities.Tools.Grid.Base
@@ -275,6 +276,71 @@ Namespace API.YouTube.Base
275276 <Browsable( True ), GridVisible, XMLVN({ "DefaultsVideo" }), Category( "Defaults Video" ), DisplayName( "Include zero size formats" ),
276277 Description( "Include formats with zero size (or undefined size)." )>
277278 Public ReadOnly Property DefaultVideoIncludeNullSize As XMLValue( Of Boolean )
279+ <Browsable( False ), XMLV( "DefaultVideoFPS" , { "DefaultsVideo" }, - 1 )>
280+ Private ReadOnly Property DefaultVideoFPS_XML As XMLValue( Of Double )
281+ <Browsable( True ), GridVisible, Category( "Defaults Video" ), DisplayName( "Defaults Video FPS" ),
282+ Description( "Set default video FPS (only to reduce video FPS). Default: -1 (disabled)." ),
283+ TypeConverter( GetType (FieldsTypeConverter)), GridFormatProvider( GetType (FpsFormatProvider))>
284+ Public Property DefaultVideoFPS As Double
285+ Get
286+ Return DefaultVideoFPS_XML
287+ End Get
288+ Set ( ByVal fps As Double )
289+ DefaultVideoFPS_XML.Value = fps
290+ End Set
291+ End Property
292+ Private Function ShouldSerializeDefaultVideoFPS() As Boolean
293+ Return DefaultVideoFPS <> DefaultVideoFPS_XML.Value
294+ End Function
295+ Private Sub ResetDefaultVideoFPS()
296+ DefaultVideoFPS = - 1
297+ End Sub
298+ Friend Class FpsFormatProvider : Implements IGridConversionProvider
299+ Private Property Converter As TypeConverter Implements IGridConversionProvider.Converter
300+ Private Property Context As ITypeDescriptorContext Implements IGridConversionProvider.Context
301+ Private Property DataType As Type Implements IGridConversionProvider.DataType
302+ Private Property Instance As Object Implements IGridConversionProvider.Instance
303+ Friend Shared ReadOnly Property MyProviderDefault As ANumbers
304+ Get
305+ Return New ANumbers(ANumbers.Cultures.Primitive) With {.DecimalDigits = 5 , .TrimDecimalDigits = True }
306+ End Get
307+ End Property
308+ Friend Const ErrorMessageDefault As String = "The fps value must be a number"
309+ Private ReadOnly MyProvider As ANumbers = MyProviderDefault
310+ Friend Function ToObject( ByVal Context As ITypeDescriptorContext, ByVal Culture As CultureInfo, ByVal Value As Object ) As Object Implements IGridConversionProvider.ToObject
311+ Return AConvert( Of Double )(Value, MyProvider, - 1 )
312+ End Function
313+ Friend Overloads Function ToString( ByVal Context As ITypeDescriptorContext, ByVal Culture As CultureInfo, ByVal Value As Object ,
314+ ByVal DestinationType As Type) As Object Implements IGridConversionProvider.ToString
315+ If ACheck( Of Double )(Value, AModes.Var, MyProvider) Then
316+ Return Value.ToString
317+ Else
318+ Return - 1
319+ End If
320+ End Function
321+ Friend Function CreateInstance( ByVal Context As ITypeDescriptorContext, ByVal NewValue As Object , ByRef RefreshGrid As Boolean ) As Object Implements IGridConversionProvider.CreateInstance
322+ If ACheck( Of Double )(NewValue, AModes.Var, MyProvider) Then
323+ Return NewValue
324+ Else
325+ RefreshGrid = True
326+ Return - 1
327+ End If
328+ End Function
329+ Friend Function Convert( ByVal Value As Object , ByVal DestinationType As Type, ByVal Provider As IFormatProvider,
330+ Optional ByVal NothingArg As Object = Nothing , Optional ByVal e As ErrorsDescriber = Nothing ) As Object Implements ICustomProvider.Convert
331+ Return AConvert(Value, AModes.Var, DestinationType,, True , - 1 , MyProvider, EDP.ReturnValue)
332+ End Function
333+ Friend Function IsValid( ByVal Context As ITypeDescriptorContext, ByVal Value As Object , ByVal DestinationType As Type) As Boolean Implements IGridValidator.IsValid
334+ If ACheck( Of Double )(Value, AModes.Var, MyProvider) Then
335+ Return True
336+ Else
337+ Throw New FormatException(ErrorMessageDefault)
338+ End If
339+ End Function
340+ Private Function GetFormat( ByVal FormatType As Type) As Object Implements IFormatProvider.GetFormat
341+ Throw New NotImplementedException( "'GetFormat' is not available in 'FpsFormatProvider'" )
342+ End Function
343+ End Class
278344# End Region
279345# Region "Defaults Audio"
280346 <Browsable( True ), GridVisible, XMLVN({ "DefaultsAudio" }, "AAC" ), Category( "Defaults Audio" ), DisplayName( "Default codec" ),
0 commit comments