Files
EgtWPFLib5/Utility/Utility.vb
T
Dario Sassi 00a338c202 Revert "Merge commit 'f1aae48a2b80f96ae94b59a69addd6cc6e48ee14'"
This reverts commit 1f49d0936e, reversing
changes made to 236eeac038.
2025-03-21 19:21:02 +01:00

47 lines
2.0 KiB
VB.net

Public Module Utility
Friend EgaltechBlue1 As New SolidColorBrush(Color.FromArgb(255, 77, 132, 196))
Friend EgaltechGreen As New SolidColorBrush(Color.FromArgb(255, 0, 255, 0))
Friend EgaltechRed As New SolidColorBrush(Color.FromArgb(255, 255, 0, 0))
Friend EgaltechYellow As New SolidColorBrush(Color.FromArgb(255, 255, 255, 0))
' Funzione che permette di trovare il primo contenitore di tipo T di un elemento grafico dependencyObject
Public Function FindAncestor(Of T As Class)(dependencyObject As DependencyObject) As T
Dim target As DependencyObject = dependencyObject
Do
target = LogicalTreeHelper.GetParent(target)
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
If IsNothing(target) Then
target = dependencyObject
Do
target = VisualTreeHelper.GetParent(target)
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
End If
Return TryCast(target, T)
End Function
' Funzione che permette di trovare il primo contenitore di tipo T di un elemento grafico dependencyObject
'Public Function FindChild(Of T As Class)(dependencyObject As DependencyObject) As T
' Dim target As DependencyObject = dependencyObject
' Do
' target = DirectCast(LogicalTreeHelper.GetChildren(target), DependencyObject)
' Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
' Return TryCast(target, T)
'End Function
Public 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 IsUUID(UUID As String) As Boolean
Dim result As Guid
Return Guid.TryParse(UUID, result)
End Function
Friend Const ToolDrawUUIDName As String = "*AUTOMATIC*"
End Module