Files
EgtDOORCreator/OptionsWindow/OptionsViewModel.vb
T
Nicola Pievani 30840bd2f6 EgtDOORCreator 1.8d4 :
- Stampa "secure : 0" nel file DDF;
- tutti i file DDF che non hanno "secure" sono automaticamnete aggiornati aggiungendo "secure" dopo "swing".
2017-04-27 15:19:31 +00:00

641 lines
19 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports EgtUILib
Public Class OptionsViewModel
Implements INotifyPropertyChanged
Dim m_rfCurrDoor As Door
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)
If QuestionSetBevel(CheckBevel(OptionModule.m_bBevelUp, value)) Then
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()
Else
Return
End If
End Set
End Property
Public Property BevelDownIsChecked As Boolean
Get
Return OptionModule.m_bBevelDown
End Get
Set(value As Boolean)
If QuestionSetBevel(CheckBevel(OptionModule.m_bBevelDown, value)) Then
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()
Else
Return
End If
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.m_EdgeTypeList
End Get
Set(value As ObservableCollection(Of String))
' carico la lista degli EdgeType appena aggiornata
Door.m_EdgeTypeList = value
' aggiorno le lista pressenti nella pagina delle impostazioni
NotifyPropertyChanged("EdgeTypeList")
' verifico che esista una porta
If Not IsNothing(m_rfCurrDoor) Then
' Aggiorno le liste degli elementi
m_rfCurrDoor.NotifyPropertyChanged("EdgeTypeList")
'EdgeDoorControl(m_rfCurrDoor.LockEdgeType)
m_rfCurrDoor.NotifyPropertyChanged("LockEdgeType")
m_rfCurrDoor.NotifyPropertyChanged("HingeEdgeType")
End If
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
Public ReadOnly Property MachinePositionMsg As String
Get
Return EgtMsg(50222)
End Get
End Property
#End Region
' Aggiorno la lista dei bevel
Private Sub RefreshEdgeTypeList()
' creo una variabile locale di tipo ObservableCollection
Dim rEdgeTypeList As New ObservableCollection(Of String)
' Carico questa lista leggendo il file Default.ini
DefaultGetPrivateProfileObservableCollection(S_EDGE, K_EDGETYPE_LIST_INI, rEdgeTypeList)
' Confronto la lista appena creata con le indicazioni raccolte nell'OptionModule (verifico se i bevel up e down sono selezionati)
' quindi aggiorno la lista eliminando se serve i bevel
SetEdgeTypeList(rEdgeTypeList, OptionModule.m_bBevelUp, OptionModule.m_bBevelDown)
' richiamo la proprietà pubblica di questa classe
EdgeTypeList = rEdgeTypeList
End Sub
' Controllo di eliminare un bevel dalla lista
Private Function CheckBevel(bBevel As Boolean, bValue As Boolean) As Integer
Dim bAnser As Integer
If bBevel And Not bValue Then
' significa che sta togliendo dalla lista
bAnser = 1
ElseIf Not bBevel And bValue Then
bAnser = 2
Else
bAnser = -1
End If
Return bAnser
End Function
' chiedo se vuole continuare
Private Function QuestionSetBevel(bCheckBevel As Integer) As Boolean
If bCheckBevel = 1 Then
If m_rfCurrDoor.LockEdgeType = "BU" Or m_rfCurrDoor.LockEdgeType = "BD" Or m_rfCurrDoor.HingeEdgeType = "BU" Or m_rfCurrDoor.HingeEdgeType = "BD" Then
If MessageBox.Show("It is a bevel of the current door. Do You want to proced?", "Caution", MessageBoxButton.YesNo, MessageBoxImage.Asterisk, MessageBoxResult.No) = MessageBoxResult.No Then
Return False
Else
' se decido di continuare
Return True
End If
Else
Return True
End If
ElseIf bCheckBevel = 2 Then
Return True
Else
Return False
End If
End Function
Sub New(rCurrDoor As Door)
m_rfCurrDoor = rCurrDoor
End Sub
#Region "COMMANDS"
#Region "CloseOptionsCommand"
''' <summary>
''' Returns a command that remove the current selected machining.
''' </summary>
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
''' <summary>
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
''' </summary>
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