Imports System.Collections.ObjectModel Imports System.ComponentModel Imports EgtUILib Public Class OptionsViewModel Implements INotifyPropertyChanged 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 WritePrivateProfileString(S_GENERAL, K_MESSAGES, m_SelectedLanguage.Name) End If End Set End Property Public ReadOnly Property MeasureUnitList As List(Of String) Get Return OptionModule.m_MeasureUnitList End Get End Property Public Property SelectedMeasureUnit As String Get Return OptionModule.m_SelectedMeasureUnit End Get Set(value As String) If value IsNot OptionModule.m_SelectedMeasureUnit Then OptionModule.m_SelectedMeasureUnit = value ' iniziliazzo il valore dell'unità di misura DdfFile.UnitMeasure = value If value = OptionModule.m_MeasureUnitList(0) Then OptionModule.m_bIsMmUnit = True ElseIf value = OptionModule.m_MeasureUnitList(1) Then OptionModule.m_bIsMmUnit = False End If EgtSetUiUnits(OptionModule.m_bIsMmUnit) WritePrivateProfileString(S_SCENE, K_MMUNITS, If(OptionModule.m_bIsMmUnit, 1, 0).ToString) End If End Set End Property Public ReadOnly Property OptionLauncher As List(Of String) Get Return OptionModule.m_OptionLauncherList End Get End Property Public Property SelectedOptionLauncher As String Get Return OptionModule.m_SelectedOptionLauncher End Get Set(value As String) If value IsNot OptionModule.m_SelectedOptionLauncher Then OptionModule.m_SelectedOptionLauncher = Trim(value) Select Case OptionModule.m_SelectedOptionLauncher Case "Open Window" WritePrivateProfileString(S_LAUNCHERWINDOW, K_LAUNCHER, CStr(0)) Case "Last Project" WritePrivateProfileString(S_LAUNCHERWINDOW, K_LAUNCHER, CStr(1)) Case "Empty" WritePrivateProfileString(S_LAUNCHERWINDOW, K_LAUNCHER, CStr(2)) End Select End If End Set End Property ' Carico i parametri associati al Bevel Up/Down Public Property BevelUpIsChecked As Boolean Get Return OptionModule.m_bBevelUp End Get Set(value As Boolean) OptionModule.m_bBevelUp = value If value Then DefaultWritePrivateProfileString(S_EDGE, K_BEVELU_INI, "1") Else DefaultWritePrivateProfileString(S_EDGE, K_BEVELU_INI, "0") End If RefreshEdgeTypeList() End Set End Property Public Property BevelDownIsChecked As Boolean Get Return OptionModule.m_bBevelDown End Get Set(value As Boolean) OptionModule.m_bBevelDown = value If value Then DefaultWritePrivateProfileString(S_EDGE, K_BEVELD_INI, "1") Else DefaultWritePrivateProfileString(S_EDGE, K_BEVELD_INI, "0") End If RefreshEdgeTypeList() End Set End Property ' Carico i valori di Default della porta Public Property WidthValue As String Get Return OptionModule.m_Width End Get Set(value As String) OptionModule.m_Width = value DefaultWritePrivateProfileString(S_SIZE, K_WIDTH_INI, OptionModule.m_Width) End Set End Property Public Property HeightValue As String Get Return OptionModule.m_Height End Get Set(value As String) OptionModule.m_Height = value DefaultWritePrivateProfileString(S_SIZE, K_HEIGHT_INI, OptionModule.m_Height) End Set End Property Public Property ThicknessValue As String Get Return OptionModule.m_Thickness End Get Set(value As String) OptionModule.m_Thickness = value DefaultWritePrivateProfileString(S_SIZE, K_THICKNESS_INI, OptionModule.m_Thickness) End Set End Property Public ReadOnly Property SwingTypeList As List(Of String) Get Return OptionModule.m_SwingTypeList End Get End Property Public Property SwingValue As String Get Return OptionModule.m_Swing End Get Set(value As String) OptionModule.m_Swing = value DefaultWritePrivateProfileString(S_SIZE, K_SWING_INI, OptionModule.m_Swing) End Set End Property Public Property EdgeTypeList As ObservableCollection(Of String) Get Return Door.EdgeTypeList End Get Set(value As ObservableCollection(Of String)) Door.EdgeTypeList = value NotifyPropertyChanged("EdgeTypeList") End Set End Property Public Property LockEdgeType As String Get Return OptionModule.m_LockEdgeType End Get Set(value As String) OptionModule.m_LockEdgeType = value DefaultWritePrivateProfileString(S_EDGE, K_LOCKEDGE_INI, OptionModule.m_LockEdgeType) End Set End Property Public Property HingeEdgeType As String Get Return OptionModule.m_HingeEdgeType End Get Set(value As String) OptionModule.m_HingeEdgeType = value DefaultWritePrivateProfileString(S_EDGE, K_HINGEDGE_INI, OptionModule.m_HingeEdgeType) End Set End Property Public Property TopType As String Get Return OptionModule.m_TopType End Get Set(value As String) OptionModule.m_TopType = value DefaultWritePrivateProfileString(S_EDGE, K_TOPEDGE_INI, OptionModule.m_TopType) End Set End Property Public Property BottomType As String Get Return OptionModule.m_BottomType End Get Set(value As String) OptionModule.m_BottomType = value DefaultWritePrivateProfileString(S_EDGE, K_BOTTOMEDGE_INI, OptionModule.m_BottomType) End Set End Property ' is Checked Public Property LockEdgeIsChecked As Boolean Get Return OptionModule.m_LockEdgeMachining End Get Set(value As Boolean) OptionModule.m_LockEdgeMachining = value If value Then DefaultWritePrivateProfileString(S_MACHINING, K_LOCKEDGEISCHECKED_INI, "1") Else DefaultWritePrivateProfileString(S_MACHINING, K_LOCKEDGEISCHECKED_INI, "0") End If End Set End Property Public Property HingeEdgeIsChecked As Boolean Get Return OptionModule.m_HingeEdgeMachining End Get Set(value As Boolean) OptionModule.m_HingeEdgeMachining = value If value Then DefaultWritePrivateProfileString(S_MACHINING, K_HINGEDGEEISCHECKED_INI, "1") Else DefaultWritePrivateProfileString(S_MACHINING, K_HINGEDGEEISCHECKED_INI, "0") End If End Set End Property Public Property TopIsChecked As Boolean Get Return OptionModule.m_TopMachining End Get Set(value As Boolean) OptionModule.m_TopMachining = value If value Then DefaultWritePrivateProfileString(S_MACHINING, K_TOPISCHECKED_INI, "1") Else DefaultWritePrivateProfileString(S_MACHINING, K_TOPISCHECKED_INI, "0") End If End Set End Property Public Property BottomIsChecked As Boolean Get Return OptionModule.m_BottomMachining End Get Set(value As Boolean) OptionModule.m_BottomMachining = value If value Then DefaultWritePrivateProfileString(S_MACHINING, K_BOTTOMISCHECKED_INI, "1") Else DefaultWritePrivateProfileString(S_MACHINING, K_BOTTOMISCHECKED_INI, "0") End If End Set End Property ' OverMaterial Public Property LockEdgeOverMaterialValue As String Get Return OptionModule.m_LockEdgeOverMaterial End Get Set(value As String) OptionModule.m_LockEdgeOverMaterial = value DefaultWritePrivateProfileString(S_OVERMATERIAL, K_LOCKEDGEOVERMATERIAL_INI, OptionModule.m_LockEdgeOverMaterial) End Set End Property Public Property HingeEdgeOverMaterialValue As String Get Return OptionModule.m_HingeEdgeOverMaterial End Get Set(value As String) OptionModule.m_HingeEdgeOverMaterial = value DefaultWritePrivateProfileString(S_OVERMATERIAL, K_HINGEDGEOVERMATERIAL_INI, OptionModule.m_HingeEdgeOverMaterial) End Set End Property Public Property TopOverMaterialValue As String Get Return OptionModule.m_TopOverMaterial End Get Set(value As String) OptionModule.m_TopOverMaterial = value DefaultWritePrivateProfileString(S_OVERMATERIAL, K_TOPOVERMATERIAL_INI, OptionModule.m_TopOverMaterial) End Set End Property Public Property BottomOverMaterialValue As String Get Return OptionModule.m_BottomOverMaterial End Get Set(value As String) OptionModule.m_BottomOverMaterial = value DefaultWritePrivateProfileString(S_OVERMATERIAL, K_BOTTOMOVERMATERIAL_INI, OptionModule.m_BottomOverMaterial) End Set End Property Public Property MyProjectDir As String Get Return IniFile.m_MyProjectDir End Get Set(value As String) If value IsNot IniFile.m_MyProjectDir Then IniFile.m_MyProjectDir = value ' iniziliazzo il valore dell'unità di misura WritePrivateProfileString(S_DOORS, K_MYPROJECTDIR, value) End If NotifyPropertyChanged("MyProjectDir") End Set End Property ' Definizione comandi Private m_cmdCloseOptions As ICommand Private m_cmdBrowse As ICommand #Region "Messages" Public ReadOnly Property Title As String Get Return EgtMsg(MSG_MAINWINDOW + 209) End Get End Property Public ReadOnly Property StartUpMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 210) End Get End Property Public ReadOnly Property CurrentLanguageMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 1) End Get End Property Public ReadOnly Property LanguageAdvertMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 2) End Get End Property Public ReadOnly Property MeasureUnit As String Get Return EgtMsg(50211) End Get End Property Public ReadOnly Property DirectoryMsg As String Get Return EgtMsg(50212) End Get End Property Public ReadOnly Property General As String Get Return EgtMsg(MSG_MAINWINDOW + 201) End Get End Property Public ReadOnly Property OptionStart As String Get Return EgtMsg(50213) End Get End Property Public ReadOnly Property CurrentUnitMeasure As String Get Return EgtMsg(50200) End Get End Property Public ReadOnly Property CurrentDirectiry As String Get Return EgtMsg(50214) End Get End Property Public ReadOnly Property WidthMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 1) End Get End Property Public ReadOnly Property EdgeMsg As String Get Return EgtMsg(50215) End Get End Property Public ReadOnly Property OverMaterialMsg As String Get Return EgtMsg(50216) End Get End Property Public ReadOnly Property HeightMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 2) End Get End Property Public ReadOnly Property ThicknessMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 3) End Get End Property Public ReadOnly Property SwingMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 4) End Get End Property Public ReadOnly Property LockEdgeMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 5) End Get End Property Public ReadOnly Property HingeEdgeMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 6) End Get End Property Public ReadOnly Property TopMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 7) End Get End Property Public ReadOnly Property BottomMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 8) End Get End Property ' Machinig Public ReadOnly Property LockEdgeOverMaterial As String Get Return EgtMsg(MSG_MAINWINDOW + 202) End Get End Property Public ReadOnly Property HingeEdgeOverMaterial As String Get Return EgtMsg(MSG_MAINWINDOW + 203) End Get End Property Public ReadOnly Property TopOverMaterial As String Get Return EgtMsg(MSG_MAINWINDOW + 204) End Get End Property Public ReadOnly Property BottomOverMaterial As String Get Return EgtMsg(MSG_MAINWINDOW + 205) End Get End Property Public ReadOnly Property MsgBrowse As String Get Return EgtMsg(50217) End Get End Property Public ReadOnly Property MsgClose As String Get Return EgtMsg(50218) End Get End Property ' BevelMsg Public ReadOnly Property BevelMsg As String Get Return EgtMsg(50219) End Get End Property Public ReadOnly Property BevelUpMsg As String Get Return EgtMsg(50220) End Get End Property Public ReadOnly Property BevelDownMsg As String Get Return EgtMsg(50221) End Get End Property #End Region ' Aggiorno la lista deli bevel Private Sub RefreshEdgeTypeList() Dim rEdgeTypeList As New ObservableCollection(Of String) DefaultGetPrivateProfileObservableCollection(S_EDGE, K_EDGETYPE_LIST_INI, rEdgeTypeList) SetEdgeTypeList(rEdgeTypeList, OptionModule.m_bBevelUp, OptionModule.m_bBevelDown) EdgeTypeList = rEdgeTypeList End Sub #Region "COMMANDS" #Region "CloseOptionsCommand" ''' ''' Returns a command that remove the current selected machining. ''' Public ReadOnly Property CloseOptionsCommand() As ICommand Get If m_cmdCloseOptions Is Nothing Then m_cmdCloseOptions = New Command(AddressOf CloseOptions) End If Return m_cmdCloseOptions End Get End Property ''' ''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand. ''' Public Sub CloseOptions() ' Chiusura finestra For Each Window In Application.Current.Windows If TypeOf Window Is OptionsView Then Dim OptionsWindow As OptionsView = DirectCast(Window, OptionsView) OptionsWindow.Close() End If Next End Sub #End Region ' CloseOptionsCommand Public ReadOnly Property BrowseCommand() As ICommand Get If m_cmdBrowse Is Nothing Then m_cmdBrowse = New Command(AddressOf Browse) End If Return m_cmdBrowse End Get End Property Public Sub Browse() Dim FolderBrowserDialog As New System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog.SelectedPath = IniFile.m_MyProjectDir ' mostriamo la finestra di dialogo aperta fino alla directory MyProjects If FolderBrowserDialog.ShowDialog <> Forms.DialogResult.OK Then ' se la risposta è diversa da OK esce Return End If MyProjectDir = FolderBrowserDialog.SelectedPath End Sub #End Region ' COMMANDS Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged Public Sub NotifyPropertyChanged(propName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) End Sub End Class