diff --git a/CadCutPageUC.xaml.vb b/CadCutPageUC.xaml.vb index a357f65..974f81d 100644 --- a/CadCutPageUC.xaml.vb +++ b/CadCutPageUC.xaml.vb @@ -89,6 +89,12 @@ Public Class CadCutPageUC Private Sub SaveBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveBtn.Click Dim sPath As String = m_MainWindow.GetTempDir() & "\" & "CurrProj.nge" EgtSaveFile(sPath, NGE.CMPTEXT) + ' Ripristino visualizzazione di eventuali pezzi in parcheggio (save li nasconde) + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + EgtSetStatus(nPartId, GDB_ST.ON_) + nPartId = EgtGetNextPart(nPartId) + End While End Sub Private Sub SimulateBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulateBtn.Click diff --git a/CurrentProjectPageUC.xaml b/CurrentProjectPageUC.xaml index 36c06fd..3277ebe 100644 --- a/CurrentProjectPageUC.xaml +++ b/CurrentProjectPageUC.xaml @@ -38,14 +38,14 @@ - - + + - + diff --git a/ImportPageUC.xaml.vb b/ImportPageUC.xaml.vb index e71df65..88df559 100644 --- a/ImportPageUC.xaml.vb +++ b/ImportPageUC.xaml.vb @@ -105,7 +105,8 @@ Public Class ImportPageUC ImportScene.SetStatusNull() ' imposto misura - If EgtUiUnitsAreMM() Then + m_bMM = EgtUiUnitsAreMM() + If m_bMM Then mmBtn.IsChecked = True Else inchBtn.IsChecked = True diff --git a/MainWindow.xaml.vb b/MainWindow.xaml.vb index ec4b4be..7ac75e7 100644 --- a/MainWindow.xaml.vb +++ b/MainWindow.xaml.vb @@ -1,22 +1,18 @@ Imports System.Collections.ObjectModel Imports EgtUILib Imports System.ComponentModel +Imports System.Threading Imports System.Windows.Threading -'Imports System.Runtime.InteropServices -'Imports System.Threading -'Imports System.Windows.Controls -'Imports System.Globalization -'Imports EgtUILib.EgtInterface -'Imports EgtUILib.Scene -'Imports System.Text - Class MainWindow - 'Dichiarazione della MachineStatusBar + ' Mutex per avere una sola istanza del programma in esecuzione + Private m_objMutex As New Mutex + + ' Dichiarazione della MachineStatusBar Friend m_MachineStatusUC As MachineStatusUC - 'Dichiarazione delle Page UserControl + ' Dichiarazione delle Page UserControl Friend m_WorkInProgressPageUC As WorkInProgressPageUC Friend m_CurrentProjectPageUC As CurrentProjectPageUC Friend m_DirectCutPageUC As DirectCutPageUC @@ -30,10 +26,10 @@ Class MainWindow Friend m_AlarmsPageUC As AlarmsPageUC Friend m_OptionsPageUC As OptionsPageUC - 'Riferimento alla NumericKeyboard necessario per poter impedire il click fuori da essa quando attiva + ' Riferimento alla NumericKeyboard necessario per poter impedire il click fuori da essa quando attiva Friend m_NumericKeyboardWD As NumericKeyboardWD - 'Dichiarazione variabili direttori + ' Dichiarazione variabili direttori Private m_sDataRoot As String = String.Empty Private m_sConfigDir As String = String.Empty Private m_sResourcesDir As String = String.Empty @@ -42,14 +38,14 @@ Class MainWindow Private Shared m_sIniFile As String = String.Empty Private m_nDebug As Integer = 0 - 'Dichiarazione lista per ListBox della ImportPage + ' Dichiarazione lista per ListBox della ImportPage Friend m_ImportItemList As New ObservableCollection(Of IconListBoxItem) - 'Dichiarazione lista materiali e materiale corrente + ' Dichiarazione lista materiali e materiale corrente Friend m_MaterialsList As New List(Of Material) Friend m_nCurrentMaterial As Integer = 0 - 'Riferimento alla pagina correntemente attiva + ' Riferimento alla pagina correntemente attiva Friend m_ActivePage As Pages Enum Pages @@ -83,7 +79,8 @@ Class MainWindow End Function Private Sub Window_Initialized(sender As Object, e As EventArgs) - + ' Verifico sia l'unica istanza + ManageSingleIstance() ' Impostazione path radice per i dati m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory If GetPrivateProfileString(S_DATA, K_DATAROOT, "", m_sDataRoot, m_sDataRoot & "\" & DAT_FILE_NAME) = 0 Then @@ -221,6 +218,41 @@ Class MainWindow End Sub + Private Sub ManageSingleIstance() + Dim bCreated As Boolean + Try + m_objMutex = New Mutex(False, "Global\OmagCut", bCreated) + Catch + bCreated = False + End Try + If Not bCreated Then + ' porto in primo piano la prima istanza + Dim bFound As Boolean = False + ' processi del programma a 32 bit + Dim localProc As Process() = Process.GetProcessesByName("OmagCutR32") + For Each p As Process In localProc + If p.Id <> Process.GetCurrentProcess().Id Then + bFound = True + ShowWindow(p.MainWindowHandle, 1) + Exit For + End If + Next + ' se non trovati processi a 32 bit provo a 64 bit + If Not bFound Then + localProc = Process.GetProcessesByName("OmagCutR64") + For Each p As Process In localProc + If p.Id <> Process.GetCurrentProcess().Id Then + bFound = True + ShowWindow(p.MainWindowHandle, SW.RESTORE) + Exit For + End If + Next + End If + ' esco dal programma + End + End If + End Sub + Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) 'Assegno AboutBoxWD come child della MainWindow @@ -577,6 +609,10 @@ Class MainWindow If m_nCurrentMaterial >= 0 And m_nCurrentMaterial < m_MaterialsList.Count() Then WritePrivateProfileString("Materials", "CurrMaterial", m_MaterialsList(m_nCurrentMaterial).Name, GetIniFile()) End If + ' Terminazione generale di EgtInterface + EgtExit() + ' Rilascio mutex + m_objMutex.Close() End Sub End Class diff --git a/NestPageUC.xaml b/NestPageUC.xaml index 918ae14..105a4d1 100644 --- a/NestPageUC.xaml +++ b/NestPageUC.xaml @@ -19,16 +19,16 @@ - - - - - - - - - + + + + + + + + +