Files
egtstone3d/ScriptWindow/ScriptWindowV.xaml.vb
T
Demetrio Cassarino f3bd024f29 -aggiunto controllo tempo per apertura script
-pulizia codice
-aggiunto apertura più file lua
2025-03-03 10:00:50 +01:00

80 lines
3.0 KiB
VB.net

Imports System.Windows.Threading
Public Class ScriptWindowV
#Region "CONSTRUCTOR"
Sub New()
' La chiamata è richiesta dalla finestra di progettazione.
InitializeComponent()
' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent().
Map.SetRefScriptWindowV(Me)
End Sub
#End Region ' Constructor
#Region "EVENTS"
Private Sub EgtMainWindow_PreviewKeyDown(sender As Object, e As KeyEventArgs)
If e.Key = Key.Escape Then
Annulla.IsCancel = True
End If
End Sub
Private Sub sNameFile_RichTxBx_TextChanged(sender As Object, e As TextChangedEventArgs)
'Try
' If Not IsNothing(Map.refScriptWindowVM) Then Map.refScriptWindowVM.SyntaxHighlighting(sNameFile_RichTxBx)
'Catch ex As Exception
'End Try
If Not IsNothing(Map.refScriptWindowVM) AndAlso Map.refScriptWindowVM.textChangedTimer Is Nothing Then
Map.refScriptWindowVM.textChangedTimer = New DispatcherTimer()
Map.refScriptWindowVM.textChangedTimer.Interval = TimeSpan.FromMilliseconds(500)
AddHandler Map.refScriptWindowVM.textChangedTimer.Tick, AddressOf OnTextChangedTimerTick
End If
If Not IsNothing(Map.refScriptWindowVM) Then
Map.refScriptWindowVM.textChangedTimer.Stop()
Map.refScriptWindowVM.textChangedTimer.Start()
End If
End Sub
Private Sub sNameFile_RichTxBx_SelectionChanged(sender As Object, e As RoutedEventArgs)
If Not IsNothing(Map.refScriptWindowVM) Then Map.refScriptWindowVM.SetToolbar()
End Sub
Private Sub sNameFile_RichTxBx_PreviewKeyDown(sender As Object, e As KeyEventArgs)
If e.Key = Key.Enter Then
Map.refScriptWindowVM.InsertText(sNameFile_RichTxBx, vbCrLf)
e.Handled = True
ElseIf e.Key = Key.Tab Then
e.Handled = True
' Ottieni la posizione corrente del cursore
Dim caretPosition As TextPointer = sNameFile_RichTxBx.CaretPosition
' Inserisci un carattere di tabulazione (3 spazi)
Dim tabString As String = " "
Dim run As New Run(tabString)
Dim textRange As New TextRange(caretPosition, caretPosition)
textRange.Text = tabString
' Aggiorna la posizione del cursore
sNameFile_RichTxBx.CaretPosition = textRange.End
End If
End Sub
Private Sub sNameFile_RichTxBx_PreviewMouseWheel(sender As Object, e As MouseWheelEventArgs)
' Ottieni il numero di righe da scorrere
Dim linesToScroll As Integer = e.Delta / 5
' Scorri il contenuto della RichTextBox
sNameFile_RichTxBx.ScrollToVerticalOffset(sNameFile_RichTxBx.VerticalOffset - linesToScroll)
End Sub
Private Sub OnTextChangedTimerTick(sender As Object, e As EventArgs)
Map.refScriptWindowVM.textChangedTimer.Stop()
If Not IsNothing(Map.refScriptWindowVM) Then Map.refScriptWindowVM.SyntaxHighlighting(sNameFile_RichTxBx)
Map.refScriptWindowVM.ProcessTextChanges()
End Sub
#End Region ' Events
End Class