0bb65431a7
-rinominato file colonne -aggiunto controllo su creazione dimensione finestra
63 lines
2.5 KiB
VB.net
63 lines
2.5 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.Windows
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Module DimensionsIniFile
|
|
|
|
Public m_sDimensionsIniFile As String
|
|
|
|
Public Sub ReadGridDimensions(GridName As String, ByRef GridDimsList As ObservableCollection(Of GridDimension))
|
|
GridDimsList = New ObservableCollection(Of GridDimension)
|
|
Dim Index As Integer = 0
|
|
Dim sValue = String.Empty
|
|
While GetPrivateProfileString(GridName, Index, String.Empty, sValue, m_sDimensionsIniFile) > 0
|
|
Dim sValueParams() As String = sValue.Split(","c)
|
|
' verifico numero minimo di parametri
|
|
If sValueParams.Count >= 4 Then
|
|
' cancello spazi
|
|
For I = 0 To sValueParams.Count - 1
|
|
sValueParams(I) = sValueParams(I).Trim()
|
|
Next
|
|
' creo valore
|
|
Dim nDimIndex As Integer
|
|
Dim nDimType As DimensionType
|
|
Dim GridLenValue As Double
|
|
Dim GridLenType As GridUnitType
|
|
Integer.TryParse(sValueParams(0), nDimIndex)
|
|
Integer.TryParse(sValueParams(1), nDimType)
|
|
StringToDoubleAdv(sValueParams(2), GridLenValue)
|
|
Integer.TryParse(sValueParams(3), GridLenType)
|
|
GridDimsList.Add(New GridDimension(GridName, nDimIndex, nDimType, New GridLength(GridLenValue, GridLenType)))
|
|
End If
|
|
Index += 1
|
|
End While
|
|
If GridDimsList.Count = 0 Then
|
|
For Ind As Integer = 0 To 4
|
|
GridDimsList.Add(New GridDimension(GridName, Ind, 0, New GridLength(1, GridUnitType.Star)))
|
|
Next
|
|
End If
|
|
For Each GridDimsItem In GridDimsList
|
|
GridDimsItem.GridDimensions = GridDimsList
|
|
Next
|
|
End Sub
|
|
|
|
' funzione per calcolare e scrivere la stringa dei valori delle righe/colonne della Grid nell'INI
|
|
Public Function SaveGridDimensions(GridName As String, GridDims As ObservableCollection(Of GridDimension)) As Boolean
|
|
Dim bOk As Boolean
|
|
Dim Index = 0
|
|
Dim sValue = String.Empty
|
|
For Each GridDimsItem In GridDims
|
|
sValue = GridDimsItem.Index & "," & GridDimsItem.DimType & "," & DoubleToString(GridDimsItem.GridLen.Value, 6) & "," & GridDimsItem.GridLen.GridUnitType
|
|
bOk = WritePrivateProfileDimension(GridName, Index, sValue)
|
|
Index += 1
|
|
Next
|
|
Return bOk
|
|
End Function
|
|
|
|
Public Function WritePrivateProfileDimension(GridName As String, Index As String, sValue As String) As Boolean
|
|
Return WritePrivateProfileString(GridName, Index, sValue, m_sDimensionsIniFile)
|
|
End Function
|
|
|
|
End Module
|