Imports System.Collections.ObjectModel
Imports EgtUILib
Public Class OptionWindowVM
Inherits VMBase
Public ReadOnly Property LanguageList As ObservableCollection(Of Language)
Get
Return OptionModule.m_LanguageList
End Get
End Property
Private m_GeomTypeList As ObservableCollection(Of SceneSelModeOpt) = New ObservableCollection(Of SceneSelModeOpt)({SceneSelModeOpt.PARTCURVES, SceneSelModeOpt.PARTSURFACES, SceneSelModeOpt.PARTCURVESANDSURFACES})
Public ReadOnly Property GeomTypeList As ObservableCollection(Of SceneSelModeOpt)
Get
Return m_GeomTypeList
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 Property SelectedMillingGeomType As SceneSelModeOpt
Get
Return OptionModule.m_SelGeomMilling
End Get
Set(value As SceneSelModeOpt)
If WritePrivateProfileString(S_MACH, K_SELGEOMMILLING, CInt(value).ToString()) Then
OptionModule.m_SelGeomMilling = value
End If
End Set
End Property
Public Property SelectedDrillingGeomType As SceneSelModeOpt
Get
Return OptionModule.m_SelGeomDrilling
End Get
Set(value As SceneSelModeOpt)
If WritePrivateProfileString(S_MACH, K_SELGEOMDRILLING, CInt(value).ToString()) Then
OptionModule.m_SelGeomDrilling = value
End If
End Set
End Property
Public Property SelectedSawingGeomType As SceneSelModeOpt
Get
Return OptionModule.m_SelGeomSawing
End Get
Set(value As SceneSelModeOpt)
If WritePrivateProfileString(S_MACH, K_SELGEOMSAWING, CInt(value).ToString()) Then
OptionModule.m_SelGeomSawing = value
End If
End Set
End Property
Public Property SelectedPocketingGeomType As SceneSelModeOpt
Get
Return OptionModule.m_SelGeomPocketing
End Get
Set(value As SceneSelModeOpt)
If WritePrivateProfileString(S_MACH, K_SELGEOMPOCKETING, CInt(value).ToString()) Then
OptionModule.m_SelGeomPocketing = value
End If
End Set
End Property
Public Property SelectedMortisingGeomType As SceneSelModeOpt
Get
Return OptionModule.m_SelGeomMortising
End Get
Set(value As SceneSelModeOpt)
If WritePrivateProfileString(S_MACH, K_SELGEOMMORTISING, CInt(value).ToString()) Then
OptionModule.m_SelGeomMortising = value
End If
End Set
End Property
Public Property SelectedChiselingGeomType As SceneSelModeOpt
Get
Return OptionModule.m_SelGeomChiseling
End Get
Set(value As SceneSelModeOpt)
If WritePrivateProfileString(S_MACH, K_SELGEOMCHISELING, CInt(value).ToString()) Then
OptionModule.m_SelGeomChiseling = value
End If
End Set
End Property
Public Property GeometryTolerance As String
Get
Return LenToString(OptionModule.m_dGeometryTolerance, 5)
End Get
Set(value As String)
Dim dVal As Double = 0
If StringToLen(value, dVal) AndAlso dVal > 0 Then
OptionModule.m_dGeometryTolerance = dVal
Map.refProjectVM.GetController.SetSurfTmTolerance(OptionModule.m_dGeometryTolerance)
WritePrivateProfileString(S_GEOMDB, K_SURFTMTOLER, DoubleToString(OptionModule.m_dGeometryTolerance, 5))
End If
End Set
End Property
Public Property NewMachiningIsLastOne As Boolean
Get
Return OptionModule.m_bNewMachiningIsLastOne
End Get
Set(value As Boolean)
OptionModule.m_bNewMachiningIsLastOne = value
WritePrivateProfileString(S_OPTIONS, K_NEWMACHININGISLASTONE, If(value, "1", "0"))
End Set
End Property
Public Property UseDispositionScript As Boolean
Get
Return OptionModule.m_bUseDispositionScript
End Get
Set(value As Boolean)
OptionModule.m_bUseDispositionScript = value
WritePrivateProfileString(S_OPTIONS, K_USEDISPOSITIONSCRIPT, If(value, "1", "0"))
End Set
End Property
Public ReadOnly Property TopSceneBackground As Brush
Get
Return New SolidColorBrush(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 Brush
Get
Return New SolidColorBrush(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 Brush
Get
Return New SolidColorBrush(Color.FromArgb(CByte(255),
CByte(OptionModule.m_GridColor.R),
CByte(OptionModule.m_GridColor.G),
CByte(OptionModule.m_GridColor.B)))
End Get
End Property
Public ReadOnly Property DefMaterialColor As Brush
Get
Return New SolidColorBrush(Color.FromArgb(CByte(255),
CByte(OptionModule.m_DefMaterialColor.R),
CByte(OptionModule.m_DefMaterialColor.G),
CByte(OptionModule.m_DefMaterialColor.B)))
End Get
End Property
Public Property SmoothTriMesh As Boolean
Get
Return OptionModule.m_bTriMeshSmoothed
End Get
Set(value As Boolean)
OptionModule.m_bTriMeshSmoothed = value
WritePrivateProfileString(S_SCENE, K_SHOWTRIAADV, If(value, "1", "0"))
EgtSetShowTriaAdv(value)
End Set
End Property
Public Property DxfScaleFactor As String
Get
Return LenToString(OptionModule.m_dDxfScaleFactor, 5)
End Get
Set(value As String)
Dim dVal As Double = 0
If StringToLen(value, dVal) AndAlso dVal > 0 Then
OptionModule.m_dDxfScaleFactor = dVal
WritePrivateProfileString(S_IMPORT, K_DXFSCALE, DoubleToString(OptionModule.m_dDxfScaleFactor, 5))
Map.refProjectVM.GetController().SetScaleForDxfImport(OptionModule.m_dDxfScaleFactor)
End If
End Set
End Property
Public Property StlScaleFactor As String
Get
Return LenToString(OptionModule.m_dStlScaleFactor, 5)
End Get
Set(value As String)
Dim dVal As Double = 0
If StringToLen(value, dVal) AndAlso dVal > 0 Then
OptionModule.m_dStlScaleFactor = dVal
WritePrivateProfileString(S_IMPORT, K_STLSCALE, DoubleToString(OptionModule.m_dStlScaleFactor, 5))
Map.refProjectVM.GetController().SetScaleForStlImport(OptionModule.m_dStlScaleFactor)
End If
End Set
End Property
Public Property ImageScaleFactor As String
Get
Return LenToString(OptionModule.m_dImgScaleFactor, 5)
End Get
Set(value As String)
Dim dVal As Double = 0
If StringToLen(value, dVal) AndAlso dVal > 0 Then
OptionModule.m_dImgScaleFactor = dVal
WritePrivateProfileString(S_IMPORT, K_IMGSCALE, DoubleToString(OptionModule.m_dImgScaleFactor, 5))
Map.refProjectVM.GetController().SetScaleForImageImport(OptionModule.m_dImgScaleFactor)
End If
End Set
End Property
Public Property ImageWidth As String
Get
Return OptionModule.m_nImgWidth.ToString()
End Get
Set(value As String)
Dim nVal As Integer = 0
If Integer.TryParse(value, nVal) AndAlso nVal > 0 Then
OptionModule.m_nImgWidth = nVal
WritePrivateProfileString(S_EXPORT, K_IMGWIDTH, OptionModule.m_nImgWidth.ToString())
Map.refProjectVM.GetController().SetDefaultForImageExport(OptionModule.m_nImgWidth, OptionModule.m_nImgHeight)
End If
End Set
End Property
Public Property ImageHeight As String
Get
Return OptionModule.m_nImgHeight.ToString()
End Get
Set(value As String)
Dim nVal As Integer = 0
If Integer.TryParse(value, nVal) AndAlso nVal > 0 Then
OptionModule.m_nImgHeight = nVal
WritePrivateProfileString(S_EXPORT, K_IMGHEIGHT, OptionModule.m_nImgHeight.ToString())
Map.refProjectVM.GetController().SetDefaultForImageExport(OptionModule.m_nImgWidth, OptionModule.m_nImgHeight)
End If
End Set
End Property
' Definizione comandi
Private m_cmdCloseOptions As ICommand
Private m_cmdTopSceneBackground As ICommand
Private m_cmdBotSceneBackground As ICommand
Private m_cmdGridColor As ICommand
Private m_cmdDefMaterialColor As ICommand
#Region "Messages"
Public ReadOnly Property Title As String
Get
Return EgtMsg(MSG_MAINWINDOW + 5)
End Get
End Property
Public ReadOnly Property GenericMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 14)
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 TopSceneBackgroundMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 10)
End Get
End Property
Public ReadOnly Property BotSceneBackgroundMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 11)
End Get
End Property
Public ReadOnly Property GridColorMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 17)
End Get
End Property
Public ReadOnly Property SmoothTriMeshMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 18)
End Get
End Property
Public ReadOnly Property CADMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 15)
End Get
End Property
Public ReadOnly Property GeometryToleranceMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 13)
End Get
End Property
Public ReadOnly Property DefMaterialColorMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 12)
End Get
End Property
Public ReadOnly Property ImportMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 19)
End Get
End Property
Public ReadOnly Property DxfScaleFactorMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 20)
End Get
End Property
Public ReadOnly Property StlScaleFactorMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 21)
End Get
End Property
Public ReadOnly Property ImageScaleFactorMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 22)
End Get
End Property
Public ReadOnly Property ExportMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 23)
End Get
End Property
Public ReadOnly Property ImageMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 24)
End Get
End Property
Public ReadOnly Property ImageWidthMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 25)
End Get
End Property
Public ReadOnly Property ImageHeightMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 26)
End Get
End Property
Public ReadOnly Property CAMMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 16)
End Get
End Property
Public ReadOnly Property MachiningSelGeomMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 6)
End Get
End Property
Public ReadOnly Property GeomTypeMillingMsg As String
Get
Return EgtMsg(MSG_MACHININGSDBPAGE + 3)
End Get
End Property
Public ReadOnly Property GeomTypeDrillingMsg As String
Get
Return EgtMsg(MSG_MACHININGSDBPAGE + 1)
End Get
End Property
Public ReadOnly Property GeomTypeSawingMsg As String
Get
Return EgtMsg(MSG_MACHININGSDBPAGE + 2)
End Get
End Property
Public ReadOnly Property GeomTypePocketingMsg As String
Get
Return EgtMsg(MSG_MACHININGSDBPAGE + 4)
End Get
End Property
Public ReadOnly Property GeomTypeMortisingMsg As String
Get
Return EgtMsg(MSG_MACHININGSDBPAGE + 5)
End Get
End Property
Public ReadOnly Property GeomTypeChiselingMsg As String
Get
Return EgtMsg(MSG_MACHININGSDBPAGE + 9)
End Get
End Property
Public ReadOnly Property NewMachiningPosMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 7)
End Get
End Property
Public ReadOnly Property UseDispositionScriptMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 8)
End Get
End Property
#End Region
#Region "COMMANDS"
#Region "TopSceneBackground"
'''
''' Returns a command that remove the current selected machining.
'''
Public ReadOnly Property TopSceneBackground_Command() As ICommand
Get
If m_cmdTopSceneBackground Is Nothing Then
m_cmdTopSceneBackground = New RelayCommand(AddressOf TopSceneBackgroundCmd)
End If
Return m_cmdTopSceneBackground
End Get
End Property
'''
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
'''
Public Sub TopSceneBackgroundCmd()
' Recupero colore da Ini
Dim BackTopColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
' Eseguo modifica con dialogo
If SelectColor(BackTopColor, BackTopColor) Then
OptionModule.m_TopSceneBackground = BackTopColor
Map.refProjectVM.GetScene.SetViewBackground(OptionModule.m_TopSceneBackground, OptionModule.m_BotSceneBackground)
WritePrivateProfileColor(S_SCENE, K_BACKTOP, OptionModule.m_TopSceneBackground)
NotifyPropertyChanged("TopSceneBackground")
End If
End Sub
#End Region ' TopSceneBackground
#Region "BotSceneBackground"
'''
''' Returns a command that remove the current selected machining.
'''
Public ReadOnly Property BotSceneBackground_Command() As ICommand
Get
If m_cmdBotSceneBackground Is Nothing Then
m_cmdBotSceneBackground = New RelayCommand(AddressOf BotSceneBackgroundCmd)
End If
Return m_cmdBotSceneBackground
End Get
End Property
'''
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
'''
Public Sub BotSceneBackgroundCmd()
' Recupero colore da Ini
Dim BackBotColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
' Eseguo modifica con dialogo
If SelectColor(BackBotColor, BackBotColor) Then
OptionModule.m_BotSceneBackground = BackBotColor
Map.refProjectVM.GetScene.SetViewBackground(OptionModule.m_TopSceneBackground, OptionModule.m_BotSceneBackground)
WritePrivateProfileColor(S_SCENE, K_BACKBOTTOM, OptionModule.m_BotSceneBackground)
NotifyPropertyChanged("BotSceneBackground")
End If
End Sub
#End Region ' BotSceneBackground
#Region "GridColor"
'''
''' Returns a command that remove the current selected machining.
'''
Public ReadOnly Property GridColor_Command() As ICommand
Get
If m_cmdGridColor Is Nothing Then
m_cmdGridColor = New RelayCommand(AddressOf GridColorCmd)
End If
Return m_cmdGridColor
End Get
End Property
'''
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
'''
Public Sub GridColorCmd()
' Recupero colore da Ini
Dim GridColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_GRID, K_MINLNCOLOR, GridColor)
' Eseguo modifica con dialogo
If SelectColor(GridColor, GridColor) Then
OptionModule.m_GridColor = GridColor
IniFile.MinLnColor = GridColor
IniFile.MajLnColor = GridColor
EgtSetGridColor(IniFile.MinLnColor, IniFile.MajLnColor)
WritePrivateProfileColor(S_GRID, K_MINLNCOLOR, OptionModule.m_GridColor)
WritePrivateProfileColor(S_GRID, K_MAJLNCOLOR, OptionModule.m_GridColor)
EgtDraw()
NotifyPropertyChanged("GridColor")
End If
End Sub
#End Region ' GridColor
#Region "DefMaterialColor"
'''
''' Returns a command that remove the current selected machining.
'''
Public ReadOnly Property DefMaterialColor_Command() As ICommand
Get
If m_cmdDefMaterialColor Is Nothing Then
m_cmdDefMaterialColor = New RelayCommand(AddressOf DefMaterialColorCmd)
End If
Return m_cmdDefMaterialColor
End Get
End Property
'''
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
'''
Public Sub DefMaterialColorCmd()
' Recupero colore da Ini
Dim DefColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
' Eseguo modifica con dialogo
If SelectColor(DefColor, DefColor) Then
OptionModule.m_DefMaterialColor = DefColor
Map.refProjectVM.GetScene.SetDefaultMaterial(OptionModule.m_DefMaterialColor)
WritePrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, OptionModule.m_DefMaterialColor)
EgtDraw()
Application.Msn.NotifyColleagues(Application.UPDATEHEADERCOLOR, OptionModule.m_DefMaterialColor)
Application.Msn.NotifyColleagues(Application.LOADOBJTREE)
NotifyPropertyChanged("DefMaterialColor")
End If
End Sub
#End Region ' DefMaterialColor
#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 RelayCommand(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 OptionWindowV Then
Dim OptionsWindow As OptionWindowV = DirectCast(Window, OptionWindowV)
OptionsWindow.Close()
End If
Next
End Sub
#End Region ' CloseOptionsCommand
#End Region ' COMMANDS
Private Function SelectColor(Col As Color3d, ByRef NewCol As Color3d) As Boolean
' Recupero colori custom
Dim sCustomColors As String = ""
GetPrivateProfileString(S_SCENE, 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 System.Windows.Forms.ColorDialog
ColorDlg.FullOpen = True
ColorDlg.CustomColors = nCustomColors.ToArray()
ColorDlg.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})
WritePrivateProfileString(S_SCENE, K_CUSTOMCOLORS, sCustomColors)
Return True
End Function
End Class
Public Class GeomTypeConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Select Case CInt(value)
Case SceneSelModeOpt.PARTCURVES
Return EgtMsg(MSG_OPTIONPAGE + 3)
Case SceneSelModeOpt.PARTSURFACES
Return EgtMsg(MSG_OPTIONPAGE + 4)
Case Else
Return EgtMsg(MSG_OPTIONPAGE + 5)
End Select
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