72a6c5e7c4
-rimosso update title
531 lines
18 KiB
VB.net
531 lines
18 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports System.IO
|
|
Imports System.Drawing
|
|
|
|
Public Class OptionWindowVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELD & PROPERTIES"
|
|
|
|
Private ReadOnly m_ThemesDataService As New ThemesDataServiceVM()
|
|
|
|
Public ReadOnly Property LanguageList As ObservableCollection(Of Language)
|
|
Get
|
|
Return OptionModule.m_LanguageList
|
|
End Get
|
|
End Property
|
|
|
|
Public Property SelectedLanguage As Language
|
|
Get
|
|
Return OptionModule.m_SelectedLanguage
|
|
End Get
|
|
Set(value As Language)
|
|
If value IsNot OptionModule.m_SelectedLanguage Then
|
|
OptionModule.m_SelectedLanguage = value
|
|
' Leggo direttorio dei messaggi (se manca uso direttorio di configurazione)
|
|
Dim sMsgDir As String = String.Empty
|
|
If GetMainPrivateProfileString(S_GENERAL, K_MESSAGESDIR, "", sMsgDir) = 0 Then
|
|
sMsgDir = Map.refMainWindowVM.MainWindowM.sConfigDir
|
|
End If
|
|
' Leggo file messaggi
|
|
Dim sMsgFilePath As String = sMsgDir & "\" & OptionModule.m_SelectedLanguage.FilePath
|
|
If Not EgtLoadMessages(sMsgFilePath) Then
|
|
EgtOutLog("Error in EgtLoadMessages")
|
|
End If
|
|
UpdateAllMessages()
|
|
WriteMainPrivateProfileString(S_GENERAL, K_MESSAGES, OptionModule.m_SelectedLanguage.Name)
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property TopSceneBackground As System.Windows.Media.Brush
|
|
Get
|
|
Return New SolidColorBrush(System.Windows.Media.Color.FromArgb(CByte(255),
|
|
CByte(OptionModule.m_TopSceneBackground.R),
|
|
CByte(OptionModule.m_TopSceneBackground.G),
|
|
CByte(OptionModule.m_TopSceneBackground.B)))
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BotSceneBackground As System.Windows.Media.Brush
|
|
Get
|
|
Return New SolidColorBrush(System.Windows.Media.Color.FromArgb(CByte(255),
|
|
CByte(OptionModule.m_BotSceneBackground.R),
|
|
CByte(OptionModule.m_BotSceneBackground.G),
|
|
CByte(OptionModule.m_BotSceneBackground.B)))
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GridColor As System.Windows.Media.Brush
|
|
Get
|
|
Return New SolidColorBrush(System.Windows.Media.Color.FromArgb(CByte(255),
|
|
CByte(OptionModule.m_GridColor.R),
|
|
CByte(OptionModule.m_GridColor.G),
|
|
CByte(OptionModule.m_GridColor.B)))
|
|
End Get
|
|
End Property
|
|
|
|
Public Property ThickLine As Boolean
|
|
Get
|
|
Return OptionModule.m_bThickLine
|
|
End Get
|
|
Set(value As Boolean)
|
|
OptionModule.m_bThickLine = value
|
|
WriteMainPrivateProfileString(S_SCENE, K_LINEWIDTH, If(value, "2", "1"))
|
|
EgtSetLineAttribs(If(value, 2, 1))
|
|
End Set
|
|
End Property
|
|
|
|
Public Property SmoothTriMesh As Boolean
|
|
Get
|
|
Return OptionModule.m_bSmoothTriMesh
|
|
End Get
|
|
Set(value As Boolean)
|
|
OptionModule.m_bSmoothTriMesh = value
|
|
WriteMainPrivateProfileString(S_SCENE, K_SHOWTRIAADV, If(value, "1", "0"))
|
|
EgtSetShowTriaAdv(value)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Themes As New ObservableCollection(Of ThemesDataServiceM)
|
|
Public Property Themes As ObservableCollection(Of ThemesDataServiceM)
|
|
Get
|
|
Return m_Themes
|
|
End Get
|
|
Set(value As ObservableCollection(Of ThemesDataServiceM))
|
|
If Not m_Themes.Equals(value) Then
|
|
m_Themes = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelectedTheme As ThemesDataServiceM
|
|
Public Property SelectedTheme As ThemesDataServiceM
|
|
Get
|
|
Return m_SelectedTheme
|
|
End Get
|
|
Set(value As ThemesDataServiceM)
|
|
m_ThemesDataService.SetTheme(value)
|
|
m_SelectedTheme = value
|
|
' salvo in file ini la scelta del tema corrente
|
|
Dim IndexThema As Integer = Themes.IndexOf(m_SelectedTheme)
|
|
If IndexThema < 0 Then
|
|
IndexThema = 0
|
|
End If
|
|
WriteMainPrivateProfileString(S_GENERAL, K_THEMA, IndexThema.ToString())
|
|
m_SelectedThema = IndexThema
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ListTopPanel As New ObservableCollection(Of Integer)({0, 1})
|
|
Public Property ListTopPanel As ObservableCollection(Of Integer)
|
|
Get
|
|
Return m_ListTopPanel
|
|
End Get
|
|
Set(value As ObservableCollection(Of Integer))
|
|
m_ListTopPanel = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelectedTopPanel As Integer = 0
|
|
Public Property SelectedTopPanel As Integer
|
|
Get
|
|
Return m_SelectedTopPanel
|
|
End Get
|
|
Set(value As Integer)
|
|
m_SelectedTopPanel = value
|
|
Map.refSceneButtonVM.SetSelTopPanel(value)
|
|
WriteMainPrivateProfileString(S_GENERAL, K_TOPPANEL, m_SelectedTopPanel.ToString())
|
|
m_SelectedThemaTopPanel = m_SelectedTopPanel
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdTopSceneBackground As ICommand
|
|
Private m_cmdBotSceneBackground As ICommand
|
|
Private m_cmdGridColor As ICommand
|
|
Private m_cmdUpdateLicenceCmd As ICommand
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property Title As String
|
|
Get
|
|
Return EgtMsg(5005) ' Opzioni
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CurrentLanguageMsg As String
|
|
Get
|
|
Return EgtMsg(6501) ' Lingua corrente
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property LanguageAdvertMsg As String
|
|
Get
|
|
Return EgtMsg(6502) ' La nuova lingua diventerà corrente dal prossimo avvio del programma.
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TopSceneBackgroundMsg As String
|
|
Get
|
|
Return EgtMsg(6510) ' Colore della vista in alto
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BotSceneBackgroundMsg As String
|
|
Get
|
|
Return EgtMsg(6511) ' Colore della vista in basso
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GenericMsg As String
|
|
Get
|
|
Return EgtMsg(6514) ' Generale
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GridColorMsg As String
|
|
Get
|
|
Return EgtMsg(6517) ' Colore della griglia
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SmoothTriMeshMsg As String
|
|
Get
|
|
Return EgtMsg(6518) ' Superfici smussate
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ThickLineMsg As String
|
|
Get
|
|
Return EgtMsg(6536) ' Linee spesse
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property UpdateLicenceMsg As String
|
|
Get
|
|
Return EgtMsg(6553) ' Aggiorna Licenza
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TemaAdvertMsg As String
|
|
Get
|
|
Return EgtMsg(110008) ' Il nuovo tema diventerà corrente quando verrà selezionato.
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TemaMsg As String
|
|
Get
|
|
Return EgtMsg(110009) ' Tema
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TemaTopPanelAdvertMsg As String
|
|
Get
|
|
Return EgtMsg(110032) ' Il nuovo top panel diventerà corrente quando selezionato
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TemaTopPanelMsg As String
|
|
Get
|
|
Return EgtMsg(110031) ' Top Panel
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#End Region ' Field & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
LoadThemes()
|
|
LoadTopPanelThemes()
|
|
Map.SetRefOptionWindowVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di selezionare il colore per modificare la scena
|
|
''' </summary>
|
|
''' <param name="Col">colore di base</param>
|
|
''' <param name="NewCol">colore nuovo</param>
|
|
''' <returns></returns>
|
|
Private Function SelectColor(Col As Color3d, ByRef NewCol As Color3d) As Boolean
|
|
' Recupero colori custom
|
|
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 False
|
|
'Recupero colore scelto
|
|
NewCol.FromColor(ColorDlg.Color)
|
|
''Salvo eventuali modifiche ai colori custom
|
|
sCustomColors = ""
|
|
For Each Color In ColorDlg.CustomColors
|
|
sCustomColors &= Color.ToString() & ","
|
|
Next
|
|
sCustomColors = sCustomColors.Trim({" "c, ","c})
|
|
WriteMainPrivateProfileString(S_COLORS, K_CUSTOMCOLORS, sCustomColors)
|
|
Return True
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Seleziona il tema se presente
|
|
''' </summary>
|
|
''' <param name="IndexThema"></param>
|
|
Public Sub SetThema(IndexThema As Integer)
|
|
If m_Themes.Count > 0 Then
|
|
m_ThemesDataService.SetTheme(m_Themes(IndexThema))
|
|
End If
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione che carica i temi del top panel
|
|
''' </summary>
|
|
Private Sub LoadTopPanelThemes()
|
|
' Seleziono elemento in ComboBox
|
|
m_SelectedTopPanel = m_ListTopPanel(OptionModule.m_SelectedThemaTopPanel)
|
|
' Attivo il tema toppanel letto sopra
|
|
If Not IsNothing(Map.refSceneButtonVM) Then Map.refSceneButtonVM.SetSelTopPanel(OptionModule.m_SelectedThemaTopPanel)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Fuzione che carica i temi del dizionario
|
|
''' </summary>
|
|
Private Sub LoadThemes()
|
|
' Popolo la lista temi
|
|
m_Themes.Add(New ThemesDataServiceM() With {
|
|
.Name = "Default",
|
|
.Path = "Utility/EgtStone3DDictionary.xaml"
|
|
})
|
|
m_Themes.Add(New ThemesDataServiceM() With {
|
|
.Name = "Dark",
|
|
.Path = "Utility/EgtStone3DDarkDictionary.xaml"
|
|
})
|
|
' Seleziono elemento in ComboBox
|
|
m_SelectedTheme = m_Themes(OptionModule.m_SelectedThema)
|
|
' Attivo il tema letto sopra
|
|
SetThema(OptionModule.m_SelectedThema)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione che aggiorna i messaggi delle opzioni
|
|
''' </summary>
|
|
Private Sub UpdateMessageOption()
|
|
NotifyPropertyChanged(NameOf(Title))
|
|
NotifyPropertyChanged(NameOf(CurrentLanguageMsg))
|
|
NotifyPropertyChanged(NameOf(LanguageAdvertMsg))
|
|
NotifyPropertyChanged(NameOf(TopSceneBackgroundMsg))
|
|
NotifyPropertyChanged(NameOf(BotSceneBackgroundMsg))
|
|
NotifyPropertyChanged(NameOf(GenericMsg))
|
|
NotifyPropertyChanged(NameOf(GridColorMsg))
|
|
NotifyPropertyChanged(NameOf(SmoothTriMeshMsg))
|
|
NotifyPropertyChanged(NameOf(ThickLineMsg))
|
|
NotifyPropertyChanged(NameOf(UpdateLicenceMsg))
|
|
NotifyPropertyChanged(NameOf(TemaAdvertMsg))
|
|
NotifyPropertyChanged(NameOf(TemaMsg))
|
|
NotifyPropertyChanged(NameOf(TemaTopPanelAdvertMsg))
|
|
NotifyPropertyChanged(NameOf(TemaTopPanelMsg))
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione che aggiorna tutti i messaggi
|
|
''' </summary>
|
|
Friend Sub UpdateAllMessages()
|
|
UpdateMessageOption()
|
|
Map.refTopPanelVM.UpdateMessagesTopPanel()
|
|
Map.refProjManagerVM.UpdateMessageProjManager()
|
|
Map.refSecondaryWindowVM.UpdateTitle()
|
|
Map.refViewPanelVM.UpdateMessageViewPanel()
|
|
Map.refViewPanelProspectiveVM.UpdateMessageViewProspectivePanel()
|
|
Map.refGridPanelVM.UpdateMessageGridPanel()
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "TopSceneBackgroundCmd"
|
|
|
|
Public ReadOnly Property TopSceneBackground_Command() As ICommand
|
|
Get
|
|
If m_cmdTopSceneBackground Is Nothing Then
|
|
m_cmdTopSceneBackground = New Command(AddressOf TopSceneBackgroundCmd)
|
|
End If
|
|
Return m_cmdTopSceneBackground
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di cambiare sfondo alla parte superiore della scena
|
|
''' </summary>
|
|
Public Sub TopSceneBackgroundCmd()
|
|
' Recupero colore da Ini
|
|
Dim BackTopColor As New Color3d(192, 192, 192)
|
|
GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
|
|
' Eseguo modifica con dialogo
|
|
If SelectColor(BackTopColor, BackTopColor) Then
|
|
OptionModule.m_TopSceneBackground = BackTopColor
|
|
Map.refSceneHostVM.MainScene.SetViewBackground(OptionModule.m_TopSceneBackground, OptionModule.m_BotSceneBackground)
|
|
WritePrivateProfileColor(S_SCENE, K_BACKTOP, OptionModule.m_TopSceneBackground)
|
|
NotifyPropertyChanged(NameOf(TopSceneBackground))
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' TopSceneBackgroundCmd
|
|
|
|
#Region "BotSceneBackgroundCmd"
|
|
|
|
Public ReadOnly Property BotSceneBackground_Command() As ICommand
|
|
Get
|
|
If m_cmdBotSceneBackground Is Nothing Then
|
|
m_cmdBotSceneBackground = New Command(AddressOf BotSceneBackgroundCmd)
|
|
End If
|
|
Return m_cmdBotSceneBackground
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di cambiare sfondo alla parte inferiore della scena
|
|
''' </summary>
|
|
Public Sub BotSceneBackgroundCmd()
|
|
' Recupero colore da Ini
|
|
Dim BackBotColor As New Color3d(192, 192, 192)
|
|
GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
|
|
' Eseguo modifica con dialogo
|
|
If SelectColor(BackBotColor, BackBotColor) Then
|
|
OptionModule.m_BotSceneBackground = BackBotColor
|
|
Map.refSceneHostVM.MainScene.SetViewBackground(OptionModule.m_TopSceneBackground, OptionModule.m_BotSceneBackground)
|
|
WritePrivateProfileColor(S_SCENE, K_BACKBOTTOM, OptionModule.m_BotSceneBackground)
|
|
NotifyPropertyChanged(NameOf(BotSceneBackground))
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' BotSceneBackgroundCmd
|
|
|
|
#Region "GridColorCmd"
|
|
|
|
Public ReadOnly Property GridColor_Command() As ICommand
|
|
Get
|
|
If m_cmdGridColor Is Nothing Then
|
|
m_cmdGridColor = New Command(AddressOf GridColorCmd)
|
|
End If
|
|
Return m_cmdGridColor
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di cambiare sfondo alla griglia della scena
|
|
''' </summary>
|
|
Public Sub GridColorCmd()
|
|
' Recupero colore da Ini
|
|
Dim GridColor As New Color3d(192, 192, 192)
|
|
GetMainPrivateProfileColor(S_GRID, K_MINLNCOLOR, GridColor)
|
|
' Eseguo modifica con dialogo
|
|
If SelectColor(GridColor, GridColor) Then
|
|
OptionModule.m_GridColor = GridColor
|
|
EgtSetGridColor(GridColor, GridColor)
|
|
WritePrivateProfileColor(S_GRID, K_MINLNCOLOR, OptionModule.m_GridColor)
|
|
WritePrivateProfileColor(S_GRID, K_MAJLNCOLOR, OptionModule.m_GridColor)
|
|
EgtDraw()
|
|
NotifyPropertyChanged(NameOf(GridColor))
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' GridColorCmd
|
|
|
|
#Region "UpdateLicenceCmd"
|
|
|
|
Public ReadOnly Property UpdateLicence_Command() As ICommand
|
|
Get
|
|
If m_cmdUpdateLicenceCmd Is Nothing Then
|
|
m_cmdUpdateLicenceCmd = New Command(AddressOf UpdateLicenceCmd)
|
|
End If
|
|
Return m_cmdUpdateLicenceCmd
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che permette l'update della licenza
|
|
''' </summary>
|
|
Public Sub UpdateLicenceCmd()
|
|
' Apro dialogo per richiesta file licenza
|
|
Dim LicDlg As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
|
|
.Title = EgtMsg(110026), ' Licenza
|
|
.InitialDirectory = Map.refMainWindowVM.MainWindowM.sConfigDir,
|
|
.Filter = "Licences (.lic)|*.lic",
|
|
.FilterIndex = 1,
|
|
.CheckFileExists = True,
|
|
.ValidateNames = True
|
|
}
|
|
If LicDlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
|
|
' Recupero il direttorio del file
|
|
Dim sDir As String = Path.GetDirectoryName(LicDlg.FileName)
|
|
' Se il file non è già nel direttorio di configurazione lo copio
|
|
If Not String.Equals(Path.GetFullPath(sDir), Path.GetFullPath(Map.refMainWindowVM.MainWindowM.sConfigDir), StringComparison.OrdinalIgnoreCase) Then
|
|
Try
|
|
File.Copy(LicDlg.FileName, Path.Combine(Map.refMainWindowVM.MainWindowM.sConfigDir, LicDlg.SafeFileName), True)
|
|
Catch ex As Exception
|
|
Return
|
|
End Try
|
|
End If
|
|
' Imposto il nuovo file di licenza nell'Ini
|
|
WriteMainPrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' UpdateLicenceCmd
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|
|
|
|
Public Class SelectedComboConverter
|
|
Implements IValueConverter
|
|
|
|
''' <summary>
|
|
''' Permette la conversione del tema del top panel selezionato in testo
|
|
''' </summary>
|
|
''' <param name="value"></param>
|
|
''' <param name="targetType"></param>
|
|
''' <param name="parameter"></param>
|
|
''' <param name="culture"></param>
|
|
''' <returns></returns>
|
|
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
|
|
If TypeOf value Is Integer Then
|
|
Select Case value
|
|
Case 0
|
|
Return EgtMsg(110031)
|
|
Case 1
|
|
Return EgtMsg(110031) & " 1"
|
|
Case Else
|
|
Return Nothing
|
|
End Select
|
|
Else
|
|
Return Nothing
|
|
End If
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Throw New NotImplementedException()
|
|
End Function
|
|
End Class
|