f365dee1c7
- Asterisco in fase di modifica; - salvataggio in caso di cambio porta solo se presente asterisco; - asterisco in fase di creazione nuova porta.
91 lines
2.9 KiB
VB.net
91 lines
2.9 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.Globalization
|
|
Imports EgtUILib
|
|
|
|
Public Module Utility
|
|
|
|
Friend Function DoubleToString(ByVal dVal As Double, ByVal nNumDec As Integer) As String
|
|
Dim sFormat As String = "F" + Math.Abs(nNumDec).ToString()
|
|
Dim sVal As String = dVal.ToString(sFormat, CultureInfo.InvariantCulture)
|
|
If nNumDec > 0 Then
|
|
Return sVal.TrimEnd("0".ToCharArray()).TrimEnd(".".ToCharArray)
|
|
Else
|
|
Return sVal
|
|
End If
|
|
End Function
|
|
|
|
Friend Function StringToDouble(ByVal sVal As String, ByRef dVal As Double) As Boolean
|
|
Return EgtLuaEvalNumExpr(sVal, dVal)
|
|
End Function
|
|
|
|
Friend Function LenToString(ByVal dVal As Double, ByVal nNumDec As Integer) As String
|
|
Return DoubleToString(EgtToUiUnits(dVal), nNumDec)
|
|
End Function
|
|
|
|
Friend Function StringToLen(ByVal sVal As String, ByRef dVal As Double) As Boolean
|
|
If EgtLuaEvalNumExpr(sVal, dVal) Then
|
|
dVal = EgtFromUiUnits(dVal)
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
'Converte il valore Boolean in una stringa ON/OFF (attributo machining)
|
|
Public Function ConvertBooleanToOnOff(bValue As Boolean) As String
|
|
If bValue Then
|
|
Return K_ON
|
|
Else
|
|
Return K_OFF
|
|
End If
|
|
End Function
|
|
|
|
' converto una stringa in boolean
|
|
Public Function ConvertOnOffToBoolean(sItem As String) As Boolean
|
|
If sItem = K_ON Then
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Friend Sub UpdateUI()
|
|
' Costringo ad aggiornare UI
|
|
Dim nDummy As Integer
|
|
Application.Current.Dispatcher.Invoke(Windows.Threading.DispatcherPriority.Background, _
|
|
New Action(Function() nDummy = 0))
|
|
End Sub
|
|
|
|
Friend Function ReadMsg(sValue As String) As String
|
|
' se numerico
|
|
If IsNumeric(sValue) Then
|
|
' ritorno il messaggio associato
|
|
Return EgtMsg(CInt(sValue))
|
|
Else
|
|
' altrimenti ritorno il nome ricevuto
|
|
Return sValue
|
|
End If
|
|
End Function
|
|
|
|
Friend Sub ClearObservableCollection(Of T)(Ob As ObservableCollection(Of T))
|
|
For Index = Ob.Count - 1 To 0 Step -1
|
|
Ob.RemoveAt(Index)
|
|
Next
|
|
End Sub
|
|
|
|
End Module
|
|
|
|
Public Class SplitConverter
|
|
Implements IValueConverter
|
|
|
|
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
|
|
Dim dValue As Double = CDbl(value)
|
|
Dim nParam As Integer = CInt(parameter)
|
|
Return dValue / nParam
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
End Class |