cf650891dc
- aggiunto import CSV (versione preliminare).
247 lines
11 KiB
VB.net
247 lines
11 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class ProjectMgrUC
|
|
|
|
' Riferimenti a pagine
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
Private m_CurrProjPage As CurrentProjectPageUC
|
|
|
|
' Riferimento alla finestra di salvataggio con nome
|
|
Friend m_SaveNameWD As SaveNameWD
|
|
|
|
Private Sub ProjectMgrUC_Initialized(sender As Object, e As EventArgs) Handles Me.Loaded
|
|
|
|
' Imposto i messaggi letti dal file dei messaggi
|
|
NewBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 3)
|
|
LoadBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 4)
|
|
SaveBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 5)
|
|
SaveNameBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 6)
|
|
CSVBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 8)
|
|
ResetCutBtn.Content = EgtMsg(MSG_NESTPAGEUC + 6)
|
|
SimulateBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) 'Simulate - Simula
|
|
WorkBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 2) 'Work - Lavora
|
|
End Sub
|
|
|
|
Private Sub ProjectMgrUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
End Sub
|
|
|
|
Private Sub NewBtn_Click(sender As Object, e As RoutedEventArgs) Handles NewBtn.Click
|
|
' Se progetto modificato, chiedo se salvarlo
|
|
If EgtGetModified() Then
|
|
Dim SaveCurrProj As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 1), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
Select Case SaveCurrProj.DialogResult
|
|
Case 0 ' Annulla
|
|
Return
|
|
Case 1 ' Si
|
|
m_CurrProjPage.SaveNamedProject()
|
|
m_CurrProjPage.SaveProject()
|
|
Case 2 ' No
|
|
' Non devo fare alcunchè
|
|
End Select
|
|
End If
|
|
' Cancello progetto salvato con nome da file ini
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", m_MainWindow.GetIniFile())
|
|
' Se macchina con due tavole, chiedo su quale si vuole operare
|
|
Dim sTabName As String = MAIN_TAB
|
|
If EgtGetTableId(SECOND_TAB) <> GDB_ID.NULL Then
|
|
' Tavolo da usare ?
|
|
Dim TableToUse As New EgtMsgBox(m_MainWindow, "", EgtMsg(91111), EgtMsgBox.Buttons.ONE_TWO, EgtMsgBox.Icons.NULL)
|
|
Select Case TableToUse.DialogResult
|
|
Case 1 ' 1
|
|
' si conferma la tavola principale
|
|
Case 0 ' 2
|
|
sTabName = SECOND_TAB
|
|
End Select
|
|
End If
|
|
' Creo nuovo progetto
|
|
m_CurrProjPage.NewProject(sTabName)
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub LoadBtn_Click(sender As Object, e As RoutedEventArgs) Handles LoadBtn.Click
|
|
' Se progetto modificato, chiedo se salvarlo
|
|
If EgtGetModified() Then
|
|
Dim SaveCurrProj As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 1), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
Select Case SaveCurrProj.DialogResult
|
|
Case 0 ' Annulla
|
|
Return
|
|
Case 1 ' Si
|
|
m_CurrProjPage.SaveNamedProject()
|
|
m_CurrProjPage.SaveProject()
|
|
Case 2 ' No
|
|
' Non devo fare alcunchè
|
|
End Select
|
|
End If
|
|
' Imposto la pagina attualmente attiva come Previous
|
|
m_MainWindow.m_PrevActivePage = m_MainWindow.m_ActivePage
|
|
' Passo alla pagina di apertura con preview
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_CurrentProjectPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_OpenPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Open
|
|
End Sub
|
|
|
|
Friend Sub PostLoad(ByVal sCurrDir As String, sCurrFile As String)
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_CurrProjPage.LoadProject(sCurrDir & "\" & sCurrFile) Then
|
|
m_CurrProjPage.NewProject()
|
|
Else
|
|
' Verifico se file salvato con nome guardando il nome della cartella in cui si trova
|
|
Dim sSaveNameDir As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_SAVENAMEDIR, "", sSaveNameDir, m_MainWindow.GetIniFile())
|
|
If sCurrDir = sSaveNameDir Then
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, sCurrFile.Substring(0, sCurrFile.Length - 4), m_MainWindow.GetIniFile())
|
|
' Salvo equivalente con indice
|
|
m_CurrProjPage.SetNextProjectIndex()
|
|
m_CurrProjPage.SaveProject()
|
|
Else
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, String.Empty, m_MainWindow.GetIniFile())
|
|
End If
|
|
End If
|
|
' Verifico se andare nel CadCut o nel FrameCut
|
|
Dim nPrjType As Integer = m_CurrProjPage.GetCurrentProjectType()
|
|
If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS And
|
|
m_MainWindow.m_PrevActivePage <> MainWindow.Pages.CadCut Then
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_FrameCutPageUC)
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut
|
|
m_MainWindow.FrameCutBtn.IsChecked = False
|
|
m_MainWindow.CadCutBtn.IsChecked = True
|
|
ElseIf nPrjType = CurrentProjectPageUC.PRJ_TYPE.FRAMES And
|
|
m_MainWindow.m_PrevActivePage <> MainWindow.Pages.FrameCut Then
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC)
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_FrameCutPageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.FrameCut
|
|
m_MainWindow.CadCutBtn.IsChecked = False
|
|
m_MainWindow.FrameCutBtn.IsChecked = True
|
|
Else
|
|
m_MainWindow.m_ActivePage = m_MainWindow.m_PrevActivePage
|
|
End If
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub SaveBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveBtn.Click
|
|
' Salvataggio con nome (solo se nome definito)
|
|
m_CurrProjPage.SaveNamedProject()
|
|
' Salvataggio con numero ciclico
|
|
m_CurrProjPage.SaveProject()
|
|
' Se cornici, ripristino visualizzazione lavorazioni
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.FrameCut Then
|
|
ShowAllCurrPhaseMachinings()
|
|
End If
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub SaveNameBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveNameBtn.Click
|
|
m_SaveNameWD = New SaveNameWD(m_MainWindow)
|
|
m_SaveNameWD.ShowDialog()
|
|
End Sub
|
|
|
|
Private Sub CSVBtn_Click(sender As Object, e As RoutedEventArgs) Handles CSVBtn.Click
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC.m_NestPage)
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC.m_CSVPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.CSV
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.CadCut
|
|
End Sub
|
|
|
|
Private Sub ResetCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles ResetCutBtn.Click
|
|
' Cancello eventuali messaggi
|
|
m_CurrProjPage.ClearMessage()
|
|
' Cancello tutte le lavorazioni
|
|
EraseMachinings(GDB_ID.NULL)
|
|
' Se progetto con pezzi piani
|
|
Dim nPrjType As Integer = m_CurrProjPage.GetCurrentProjectType()
|
|
If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS Then
|
|
' Reinserisco tutte le lavorazioni piane
|
|
AddMachinings(GDB_ID.NULL, True, False)
|
|
' Se altrimenti progetto con cornici
|
|
ElseIf nPrjType = CurrentProjectPageUC.PRJ_TYPE.FRAMES Then
|
|
' Reinserisco tutte le lavorazioni delle cornici
|
|
AddFrameMachinings()
|
|
End If
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub SimulateBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulateBtn.Click
|
|
m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut Then
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC)
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.CadCut
|
|
Else
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_FrameCutPageUC)
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.FrameCut
|
|
End If
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation
|
|
End Sub
|
|
|
|
Private Sub WorkBtn_Click(sender As Object, e As RoutedEventArgs) Handles WorkBtn.Click
|
|
Dim bOk As Boolean = True
|
|
' Verifico l'attrezzaggio degli utensili utilizzati
|
|
Dim sMissingTools As String = String.Empty
|
|
If Not VerifySetup(sMissingTools) Then
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90322) & " " & sMissingTools) 'Mancano gli utensili : ...
|
|
Return
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Se pezzi piani e non c'è ordine delle lavorazioni, ne faccio uno automatico
|
|
Dim nPrjType As Integer = m_CurrProjPage.GetCurrentProjectType()
|
|
If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS And
|
|
Not m_CurrProjPage.GetOrderMachiningFlag() Then
|
|
bOk = SortAllMachinings()
|
|
If bOk Then
|
|
m_CurrProjPage.SetOrderMachiningFlag()
|
|
Dim bModif As Boolean = TestAllMachiningsForStrict()
|
|
If bModif Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90321)) 'Ridotte alcune lavorazioni per evitare interferenze
|
|
End If
|
|
End If
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Disabilito impostazione modificato
|
|
EgtDisableModified()
|
|
' Aggiorno le lavorazioni
|
|
bOk = UpdateAllMachiningsToolpaths() And bOk
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Salvo il progetto con le lavorazioni
|
|
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\MachProj.nge"
|
|
m_CurrProjPage.SaveFile(sMchPath)
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Genero file CNC (lancio anche se errore in precedenza)
|
|
Dim sCncPath As String = m_MainWindow.GetCncDir() & "\CadCut" & m_MainWindow.m_CurrentMachine.sIsoFileExt
|
|
bOk = EgtGenerate(sCncPath, "OmagCut") And bOk
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Ripristino come fase corrente quella iniziale
|
|
EgtSetCurrPhase(1)
|
|
' Se nesting di pezzi piani, nascondo tutte le lavorazioni
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut Then
|
|
HideAllMachinings()
|
|
Else
|
|
ShowAllCurrPhaseMachinings()
|
|
End If
|
|
' Abilito impostazione modificato
|
|
EgtEnableModified()
|
|
' Se errore in generazione, segnalo l'errore ed esco
|
|
If Not bOk Then
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90314)) 'Errore nella generazione del programma CN
|
|
Return
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Download programma (eventuali errori sono segnalati dalla funzione)
|
|
If m_MainWindow.m_CNCommunication.SendProgram(sCncPath, 900) Then
|
|
' copio il progetto corrente come progetto in lavorazione
|
|
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
|
|
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|