b325b8470c
- dati TRF non più richiesti per default sui componenti - aggiunta gestione cambio progetto visualizzato in OmagVIEW.
192 lines
7.0 KiB
VB.net
192 lines
7.0 KiB
VB.net
Imports System.Globalization
|
|
Imports EgtUILib
|
|
|
|
Module Utility
|
|
|
|
'--------------------------------------------------------------------------------------------------
|
|
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 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
|
|
If String.IsNullOrEmpty(sVal) Then Return False
|
|
Return EgtLuaEvalNumExpr(sVal, dVal)
|
|
End Function
|
|
|
|
Friend Function StringToInt(sVal As String, ByRef nVal As Integer) As Boolean
|
|
Dim dVal As Double = 0
|
|
If Not StringToDouble(sVal, dVal) Then Return False
|
|
nVal = CInt(Math.Round(dVal))
|
|
Return True
|
|
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 String.IsNullOrEmpty(sVal) Then Return False
|
|
If EgtLuaEvalNumExpr(sVal, dVal) Then
|
|
dVal = EgtFromUiUnits(dVal)
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Friend Function UIExprToExpr(ByVal sUIExpr As String) As String
|
|
If String.IsNullOrWhiteSpace(sUIExpr) Then
|
|
Return ""
|
|
End If
|
|
Return sUIExpr.Replace("""", "*GEO.ONE_INCH")
|
|
End Function
|
|
|
|
Friend Function ExprToUIExpr(ByVal sExpr As String) As String
|
|
If String.IsNullOrWhiteSpace(sExpr) Then
|
|
Return ""
|
|
End If
|
|
Return sExpr.Replace("*GEO.ONE_INCH", """")
|
|
End Function
|
|
|
|
Friend Function DistToString(vtDist As Vector3d) As String
|
|
Dim nDec As Integer = If(EgtUiUnitsAreMM(), 1, 2)
|
|
Dim sDistance As String = EgtMsg(1301) 'Dist=
|
|
sDistance &= LenToString(vtDist.Len(), nDec) & vbCrLf
|
|
sDistance &= " dX=" & LenToString(vtDist.x, nDec)
|
|
sDistance &= " dY=" & LenToString(vtDist.y, nDec)
|
|
sDistance &= " dZ=" & LenToString(vtDist.z, nDec)
|
|
Return sDistance
|
|
End Function
|
|
|
|
'--------------------------------------------------------------------------------------------------
|
|
Friend Function GetValueWithKey(sString As String, sKey As String) As String
|
|
If String.IsNullOrWhiteSpace(sString) Then Return ""
|
|
Dim sPurged As String = sString.Trim()
|
|
Dim nPos As Integer = sPurged.IndexOf("="c)
|
|
If nPos < 0 Then Return ""
|
|
If String.Compare(sPurged.Substring(0, nPos), sKey, True) = 0 Then Return sPurged.Substring(nPos + 1)
|
|
Return ""
|
|
End Function
|
|
|
|
'--------------------------------------------------------------------------------------------------
|
|
Friend Sub HideParkedParts(Optional bDisableModified As Boolean = True)
|
|
' Se richiesto, disabilito impostazione modificato
|
|
Dim bOldEnMod As Boolean = False
|
|
If bDisableModified Then
|
|
bOldEnMod = EgtGetEnableModified()
|
|
If bOldEnMod Then EgtDisableModified()
|
|
End If
|
|
' Nascondo pezzi parcheggiati
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
EgtSetStatus(nPartId, GDB_ST.OFF)
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
' Se necessario, ripristino precedente impostazione modificato
|
|
If bOldEnMod Then EgtEnableModified()
|
|
End Sub
|
|
|
|
Friend Sub ShowParkedParts(Optional bDisableModified As Boolean = True)
|
|
' Se richiesto, disabilito impostazione modificato
|
|
Dim bOldEnMod As Boolean = False
|
|
If bDisableModified Then
|
|
bOldEnMod = EgtGetEnableModified()
|
|
If bOldEnMod Then EgtDisableModified()
|
|
End If
|
|
' Visualizzo pezzi parcheggiati
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
EgtSetStatus(nPartId, GDB_ST.ON_)
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
' Se necessario, ripristino precedente impostazione modificato
|
|
If bOldEnMod Then EgtEnableModified()
|
|
End Sub
|
|
|
|
Friend Function AdjustFlatPart(nPartId As Integer) As Boolean
|
|
' Ciclo sui layer
|
|
Dim nLayerId As Integer = EgtGetFirstLayer(nPartId)
|
|
While nLayerId <> GDB_ID.NULL
|
|
' Recupero il layer successivo
|
|
Dim nNextLayerId As Integer = EgtGetNextLayer(nLayerId)
|
|
' Recupero il nome del layer
|
|
Dim sLayName As String = String.Empty
|
|
If EgtGetName(nLayerId, sLayName) Then
|
|
' Se layer OutLoop o InLoop
|
|
If String.Compare(sLayName, NAME_OUTLOOP, True) = 0 Or
|
|
String.Compare(sLayName, NAME_INLOOP, True) = 0 Then
|
|
' Sistemo i layer per applicare facilmente le lavorazioni
|
|
EgtAdjustFlatPartLayer(nLayerId)
|
|
End If
|
|
' Se senza nome, lo elimino
|
|
Else
|
|
EgtErase(nLayerId)
|
|
End If
|
|
' Passo al layer successivo
|
|
nLayerId = nNextLayerId
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
'--------------------------------------------------------------------------------------------------
|
|
Public Class Language
|
|
|
|
Private m_sLanguageName As String
|
|
Private m_sFileName As String
|
|
|
|
Public Property LanguageName As String
|
|
Get
|
|
Return m_sLanguageName
|
|
End Get
|
|
Set(value As String)
|
|
m_sLanguageName = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property FileName As String
|
|
Get
|
|
Return m_sFileName
|
|
End Get
|
|
Set(value As String)
|
|
m_sFileName = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(LanguageName As String, FileName As String)
|
|
Me.LanguageName = LanguageName
|
|
Me.FileName = FileName
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Function GetPrivateProfileLanguage(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByVal lpFileName As String) As Language
|
|
|
|
Dim sVal As String = String.Empty
|
|
GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
If sItems.Count() = 2 Then
|
|
Return New Language(sItems(0), sItems(1))
|
|
End If
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
End Module
|