Files
EgtCAM5/OptionsWindow/OptionWindowVM.vb
T
Emmanuele Sassi c4a9533a17 EgtCAM5 1.9f1 :
- Aggiunta finestra di expander per stime tempi e lunghezze di lavorazione.
2018-06-05 09:49:22 +00:00

491 lines
18 KiB
VB.net

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(m_GeometryTolerance, 5)
End Get
Set(value As String)
Dim dVal As Double = 0
If StringToLen(value, dVal) AndAlso dVal > 0 Then
m_GeometryTolerance = dVal
Map.refProjectVM.GetController.SetSurfTmTolerance(m_GeometryTolerance)
WritePrivateProfileString(S_GEOMDB, K_SURFTMTOLER, DoubleToString(m_GeometryTolerance, 5))
End If
End Set
End Property
Public Property NewMachiningIsLastOne As Boolean
Get
Return m_bNewMachiningIsLastOne
End Get
Set(value As Boolean)
m_bNewMachiningIsLastOne = value
WritePrivateProfileString(S_OPTIONS, K_NEWMACHININGISLASTONE, If(value, 1, 0).ToString)
End Set
End Property
Public Property UseDispositionScript As Boolean
Get
Return m_bUseDispositionScript
End Get
Set(value As Boolean)
m_bUseDispositionScript = value
WritePrivateProfileString(S_OPTIONS, K_USEDISPOSITIONSCRIPT, If(value, 1, 0).ToString)
End Set
End Property
Public ReadOnly Property TopSceneBackground As Brush
Get
Return New SolidColorBrush(Color.FromArgb(CByte(255),
CByte(m_TopSceneBackground.R),
CByte(m_TopSceneBackground.G),
CByte(m_TopSceneBackground.B)))
End Get
End Property
Public ReadOnly Property BotSceneBackground As Brush
Get
Return New SolidColorBrush(Color.FromArgb(CByte(255),
CByte(m_BotSceneBackground.R),
CByte(m_BotSceneBackground.G),
CByte(m_BotSceneBackground.B)))
End Get
End Property
Public ReadOnly Property DefMaterialColor As Brush
Get
Return New SolidColorBrush(Color.FromArgb(CByte(255),
CByte(m_DefMaterialColor.R),
CByte(m_DefMaterialColor.G),
CByte(m_DefMaterialColor.B)))
End Get
End Property
' Definizione comandi
Private m_cmdCloseOptions As ICommand
Private m_cmdTopSceneBackground As ICommand
Private m_cmdBotSceneBackground 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 CADMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 15)
End Get
End Property
Public ReadOnly Property CAMMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 16)
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 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 GeometryToleranceMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 13)
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
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 DefMaterialColorMsg As String
Get
Return EgtMsg(MSG_OPTIONPAGE + 12)
End Get
End Property
#End Region
#Region "COMMANDS"
#Region "TopSceneBackground"
''' <summary>
''' Returns a command that remove the current selected machining.
''' </summary>
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
''' <summary>
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
''' </summary>
Public Sub TopSceneBackgroundCmd()
Dim TopColorDialog As New System.Windows.Forms.ColorDialog
Dim BackTopColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
TopColorDialog.FullOpen = True
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
TopColorDialog.CustomColors = nCustomColors.ToArray()
TopColorDialog.Color = System.Drawing.Color.FromArgb(BackTopColor.A,
BackTopColor.R,
BackTopColor.G,
BackTopColor.B)
If TopColorDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
m_TopSceneBackground = New Color3d(TopColorDialog.Color.R,
TopColorDialog.Color.G,
TopColorDialog.Color.B,
TopColorDialog.Color.A)
Map.refProjectVM.GetScene.SetViewBackground(m_TopSceneBackground, m_BotSceneBackground)
WritePrivateProfileColor(S_SCENE, K_BACKTOP, m_TopSceneBackground)
sCustomColors = ""
For Each Color In TopColorDialog.CustomColors
sCustomColors &= Color & ", "
Next
sCustomColors.Trim({" "c, ","c})
WritePrivateProfileString(S_SCENE, K_CUSTOMCOLORS, sCustomColors)
NotifyPropertyChanged("TopSceneBackground")
End If
End Sub
#End Region ' TopSceneBackground
#Region "BotSceneBackground"
''' <summary>
''' Returns a command that remove the current selected machining.
''' </summary>
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
''' <summary>
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
''' </summary>
Public Sub BotSceneBackgroundCmd()
Dim BotColorDialog As New System.Windows.Forms.ColorDialog
Dim BackBotColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
BotColorDialog.FullOpen = True
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
BotColorDialog.CustomColors = nCustomColors.ToArray()
BotColorDialog.Color = System.Drawing.Color.FromArgb(BackBotColor.A,
BackBotColor.R,
BackBotColor.G,
BackBotColor.B)
If BotColorDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
m_BotSceneBackground = New Color3d(BotColorDialog.Color.R,
BotColorDialog.Color.G,
BotColorDialog.Color.B,
BotColorDialog.Color.A)
Map.refProjectVM.GetScene.SetViewBackground(m_TopSceneBackground, m_BotSceneBackground)
WritePrivateProfileColor(S_SCENE, K_BACKBOTTOM, m_BotSceneBackground)
sCustomColors = ""
For Each Color In BotColorDialog.CustomColors
sCustomColors &= Color & ", "
Next
sCustomColors.Trim({" "c, ","c})
WritePrivateProfileString(S_SCENE, K_CUSTOMCOLORS, sCustomColors)
NotifyPropertyChanged("BotSceneBackground")
End If
End Sub
#End Region ' BotSceneBackground
#Region "DefMaterialColor"
''' <summary>
''' Returns a command that remove the current selected machining.
''' </summary>
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
''' <summary>
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
''' </summary>
Public Sub DefMaterialColorCmd()
Dim DefColorDialog As New System.Windows.Forms.ColorDialog
Dim DefColor As New Color3d(192, 192, 192)
GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
DefColorDialog.FullOpen = True
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
DefColorDialog.CustomColors = nCustomColors.ToArray()
DefColorDialog.Color = System.Drawing.Color.FromArgb(DefColor.A,
DefColor.R,
DefColor.G,
DefColor.B)
If DefColorDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
m_DefMaterialColor = New Color3d(DefColorDialog.Color.R,
DefColorDialog.Color.G,
DefColorDialog.Color.B,
100)
Map.refProjectVM.GetScene.SetDefaultMaterial(m_DefMaterialColor)
WritePrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, m_DefMaterialColor)
sCustomColors = ""
For Each Color In DefColorDialog.CustomColors
sCustomColors &= Color & ", "
Next
sCustomColors.Trim({" "c, ","c})
WritePrivateProfileString(S_SCENE, K_CUSTOMCOLORS, sCustomColors)
EgtDraw()
Application.Msn.NotifyColleagues(Application.UPDATEHEADERCOLOR, m_DefMaterialColor)
Application.Msn.NotifyColleagues(Application.LOADOBJTREE)
NotifyPropertyChanged("DefMaterialColor")
End If
End Sub
#End Region ' DefMaterialColor
#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 RelayCommand(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 OptionWindowV Then
Dim OptionsWindow As OptionWindowV = DirectCast(Window, OptionWindowV)
OptionsWindow.Close()
End If
Next
End Sub
#End Region ' CloseOptionsCommand
#End Region ' COMMANDS
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