Files
OmagCUT/SaveNameWD.xaml.vb
T
Emmanuele Sassi 113f07fee0 OmagCUT :
- Correzione chiusura EgtMsgBox che causava rallentamenti su alcuni PC.
2017-05-02 15:47:28 +00:00

86 lines
3.5 KiB
VB.net

Imports System.IO
Imports EgtUILib
Imports EgtWPFLib
Public Class SaveNameWD
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
Sub New(Owner As Window)
Me.Owner = Owner
InitializeComponent()
End Sub
Private Sub SaveNameWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
Me.Top = Owner.Top + Owner.Height / 2 - Me.Height / 2
Me.Left = Owner.Left + Owner.Width / 2 - Me.Width / 2
If m_MainWindow.m_ActivePage <> MainWindow.Pages.DirectCut Then
SaveNameTxbl.Text = EgtMsg(MSG_CADCUTPAGEUC + 7) 'Nuovo nome del progetto
GetPrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", SaveNameTxBx.Text, m_MainWindow.GetIniFile())
Else
SaveNameTxbl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 45) 'Nuovo nome della dima
End If
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
Dim sPath As String = String.Empty
If m_MainWindow.m_ActivePage <> MainWindow.Pages.DirectCut Then
' Creo path completa con nome inserito
sPath = m_MainWindow.GetNamedSaveDir() & "\" & SaveNameTxBx.Text & ".nge"
Else
sPath = m_MainWindow.GetCopyTemplateDir() & "\" & SaveNameTxBx.Text & ".dxf"
End If
' Verifico se il nome inserito è già utilizzato
If File.Exists(sPath) Then
Dim ConfirmWD As EgtMsgBox
If m_MainWindow.IsSiemensPc() Then
ConfirmWD = New EgtMsgBox(m_MainWindow, m_MainWindow.ActualWidth / 15 * 4.5, EgtMsgBox.WidthType.PIXEL, "", EgtMsg(MSG_EGTMSGBOX + 6), EgtMsgBox.Buttons.OK_CANCEL, EgtMsgBox.Icons.NULL)
Else
ConfirmWD = New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 6), EgtMsgBox.Buttons.OK_CANCEL, EgtMsgBox.Icons.NULL)
End If
Select Case ConfirmWD.m_nPressedBtn
Case 0 'Cancel
' Esco
Return
End Select
End If
If m_MainWindow.m_ActivePage <> MainWindow.Pages.DirectCut Then
' Aggiorno file Ini
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, SaveNameTxBx.Text, m_MainWindow.GetIniFile())
' Eseguo salvataggio
m_MainWindow.m_CurrentProjectPageUC.SaveNamedProject()
m_MainWindow.m_CurrentProjectPageUC.SaveProject()
' Se cornici, ripristino visualizzazione lavorazioni
If m_MainWindow.m_ActivePage = MainWindow.Pages.FrameCut Then
ShowAllCurrPhaseMachinings()
End If
Else
' Recupero nome gruppo da esportare
Dim nId = EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_COPYTEMPLATE)
' Se UI in pollici, scalo opportunamente per avere DXF in pollici
Dim bScale As Boolean = Not EgtUiUnitsAreMM()
If bScale Then EgtScale(nId, Frame3d.GLOB, 1 / ONEINCH, 1 / ONEINCH, 1 / ONEINCH, GDB_RT.GLOB)
' Eseguo esportazione
EgtExportDxf(nId, sPath)
' Se necessario, ripristino scala
If bScale Then EgtScale(nId, Frame3d.GLOB, ONEINCH, ONEINCH, ONEINCH, GDB_RT.GLOB)
End If
EgtDraw()
Close()
End Sub
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
EgtDraw()
Close()
End Sub
Private Sub Me_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.Key = Key.System And e.SystemKey = Key.F4 Then
e.Handled = True
End If
End Sub
End Class