-aggiunto svg per script

-sistemato dizionario
-sistemato rimozione del testo su invio
This commit is contained in:
Demetrio Cassarino
2025-02-19 16:52:54 +01:00
parent 93e1651af4
commit 862ee938c3
6 changed files with 85 additions and 13 deletions
+10 -7
View File
@@ -75,21 +75,22 @@
<ToggleButton Command="EditingCommands.AlignLeft"
CommandTarget="{Binding ElementName=sNameFile_RichTxBx}"
IsChecked="{Binding LeftIsChecked}" Height="25" Width="20" BorderThickness="0" Margin="0"
Style="{StaticResource General_ToogleButton}">
IsChecked="{Binding LeftIsChecked}"
Style="{StaticResource ScriptToggleButton}">
<EgtStone3D:SVGV FileSource="{Binding FileAlignLeftSVG, UpdateSourceTrigger=PropertyChanged}"/>
</ToggleButton>
<ToggleButton Command="EditingCommands.AlignCenter"
CommandTarget="{Binding ElementName=sNameFile_RichTxBx}"
IsChecked="{Binding CenterIsChecked}" Height="25" Width="20" BorderThickness="0" Margin="2,0,0,0"
Style="{StaticResource General_ToogleButton}">
IsChecked="{Binding CenterIsChecked}"
Style="{StaticResource ScriptToggleButton1}">
<EgtStone3D:SVGV FileSource="{Binding FileAlignCenterSVG, UpdateSourceTrigger=PropertyChanged}"/>
</ToggleButton>
<ToggleButton Content="J"
Command="EditingCommands.AlignJustify"
<ToggleButton Command="EditingCommands.AlignJustify"
CommandTarget="{Binding ElementName=sNameFile_RichTxBx}"
IsChecked="{Binding JustifyIsChecked}"
Style="{StaticResource General_ToogleButton}"/>
Style="{StaticResource ScriptToggleButton1}">
<EgtStone3D:SVGV FileSource="{Binding FileAlignJustifySVG, UpdateSourceTrigger=PropertyChanged}"/>
</ToggleButton>
<Separator Style="{StaticResource Script_Separator}"/>
@@ -112,6 +113,8 @@
Style="{StaticResource Script_TxBx}"/>-->
<RichTextBox Grid.Row="2"
Name="sNameFile_RichTxBx"
TextChanged="sNameFile_RichTxBx_TextChanged"
PreviewKeyDown="sNameFile_RichTxBx_PreviewKeyDown"
Style="{StaticResource Script_RichTxBx}">
<FlowDocument Name="FDocumentFile">
<Paragraph>
+11 -2
View File
@@ -1,4 +1,6 @@
Public Class ScriptWindowV
Imports System.Text.RegularExpressions
Public Class ScriptWindowV
#Region "CONSTRUCTOR"
@@ -22,13 +24,20 @@
End Sub
Private Sub sNameFile_RichTxBx_TextChanged(sender As Object, e As TextChangedEventArgs)
If Not IsNothing(Map.refScriptWindowVM) Then Map.refScriptWindowVM.m_bTextHasChanged = True
sNameFile_RichTxBx.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Purple)
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
End If
End Sub
#End Region ' Events
End Class
+32 -1
View File
@@ -2,6 +2,7 @@
Imports EgtWPFLib5
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Public Class ScriptWindowVM
Inherits VMBase
@@ -27,7 +28,6 @@ Public Class ScriptWindowVM
Return m_sRichTextParagraph
End Get
Set(value As String)
'm_sRichTextParagraph = StringFromRichTextBox(Map.refScriptWindowV.sNameFile_RichTxBx)
m_sRichTextParagraph = value
NotifyPropertyChanged(NameOf(sRichTextParagraph))
End Set
@@ -201,6 +201,20 @@ Public Class ScriptWindowVM
NotifyPropertyChanged(NameOf(FileAlignCenterSVG))
End Sub
Private m_FileAlignJustifySVG As String = String.Empty
Public Property FileAlignJustifySVG As String
Get
Return m_FileAlignJustifySVG
End Get
Set(value As String)
m_FileAlignJustifySVG = value
NotifyPropertyChanged(NameOf(FileAlignJustifySVG))
End Set
End Property
Friend Sub SetFileAlignJustifySVG(sFileAlignJustifySVG As String)
m_FileAlignJustifySVG = sFileAlignJustifySVG
NotifyPropertyChanged(NameOf(FileAlignJustifySVG))
End Sub
#Region "Messages"
@@ -251,6 +265,7 @@ Public Class ScriptWindowVM
SetFileAlignLeftSVG(Map.refMainWindowVM.MainWindowM.sResourcesDir & "\alignleft.svg")
SetFileAlignCenterSVG(Map.refMainWindowVM.MainWindowM.sResourcesDir & "\aligncenter.svg")
SetFileAlignJustifySVG(Map.refMainWindowVM.MainWindowM.sResourcesDir & "\alignjustify.svg")
End Sub
#End Region ' Constructor
@@ -360,6 +375,22 @@ Public Class ScriptWindowVM
m_bJustifyIsChecked = textRange.GetPropertyValue(FlowDocument.TextAlignmentProperty).Equals(TextAlignment.Justify)
End Sub
Public Sub InsertText(ByVal rtb As RichTextBox, ByVal content As String)
If Not String.IsNullOrEmpty(content) Then
rtb?.BeginChange()
If Not String.IsNullOrEmpty(rtb.Selection.Text) Then
rtb.Selection.Text = String.Empty
End If
Dim tp = rtb.CaretPosition.GetPositionAtOffset(0, LogicalDirection.Forward)
rtb.CaretPosition.InsertTextInRun(content)
rtb.CaretPosition = tp
rtb.EndChange()
Keyboard.Focus(rtb)
End If
End Sub
#End Region ' Methods
#Region "COMMANDS"