TestEIn 1.6a6 :
- spostati i comandi di Progetto da Scene a Controller - migliorata gestione focus con inputbox.
This commit is contained in:
+312
-3
@@ -1,7 +1,7 @@
|
||||
'----------------------------------------------------------------------------
|
||||
' EgalTech 2014-2015
|
||||
'----------------------------------------------------------------------------
|
||||
' File : Controller.vb Data : 04.11.14 Versione : 1.6a3
|
||||
' File : Controller.vb Data : 27.01.15 Versione : 1.6a6
|
||||
' Contenuto : Classe Controller (parte di MVC).
|
||||
'
|
||||
'
|
||||
@@ -19,7 +19,18 @@ Imports System.Text
|
||||
Public Class Controller
|
||||
|
||||
' Events
|
||||
Public Event PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByRef sCheckLabel As String,
|
||||
Public Event OnNewProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnOpeningProject(ByVal sender As Object)
|
||||
Public Event OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnSavingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnSavedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean)
|
||||
Public Event OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnExportingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExportedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnExecutingScript(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExecutedScript(ByVal sender As Object, ByVal bOk As Boolean, ByVal sError As String)
|
||||
Public Event PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String,
|
||||
ByVal bShowCombo As Boolean, ByVal bShowBtn As Boolean)
|
||||
Public Event SetInputBoxText(ByVal sText As String)
|
||||
Public Event SetInputBoxCheck(ByVal bCheck As Boolean)
|
||||
@@ -149,6 +160,304 @@ Public Class Controller
|
||||
Private OFFSET_STD As Double = 0
|
||||
|
||||
' Metodi
|
||||
Public Function NewProject(Optional ByVal bCreatePart As Boolean = False) As Boolean
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not ManageModified() Then
|
||||
Return False
|
||||
End If
|
||||
' eseguo
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = EgtNewFile()
|
||||
If bOk And bCreatePart Then
|
||||
' inserisco un nuovo gruppo (piece) sotto la radice
|
||||
Dim nIdNewPart As Integer = EgtCreateGroup(GDB_ID.ROOT)
|
||||
' inserisco un nuovo gruppo (layer) sotto quello appena creato
|
||||
Dim nIdNewLayer As Integer = EgtCreateGroup(nIdNewPart)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
' aggiorno
|
||||
EgtZoom(ZM.ALL)
|
||||
ResetCurrFile()
|
||||
ResetCurrPartLayer()
|
||||
ResetModified()
|
||||
' Gestione risultato
|
||||
RaiseEvent OnNewProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function OpenProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not ManageModified() Then
|
||||
Return False
|
||||
End If
|
||||
' eseguo
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Open"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Prima del caricamento
|
||||
RaiseEvent OnOpeningProject(Me)
|
||||
'Caricamento del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = EgtOpenFile(sFile)
|
||||
DisableCommandLog()
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetCurrFile(sFile)
|
||||
ResetCurrPartLayer()
|
||||
ResetModified()
|
||||
'Gestione risultato
|
||||
RaiseEvent OnOpenProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function InsertProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Insert"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Inserimento del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtInsertFile(sFile)
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetModified()
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function SaveProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
If String.IsNullOrWhiteSpace(sFile) Or EgtGetFileType(sFile) <> FT.NGE Then
|
||||
Return SaveAsProject(sFile, nType)
|
||||
Else
|
||||
'Prima del salvataggio
|
||||
SetCurrFile(sFile)
|
||||
RaiseEvent OnSavingProject(Me, sFile)
|
||||
'Salvataggio del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = EgtSaveFile(sFile, nType)
|
||||
DisableCommandLog()
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
If bOk Then
|
||||
ResetModified()
|
||||
End If
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function SaveAsProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
'Eventuale sistemazione estensione
|
||||
sFile = IO.Path.ChangeExtension(sFile, "nge")
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Save"
|
||||
SaveFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge"
|
||||
SaveFileDialog.FileName = sFile
|
||||
SaveFileDialog.InitialDirectory = IO.Path.GetDirectoryName(sFile)
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Prima del salvataggio
|
||||
SetCurrFile(SaveFileDialog.FileName)
|
||||
RaiseEvent OnSavingProject(Me, SaveFileDialog.FileName)
|
||||
'Salvataggio del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = EgtSaveFile(SaveFileDialog.FileName, nType)
|
||||
DisableCommandLog()
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
If bOk Then
|
||||
ResetModified()
|
||||
End If
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ImportProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not ManageModified() Then
|
||||
Return False
|
||||
End If
|
||||
' eseguo
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Import"
|
||||
OpenFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|Part program ISO (*.cnc)|*.cnc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 4
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Riconoscimento tipo file
|
||||
Dim nFileType As Integer = EgtGetFileType(sFile)
|
||||
Dim bOkType = (nFileType = FT.DXF Or nFileType = FT.STL Or nFileType = FT.CNC)
|
||||
'Prima del caricamento
|
||||
RaiseEvent OnImportingProject(Me, bOkType)
|
||||
If Not bOkType Then
|
||||
Return False
|
||||
End If
|
||||
'Pulizia GeomDB
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtNewFile()
|
||||
'Importazione
|
||||
EnableCommandLog()
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = bOk And EgtImportDxf(sFile)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = bOk And EgtImportStl(sFile)
|
||||
ElseIf nFileType = FT.CNC Then
|
||||
bOk = bOk And EgtImportCnc(sFile)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetCurrFile(sFile)
|
||||
ResetCurrPartLayer()
|
||||
SetModified()
|
||||
'Gestione risultato
|
||||
RaiseEvent OnImportedProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ExportProject(Optional ByVal sFile As String = "") As Boolean
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Export"
|
||||
SaveFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|All Files (*.*)|*.*"
|
||||
SaveFileDialog.FilterIndex = 3
|
||||
SaveFileDialog.FileName = sFile
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Riconoscimento tipo file
|
||||
Dim nFileType As Integer = EgtGetFileType(SaveFileDialog.FileName)
|
||||
If nFileType <> FT.DXF And nFileType <> FT.STL Then
|
||||
MessageBox.Show("File type unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return False
|
||||
End If
|
||||
'Prima dell'esportazione
|
||||
RaiseEvent OnExportingProject(Me, SaveFileDialog.FileName)
|
||||
'Esportazione del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = False
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = EgtExportDxf(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = EgtExportStl(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnExportedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function Exec(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Exec Script"
|
||||
OpenFileDialog.Filter = "Lua commands(*.lua)|*.lua" &
|
||||
"|Test commands(*.tsc)|*.tsc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Ne verifico il tipo
|
||||
Dim sExt As String = UCase(IO.Path.GetExtension(sFile))
|
||||
If (sExt <> ".LUA" And sExt <> ".TSC") Then
|
||||
MessageBox.Show("Script type unknow", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return False
|
||||
End If
|
||||
'Prima dell'esecuzione
|
||||
RaiseEvent OnExecutingScript(Me, sFile)
|
||||
'Esecuzione
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = False
|
||||
If (sExt = ".LUA") Then
|
||||
bOk = EgtLuaExecFile(sFile)
|
||||
Else
|
||||
bOk = EgtTscExecFile(sFile)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetModified()
|
||||
'Gestione risultato
|
||||
Dim sError As String = String.Empty
|
||||
If Not bOk Then
|
||||
If (sExt = ".LUA") Then
|
||||
EgtLuaGetLastError(sError)
|
||||
Else
|
||||
sError = "Error executing script"
|
||||
End If
|
||||
End If
|
||||
RaiseEvent OnExecutedScript(Me, bOk, sError)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Sub MouseSelectedAll()
|
||||
' eseguo la selezione ed aggiorno
|
||||
EnableCommandLog()
|
||||
EgtSelectAll(True)
|
||||
DisableCommandLog()
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Public Sub MouseDeselectedAll()
|
||||
' eseguo la selezione ed aggiorno
|
||||
EnableCommandLog()
|
||||
EgtDeselectAll()
|
||||
DisableCommandLog()
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Public Sub MouseSelectedObj(ByVal nId As Integer, ByVal bLast As Boolean)
|
||||
EnableCommandLog()
|
||||
If EgtIsSelectedObj(nId) Then
|
||||
@@ -3624,7 +3933,7 @@ Public Class Controller
|
||||
Dim nRes = MessageBox.Show(sMsg, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
|
||||
Select Case nRes
|
||||
Case Windows.Forms.DialogResult.Yes
|
||||
m_Scene.SaveProject(m_sCurrFile)
|
||||
SaveProject(m_sCurrFile)
|
||||
Return True
|
||||
Case Windows.Forms.DialogResult.No
|
||||
Return True
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
'----------------------------------------------------------------------------
|
||||
' EgalTech 2014-2015
|
||||
'----------------------------------------------------------------------------
|
||||
' File : EgtInterface.vb Data : 18.01.15 Versione : 1.6a3
|
||||
' File : EgtInterface.vb Data : 27.01.15 Versione : 1.6a6
|
||||
' Contenuto : Modulo EgtInterface (interfaccia verso il motore EgalTech).
|
||||
'
|
||||
'
|
||||
@@ -804,7 +804,7 @@ Public Function EgtOpenFile(ByVal sFilePath As String) As Boolean
|
||||
End Function
|
||||
|
||||
<DllImport(EgtIntDll, CharSet:=CharSet.Unicode)>
|
||||
Public Function EgtImportFile(ByVal sFilePath As String) As Boolean
|
||||
Public Function EgtInsertFile(ByVal sFilePath As String) As Boolean
|
||||
End Function
|
||||
|
||||
<DllImport(EgtIntDll, CharSet:=CharSet.Unicode)>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'----------------------------------------------------------------------------
|
||||
' EgalTech 2014-2015
|
||||
'----------------------------------------------------------------------------
|
||||
' File : Form1.vb Data : 18.01.15 Versione : 1.6a3
|
||||
' File : Form1.vb Data : 27.01.15 Versione : 1.6a6
|
||||
' Contenuto : Classe Form1 (dialogo principale dell'applicazione).
|
||||
'
|
||||
'
|
||||
@@ -207,7 +207,7 @@ Public Class Form1
|
||||
tsStatusReg.BackColor = Color.Red
|
||||
End If
|
||||
' Apro progetto vuoto
|
||||
Scene1.NewProject(True)
|
||||
m_Controller.NewProject(True)
|
||||
End Sub
|
||||
|
||||
Private Sub Form1_Shown(sender As System.Object, e As EventArgs) Handles MyBase.Shown
|
||||
@@ -223,13 +223,13 @@ Public Class Form1
|
||||
Dim nFileType As Integer = EgtGetFileType(s)
|
||||
Select Case nFileType
|
||||
Case FT.NGE, FT.NFE
|
||||
Scene1.OpenProject(s, False)
|
||||
m_Controller.OpenProject(s, False)
|
||||
bOpen = True
|
||||
Case FT.DXF, FT.STL, FT.CNC
|
||||
Scene1.ImportProject(s, False)
|
||||
m_Controller.ImportProject(s, False)
|
||||
bOpen = True
|
||||
Case FT.TSC, FT.LUA
|
||||
Scene1.Exec(s, False)
|
||||
m_Controller.Exec(s, False)
|
||||
bOpen = True
|
||||
End Select
|
||||
Exit For
|
||||
@@ -272,6 +272,14 @@ Public Class Form1
|
||||
tsStatusCursorPos.Text = sCursorPos
|
||||
End Sub
|
||||
|
||||
Private Sub OnMouseSelectedAll(ByVal sender As Object) Handles Scene1.OnMouseSelectedAll
|
||||
m_Controller.MouseSelectedAll()
|
||||
End Sub
|
||||
|
||||
Private Sub OnMouseDeselectedAll(ByVal sender As Object) Handles Scene1.OnMouseDeselectedAll
|
||||
m_Controller.MouseDeselectedAll()
|
||||
End Sub
|
||||
|
||||
Private Sub OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean) Handles Scene1.OnMouseSelectedObj
|
||||
m_Controller.MouseSelectedObj(nId, bLast)
|
||||
End Sub
|
||||
@@ -314,44 +322,34 @@ Public Class Form1
|
||||
tsStatusOutput.Text = sDistance
|
||||
End Sub
|
||||
|
||||
Private Sub OnNewProject(ByVal sender As Object, ByVal bOk As Boolean) Handles Scene1.OnNewProject
|
||||
m_Controller.ResetCurrFile()
|
||||
m_Controller.ExecuteCommand(CMD.RESETCURRPARTLAYER)
|
||||
m_Controller.ResetModified()
|
||||
Private Sub OnNewProject(ByVal sender As Object, ByVal bOk As Boolean) Handles m_Controller.OnNewProject
|
||||
If Not bOk Then
|
||||
MessageBox.Show("Error on new file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OnOpeningProject(ByVal sender As Object) Handles Scene1.OnOpeningProject
|
||||
Private Sub OnOpeningProject(ByVal sender As Object) Handles m_Controller.OnOpeningProject
|
||||
ClearObjTree()
|
||||
End Sub
|
||||
|
||||
Private Sub OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles Scene1.OnOpenProject
|
||||
m_Controller.SetCurrFile(sFile)
|
||||
m_Controller.ExecuteCommand(CMD.RESETCURRPARTLAYER)
|
||||
m_Controller.ResetModified()
|
||||
Private Sub OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnOpenProject
|
||||
WritePrivateProfileString("General", "LastNgeDir", Path.GetDirectoryName(sFile), m_sIniFile)
|
||||
If Not bOk Then
|
||||
MessageBox.Show("Error opening file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OnSavingProject(ByVal sender As Object, ByVal sFile As String) Handles Scene1.OnSavingProject
|
||||
m_Controller.SetCurrFile(sFile)
|
||||
EmitTitle()
|
||||
Private Sub OnSavingProject(ByVal sender As Object, ByVal sFile As String) Handles m_Controller.OnSavingProject
|
||||
WritePrivateProfileString("General", "LastNgeDir", Path.GetDirectoryName(sFile), m_sIniFile)
|
||||
End Sub
|
||||
|
||||
Private Sub OnSavedProject(ByVal sender As Object, ByVal bOk As Boolean) Handles Scene1.OnSavedProject
|
||||
If bOk Then
|
||||
m_Controller.ResetModified()
|
||||
Else
|
||||
Private Sub OnSavedProject(ByVal sender As Object, ByVal bOk As Boolean) Handles m_Controller.OnSavedProject
|
||||
If Not bOk Then
|
||||
MessageBox.Show("Error saving file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean) Handles Scene1.OnImportingProject
|
||||
Private Sub OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean) Handles m_Controller.OnImportingProject
|
||||
If bOkType Then
|
||||
ClearObjTree()
|
||||
Else
|
||||
@@ -359,39 +357,35 @@ Public Class Form1
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles Scene1.OnImportedProject
|
||||
m_Controller.SetCurrFile(sFile)
|
||||
m_Controller.ExecuteCommand(CMD.RESETCURRPARTLAYER)
|
||||
m_Controller.SetModified()
|
||||
Private Sub OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnImportedProject
|
||||
WritePrivateProfileString("General", "LastImpDir", Path.GetDirectoryName(sFile), m_sIniFile)
|
||||
If Not bOk Then
|
||||
MessageBox.Show("Error importing file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OnExportingProject(ByVal sender As Object, ByVal sFile As String) Handles Scene1.OnExportingProject
|
||||
Private Sub OnExportingProject(ByVal sender As Object, ByVal sFile As String) Handles m_Controller.OnExportingProject
|
||||
WritePrivateProfileString("General", "LastExpDir", Path.GetDirectoryName(sFile), m_sIniFile)
|
||||
End Sub
|
||||
|
||||
Private Sub OnExportedProject(ByVal sender As Object, ByVal bOk As Boolean) Handles Scene1.OnExportedProject
|
||||
Private Sub OnExportedProject(ByVal sender As Object, ByVal bOk As Boolean) Handles m_Controller.OnExportedProject
|
||||
If Not bOk Then
|
||||
MessageBox.Show("Error exporting file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OnExecutingScript(ByVal sender As Object, ByVal sFile As String) Handles Scene1.OnExecutingScript
|
||||
Private Sub OnExecutingScript(ByVal sender As Object, ByVal sFile As String) Handles m_Controller.OnExecutingScript
|
||||
WritePrivateProfileString("General", "LastLuaDir", Path.GetDirectoryName(sFile), m_sIniFile)
|
||||
ClearObjTree()
|
||||
End Sub
|
||||
|
||||
Private Sub OnExecutedScript(ByVal sender As Object, ByVal bOk As Boolean, ByVal sError As String) Handles Scene1.OnExecutedScript
|
||||
m_Controller.SetModified()
|
||||
Private Sub OnExecutedScript(ByVal sender As Object, ByVal bOk As Boolean, ByVal sError As String) Handles m_Controller.OnExecutedScript
|
||||
If Not bOk Then
|
||||
MessageBox.Show(sError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OnPrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByRef sCheckLabel As String,
|
||||
Private Sub OnPrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String,
|
||||
ByVal bShowCombo As Boolean, ByVal bShowBtn As Boolean) Handles m_Controller.PrepareInputBox
|
||||
PrepareInputBox(sTitle, sLabel, sCheckLabel, bShowCombo, bShowBtn)
|
||||
End Sub
|
||||
@@ -474,70 +468,54 @@ Public Class Form1
|
||||
|
||||
'-------------------------------- Buttons --------------------------------------------------------
|
||||
Private Sub btnNew_Click(sender As System.Object, e As System.EventArgs) Handles btnNew.Click
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not m_Controller.ManageModified() Then
|
||||
Return
|
||||
End If
|
||||
' eseguo
|
||||
Scene1.NewProject(True)
|
||||
m_Controller.NewProject(True)
|
||||
End Sub
|
||||
|
||||
Private Sub btnOpen_Click(sender As System.Object, e As System.EventArgs) Handles btnOpen.Click
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not m_Controller.ManageModified() Then
|
||||
Return
|
||||
End If
|
||||
' eseguo
|
||||
Dim sDir As String = String.Empty
|
||||
GetPrivateProfileString("General", "LastNgeDir", "", sDir, m_sIniFile)
|
||||
Scene1.OpenProject(sDir)
|
||||
End Sub
|
||||
|
||||
Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
|
||||
Dim nType As NGE = GetPrivateProfileInt("GeomDB", "SaveType", NGE.CMPTEXT, m_sIniFile)
|
||||
If Not String.IsNullOrWhiteSpace(m_Controller.GetCurrFile()) Then
|
||||
Scene1.SaveProject(m_Controller.GetCurrFile(), nType)
|
||||
Else
|
||||
Dim sFile As String = String.Empty
|
||||
GetPrivateProfileString("General", "LastNgeDir", "", sFile, m_sIniFile)
|
||||
sFile.TrimEnd("\"c)
|
||||
sFile += "\New.nge"
|
||||
Scene1.SaveAsProject(sFile, nType)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub btnSaveAs_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveAs.Click
|
||||
Dim nType As NGE = GetPrivateProfileInt("GeomDB", "SaveType", NGE.CMPTEXT, m_sIniFile)
|
||||
Scene1.SaveAsProject(m_Controller.GetCurrFile(), nType)
|
||||
End Sub
|
||||
|
||||
Private Sub btnImport_Click(sender As System.Object, e As System.EventArgs) Handles btnImport.Click
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not m_Controller.ManageModified() Then
|
||||
Return
|
||||
End If
|
||||
' eseguo
|
||||
Dim sDir As String = String.Empty
|
||||
GetPrivateProfileString("General", "LastImpDir", "", sDir, m_sIniFile)
|
||||
Scene1.ImportProject(sDir)
|
||||
End Sub
|
||||
|
||||
Private Sub btnExport_Click(sender As System.Object, e As System.EventArgs) Handles btnExport.Click
|
||||
Scene1.ExportProject(Path.ChangeExtension(m_Controller.GetCurrFile(), "dxf"))
|
||||
m_Controller.OpenProject(sDir)
|
||||
End Sub
|
||||
|
||||
Private Sub btnInsert_Click(sender As System.Object, e As System.EventArgs) Handles btnInsert.Click
|
||||
' eseguo
|
||||
Dim sDir As String = String.Empty
|
||||
GetPrivateProfileString("General", "LastNgeDir", "", sDir, m_sIniFile)
|
||||
Scene1.InsertProject(sDir)
|
||||
m_Controller.SetModified()
|
||||
m_Controller.InsertProject(sDir)
|
||||
End Sub
|
||||
|
||||
Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
|
||||
Dim nType As NGE = GetPrivateProfileInt("GeomDB", "SaveType", NGE.CMPTEXT, m_sIniFile)
|
||||
If Not String.IsNullOrWhiteSpace(m_Controller.GetCurrFile()) Then
|
||||
m_Controller.SaveProject(m_Controller.GetCurrFile(), nType)
|
||||
Else
|
||||
Dim sFile As String = String.Empty
|
||||
GetPrivateProfileString("General", "LastNgeDir", "", sFile, m_sIniFile)
|
||||
sFile.TrimEnd("\"c)
|
||||
sFile += "\New.nge"
|
||||
m_Controller.SaveAsProject(sFile, nType)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub btnSaveAs_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveAs.Click
|
||||
Dim nType As NGE = GetPrivateProfileInt("GeomDB", "SaveType", NGE.CMPTEXT, m_sIniFile)
|
||||
m_Controller.SaveAsProject(m_Controller.GetCurrFile(), nType)
|
||||
End Sub
|
||||
|
||||
Private Sub btnImport_Click(sender As System.Object, e As System.EventArgs) Handles btnImport.Click
|
||||
Dim sDir As String = String.Empty
|
||||
GetPrivateProfileString("General", "LastImpDir", "", sDir, m_sIniFile)
|
||||
m_Controller.ImportProject(sDir)
|
||||
End Sub
|
||||
|
||||
Private Sub btnExport_Click(sender As System.Object, e As System.EventArgs) Handles btnExport.Click
|
||||
m_Controller.ExportProject(Path.ChangeExtension(m_Controller.GetCurrFile(), "dxf"))
|
||||
End Sub
|
||||
|
||||
Private Sub btnExec_Click(sender As System.Object, e As System.EventArgs) Handles btnExec.Click
|
||||
Dim sDir As String = String.Empty
|
||||
GetPrivateProfileString("General", "LastLuaDir", "", sDir, m_sIniFile)
|
||||
Scene1.Exec(sDir)
|
||||
m_Controller.Exec(sDir)
|
||||
End Sub
|
||||
|
||||
Private Sub rbtWireFrame_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbtWireFrame.CheckedChanged
|
||||
@@ -890,10 +868,12 @@ Public Class Form1
|
||||
InputCheck.Hide()
|
||||
InputCombo.Hide()
|
||||
btnShow.Hide()
|
||||
Scene1.Focus()
|
||||
End Sub
|
||||
|
||||
Private Function SetInputBoxText(ByVal sVal As String) As Boolean
|
||||
InputText.Text = sVal
|
||||
InputText.Focus()
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
@@ -43,5 +43,5 @@ Imports System.Runtime.InteropServices
|
||||
' utilizzando l'asterisco (*) come descritto di seguito:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.6.1.4")>
|
||||
<Assembly: AssemblyFileVersion("1.6.1.4")>
|
||||
<Assembly: AssemblyVersion("1.6.1.6")>
|
||||
<Assembly: AssemblyFileVersion("1.6.1.6")>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'----------------------------------------------------------------------------
|
||||
' EgalTech 2014-2015
|
||||
'----------------------------------------------------------------------------
|
||||
' File : Scene.vb Data : 18.01.15 Versione : 1.6a3
|
||||
' File : Scene.vb Data : 27.01.15 Versione : 1.6a6
|
||||
' Contenuto : Classe Scene (parte di MVC).
|
||||
'
|
||||
'
|
||||
@@ -183,6 +183,8 @@ Public Class Scene
|
||||
End Sub
|
||||
|
||||
'---- Events ----------
|
||||
Public Event OnMouseSelectedAll(ByVal sender As Object)
|
||||
Public Event OnMouseDeselectedAll(ByVal sender As Object)
|
||||
Public Event OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean)
|
||||
Public Event OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer)
|
||||
Public Event OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer)
|
||||
@@ -197,24 +199,8 @@ Public Class Scene
|
||||
Public Event OnMouseSelectedDir(ByVal sender As Object, ByVal VtDir As Vector3d)
|
||||
Public Event OnMouseMoveSelPoint(ByVal sender As Object, ByVal PtP As Point3d)
|
||||
Public Event OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP)
|
||||
Public Event OnNewProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnOpeningProject(ByVal sender As Object)
|
||||
Public Event OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnSavingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnSavedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean)
|
||||
Public Event OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnExportingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExportedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnExecutingScript(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExecutedScript(ByVal sender As Object, ByVal bOk As Boolean, ByVal sError As String)
|
||||
|
||||
'---- Mouse -----------
|
||||
Protected Overrides Sub OnMouseEnter(e As System.EventArgs)
|
||||
MyBase.OnMouseEnter(e)
|
||||
Focus()
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs)
|
||||
' Imposto il contesto della scena come corrente
|
||||
EgtSetCurrentContext(m_nGseContext)
|
||||
@@ -306,7 +292,26 @@ Public Class Scene
|
||||
' se stato selezione punto
|
||||
ElseIf m_nStatus = ST.SELPOINT Then
|
||||
If Not m_bDragOn Then
|
||||
RaiseEvent OnMouseDone(Me)
|
||||
' rendo selezionabile gruppo di drag
|
||||
If Not m_bDragSelectable Then
|
||||
EgtUnselectableRemove(m_nDragGroup)
|
||||
End If
|
||||
' eseguo selezione
|
||||
Dim nSel As Integer = GDB_ID.NULL
|
||||
EgtSelect(e.Location, DIM_SEL, DIM_SEL, nSel)
|
||||
' ripristino stato precedente di selezionabilità drag
|
||||
If Not m_bDragSelectable Then
|
||||
EgtUnselectableAdd(m_nDragGroup)
|
||||
End If
|
||||
' click su geometria di drag equivale a Done
|
||||
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
||||
While nId <> GDB_ID.NULL
|
||||
If EgtGetParent(nId) = m_nDragGroup Then
|
||||
RaiseEvent OnMouseDone(Me)
|
||||
Exit While
|
||||
End If
|
||||
nId = EgtGetNextObjInSelWin()
|
||||
End While
|
||||
ElseIf EgtGetGraphicSnapPoint(m_nSnapType, e.Location, DIM_SEL, DIM_SEL, m_ptPrev) Then
|
||||
' se Snap Sketch o Grid e premuto SHIFT si passa a modalità elevatore
|
||||
If (m_nSnapType = SP.PT_SKETCH Or m_nSnapType = SP.PT_GRID) And
|
||||
@@ -434,11 +439,16 @@ Public Class Scene
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs)
|
||||
' salvo il contesto corrente e imposto quello della scena
|
||||
' Salvo il contesto corrente e imposto quello della scena
|
||||
Dim nOldGseCtx = EgtGetCurrentContext()
|
||||
If nOldGseCtx <> m_nGseContext Then
|
||||
EgtSetCurrentContext(m_nGseContext)
|
||||
End If
|
||||
' Se sono abbastanza all'interno della scena (10% della dimensione), imposto il focus
|
||||
If e.Location.X > 0.1 * Size.Width AndAlso e.Location.X < 0.9 * Size.Width AndAlso
|
||||
e.Location.Y > 0.1 * Size.Height AndAlso e.Location.Y < 0.9 * Size.Height Then
|
||||
Focus()
|
||||
End If
|
||||
' Visualizzo le coordinate del mouse
|
||||
ShowCursorPos(e.Location)
|
||||
' --- Premuto tasto sinistro ---
|
||||
@@ -758,15 +768,9 @@ Public Class Scene
|
||||
Private Sub MenuScene_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles MenuScene.ItemClicked
|
||||
' Per selezione
|
||||
If e.ClickedItem.Name = "cmdSelectAll" Then
|
||||
EgtEnableCommandLogger()
|
||||
EgtSelectAll(True)
|
||||
EgtDisableCommandLogger()
|
||||
EgtDraw()
|
||||
RaiseEvent OnMouseSelectedAll(Me)
|
||||
ElseIf e.ClickedItem.Name = "cmdDeselectAll" Then
|
||||
EgtEnableCommandLogger()
|
||||
EgtDeselectAll()
|
||||
EgtDisableCommandLogger()
|
||||
EgtDraw()
|
||||
RaiseEvent OnMouseDeselectedAll(Me)
|
||||
ElseIf e.ClickedItem.Name = "cmdWinSelect" Then
|
||||
m_nStatus = ST.WINSEL
|
||||
ElseIf e.ClickedItem.Name = "cmdSelectPart" Then
|
||||
@@ -915,6 +919,7 @@ Public Class Scene
|
||||
|
||||
'---- Drag Group ------
|
||||
Private m_bDragOn As Boolean = True
|
||||
Private m_bDragSelectable As Boolean = False
|
||||
Private m_nDragGroup As Integer = GDB_ID.NULL
|
||||
|
||||
Public Sub EnableDrag()
|
||||
@@ -936,7 +941,10 @@ Public Class Scene
|
||||
End If
|
||||
EgtSetLevel(m_nDragGroup, GDB_LV.TEMP)
|
||||
EgtSetMark(m_nDragGroup)
|
||||
If Not bSelectable Then
|
||||
m_bDragSelectable = bSelectable
|
||||
If m_bDragSelectable Then
|
||||
EgtUnselectableRemove(m_nDragGroup)
|
||||
Else
|
||||
EgtUnselectableAdd(m_nDragGroup)
|
||||
End If
|
||||
Return True
|
||||
@@ -944,6 +952,7 @@ Public Class Scene
|
||||
|
||||
Public Function EraseDragGroup() As Boolean
|
||||
EgtErase(m_nDragGroup)
|
||||
m_bDragSelectable = False
|
||||
EgtUnselectableRemove(m_nDragGroup)
|
||||
m_nDragGroup = GDB_ID.NULL
|
||||
Return True
|
||||
@@ -968,236 +977,6 @@ Public Class Scene
|
||||
Return m_nDragGroup
|
||||
End Function
|
||||
|
||||
'---- Main Buttons ----
|
||||
Public Function NewProject(Optional ByVal bCreatePart As Boolean = False) As Boolean
|
||||
Dim bOk As Boolean = EgtNewFile()
|
||||
If bOk And bCreatePart Then
|
||||
' inserisco un nuovo gruppo (piece) sotto la radice
|
||||
Dim nIdNewPart As Integer = EgtCreateGroup(GDB_ID.ROOT)
|
||||
' inserisco un nuovo gruppo (layer) sotto quello appena creato
|
||||
Dim nIdNewLayer As Integer = EgtCreateGroup(nIdNewPart)
|
||||
End If
|
||||
EgtZoom(ZM.ALL)
|
||||
' Gestione risultato
|
||||
RaiseEvent OnNewProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function OpenProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Open"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Prima del caricamento
|
||||
RaiseEvent OnOpeningProject(Me)
|
||||
'Caricamento del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtOpenFile(sFile)
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnOpenProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function InsertProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Insert"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Inserimento del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtImportFile(sFile)
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = Cursors.Default
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function SaveProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
If String.IsNullOrWhiteSpace(sFile) Or EgtGetFileType(sFile) <> FT.NGE Then
|
||||
Return SaveAsProject(sFile, nType)
|
||||
Else
|
||||
'Prima del salvataggio
|
||||
RaiseEvent OnSavingProject(Me, sFile)
|
||||
'Salvataggio del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtSaveFile(sFile, nType)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function SaveAsProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
'Eventuale sistemazione estensione
|
||||
sFile = Path.ChangeExtension(sFile, "nge")
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Save"
|
||||
SaveFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge"
|
||||
SaveFileDialog.FileName = sFile
|
||||
SaveFileDialog.InitialDirectory = Path.GetDirectoryName(sFile)
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Prima del salvataggio
|
||||
RaiseEvent OnSavingProject(Me, SaveFileDialog.FileName)
|
||||
'Salvataggio del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtSaveFile(SaveFileDialog.FileName, nType)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ImportProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Import"
|
||||
OpenFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|Part program ISO (*.cnc)|*.cnc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 4
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Riconoscimento tipo file
|
||||
Dim nFileType As Integer = EgtGetFileType(sFile)
|
||||
Dim bOkType = (nFileType = FT.DXF Or nFileType = FT.STL Or nFileType = FT.CNC)
|
||||
'Prima del caricamento
|
||||
RaiseEvent OnImportingProject(Me, bOkType)
|
||||
If Not bOkType Then
|
||||
Return False
|
||||
End If
|
||||
'Pulizia GeomDB
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtNewFile()
|
||||
'Importazione
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = bOk And EgtImportDxf(sFile)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = bOk And EgtImportStl(sFile)
|
||||
ElseIf nFileType = FT.CNC Then
|
||||
bOk = bOk And EgtImportCnc(sFile)
|
||||
End If
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnImportedProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ExportProject(Optional ByVal sFile As String = "") As Boolean
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Export"
|
||||
SaveFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|All Files (*.*)|*.*"
|
||||
SaveFileDialog.FilterIndex = 3
|
||||
SaveFileDialog.FileName = sFile
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Riconoscimento tipo file
|
||||
Dim nFileType As Integer = EgtGetFileType(SaveFileDialog.FileName)
|
||||
If nFileType <> FT.DXF And nFileType <> FT.STL Then
|
||||
MessageBox.Show("File type unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return False
|
||||
End If
|
||||
'Prima dell'esportazione
|
||||
RaiseEvent OnExportingProject(Me, SaveFileDialog.FileName)
|
||||
'Esportazione del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = False
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = EgtExportDxf(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = EgtExportStl(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
End If
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnExportedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function Exec(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Exec Script"
|
||||
OpenFileDialog.Filter = "Lua commands(*.lua)|*.lua" &
|
||||
"|Test commands(*.tsc)|*.tsc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Ne verifico il tipo
|
||||
Dim sExt As String = UCase(Path.GetExtension(sFile))
|
||||
If (sExt <> ".LUA" And sExt <> ".TSC") Then
|
||||
MessageBox.Show("Script type unknow", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return False
|
||||
End If
|
||||
'Prima dell'esecuzione
|
||||
RaiseEvent OnExecutingScript(Me, sFile)
|
||||
'Esecuzione
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = False
|
||||
If (sExt = ".LUA") Then
|
||||
bOk = EgtLuaExecFile(sFile)
|
||||
Else
|
||||
bOk = EgtTscExecFile(sFile)
|
||||
End If
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
Dim sError As String = String.Empty
|
||||
If Not bOk Then
|
||||
If (sExt = ".LUA") Then
|
||||
EgtLuaGetLastError(sError)
|
||||
Else
|
||||
sError = "Error executing script"
|
||||
End If
|
||||
End If
|
||||
RaiseEvent OnExecutedScript(Me, bOk, sError)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
'---- Zoom Buttons ----
|
||||
Public Sub ZoomAll()
|
||||
EgtZoom(ZM.ALL)
|
||||
|
||||
Reference in New Issue
Block a user