Imports System.Drawing.Text Imports System.Collections.ObjectModel Imports System.IO 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 Private m_UnitMeasureList As List(Of String) = New List(Of String)({"mm", "inch", EgtMsg(MSG_OPTIONPAGE + 45)}) Public ReadOnly Property UnitMeasureList As List(Of String) Get Return m_UnitMeasureList End Get End Property Private m_FontList As New ObservableCollection(Of String) Public ReadOnly Property FontList As ObservableCollection(Of String) Get Dim sNfeDir As String = String.Empty GetPrivateProfileString(S_GEOMDB, K_NFEFONTDIR, "", sNfeDir) Dim EgtFontList As String() = Directory.GetFiles(sNfeDir) For i = 0 To EgtFontList.Count - 1 m_FontList.Add(Path.GetFileName(EgtFontList(i))) Next Dim fonts As New InstalledFontCollection For i = 0 To fonts.Families.Count - 1 m_FontList.Add(fonts.Families(i).Name) Next Return m_FontList End Get End Property Private m_ScaleDXFList As List(Of String) = New List(Of String)({"mm", "inch", EgtMsg(MSG_OPTIONPAGE + 46)}) Public ReadOnly Property ScaleDXFList As List(Of String) Get Return m_ScaleDXFList End Get End Property Private m_ScaleSTLList As List(Of String) = New List(Of String)({"mm", "inch", EgtMsg(MSG_OPTIONPAGE + 46)}) Public ReadOnly Property ScaleSTLList As List(Of String) Get Return m_ScaleSTLList End Get End Property Private m_ScaleImageList As List(Of String) = New List(Of String)({"mm", "inch", EgtMsg(MSG_OPTIONPAGE + 46)}) Public ReadOnly Property ScaleImageList As List(Of String) Get Return m_ScaleImageList 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 ThickLine As Boolean Get Return OptionModule.m_bThickLine End Get Set(value As Boolean) OptionModule.m_bThickLine = value WritePrivateProfileString(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 WritePrivateProfileString(S_SCENE, K_SHOWTRIAADV, If(value, "1", "0")) EgtSetShowTriaAdv(value) End Set End Property Public Property SelectedTextFont As String Get Return m_FontList(m_FontList.IndexOf(OptionModule.m_sFontText)) End Get Set(value As String) OptionModule.m_sFontText = value Dim sNfeDir As String = String.Empty GetPrivateProfileString(S_GEOMDB, K_NFEFONTDIR, "", sNfeDir) EgtSetFont(sNfeDir, OptionModule.m_sFontText) WritePrivateProfileString(S_GEOMDB, K_DEFAULTFONT, OptionModule.m_sFontText) 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) NotifyPropertyChanged("DxfScaleFactor") 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) NotifyPropertyChanged("StlScaleFactor") 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) NotifyPropertyChanged("ImageScaleFactor") 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 Public Property ExtLineLen As String Get Return LenToString(OptionModule.m_dExtLineLen, 5) End Get Set(value As String) Dim dVal As Double = 0 If StringToLen(value, dVal) AndAlso dVal > 0 Then OptionModule.m_dExtLineLen = dVal EgtSetCurrDimensionStyle(m_dExtLineLen, m_dArrowLen, m_dTextDist, m_nLenIsMM, m_nDecDigit, m_sFont, m_dTextHeight) WritePrivateProfileString(S_DIMENSIONSTYLE, K_EXTLINELEN, DoubleToString(OptionModule.m_dExtLineLen, 5)) End If End Set End Property Public Property ArrowLen As String Get Return LenToString(OptionModule.m_dArrowLen, 5) End Get Set(value As String) Dim dVal As Double = 0 If StringToLen(value, dVal) AndAlso dVal > 0 Then OptionModule.m_dArrowLen = dVal EgtSetCurrDimensionStyle(m_dExtLineLen, m_dArrowLen, m_dTextDist, m_nLenIsMM, m_nDecDigit, m_sFont, m_dTextHeight) WritePrivateProfileString(S_DIMENSIONSTYLE, K_ARROWLEN, DoubleToString(OptionModule.m_dArrowLen, 5)) End If End Set End Property Public Property TextDist As String Get Return LenToString(OptionModule.m_dTextDist, 5) End Get Set(value As String) Dim dVal As Double = 0 If StringToLen(value, dVal) AndAlso dVal > 0 Then OptionModule.m_dTextDist = dVal EgtSetCurrDimensionStyle(m_dExtLineLen, m_dArrowLen, m_dTextDist, m_nLenIsMM, m_nDecDigit, m_sFont, m_dTextHeight) WritePrivateProfileString(S_DIMENSIONSTYLE, K_TEXTDIST, DoubleToString(OptionModule.m_dTextDist, 5)) End If End Set End Property Public Property SelectedUnitMeasure As String Get If OptionModule.m_nLenIsMM = 0 Then Return "inch" ElseIf OptionModule.m_nLenIsMM = 1 Then Return "mm" Else Return EgtMsg(MSG_OPTIONPAGE + 45) End If End Get Set(value As String) Dim nVal As Integer = 2 If value = "inch" Then nVal = 0 ElseIf value = "mm" Then nVal = 1 End If OptionModule.m_nLenIsMM = nVal EgtSetCurrDimensionStyle(m_dExtLineLen, m_dArrowLen, m_dTextDist, m_nLenIsMM, m_nDecDigit, m_sFont, m_dTextHeight) WritePrivateProfileString(S_DIMENSIONSTYLE, K_LENISMM, OptionModule.m_nLenIsMM.ToString()) End Set End Property Public Property DecDigit As String Get Return OptionModule.m_nDecDigit.ToString() End Get Set(value As String) Dim nVal As Integer = 0 If Integer.TryParse(value, nVal) AndAlso nVal > 0 Then OptionModule.m_nDecDigit = nVal EgtSetCurrDimensionStyle(m_dExtLineLen, m_dArrowLen, m_dTextDist, m_nLenIsMM, m_nDecDigit, m_sFont, m_dTextHeight) WritePrivateProfileString(S_DIMENSIONSTYLE, K_DECDIGIT, OptionModule.m_nDecDigit.ToString()) End If End Set End Property Public Property SelectedFont As String Get Return m_FontList(m_FontList.IndexOf(OptionModule.m_sFont)) End Get Set(value As String) OptionModule.m_sFont = value EgtSetCurrDimensionStyle(m_dExtLineLen, m_dArrowLen, m_dTextDist, m_nLenIsMM, m_nDecDigit, m_sFont, m_dTextHeight) WritePrivateProfileString(S_DIMENSIONSTYLE, K_DIMFONT, OptionModule.m_sFont) End Set End Property Public Property TextHeight As String Get Return LenToString(OptionModule.m_dTextHeight, 5) End Get Set(value As String) Dim dVal As Double = 0 If StringToLen(value, dVal) AndAlso dVal > 0 Then OptionModule.m_dTextHeight = dVal EgtSetCurrDimensionStyle(m_dExtLineLen, m_dArrowLen, m_dTextDist, m_nLenIsMM, m_nDecDigit, m_sFont, m_dTextHeight) WritePrivateProfileString(S_DIMENSIONSTYLE, K_TEXTHEIGHT, DoubleToString(OptionModule.m_dTextHeight, 5)) End If End Set End Property Private m_DXFScaleEnable As Boolean = False Public Property DXFScaleEnable As Boolean Get Return m_DXFScaleEnable End Get Set(value As Boolean) m_DXFScaleEnable = value NotifyPropertyChanged("DXFScaleEnable") End Set End Property Private m_STLScaleEnable As Boolean = False Public Property STLScaleEnable As Boolean Get Return m_STLScaleEnable End Get Set(value As Boolean) m_STLScaleEnable = value NotifyPropertyChanged("STLScaleEnable") End Set End Property Private m_ImageScaleEnable As Boolean = False Public Property ImageScaleEnable As Boolean Get Return m_ImageScaleEnable End Get Set(value As Boolean) m_ImageScaleEnable = value NotifyPropertyChanged("ImageScaleEnable") End Set End Property Public Property SelectedDXFScale As String Get If Math.Abs(OptionModule.m_dDxfScaleFactor - ONEMM) < EPS_SMALL * 10 Then Return ScaleDXFList(ScaleDXFList.IndexOf("mm")) ElseIf Math.Abs(OptionModule.m_dDxfScaleFactor - ONEINCH) < EPS_SMALL * 10 Then Return ScaleDXFList(ScaleDXFList.IndexOf("inch")) Else DXFScaleEnable = True Return ScaleDXFList(ScaleDXFList.IndexOf(EgtMsg(MSG_OPTIONPAGE + 46))) End If End Get Set(value As String) If value = "mm" Then DxfScaleFactor = LenToString(ONEMM, 3) DXFScaleEnable = False ElseIf value = "inch" Then DxfScaleFactor = LenToString(ONEINCH, 4) DXFScaleEnable = False Else DXFScaleEnable = True DxfScaleFactor = LenToString(OptionModule.m_dDxfScaleFactor, 4) End If End Set End Property Public Property SelectedSTLScale As String Get If Math.Abs(OptionModule.m_dStlScaleFactor - ONEMM) < EPS_SMALL * 10 Then Return ScaleSTLList(ScaleSTLList.IndexOf("mm")) ElseIf Math.Abs(OptionModule.m_dStlScaleFactor - ONEINCH) < EPS_SMALL * 10 Then Return ScaleSTLList(ScaleSTLList.IndexOf("inch")) Else STLScaleEnable = True Return ScaleSTLList(ScaleSTLList.IndexOf(EgtMsg(MSG_OPTIONPAGE + 46))) End If End Get Set(value As String) If value = "mm" Then StlScaleFactor = LenToString(ONEMM, 3) STLScaleEnable = False ElseIf value = "inch" Then StlScaleFactor = LenToString(ONEINCH, 4) STLScaleEnable = False Else StlScaleFactor = LenToString(OptionModule.m_dStlScaleFactor, 4) STLScaleEnable = True End If End Set End Property Public Property SelectedImageScale As String Get If Math.Abs(OptionModule.m_dImgScaleFactor - ONEMM) < EPS_SMALL * 10 Then Return ScaleImageList(ScaleImageList.IndexOf("mm")) ElseIf Math.Abs(OptionModule.m_dImgScaleFactor - ONEINCH) < EPS_SMALL * 10 Then Return ScaleImageList(ScaleImageList.IndexOf("inch")) Else ImageScaleEnable = True Return ScaleImageList(ScaleImageList.IndexOf(EgtMsg(MSG_OPTIONPAGE + 46))) ImageScaleEnable = True End If End Get Set(value As String) If value = "mm" Then ImageScaleFactor = LenToString(ONEMM, 3) ImageScaleEnable = False ElseIf value = "inch" Then ImageScaleFactor = LenToString(ONEINCH, 4) ImageScaleEnable = False Else ImageScaleFactor = LenToString(OptionModule.m_dImgScaleFactor, 4) ImageScaleEnable = True End If End Set End Property Public Property SpecialOn As Boolean Get Return OptionModule.m_bSpecialOn End Get Set(value As Boolean) OptionModule.m_bSpecialOn = value WritePrivateProfileString(S_SPECIAL, K_SPECIALENABLE, If( value, "1", "0")) End Set End Property Public ReadOnly Property BeamEnabled As Boolean Get Return (IniFile.m_nKeyOptions And KEY_OPT.BEAM) <> 0 End Get End Property Public ReadOnly Property BeamActive As Boolean Get Return IniFile.IsActiveBeam() End Get End Property Public Property BeamOn As Boolean Get Return BeamEnabled AndAlso OptionModule.m_bBeamOn End Get Set(value As Boolean) OptionModule.m_bBeamOn = value WritePrivateProfileString(S_BEAM, K_BEAMENABLE, If( value, "1", "0")) End Set End Property Public ReadOnly Property WallEnabled As Boolean Get Return (IniFile.m_nKeyOptions And KEY_OPT.WALL) <> 0 End Get End Property Public ReadOnly Property WallActive As Boolean Get Return IniFile.IsActiveWall() End Get End Property Public Property WallOn As Boolean Get Return WallEnabled AndAlso OptionModule.m_bWallOn End Get Set(value As Boolean) OptionModule.m_bWallOn = value WritePrivateProfileString(S_WALL, K_WALLENABLE, If( value, "1", "0")) End Set End Property Public ReadOnly Property DoorsEnabled As Boolean Get Return (IniFile.m_nKeyOptions And KEY_OPT.DOORS) <> 0 End Get End Property Public Property DoorsOn As Boolean Get Return DoorsEnabled AndAlso OptionModule.m_bDoorsOn End Get Set(value As Boolean) OptionModule.m_bDoorsOn = value WritePrivateProfileString(S_DOORS, K_DDFENABLE, If( value, "1", "0")) End Set End Property Public ReadOnly Property GunstockEnabled As Boolean Get Return (IniFile.m_nKeyOptions And KEY_OPT.GUNSTOCK) <> 0 End Get End Property Public Property GunstockOn As Boolean Get Return OptionModule.m_bGunstockOn End Get Set(value As Boolean) OptionModule.m_bGunstockOn = value WritePrivateProfileString(S_GUNSTOCK, K_GUNSTOCKENABLE, If( value, "1", "0")) 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_cmdUpdateLicenceCmd As ICommand Private m_cmdDefMaterialColor As ICommand Private m_cmdAddMachineCmd As ICommand Private m_cmdExportMachineCmd As ICommand Private m_cmdUpdateBeamCmd As ICommand Private m_cmdUpdateWallCmd 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 ThickLineMsg As String Get Return EgtMsg( 6536) ' Linee spesse End Get End Property Public ReadOnly Property SmoothTriMeshMsg As String Get Return EgtMsg( 6518) ' Superfici smussate End Get End Property Public ReadOnly Property UpdateLicenceMsg As String Get Return EgtMsg( 6553) ' Aggiorna licenza 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 DimensionMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 44) ' Quotatura End Get End Property Public ReadOnly Property ExtLineLenMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 37) ' Estensione linea End Get End Property Public ReadOnly Property ArrowLenMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 38) ' Dimensione freccia End Get End Property Public ReadOnly Property TextDistMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 39) ' Distanza messaggio End Get End Property Public ReadOnly Property LenIsMMMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 40) ' Unità di misura End Get End Property Public ReadOnly Property DecDigitMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 41) ' Numero dicmali End Get End Property Public ReadOnly Property FontMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 42) ' Caretteri End Get End Property Public ReadOnly Property TextHeightMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 43) ' Dimensione testo 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 UnitScaleMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 47) ' Unità di scala End Get End Property Public ReadOnly Property FactorScaleMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 48) ' Fattore di scala 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 Public ReadOnly Property AddMachineMsg As String Get Return EgtMsg(MSG_OPTIONPAGE + 27) ' Aggiungi macchina End Get End Property Public ReadOnly Property ExportMachineMsg As String Get Return EgtMsg(6549) ' Esporta macchina End Get End Property Public ReadOnly Property ExtraMsg As String Get Return "Extra" End Get End Property Public ReadOnly Property SpecialMsg As String Get Return "Special" End Get End Property Public ReadOnly Property BeamMsg As String Get Return "Beam" End Get End Property Public ReadOnly Property WallMsg As String Get Return "Wall" End Get End Property Public ReadOnly Property DoorsMsg As String Get Return "Doors" End Get End Property Public ReadOnly Property GunstockMsg As String Get Return "Gunstock" End Get End Property Public ReadOnly Property UpdateMsg As String Get Return EgtMsg(6554) ' Aggiorna 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() Map.refManageLayerExpanderVM.UpdateHeaderColor(OptionModule.m_DefMaterialColor) Map.refManageLayerExpanderVM.LoadObjTree() NotifyPropertyChanged("DefMaterialColor") End If End Sub #End Region ' DefMaterialColor #Region "UpdateLicence" ''' ''' Returns a command that update the licence. ''' Public ReadOnly Property UpdateLicence_Command() As ICommand Get If m_cmdUpdateLicenceCmd Is Nothing Then m_cmdUpdateLicenceCmd = New RelayCommand(AddressOf UpdateLicenceCmd) End If Return m_cmdUpdateLicenceCmd End Get End Property ''' ''' Update the licence. ''' Public Sub UpdateLicenceCmd() ' Apro dialogo per richiesta file licenza Dim LicDlg As New Microsoft.Win32.OpenFileDialog() With { .DefaultExt = ".lic", .Filter = "Licences (.lic)|*.lic", .CheckFileExists = True, .ValidateNames = True } If LicDlg.ShowDialog() = True 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(IniFile.m_sConfigDir), StringComparison.OrdinalIgnoreCase) Then Try File.Copy(LicDlg.FileName, Path.Combine(IniFile.m_sConfigDir, LicDlg.SafeFileName), True) Catch ex As Exception Return End Try End If ' Imposto il nuovo file di licenza nell'Ini WritePrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName) End If End Sub #End Region ' AddMachine #Region "AddMachine" ''' ''' Returns a command that add a new machining. ''' Public ReadOnly Property AddMachine_Command() As ICommand Get If m_cmdAddMachineCmd Is Nothing Then m_cmdAddMachineCmd = New RelayCommand(AddressOf AddMachineCmd) End If Return m_cmdAddMachineCmd End Get End Property ''' ''' Add a new machining. ''' Public Sub AddMachineCmd() ' Apro dialogo per richiesta file zip di macchina Dim MachDlg As New Microsoft.Win32.OpenFileDialog() With { .DefaultExt = ".zip", .Filter = "Machines (.zip)|*.zip", .CheckFileExists = True, .ValidateNames = True } If MachDlg.ShowDialog() <> True Then Return Dim sMachZip As String = MachDlg.FileName Dim sMachName As String = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(sMachZip)) Dim sMachDir As String = Path.Combine(IniFile.m_sMachinesRoot, sMachName) ' Preparo direttorio temporaneo Dim sTempDir As String = Path.Combine(IniFile.m_sMachinesRoot, "Temp") If My.Computer.FileSystem.DirectoryExists( sTempDir) Then My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CreateDirectory( sTempDir) ' Unzip nel direttorio temporaneo Using zip As New Ionic.Zip.ZipFile(sMachZip) zip.ExtractAll( sTempDir, Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite) End Using ' Se non è una macchina segnalo il problema ed esco If Not My.Computer.FileSystem.FileExists( Path.Combine( sTempDir, sMachName, sMachName & ".ini")) Or Not My.Computer.FileSystem.FileExists( Path.Combine( sTempDir, sMachName, sMachName & ".mlde")) Then ' Il file {0} non contiene una macchina - Avviso Dim sOut As String = String.Format(EgtMsg(MSG_OPTIONPAGE + 29), sMachZip) MessageBox.Show(sOut, EgtMsg(MSG_MESSAGEBOX + 2), MessageBoxButton.OK, MessageBoxImage.Warning) ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End If ' Imposto data e ora correnti al file mlde della macchina Try File.SetLastWriteTime( Path.Combine( sTempDir, sMachName, sMachName & ".mlde"), System.DateTime.Now) Catch ex As Exception End Try ' Verifico esistenza di una macchina con lo stesso nome Dim bOldExists As Boolean = My.Computer.FileSystem.DirectoryExists( sMachDir) Dim bUpdate As Boolean = True If bOldExists Then Dim MachBox As New MachineBox( Application.Current.MainWindow, sMachName) Select MachBox.ShowDialog() Case MessageBoxResult.Yes bUpdate = False Case MessageBoxResult.No bUpdate = True Case MessageBoxResult.Cancel ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End Select ' Faccio una copia di backup della macchina corrente Dim sBackupDir As String = sMachDir & ".old" If My.Computer.FileSystem.DirectoryExists( sBackupDir) Then My.Computer.FileSystem.DeleteDirectory( sBackupDir, FileIO.DeleteDirectoryOption.DeleteAllContents) End If Try My.Computer.FileSystem.MoveDirectory( sMachDir, sBackupDir, True) Catch ex As Exception ' Ripristino lo stato originale ed esco My.Computer.FileSystem.MoveDirectory( sBackupDir, sMachDir, True) ' L'aggiornamento della macchina "{0}" non è riuscito. Dim sKo As String = String.Format(EgtMsg(MSG_OPTIONPAGE + 35), sMachName) EgtOutLog( sKo) MessageBox.Show(sKo, EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK) Return End Try End If ' Installo la macchina My.Computer.FileSystem.MoveDirectory( Path.Combine( sTempDir, sMachName), sMachDir, True) ' Se è un aggiornamento, recupero utensili, lavorazioni, attrezzaggi e dati per travi If bOldExists And bUpdate Then Dim sBackupDir As String = sMachDir & ".old" If My.Computer.FileSystem.DirectoryExists( sBackupDir & "\Tools") Then If My.Computer.FileSystem.DirectoryExists( sMachDir & "\Tools") Then My.Computer.FileSystem.DeleteDirectory( sMachDir & "\Tools", FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CopyDirectory( sBackupDir & "\Tools", sMachDir & "\Tools", True) End If If My.Computer.FileSystem.DirectoryExists( sBackupDir & "\Machinings") Then If My.Computer.FileSystem.DirectoryExists( sMachDir & "\Machinings") Then My.Computer.FileSystem.DeleteDirectory( sMachDir & "\Machinings", FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CopyDirectory( sBackupDir & "\Machinings", sMachDir & "\Machinings", True) End If If My.Computer.FileSystem.DirectoryExists( sBackupDir & "\SetUp") Then If My.Computer.FileSystem.DirectoryExists( sMachDir & "\SetUp") Then My.Computer.FileSystem.DeleteDirectory( sMachDir & "\SetUp", FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CopyDirectory( sBackupDir & "\SetUp", sMachDir & "\SetUp", True) End If If My.Computer.FileSystem.DirectoryExists( sBackupDir & "\Beam") Then ' Flag per sovrascrivere vecchio file BeamData.lua con nuovo Dim bBeamDataExists As Boolean = False Const sBeamData As String = "\BeamData.lua" ' Flag per sovrascrivere vecchio file MachiningTypes.ini Dim bMchgTypesExists As Boolean = False Const sMchgTypes As String = "\MachiningTypes.ini" If My.Computer.FileSystem.DirectoryExists( sMachDir & "\Beam") Then If My.Computer.FileSystem.FileExists( sMachDir & "\Beam" & sBeamData) Then bBeamDataExists = True My.Computer.FileSystem.MoveFile( sMachDir & "\Beam" & sBeamData, sMachDir & sBeamData, True) End If If My.Computer.FileSystem.FileExists( sMachDir & "\Beam" & sMchgTypes) Then bMchgTypesExists = True My.Computer.FileSystem.MoveFile( sMachDir & "\Beam" & sMchgTypes, sMachDir & sMchgTypes, True) End If My.Computer.FileSystem.DeleteDirectory( sMachDir & "\Beam", FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CopyDirectory( sBackupDir & "\Beam", sMachDir & "\Beam", True) If bBeamDataExists Then My.Computer.FileSystem.MoveFile( sMachDir & sBeamData, sMachDir & "\Beam" & sBeamData, True) If bMchgTypesExists Then My.Computer.FileSystem.MoveFile( sMachDir & sMchgTypes, sMachDir & "\Beam" & sMchgTypes, True) End If If My.Computer.FileSystem.DirectoryExists( sBackupDir & "\Wall") Then ' Flag per sovrascrittura vecchio file WallData.lua con nuovo Dim bWallDataExists As Boolean = False Const sWallData As String = "\WallData.lua" ' Flag per sovrascrivere vecchio file MachiningTypes.ini Dim bMchgTypesExists As Boolean = False Const sMchgTypes As String = "\MachiningTypes.ini" If My.Computer.FileSystem.DirectoryExists( sMachDir & "\Wall") Then If My.Computer.FileSystem.FileExists( sMachDir & "\Wall" & sWallData) Then bWallDataExists = True My.Computer.FileSystem.MoveFile( sMachDir & "\Wall" & sWallData, sMachDir & sWallData, True) End If If My.Computer.FileSystem.FileExists( sMachDir & "\Wall" & sMchgTypes) Then bMchgTypesExists = True My.Computer.FileSystem.MoveFile( sMachDir & "\Wall" & sMchgTypes, sMachDir & sMchgTypes, True) End If My.Computer.FileSystem.DeleteDirectory( sMachDir & "\Wall", FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CopyDirectory( sBackupDir & "\Wall", sMachDir & "\Wall", True) If bWallDataExists Then My.Computer.FileSystem.MoveFile( sMachDir & sWallData, sMachDir & "\Wall" & sWallData, True) If bMchgTypesExists Then My.Computer.FileSystem.MoveFile( sMachDir & sMchgTypes, sMachDir & "\Wall" & sMchgTypes, True) End If End If 'La macchina "{0}" è stata aggiornata con successo. Dim sOk As String = String.Format(EgtMsg(MSG_OPTIONPAGE + 30), sMachName) EgtOutLog( sOk) MessageBox.Show(sOk, EgtMsg(MSG_MESSAGEBOX + 3), MessageBoxButton.OK) ' Rimuovo il direttorio temporaneo My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) ' Aggiorno la lista delle macchina Map.refMachinePanelVM.InsertMachine(sMachDir) End Sub #End Region ' AddMachine #Region "ExportMachine" ''' ''' Returns a command that export a new machining. ''' Public ReadOnly Property ExportMachine_Command() As ICommand Get If m_cmdExportMachineCmd Is Nothing Then m_cmdExportMachineCmd = New RelayCommand(AddressOf ExportMachineCmd) End If Return m_cmdExportMachineCmd End Get End Property ''' ''' Export the current machine. ''' Public Sub ExportMachineCmd() ' Recupero il nome della macchina correntemente selezionata Dim sCurrMachineName As String = String.Empty EgtGetCurrMachineName(sCurrMachineName) ' Creo il dialog per scegliere dove salvare lo zip Dim sDirPath As String = String.Empty Dim folderDialog As New Windows.Forms.FolderBrowserDialog folderDialog.Description = EgtMsg(6550) If folderDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then Return End If sDirPath = folderDialog.SelectedPath ' Creo zip file da salvare Dim sZipToCreate As String = sDirPath & "\" & sCurrMachineName & ".zip" If File.Exists(sZipToCreate) Then File.Delete(sZipToCreate) End If Try Using zip As New Ionic.Zip.ZipFile(sZipToCreate) zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always zip.AlternateEncoding = Text.Encoding.UTF8 ' aggiungo i file della Macchina Dim sMachineDir As String = IniFile.m_sMachinesRoot & "\" & sCurrMachineName If Directory.Exists(sMachineDir) Then zip.AddSelectedFiles( "name != *\.git\*.* and name != *.git*", sMachineDir, sCurrMachineName, True) End If ' salvo lo zip zip.Save() End Using Catch ex1 As Exception EgtOutLog("Exception in zip: " & ex1.ToString()) ' L'esportazione della macchina "{0}" non è riuscita. Dim sKo As String = String.Format(EgtMsg(6551), sCurrMachineName) EgtOutLog(sKo) MessageBox.Show(sKo, EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK) return End Try 'La macchina "{0}" è stata esportata con successo. Dim sOk As String = String.Format(EgtMsg(6552), sCurrMachineName) EgtOutLog(sOk) MessageBox.Show(sOk, EgtMsg(MSG_MESSAGEBOX + 3), MessageBoxButton.OK) End Sub #End Region ' ExportMachine #Region "UpdateBeam" Public ReadOnly Property UpdateBeam_Command() As ICommand Get If m_cmdUpdateBeamCmd Is Nothing Then m_cmdUpdateBeamCmd = New RelayCommand(AddressOf UpdateBeamCmd) End If Return m_cmdUpdateBeamCmd End Get End Property Public Sub UpdateBeamCmd() ' Recupero la versione del programma in esecuzione Dim sExeVer As String = IniFile.GetProgramVersion() ' Verifico presenza di una precedente installazione del Beam Dim sBeamVer As String = "" IniFile.GetSpecialLuaVersion( IniFile.m_sBeamDirPath, sBeamVer) If String.IsNullOrEmpty( sBeamVer) Then ' Il modulo "{0}" non è stato trovato, impossibile aggiornare. - Avviso Dim sOut As String = String.Format(EgtMsg(6555), "Beam") MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Esco Return End If ' Apro dialogo per richiesta file zip del Beam Dim BeamDlg As New Microsoft.Win32.OpenFileDialog() With { .DefaultExt = ".zip", .Filter = "Beam (.zip)|*.zip", .CheckFileExists = True, .ValidateNames = True } If BeamDlg.ShowDialog() <> True Then Return Dim sBeamZip As String = BeamDlg.FileName ' Preparo direttorio temporaneo Dim sTempDir As String = Path.Combine(IniFile.m_sTempDir, "Beam") If My.Computer.FileSystem.DirectoryExists( sTempDir) Then My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CreateDirectory( sTempDir) ' Unzip nel direttorio temporaneo Using zip As New Ionic.Zip.ZipFile(sBeamZip) zip.ExtractAll( sTempDir, Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite) End Using ' Recupero i dati del nuovo Beam Dim sNewName = "" Dim sNewVer = "" Dim sNewMinExe = "" IniFile.GetSpecialLuaData( sTempDir, sNewName, sNewVer, sNewMinExe) ' Verifico che sia veramente il Beam If String.Compare(sNewName, "Beam") <> 0 Then ' Il file zip non contiene il modulo "{0}". - Avviso Dim sOut As String = String.Format(EgtMsg(6556), "Beam") MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End If ' Verifico la versione minima del programma If String.Compare(sExeVer, sNewMinExe) < 0 Then ' Il nuovo modulo "{0}" richiede un programma con versione minima {1}. - Avviso Dim sOut As String = String.Format(EgtMsg(6557), "Beam", sNewMinExe) MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End If ' Verifico la versione del Beam e se più vecchia chiedo cosa fare If String.Compare(sNewVer, sBeamVer) < 0 Then ' La versione del nuovo modulo "{0}" è più vecchia dell'attuale. Vuoi sovrascrivere lo stesso ? Dim sOut As String = String.Format(EgtMsg(6558), "Beam") if MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15003), MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.No Then ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End If End If ' Faccio una copia di backup del Beam corrente Dim sBackupDir As String = IniFile.m_sBeamDirPath & ".old" If My.Computer.FileSystem.DirectoryExists( sBackupDir) Then My.Computer.FileSystem.DeleteDirectory( sBackupDir, FileIO.DeleteDirectoryOption.DeleteAllContents) End If Try My.Computer.FileSystem.MoveDirectory( IniFile.m_sBeamDirPath, sBackupDir, True) Catch ex As Exception ' Ripristino lo stato originale ed esco My.Computer.FileSystem.MoveDirectory( sBackupDir, IniFile.m_sBeamDirPath, True) ' L'aggiornamento del modulo "{0}" non è riuscito. - Errore Dim sOut As String = String.Format(EgtMsg(6559), "Beam") EgtOutLog( sOut) MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End Try ' Installo il Beam My.Computer.FileSystem.MoveDirectory( sTempDir, IniFile.m_sBeamDirPath, True) ' Il modulo "{0}" è stata aggiornato con successo. - Info Dim sOk As String = String.Format(EgtMsg(6560), "Beam") EgtOutLog( sOk) MessageBox.Show(Application.Current.MainWindow, sOk, EgtMsg(15003), MessageBoxButton.OK) End Sub #End Region ' UpdateBeam #Region "UpdateWall" Public ReadOnly Property UpdateWall_Command() As ICommand Get If m_cmdUpdateWallCmd Is Nothing Then m_cmdUpdateWallCmd = New RelayCommand(AddressOf UpdateWallCmd) End If Return m_cmdUpdateWallCmd End Get End Property Public Sub UpdateWallCmd() ' Recupero la versione del programma in esecuzione Dim sExeVer As String = IniFile.GetProgramVersion() ' Verifico presenza di una precedente installazione del Wall Dim sWallVer As String = "" IniFile.GetSpecialLuaVersion( IniFile.m_sWallDirPath, sWallVer) If String.IsNullOrEmpty( sWallVer) Then ' Il modulo "{0}" non è stato trovato, impossibile aggiornare. - Avviso Dim sOut As String = String.Format(EgtMsg(6555), "Wall") MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Esco Return End If ' Apro dialogo per richiesta file zip del Wall Dim WallDlg As New Microsoft.Win32.OpenFileDialog() With { .DefaultExt = ".zip", .Filter = "Wall (.zip)|*.zip", .CheckFileExists = True, .ValidateNames = True } If WallDlg.ShowDialog() <> True Then Return Dim sWallZip As String = WallDlg.FileName ' Preparo direttorio temporaneo Dim sTempDir As String = Path.Combine(IniFile.m_sTempDir, "Wall") If My.Computer.FileSystem.DirectoryExists( sTempDir) Then My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CreateDirectory( sTempDir) ' Unzip nel direttorio temporaneo Using zip As New Ionic.Zip.ZipFile(sWallZip) zip.ExtractAll( sTempDir, Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite) End Using ' Recupero i dati del nuovo Wall Dim sNewName = "" Dim sNewVer = "" Dim sNewMinExe = "" IniFile.GetSpecialLuaData( sTempDir, sNewName, sNewVer, sNewMinExe) ' Verifico che sia veramente il Wall If String.Compare(sNewName, "Wall") <> 0 Then ' Il file zip non contiene il modulo "{0}". - Avviso Dim sOut As String = String.Format(EgtMsg(6556), "Wall") MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End If ' Verifico la versione minima del programma If String.Compare(sExeVer, sNewMinExe) < 0 Then ' Il nuovo modulo "{0}" richiede un programma con versione minima {1}. - Avviso Dim sOut As String = String.Format(EgtMsg(6557), "Wall", sNewMinExe) MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End If ' Verifico la versione del Wall e se più vecchia chiedo cosa fare If String.Compare(sNewVer, sWallVer) < 0 Then ' La versione del nuovo modulo "{0}" è più vecchia dell'attuale. Vuoi sovrascrivere lo stesso ? Dim sOut As String = String.Format(EgtMsg(6558), "Wall") if MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15003), MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.No Then ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End If End If ' Faccio una copia di backup del Wall corrente Dim sBackupDir As String = IniFile.m_sWallDirPath & ".old" If My.Computer.FileSystem.DirectoryExists( sBackupDir) Then My.Computer.FileSystem.DeleteDirectory( sBackupDir, FileIO.DeleteDirectoryOption.DeleteAllContents) End If Try My.Computer.FileSystem.MoveDirectory( IniFile.m_sWallDirPath, sBackupDir, True) Catch ex As Exception ' Ripristino lo stato originale ed esco My.Computer.FileSystem.MoveDirectory( sBackupDir, IniFile.m_sWallDirPath, True) ' L'aggiornamento del modulo "{0}" non è riuscito. - Errore Dim sOut As String = String.Format(EgtMsg(6559), "Wall") EgtOutLog( sOut) MessageBox.Show(Application.Current.MainWindow, sOut, EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Rimuovo il direttorio temporaneo ed esco My.Computer.FileSystem.DeleteDirectory( sTempDir, FileIO.DeleteDirectoryOption.DeleteAllContents) Return End Try ' Installo il Wall My.Computer.FileSystem.MoveDirectory( sTempDir, IniFile.m_sWallDirPath, True) ' Il modulo "{0}" è stata aggiornato con successo. - Info Dim sOk As String = String.Format(EgtMsg(6560), "Wall") EgtOutLog( sOk) MessageBox.Show(Application.Current.MainWindow, sOk, EgtMsg(15003), MessageBoxButton.OK) End Sub #End Region ' UpdateWall #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