TaskFlow/app/DD_PM_WINDREAM/ModuleFinalIndexProperties.vb
2019-04-25 13:38:07 +02:00

164 lines
5.9 KiB
VB.net

Imports System.ComponentModel
Imports System.Drawing.Design
Imports System.Globalization
Imports FormsUtils
Module ModuleFinalIndexProperties
<TypeConverter(GetType(PropertiesDeluxeTypeConverter))>
Public Class FinalIndexProperties
<Category("Information")>
<[ReadOnly](True)>
Public Property GUID As Integer
<Category("Information")>
<[ReadOnly](True)>
Public Property ConnectionId As Integer
<Category("Sonstiges")>
Public Property Description As String
<Category("Sonstiges")>
Public Property Active As Boolean
''' <summary>
''' Eigenschaft, die den SQL Editor anzeigt
''' </summary>
<Category("Daten - SQL")>
Public Property SQLCommand As SQLValue
' Eigenschaften für die verschiedenen Index-Typen
<DisplayName("Value")>
<Category("Daten - Fester Wert")>
<PropertyAttributesProvider("IndexTypeStringProvider")>
Public Property StringValue As String
<DisplayName("Value")>
<Category("Daten - Fester Wert")>
<PropertyAttributesProvider("IndexTypeBooleanProvider")>
Public Property BoolValue As Boolean
<DisplayName("Value")>
<Category("Daten - Fester Wert")>
<PropertyAttributesProvider("IndexTypeFloatProvider")>
Public Property FloatValue As Double
<DisplayName("Value")>
<Category("Daten - Fester Wert")>
<PropertyAttributesProvider("IndexTypeDateProvider")>
Public Property DateValue As Date
<DisplayName("Value")>
<Category("Daten - Fester Wert")>
<PropertyAttributesProvider("IndexTypeIntegerProvider")>
Public Property IntegerValue As Integer
<Category("Index")>
<TypeConverter(GetType(IndexListConverter))>
Public Property IndexName As String
<Category("Index")>
<[ReadOnly](True)>
Public Property VectorIndex As Boolean
<Category("Index")>
<DisplayName("Allow Multivalues")>
<PropertyAttributesProvider("VectorIndexBooleanProvider")>
Public Property AllowAddNewValues As Boolean
<Category("Index")>
<PropertyAttributesProvider("VectorIndexBooleanProvider")>
Public Property PreventDuplicates As Boolean
' Eigenschaften für die Liste der Indicies
<Browsable(False)>
Public Property Indicies As List(Of String)
<Browsable(False)>
Public Property IndiciesType As List(Of Integer)
Public Sub VectorIndexBooleanProvider(attrs As PropertyAttributes)
MaybeSetReadOnlyIfNotVectorIndex(attrs)
End Sub
Public Sub IndexTypeBooleanProvider(attrs As PropertyAttributes)
MaybeSetBrowsable(attrs, {ClassFinalIndex.INDEX_TYPE_BOOLEAN, ClassFinalIndex.INDEX_TYPE_VECTOR_BOOLEAN})
MaybeSetReadOnlyIfSQLHasNoValue(attrs)
End Sub
Public Sub IndexTypeStringProvider(attrs As PropertyAttributes)
MaybeSetBrowsable(attrs, {ClassFinalIndex.INDEX_TYPE_STRING, ClassFinalIndex.INDEX_TYPE_VECTOR_STRING})
MaybeSetReadOnlyIfSQLHasNoValue(attrs)
End Sub
Public Sub IndexTypeFloatProvider(attrs As PropertyAttributes)
MaybeSetBrowsable(attrs, {ClassFinalIndex.INDEX_TYPE_FLOAT})
MaybeSetReadOnlyIfSQLHasNoValue(attrs)
End Sub
Public Sub IndexTypeIntegerProvider(attrs As PropertyAttributes)
MaybeSetBrowsable(attrs, {ClassFinalIndex.INDEX_TYPE_INTEGER, ClassFinalIndex.INDEX_TYPE_VECTOR_INTEGER_64})
MaybeSetReadOnlyIfSQLHasNoValue(attrs)
End Sub
Public Sub IndexTypeDateProvider(attrs As PropertyAttributes)
MaybeSetBrowsable(attrs, {ClassFinalIndex.INDEX_TYPE_DATE, ClassFinalIndex.INDEX_TYPE_VECTOR_DATE})
MaybeSetReadOnlyIfSQLHasNoValue(attrs)
End Sub
Public Sub MaybeSetReadOnlyIfSQLHasNoValue(attrs As PropertyAttributes)
Dim hasSQLValue As Boolean = (SQLCommand.Value <> String.Empty)
If hasSQLValue Then
attrs.IsReadOnly = True
Else
attrs.IsReadOnly = False
End If
End Sub
Public Sub MaybeSetReadOnlyIfNotVectorIndex(attrs As PropertyAttributes)
' Get index (position in array) for selected index (windream)
Dim oIndex As Integer = Indicies.IndexOf(IndexName)
If oIndex < 0 Then
attrs.IsReadOnly = True
Exit Sub
End If
' get type of windream index
Dim oType As Integer = IndiciesType.Item(oIndex)
Dim oVectoryTypes = {
ClassFinalIndex.INDEX_TYPE_VECTOR_DATE,
ClassFinalIndex.INDEX_TYPE_VECTOR_BOOLEAN,
ClassFinalIndex.INDEX_TYPE_VECTOR_INTEGER_64,
ClassFinalIndex.INDEX_TYPE_VECTOR_INTEGER,
ClassFinalIndex.INDEX_TYPE_VECTOR_STRING,
ClassFinalIndex.INDEX_TYPE_VECTOR_CURRENCY,
ClassFinalIndex.INDEX_TYPE_VECTOR_FLOAT,
ClassFinalIndex.INDEX_TYPE_VECTOR_DATETIME
}
' if type of index is not a vector, set attribute to read only
If oVectoryTypes.Contains(oType) Then
attrs.IsReadOnly = False
Else
attrs.IsReadOnly = True
End If
End Sub
Public Sub MaybeSetBrowsable(attrs As PropertyAttributes, indexType As Integer())
Dim i As Integer = Indicies.IndexOf(IndexName)
' IndexName wurde nicth gefunden oder ist leerer/ungültiger String
If i < 0 Then
attrs.IsBrowsable = False
Exit Sub
End If
Dim type As Integer = IndiciesType.Item(i)
If indexType.Contains(type) Then
attrs.IsBrowsable = True
Else
attrs.IsBrowsable = False
End If
End Sub
End Class
End Module