-modifa a script rimesso richtext
This commit is contained in:
@@ -8,6 +8,8 @@ Public Class ScriptWindowVM
|
||||
|
||||
#Region "FIELD & PROPERTIES"
|
||||
|
||||
Friend m_bTextHasChanged As Boolean = False
|
||||
|
||||
Private m_sNameFile As String = String.Empty
|
||||
Public Property sNameFile As String
|
||||
Get
|
||||
@@ -31,6 +33,175 @@ Public Class ScriptWindowVM
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_nFontSizeList As New List(Of Integer)
|
||||
Public Property FontSizeList As List(Of Integer)
|
||||
Get
|
||||
Return m_nFontSizeList
|
||||
End Get
|
||||
Set(value As List(Of Integer))
|
||||
m_nFontSizeList = value
|
||||
NotifyPropertyChanged(NameOf(FontSizeList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_nSelFontSize As Integer
|
||||
Public Property SelFontSize As Integer
|
||||
Get
|
||||
Return m_nSelFontSize
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
m_nSelFontSize = value
|
||||
If Not IsNothing(m_nSelFontSize) Then ChangeFontSize(m_nSelFontSize)
|
||||
NotifyPropertyChanged(NameOf(SelFontSize))
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetSelFontSize(value As Integer)
|
||||
m_nSelFontSize = value
|
||||
NotifyPropertyChanged(NameOf(SelFontSize))
|
||||
End Sub
|
||||
|
||||
Private m_sFontFamilyList As New List(Of FontFamily)
|
||||
Public Property FontFamilyList As List(Of FontFamily)
|
||||
Get
|
||||
Return m_sFontFamilyList
|
||||
End Get
|
||||
Set(value As List(Of FontFamily))
|
||||
m_sFontFamilyList = value
|
||||
NotifyPropertyChanged(NameOf(FontFamilyList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_sSelFontFamily As FontFamily
|
||||
Public Property SelFontFamily As FontFamily
|
||||
Get
|
||||
Return m_sSelFontFamily
|
||||
End Get
|
||||
Set(value As FontFamily)
|
||||
m_sSelFontFamily = value
|
||||
If Not IsNothing(m_sSelFontFamily) Then ChangeFontFamily(m_sSelFontFamily)
|
||||
NotifyPropertyChanged(NameOf(SelFontFamily))
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetSelFontFamily(value As FontFamily)
|
||||
m_sSelFontFamily = value
|
||||
NotifyPropertyChanged(NameOf(SelFontFamily))
|
||||
End Sub
|
||||
|
||||
Private m_bBoldIsChecked As Boolean = False
|
||||
Public Property BoldIsChecked As Boolean
|
||||
Get
|
||||
Return m_bBoldIsChecked
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bBoldIsChecked = value
|
||||
NotifyPropertyChanged(NameOf(BoldIsChecked))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_bItalicIsChecked As Boolean = False
|
||||
Public Property ItalicIsChecked As Boolean
|
||||
Get
|
||||
Return m_bItalicIsChecked
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bItalicIsChecked = value
|
||||
NotifyPropertyChanged(NameOf(ItalicIsChecked))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_bUnderlineChecked As Boolean = False
|
||||
Public Property UnderlineChecked As Boolean
|
||||
Get
|
||||
Return m_bUnderlineChecked
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bUnderlineChecked = value
|
||||
NotifyPropertyChanged(NameOf(UnderlineChecked))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_bLeftIsChecked As Boolean = False
|
||||
Public Property LeftIsChecked As Boolean
|
||||
Get
|
||||
Return m_bLeftIsChecked
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bLeftIsChecked = value
|
||||
SetCenterIsChecked(False)
|
||||
SetJustifyIsChecked(False)
|
||||
NotifyPropertyChanged(NameOf(LeftIsChecked))
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetLeftIsChecked(value As Boolean)
|
||||
m_bLeftIsChecked = value
|
||||
NotifyPropertyChanged(NameOf(LeftIsChecked))
|
||||
End Sub
|
||||
|
||||
Private m_bCenterIsChecked As Boolean = False
|
||||
Public Property CenterIsChecked As Boolean
|
||||
Get
|
||||
Return m_bCenterIsChecked
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bCenterIsChecked = value
|
||||
SetLeftIsChecked(False)
|
||||
SetJustifyIsChecked(False)
|
||||
NotifyPropertyChanged(NameOf(CenterIsChecked))
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetCenterIsChecked(value As Boolean)
|
||||
m_bCenterIsChecked = value
|
||||
NotifyPropertyChanged(NameOf(CenterIsChecked))
|
||||
End Sub
|
||||
|
||||
Private m_bJustifyIsChecked As Boolean = False
|
||||
Public Property JustifyIsChecked As Boolean
|
||||
Get
|
||||
Return m_bJustifyIsChecked
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bJustifyIsChecked = value
|
||||
SetLeftIsChecked(False)
|
||||
SetCenterIsChecked(False)
|
||||
NotifyPropertyChanged(NameOf(JustifyIsChecked))
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetJustifyIsChecked(value As Boolean)
|
||||
m_bJustifyIsChecked = value
|
||||
NotifyPropertyChanged(NameOf(JustifyIsChecked))
|
||||
End Sub
|
||||
|
||||
Private m_FileAlignLeftSVG As String = String.Empty
|
||||
Public Property FileAlignLeftSVG As String
|
||||
Get
|
||||
Return m_FileAlignLeftSVG
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_FileAlignLeftSVG = value
|
||||
NotifyPropertyChanged(NameOf(FileAlignLeftSVG))
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetFileAlignLeftSVG(sFileAlignLeftSVG As String)
|
||||
m_FileAlignLeftSVG = sFileAlignLeftSVG
|
||||
NotifyPropertyChanged(NameOf(FileAlignLeftSVG))
|
||||
End Sub
|
||||
|
||||
Private m_FileAlignCenterSVG As String = String.Empty
|
||||
Public Property FileAlignCenterSVG As String
|
||||
Get
|
||||
Return m_FileAlignCenterSVG
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_FileAlignCenterSVG = value
|
||||
NotifyPropertyChanged(NameOf(FileAlignCenterSVG))
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetFileAlignCenterSVG(sFileAlignCenterSVG As String)
|
||||
m_FileAlignCenterSVG = sFileAlignCenterSVG
|
||||
NotifyPropertyChanged(NameOf(FileAlignCenterSVG))
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "Messages"
|
||||
|
||||
Public ReadOnly Property Title As String
|
||||
@@ -62,6 +233,8 @@ Public Class ScriptWindowVM
|
||||
' Definizione Comandi
|
||||
Private m_ConfermaCmd As ICommand
|
||||
Private m_cmdSaveAs As ICommand
|
||||
Private m_cmdAnnulla As ICommand
|
||||
Private m_cmdTextColor As ICommand
|
||||
|
||||
#End Region ' Fields & Properties
|
||||
|
||||
@@ -69,6 +242,15 @@ Public Class ScriptWindowVM
|
||||
|
||||
Sub New()
|
||||
Map.SetRefScriptWindowVM(Me)
|
||||
|
||||
If m_nFontSizeList.Count <= 0 Then CreateFontSizeList()
|
||||
|
||||
If m_sFontFamilyList.Count <= 0 Then CreateFontFamilyList()
|
||||
|
||||
SetToolbar()
|
||||
|
||||
SetFileAlignLeftSVG(Map.refMainWindowVM.MainWindowM.sResourcesDir & "\alignleft.svg")
|
||||
SetFileAlignCenterSVG(Map.refMainWindowVM.MainWindowM.sResourcesDir & "\aligncenter.svg")
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructor
|
||||
@@ -128,6 +310,56 @@ Public Class ScriptWindowVM
|
||||
Return textRange.Text
|
||||
End Function
|
||||
|
||||
Private Sub CreateFontSizeList()
|
||||
For Size As Integer = 8 To 20
|
||||
If Size Mod 2 = 0 Then
|
||||
m_nFontSizeList.Add(Size)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Funzione che permette di cambiare la dimensione della font
|
||||
''' </summary>
|
||||
''' <param name="nSelFontSize">fontsize selezionata</param>
|
||||
Private Sub ChangeFontSize(nSelFontSize As Integer)
|
||||
If nSelFontSize = GDB_ID.NULL Then Return
|
||||
Dim pixelSize As Double = Convert.ToDouble(nSelFontSize) * (96 / 72)
|
||||
Dim textRange = New TextRange(Map.refScriptWindowV.sNameFile_RichTxBx.Selection.Start, Map.refScriptWindowV.sNameFile_RichTxBx.Selection.[End])
|
||||
textRange.ApplyPropertyValue(TextElement.FontSizeProperty, pixelSize)
|
||||
End Sub
|
||||
|
||||
Private Sub CreateFontFamilyList()
|
||||
For Each FontFamily As FontFamily In Fonts.SystemFontFamilies
|
||||
m_sFontFamilyList.Add(FontFamily)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub ChangeFontFamily(sSelFontFamily As FontFamily)
|
||||
If sSelFontFamily Is Nothing Then Return
|
||||
Dim fontFamily As String = sSelFontFamily.ToString()
|
||||
Dim textRange = New TextRange(Map.refScriptWindowV.sNameFile_RichTxBx.Selection.Start, Map.refScriptWindowV.sNameFile_RichTxBx.Selection.[End])
|
||||
textRange.ApplyPropertyValue(TextElement.FontFamilyProperty, fontFamily)
|
||||
End Sub
|
||||
|
||||
Friend Sub SetToolbar()
|
||||
Dim textRange = New TextRange(Map.refScriptWindowV.sNameFile_RichTxBx.Selection.Start, Map.refScriptWindowV.sNameFile_RichTxBx.Selection.[End])
|
||||
Dim fontFamily As Object = textRange.GetPropertyValue(TextElement.FontFamilyProperty)
|
||||
SetSelFontFamily(fontFamily)
|
||||
Dim fontSize As Object = textRange.GetPropertyValue(TextElement.FontSizeProperty)
|
||||
SetSelFontSize(fontSize)
|
||||
|
||||
If Not String.IsNullOrEmpty(textRange.Text) Then
|
||||
m_bBoldIsChecked = textRange.GetPropertyValue(TextElement.FontWeightProperty).Equals(FontWeights.Bold)
|
||||
m_bItalicIsChecked = textRange.GetPropertyValue(TextElement.FontStyleProperty).Equals(FontStyles.Italic)
|
||||
m_bUnderlineChecked = textRange.GetPropertyValue(Inline.TextDecorationsProperty).Equals(TextDecorations.Underline)
|
||||
End If
|
||||
|
||||
m_bLeftIsChecked = textRange.GetPropertyValue(FlowDocument.TextAlignmentProperty).Equals(TextAlignment.Left)
|
||||
m_bCenterIsChecked = textRange.GetPropertyValue(FlowDocument.TextAlignmentProperty).Equals(TextAlignment.Center)
|
||||
m_bJustifyIsChecked = textRange.GetPropertyValue(FlowDocument.TextAlignmentProperty).Equals(TextAlignment.Justify)
|
||||
End Sub
|
||||
|
||||
#End Region ' Methods
|
||||
|
||||
#Region "COMMANDS"
|
||||
@@ -171,7 +403,67 @@ Public Class ScriptWindowVM
|
||||
SaveProject()
|
||||
End Sub
|
||||
|
||||
#End Region ' SaveAsCommand
|
||||
#End Region ' SaveAsCommand
|
||||
|
||||
#Region "AnnullaCmd"
|
||||
|
||||
Public ReadOnly Property AnnullaCmd As ICommand
|
||||
Get
|
||||
If m_cmdAnnulla Is Nothing Then
|
||||
m_cmdAnnulla = New Command(AddressOf Annulla)
|
||||
End If
|
||||
Return m_cmdAnnulla
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub Annulla()
|
||||
Map.refScriptWindowV.Close()
|
||||
End Sub
|
||||
|
||||
#End Region ' AnnullaCmd
|
||||
|
||||
#Region "TextColorCmd"
|
||||
|
||||
Public ReadOnly Property TextColorCmd As ICommand
|
||||
Get
|
||||
If m_cmdTextColor Is Nothing Then
|
||||
m_cmdTextColor = New Command(AddressOf TextColor)
|
||||
End If
|
||||
Return m_cmdTextColor
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub TextColor()
|
||||
' Recupero colori custom
|
||||
Dim Col As New Color3d(10, 122, 150)
|
||||
Dim sCustomColors As String = ""
|
||||
GetMainPrivateProfileString(S_COLORS, K_CUSTOMCOLORS, "", sCustomColors)
|
||||
Dim CustomColors() As String = sCustomColors.Split(","c)
|
||||
Dim nCustomColors As New List(Of Integer)
|
||||
For Each Color In CustomColors
|
||||
Dim nColor As Integer
|
||||
If Integer.TryParse(Color, nColor) Then
|
||||
nCustomColors.Add(nColor)
|
||||
End If
|
||||
Next
|
||||
' Creo dialogo colori
|
||||
Dim ColorDlg As New EgtColorPickerV(Application.Current.MainWindow, New EgtColorPickerVM()) With {
|
||||
.CustomColors = nCustomColors.ToArray(),
|
||||
.Color = Col.ToColor()
|
||||
}
|
||||
' Visualizzo dialogo
|
||||
If ColorDlg.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return
|
||||
'Recupero colore scelto
|
||||
Dim selColor As New SolidColorBrush(System.Windows.Media.Color.FromArgb(CByte(ColorDlg.Color.A),
|
||||
CByte(ColorDlg.Color.R),
|
||||
CByte(ColorDlg.Color.G),
|
||||
CByte(ColorDlg.Color.B)))
|
||||
Dim textRange = New TextRange(Map.refScriptWindowV.sNameFile_RichTxBx.Selection.Start, Map.refScriptWindowV.sNameFile_RichTxBx.Selection.[End])
|
||||
textRange.ApplyPropertyValue(TextElement.ForegroundProperty, selColor)
|
||||
End Sub
|
||||
|
||||
#End Region ' TextColorCmd
|
||||
|
||||
|
||||
#End Region ' Commands
|
||||
|
||||
|
||||
Reference in New Issue
Block a user