eaafed66b0
- migliorata gestione trasmissione - aggiunti messaggi vari.
298 lines
12 KiB
VB.net
298 lines
12 KiB
VB.net
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Public Class OpenPageUC
|
|
|
|
'Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
|
|
'Dichiarazione del UserControl SceneButtons
|
|
Friend m_SceneButtons As SceneButtonsUC
|
|
|
|
' Properties
|
|
Private m_sCurrDir As String = String.Empty
|
|
Private m_sCurrFile As String = String.Empty
|
|
Private m_bFirst As Boolean = True
|
|
Private m_bFileOk As Boolean = False
|
|
|
|
'Dichiarazione Scene
|
|
Friend WithEvents OpenScene As New Scene
|
|
Dim OpenSceneHost As New System.Windows.Forms.Integration.WindowsFormsHost
|
|
|
|
Private Sub OpenPage_Initialized(sender As Object, e As EventArgs)
|
|
|
|
'Creazione del UserCOntrol SceneButtons
|
|
m_SceneButtons = New SceneButtonsUC
|
|
|
|
'Posizionemento nella griglia del UserControl SceneButtons
|
|
m_SceneButtons.SetValue(Grid.ColumnProperty, 0)
|
|
BottomButtonsGrid.Children.Add(m_SceneButtons)
|
|
|
|
'Assegnazione scena all'host e posizionamento nella OpenPageGrid
|
|
OpenSceneHost.Child = OpenScene
|
|
OpenSceneHost.SetValue(Grid.ColumnProperty, 1)
|
|
OpenSceneHost.SetValue(Grid.RowProperty, 0)
|
|
OpenSceneHost.SetValue(Grid.RowSpanProperty, 2)
|
|
Me.OpenPageGrid.Children.Add(OpenSceneHost)
|
|
|
|
'Definizione del collegamento tra ItemList e ListBox1
|
|
FileListBox.ItemsSource = m_MainWindow.OpenItemList
|
|
|
|
End Sub
|
|
|
|
Private Sub OpenPage_Loaded(sender As Object, e As RoutedEventArgs)
|
|
|
|
If m_bFirst Then
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor, m_MainWindow.GetIniFile())
|
|
OpenScene.SetDefaultMaterial(DefColor)
|
|
' imposto colori sfondo
|
|
Dim BackTopColor As New Color3d(192, 192, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor, m_MainWindow.GetIniFile())
|
|
Dim BackBotColor As New Color3d(BackTopColor)
|
|
GetPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor, m_MainWindow.GetIniFile())
|
|
OpenScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_MARK, MarkColor, m_MainWindow.GetIniFile())
|
|
OpenScene.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor, m_MainWindow.GetIniFile())
|
|
OpenScene.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_MainWindow.GetIniFile())
|
|
OpenScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor, m_MainWindow.GetIniFile())
|
|
OpenScene.SetDistLineMaterial(DstLnColor)
|
|
' imposto parametri OpenGL
|
|
Dim nDriver As Integer = GetPrivateProfileInt(S_OPENGL, K_DRIVER, 3, m_MainWindow.GetIniFile())
|
|
Dim b2Buff As Boolean = (GetPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1, m_MainWindow.GetIniFile()) <> 0)
|
|
Dim nColorBits As Integer = GetPrivateProfileInt(S_OPENGL, K_COLORBITS, 32, m_MainWindow.GetIniFile())
|
|
Dim nDepthBits As Integer = GetPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32, m_MainWindow.GetIniFile())
|
|
OpenScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
' Inizializzazione delle viste
|
|
OpenScene.Init()
|
|
' Imposto griglia
|
|
LoadGridData()
|
|
' leggo direttorio corrente
|
|
GetPrivateProfileString(S_FILEOPEN, K_LASTNGEDIR, "", m_sCurrDir, m_MainWindow.GetIniFile())
|
|
' lo carico
|
|
LoadCurrDir()
|
|
m_bFirst = False
|
|
Else
|
|
EgtSetCurrentContext(OpenScene.GetCtx())
|
|
End If
|
|
|
|
' Pulisco tutto
|
|
ClearView()
|
|
' inibisco selezione diretta da Scene
|
|
OpenScene.SetStatusNull()
|
|
|
|
End Sub
|
|
|
|
Private Sub LoadGridData()
|
|
Dim dSnapStep As Double = GetPrivateProfileDouble(S_GRID, K_SNAPSTEP, 10, m_MainWindow.GetIniFile())
|
|
Dim nMinLineSStep As Integer = GetPrivateProfileInt(S_GRID, K_MINLINESSTEP, 1, m_MainWindow.GetIniFile())
|
|
Dim nMajLineSStep As Integer = GetPrivateProfileInt(S_GRID, K_MAJLINESSTEP, 10, m_MainWindow.GetIniFile())
|
|
Dim nExtSStep As Integer = GetPrivateProfileInt(S_GRID, K_EXTSSTEP, 50, m_MainWindow.GetIniFile())
|
|
Dim MinLnColor As New Color3d(160, 160, 160)
|
|
GetPrivateProfileColor(S_GRID, K_MINLNCOLOR, MinLnColor, m_MainWindow.GetIniFile())
|
|
Dim MajLnColor As New Color3d(160, 160, 160)
|
|
GetPrivateProfileColor(S_GRID, K_MAJLNCOLOR, MajLnColor, m_MainWindow.GetIniFile())
|
|
EgtSetGridFrame(Frame3d.GLOB)
|
|
EgtSetGridGeo(dSnapStep, nMinLineSStep, nMajLineSStep, nExtSStep)
|
|
EgtSetGridColor(MinLnColor, MajLnColor)
|
|
Dim bShowGrid As Boolean = (GetPrivateProfileInt(S_GRID, K_SHOWGRID, 1, m_MainWindow.GetIniFile()) <> 0)
|
|
EgtSetGridShow(bShowGrid, False)
|
|
End Sub
|
|
|
|
Private Function LoadCurrDir() As Boolean
|
|
' se direttorio corrente non valido, carico l'elenco dei dischi
|
|
If String.IsNullOrWhiteSpace(m_sCurrDir) OrElse Not IO.Directory.Exists(m_sCurrDir) Then
|
|
Return LoadDisks()
|
|
End If
|
|
Dim TempPath As New Text.StringBuilder(260)
|
|
PathCompactPathEx(TempPath, m_sCurrDir, 28, 0)
|
|
' lo visualizzo
|
|
FilePathTxBl.Content = TempPath.ToString
|
|
' pulisco la lista
|
|
m_MainWindow.OpenItemList.Clear()
|
|
' per risalire al direttorio padre
|
|
m_MainWindow.OpenItemList.Add(New IconListBoxItem("..", 0))
|
|
' elenco dei sottodirettori
|
|
Dim DirInfo As New DirectoryInfo(m_sCurrDir)
|
|
Dim vDirI As DirectoryInfo() = DirInfo.GetDirectories("*")
|
|
Dim DirI As DirectoryInfo
|
|
For Each DirI In vDirI
|
|
If (DirI.Attributes And FileAttributes.Hidden) <> FileAttributes.Hidden Then
|
|
m_MainWindow.OpenItemList.Add(New IconListBoxItem(DirI.Name, 2))
|
|
End If
|
|
Next
|
|
' elenco dei file
|
|
Dim vFileI As FileInfo() = DirInfo.GetFiles()
|
|
Dim FileI As FileInfo
|
|
For Each FileI In vFileI
|
|
Dim sExt As String = Path.GetExtension(FileI.Name).ToUpper()
|
|
If sExt = ".NGE" Then
|
|
m_MainWindow.OpenItemList.Add(New IconListBoxItem(FileI.Name, 3))
|
|
End If
|
|
Next
|
|
' pulisco la vista
|
|
ClearView()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function LoadDisks() As Boolean
|
|
' dir corrente vuoto
|
|
m_sCurrDir = ""
|
|
' lo visualizzo
|
|
FilePathTxBl.Content = m_sCurrDir
|
|
' pulisco la lista
|
|
m_MainWindow.OpenItemList.Clear()
|
|
' elenco dei dischi
|
|
Dim vDriI As DriveInfo() = DriveInfo.GetDrives()
|
|
Dim DriI As DriveInfo
|
|
For Each DriI In vDriI
|
|
m_MainWindow.OpenItemList.Add(New IconListBoxItem(DriI.Name, 1))
|
|
Next
|
|
' pulisco la vista
|
|
ClearView()
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub FileListBox_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) Handles FileListBox.PreviewMouseUp
|
|
' Recupero item selezionato
|
|
If FileListBox.SelectedItems.Count() = 0 Then
|
|
Return
|
|
End If
|
|
Dim vItems As IconListBoxItem = FileListBox.SelectedItems(0)
|
|
|
|
' A seconda del tipo
|
|
Select Case vItems.PictureID
|
|
Case 0 ' Vai nel direttorio padre
|
|
m_sCurrDir = IO.Path.GetDirectoryName(m_sCurrDir)
|
|
m_sCurrFile = ""
|
|
LoadCurrDir()
|
|
Case 1 ' Vai nella radice del disco
|
|
m_sCurrDir = vItems.Name
|
|
m_sCurrFile = ""
|
|
LoadCurrDir()
|
|
Case 2 ' Vai nel sottodirettorio
|
|
m_sCurrDir = IO.Path.Combine(m_sCurrDir, vItems.Name)
|
|
m_sCurrFile = ""
|
|
LoadCurrDir()
|
|
Case 3 ' File
|
|
m_sCurrFile = vItems.Name
|
|
LoadCurrFile()
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
Private Sub FileListBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles FileListBox.SelectionChanged
|
|
' Recupero item selezionato
|
|
If FileListBox.SelectedItems.Count() = 0 Then
|
|
Return
|
|
End If
|
|
Dim vItems As IconListBoxItem = FileListBox.SelectedItems(0)
|
|
|
|
' Gestisco solo aggiornamento visualizzazione file
|
|
If vItems.PictureID = 3 Then
|
|
m_sCurrFile = vItems.Name
|
|
LoadCurrFile()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ClearView() As Boolean
|
|
' Pulisco il DB geometrico locale
|
|
EgtNewFile()
|
|
' Eseguo zoom
|
|
OpenScene.ZoomAll()
|
|
' Cancello messaggio
|
|
Me.MessageTxBl.Text = ""
|
|
Me.MessageBrd.Background = Brushes.White
|
|
m_bFileOk = False
|
|
OkBtn.IsEnabled = False
|
|
Return True
|
|
End Function
|
|
|
|
Private Function LoadCurrFile() As Boolean
|
|
' Pulisco il DB geometrico locale
|
|
Dim bOk As Boolean = EgtNewFile()
|
|
' Costruisco path completa del componente
|
|
Dim sPath = IO.Path.Combine(m_sCurrDir, m_sCurrFile)
|
|
' Riconoscimento tipo
|
|
Dim nFileType As Integer = EgtGetFileType(sPath)
|
|
If nFileType = FT.NGE Then
|
|
' Carico Nge
|
|
bOk = bOk AndAlso EgtOpenFile(sPath)
|
|
Else
|
|
' Formato sconosciuto
|
|
bOk = False
|
|
End If
|
|
' Cerco contrassegno di progetto SarmaxWall
|
|
Dim nMarkId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_PROJMARK)
|
|
m_bFileOk = bOk And (nMarkId <> GDB_ID.NULL)
|
|
If m_bFileOk Then
|
|
Me.MessageTxBl.Text = ""
|
|
Me.MessageBrd.Background = Brushes.White
|
|
OkBtn.IsEnabled = True
|
|
Else
|
|
Me.MessageTxBl.Text = EgtMsg(MSG_OPENPAGEUC + 1) 'Progetto non valido
|
|
Me.MessageBrd.Background = Brushes.Tomato
|
|
OkBtn.IsEnabled = False
|
|
End If
|
|
' Eseguo zoom
|
|
OpenScene.ZoomAll()
|
|
Return bOk
|
|
End Function
|
|
|
|
Private Sub OnMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles OpenScene.OnMouseDownScene
|
|
End Sub
|
|
|
|
Private Sub ConfirmBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
|
|
' Verifico che il file corrente sia valido
|
|
If Not m_bFileOk Then
|
|
Return
|
|
End If
|
|
' Passo al contesto principale
|
|
EgtSetCurrentContext(m_MainWindow.m_PlacePageUC.PlaceScene.GetCtx())
|
|
' Costruisco path completa del componente
|
|
Dim sPath = IO.Path.Combine(m_sCurrDir, m_sCurrFile)
|
|
' Apro il progetto
|
|
EgtOpenFile(sPath)
|
|
' Dichiaro progetto modificato
|
|
EgtSetModified()
|
|
' Aggiorno ambiente principale
|
|
EgtZoom(ZM.ALL, False)
|
|
m_MainWindow.m_PlacePageUC.MyDraw()
|
|
'Istruzioni per chiudere ImportPageUC e aprire PlacePage UC
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_OpenPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_PlacePageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Place
|
|
m_MainWindow.OpenBtn.IsChecked = False
|
|
m_MainWindow.PlaceBtn.IsChecked = True
|
|
End Sub
|
|
|
|
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
|
|
'Istruzioni per chiudere ImportPageUC e aprire PlacePage UC
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_OpenPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_PlacePageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Place
|
|
m_MainWindow.OpenBtn.IsChecked = False
|
|
m_MainWindow.PlaceBtn.IsChecked = True
|
|
End Sub
|
|
|
|
Private Sub OpenPage_Unloaded(sender As Object, e As RoutedEventArgs)
|
|
' Salvo direttorio corrente
|
|
WritePrivateProfileString(S_FILEOPEN, K_LASTNGEDIR, m_sCurrDir, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
|
|
End Class
|