c529c9dd59
- aggiungo file mancanti.
292 lines
13 KiB
VB.net
292 lines
13 KiB
VB.net
Imports System.Runtime.InteropServices
|
|
Imports System.Threading
|
|
|
|
Imports System.Windows.Controls
|
|
Imports System.Globalization
|
|
Imports EgtUILib
|
|
Imports EgtUILib.EgtInterface
|
|
Imports EgtUILib.Scene
|
|
Imports System.Text
|
|
|
|
Class MainWindow
|
|
|
|
Private m_sDataRoot As String = String.Empty
|
|
Private m_sConfigDir As String = String.Empty
|
|
Private m_sTempDir As String = String.Empty
|
|
Private m_sMachinesRoot As String = String.Empty
|
|
Private Shared m_sIniFile As String = String.Empty
|
|
Private m_nDebug As Integer = 0
|
|
Private WithEvents m_Controller1 As New Controller
|
|
Private WithEvents m_Controller2 As New Controller
|
|
|
|
'Per creazione Scene
|
|
Friend WithEvents MachiningScene As Scene
|
|
Friend WithEvents ActiveScene As Scene
|
|
Friend TavolaInLavorazioneHost As New System.Windows.Forms.Integration.WindowsFormsHost
|
|
Friend TavolaInProgettoHost As New System.Windows.Forms.Integration.WindowsFormsHost
|
|
|
|
'Per TagliCadUC
|
|
Friend m_TagliCadUC As TagliCadUC
|
|
Private m_ComponentiUC As ComponentiUC
|
|
Friend m_GrezzoUC As GrezzoUC
|
|
Friend WithEvents m_NumericKeyboardWD As NumericKeyboardWD
|
|
|
|
'Riferimento alla textbox che ha aperto la tastiera
|
|
'Friend m_TxBxGotKeyboardFocus As TextBox
|
|
|
|
'***********************************************
|
|
|
|
Public Shared Function GetIniFile() As String
|
|
Return m_sIniFile
|
|
End Function
|
|
|
|
Private Sub Window_Initialized(sender As Object, e As EventArgs)
|
|
|
|
' 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
|
|
m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory
|
|
End If
|
|
' Impostazione direttorio di configurazione
|
|
m_sConfigDir = m_sDataRoot & "\" & CONF_DIR
|
|
' Impostazione direttorio per file temporanei
|
|
m_sTempDir = m_sDataRoot & "\" & TEMP_DIR
|
|
' Impostazione path Ini file
|
|
m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME
|
|
' Impostazione direttorio per le macchine
|
|
If GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", m_sMachinesRoot, m_sIniFile) = 0 Then
|
|
m_sMachinesRoot = m_sDataRoot & "\" & MACHINES_DFL_DIR
|
|
End If
|
|
' Leggo e imposto chiave di protezione
|
|
Dim sLicFileName As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_LICENCE, LIC_FILE_NAME, sLicFileName, m_sIniFile)
|
|
Dim sLicFile As String = m_sConfigDir & "\" & sLicFileName
|
|
Dim sKey As String = String.Empty
|
|
GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile)
|
|
EgtSetKey(sKey)
|
|
'Inizializzazione generale di EgtInterface
|
|
m_nDebug = GetPrivateProfileInt(S_GENERAL, K_DEBUG, 0, m_sIniFile)
|
|
Dim sLogFile As String = m_sTempDir & "\" & GENLOG_FILE_NAME
|
|
Dim sLogMsg As String = My.Application.Info.Description.ToString() & " ver. " & My.Application.Info.Version.ToString()
|
|
EgtInit(m_nDebug, sLogFile, sLogMsg)
|
|
' Leggo file messaggi
|
|
Dim sMsgFile As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_MESSAGES, "", sMsgFile, m_sIniFile)
|
|
Dim sMsgFilePath As String = m_sConfigDir & "\" & sMsgFile
|
|
If Not EgtLoadMessages(sMsgFilePath) Then
|
|
EgtOutLog("Error in EgtLoadMessages")
|
|
End If
|
|
|
|
'Creazione UserControl dinamici
|
|
m_TagliCadUC = New TagliCadUC
|
|
m_ComponentiUC = New ComponentiUC
|
|
m_GrezzoUC = New GrezzoUC
|
|
m_NumericKeyboardWD = New NumericKeyboardWD
|
|
|
|
'Posiziono gli Host nelle rispettive griglie
|
|
TavolaInLavorazioneHost.SetValue(Grid.ColumnProperty, 0)
|
|
TavolaInLavorazioneHost.SetValue(Grid.RowProperty, 1)
|
|
TavolaInProgettoHost.SetValue(Grid.ColumnProperty, 0)
|
|
TavolaInProgettoHost.SetValue(Grid.RowProperty, 1)
|
|
|
|
'Assegno l'host TavolaInLavorazioneHost a LavoroInCorsoUC
|
|
LavoroInCorsoUC.BackGroundGridLavoroInCorso.Children.Add(TavolaInLavorazioneHost)
|
|
|
|
End Sub
|
|
|
|
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
|
|
|
|
'Assegno la NumericKeyboardWD come child della MainWindow
|
|
m_NumericKeyboardWD.Owner = Me
|
|
|
|
'Creo la scena
|
|
Me.MachiningScene = New Scene
|
|
Me.ActiveScene = New Scene
|
|
|
|
'Assegno il controllo Scena come Child dell'host
|
|
TavolaInLavorazioneHost.Child = MachiningScene
|
|
TavolaInProgettoHost.Child = ActiveScene
|
|
|
|
'' 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
|
|
' m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory
|
|
'End If
|
|
'' Impostazione direttorio di configurazione
|
|
'm_sConfigDir = m_sDataRoot & "\" & CONF_DIR
|
|
'' Impostazione direttorio per file temporanei
|
|
'm_sTempDir = m_sDataRoot & "\" & TEMP_DIR
|
|
'' Impostazione path Ini file
|
|
'm_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME
|
|
'' Impostazione direttorio per le macchine
|
|
'If GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", m_sMachinesRoot, m_sIniFile) = 0 Then
|
|
' m_sMachinesRoot = m_sDataRoot & "\" & MACHINES_DFL_DIR
|
|
'End If
|
|
'' Leggo e imposto chiave di protezione
|
|
'Dim sLicFileName As String = String.Empty
|
|
'GetPrivateProfileString(S_GENERAL, K_LICENCE, LIC_FILE_NAME, sLicFileName, m_sIniFile)
|
|
'Dim sLicFile As String = m_sConfigDir & "\" & sLicFileName
|
|
'Dim sKey As String = String.Empty
|
|
'GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile)
|
|
'EgtSetKey(sKey)
|
|
''Inizializzazione generale di EgtInterface
|
|
'm_nDebug = GetPrivateProfileInt(S_GENERAL, K_DEBUG, 0, m_sIniFile)
|
|
'Dim sLogFile As String = m_sTempDir & "\" & GENLOG_FILE_NAME
|
|
'Dim sLogMsg As String = My.Application.Info.Description.ToString() & " ver. " & My.Application.Info.Version.ToString()
|
|
'EgtInit(m_nDebug, sLogFile, sLogMsg)
|
|
'' Leggo file messaggi
|
|
'Dim sMsgFile As String = String.Empty
|
|
'GetPrivateProfileString(S_GENERAL, K_MESSAGES, "", sMsgFile, m_sIniFile)
|
|
'Dim sMsgFilePath As String = m_sConfigDir & "\" & sMsgFile
|
|
'If Not EgtLoadMessages(sMsgFilePath) Then
|
|
' EgtOutLog("Error in EgtLoadMessages")
|
|
'End If
|
|
' imposto dir font Nfe e font default
|
|
Dim sNfeDir As String = String.Empty
|
|
GetPrivateProfileString(S_GEOMDB, K_NFEFONTDIR, "", sNfeDir, m_sIniFile)
|
|
Dim sDefFont As String = String.Empty
|
|
GetPrivateProfileString(S_GEOMDB, K_DEFAULTFONT, "", sDefFont, m_sIniFile)
|
|
EgtSetFont(sNfeDir, sDefFont)
|
|
' imposto direttorio di default per libreria Lua
|
|
Dim sLuaLibsDir As String = String.Empty
|
|
GetPrivateProfileString(S_LUA, K_LIBSDIR, "", sLuaLibsDir, m_sIniFile)
|
|
EgtSetLuaLibs(sLuaLibsDir)
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor, m_sIniFile)
|
|
MachiningScene.SetDefaultMaterial(DefColor)
|
|
ActiveScene.SetDefaultMaterial(DefColor)
|
|
' imposto colori sfondo
|
|
Dim BackTopColor As New Color3d(192, 192, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor, m_sIniFile)
|
|
Dim BackBotColor As New Color3d(BackTopColor)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor, m_sIniFile)
|
|
MachiningScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
ActiveScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_MARK, MarkColor, m_sIniFile)
|
|
MachiningScene.SetMarkMaterial(MarkColor)
|
|
ActiveScene.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor, m_sIniFile)
|
|
MachiningScene.SetSelSurfMaterial(SelSurfColor)
|
|
ActiveScene.SetSelSurfMaterial(SelSurfColor)
|
|
' imposto tipo e colore del rettangolo di zoom
|
|
Dim bOutline As Boolean = True
|
|
Dim ZwColor As New Color3d(0, 0, 0)
|
|
GetPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor, m_sIniFile)
|
|
MachiningScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
ActiveScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor, m_sIniFile)
|
|
MachiningScene.SetDistLineMaterial(DstLnColor)
|
|
ActiveScene.SetDistLineMaterial(DstLnColor)
|
|
' imposto parametri OpenGL
|
|
Dim nDriver As Integer = GetPrivateProfileInt(S_OPENGL, K_DRIVER, 3, m_sIniFile)
|
|
Dim b2Buff As Boolean = (GetPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1, m_sIniFile) <> 0)
|
|
Dim nColorBits As Integer = GetPrivateProfileInt(S_OPENGL, K_COLORBITS, 32, m_sIniFile)
|
|
Dim nDepthBits As Integer = GetPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32, m_sIniFile)
|
|
MachiningScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
ActiveScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
'Inizializzazione delle viste
|
|
If Not MachiningScene.Init() Then
|
|
Close()
|
|
End If
|
|
ActiveScene.Init()
|
|
'Impostazioni modificabili vista 2 (vanno fatte dopo Init)
|
|
'EgtSetMarkAttribs(New Color3d(128, 255, 255))
|
|
'EgtSetGeoLineAttribs(New Color3d(0, 255, 0))
|
|
'EgtSetWinRectAttribs(False, New Color3d(255, 128, 128, 30))
|
|
' Impostazione dei controller
|
|
m_Controller1.SetScene(MachiningScene)
|
|
m_Controller2.SetScene(ActiveScene)
|
|
'Attiva scena 1
|
|
'OnMouseDownScene(scene1)
|
|
'Posizione e dimensioni del Form
|
|
'If ModifierKeys <> Keys.Shift Then
|
|
' Dim nFlag As Integer
|
|
' Dim nLeft As Integer
|
|
' Dim nTop As Integer
|
|
' Dim nWidth As Integer
|
|
' Dim nHeight As Integer
|
|
' GetPrivateProfileWinPos("General", "WinPlace", nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFile)
|
|
' Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
|
|
' Me.Location = New Point(nLeft, nTop)
|
|
' Me.Size = New Size(nWidth, nHeight)
|
|
' WindowState = IIf(nFlag = 1, FormWindowState.Maximized, FormWindowState.Normal)
|
|
'End If
|
|
|
|
'Eventi da UserControl
|
|
'TagliCadUC
|
|
AddHandler m_TagliCadUC.ComponentsBtnMW_Click, AddressOf ComponentsBtnMW_Click
|
|
AddHandler m_TagliCadUC.ZoomAllBtnMW_Click, AddressOf ZoomAllBtnMW_Click
|
|
|
|
End Sub
|
|
|
|
Private Sub TabControl_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
|
|
If (e.RemovedItems.Count > 0) Then
|
|
If (e.RemovedItems.Item(0).Equals(TabTagliDiretti)) Then
|
|
TagliDirettiUC.BackGroundGridTagliDiretti.Children.Remove(TavolaInProgettoHost)
|
|
End If
|
|
If (TabTagliCad.IsSelected = False) Then
|
|
m_TagliCadUC.BackGroundGridLavorazioniPiane.Children.Remove(TavolaInProgettoHost)
|
|
End If
|
|
If (TabLavorazioneCornici.IsSelected = False) Then
|
|
CorniciUC.BackGroundGridLavorazioneCornici.Children.Remove(TavolaInProgettoHost)
|
|
End If
|
|
|
|
End If
|
|
|
|
If (TabTagliDiretti.IsSelected) Then
|
|
TagliDirettiUC.BackGroundGridTagliDiretti.Children.Add(TavolaInProgettoHost)
|
|
Exit Sub
|
|
End If
|
|
If (TabTagliCad.IsSelected) Then
|
|
TagliCadContent.Content = m_TagliCadUC
|
|
m_TagliCadUC.BackGroundGridLavorazioniPiane.Children.Add(TavolaInProgettoHost)
|
|
Exit Sub
|
|
End If
|
|
If (TabLavorazioneCornici.IsSelected) Then
|
|
CorniciUC.BackGroundGridLavorazioneCornici.Children.Add(TavolaInProgettoHost)
|
|
Exit Sub
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub ExitBtnMW_Click(sender As Object, e As RoutedEventArgs)
|
|
Close()
|
|
End Sub
|
|
|
|
'-- ** Eventi del TABITEM LAVORAZIONI PIANE ** --
|
|
|
|
Private Sub ComponentsBtnMW_Click(sender As Object, e As RoutedEventArgs)
|
|
TagliCadContent.Content = m_ComponentiUC
|
|
End Sub
|
|
|
|
Private Sub ZoomAllBtnMW_Click(sender As Object, e As RoutedEventArgs)
|
|
MachiningScene.ZoomAll()
|
|
End Sub
|
|
|
|
'Impedisce di clickare fuori dal UC Componenti finchè questo è aperto
|
|
Private Sub MainWindow_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
|
|
If (m_ComponentiUC.IsVisible And Not m_ComponentiUC.IsMouseOver) Then
|
|
e.Handled = True
|
|
End If
|
|
If (m_GrezzoUC.IsVisible And Not m_GrezzoUC.IsMouseOver) Then
|
|
e.Handled = True
|
|
End If
|
|
If (m_NumericKeyboardWD.IsVisible And Not m_NumericKeyboardWD.IsMouseOver) Then
|
|
e.Handled = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MainWindow_KeyDown(sender As Object, e As KeyEventArgs)
|
|
If (m_NumericKeyboardWD.IsVisible And e.Key = Key.Enter) Then
|
|
m_NumericKeyboardWD.Visibility = Windows.Visibility.Hidden
|
|
End If
|
|
End Sub
|
|
|
|
End Class |