-modifica finestra egtmanagedialog

This commit is contained in:
Demetrio Cassarino
2026-02-13 16:31:02 +01:00
parent c045740b10
commit 117e603663
2 changed files with 75 additions and 61 deletions
@@ -1,12 +1,10 @@
Imports System.Windows.Forms
Public Class EgtManageFileDialogV
Public Class EgtManageFileDialogV
#Region "FIELDS & PROPERTIES"
Private WithEvents m_EgtManageFileDialogVM As EgtManageFileDialogVM
Private Shadows DialogResult As DialogResult
Private Shadows DialogResult As Boolean
''' <summary>
''' Stringa che specifica il titolo da mostrare
@@ -117,7 +115,7 @@ Public Class EgtManageFileDialogV
#Region "EVENTS"
Private Sub CloseWindow(DialogResult As DialogResult) Handles m_EgtManageFileDialogVM.OnCloseWindow
Private Sub CloseWindow(DialogResult As Boolean) Handles m_EgtManageFileDialogVM.OnCloseWindow
Me.DialogResult = DialogResult
Me.Close()
End Sub
@@ -126,7 +124,7 @@ Public Class EgtManageFileDialogV
#Region "METHODS"
Public Overloads Function ShowDialog() As DialogResult
Public Overloads Function ShowDialog() As Boolean
MyBase.ShowDialog()
Return Me.DialogResult
End Function
+71 -55
View File
@@ -1,6 +1,5 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports System.Windows.Forms
Imports EgtUILib
Imports System.Data
@@ -36,7 +35,7 @@ Public Class EgtManageFileDialogVM
End Set
End Property
'Scelta della modalità di salvataggio 1 = file 2 = folder
' Scelta della modalità di salvataggio 1 = file 2 = folder
Private m_nMode As Integer
Public Property nMode As Integer
Get
@@ -125,7 +124,7 @@ Public Class EgtManageFileDialogVM
NotifyPropertyChanged(NameOf(ItemSelected))
End Sub
'Percorso del file o della cartella
' Percorso del file o della cartella
Private m_sSelPath As String
Public Overloads Property sSelPath As String
Get
@@ -137,7 +136,7 @@ Public Class EgtManageFileDialogVM
End Set
End Property
'Textbox per visualizzare il file o la folder selezionata
' Textbox per visualizzare il file o la folder selezionata
Private m_sSaveFileName As String
Public Property sSaveFileName As String
Get
@@ -149,7 +148,7 @@ Public Class EgtManageFileDialogVM
End Set
End Property
'Lista filtri estensione
' Lista filtri estensione
Private m_FilterList As ObservableCollection(Of EgtExstension)
Public Property FilterList As ObservableCollection(Of EgtExstension)
Get
@@ -160,7 +159,7 @@ Public Class EgtManageFileDialogVM
End Set
End Property
'Scelta filtro estensione per visualizzazione
' Scelta filtro estensione per visualizzazione
Public m_SelFilter As EgtExstension
Public Property SelFilter As EgtExstension
Get
@@ -186,7 +185,7 @@ Public Class EgtManageFileDialogVM
End Set
End Property
'Scelta modalita' di visualizzazione
' Scelta modalita' di visualizzazione
Private m_SelViewMode As IdNameStruct
Public Property SelViewMode As IdNameStruct
Get
@@ -198,18 +197,18 @@ Public Class EgtManageFileDialogVM
Case VisualizationType.LISTTEMPLATE
m_nSelTab = VisualizationContainerType.LISTBOX
nSelTempleteListView = 0
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, CStr(VisualizationType.LISTTEMPLATE))
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.LISTTEMPLATE)
Case VisualizationType.TILESTEMPLATE
m_nSelTab = VisualizationContainerType.LISTBOX
nSelTempleteListView = 1
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, CStr(VisualizationType.TILESTEMPLATE))
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.TILESTEMPLATE)
Case VisualizationType.CONTENTTEMPLATE
m_nSelTab = VisualizationContainerType.LISTBOX
nSelTempleteListView = 2
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, CStr(VisualizationType.CONTENTTEMPLATE))
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.CONTENTTEMPLATE)
Case VisualizationType.DETAILSTEMPLATE
m_nSelTab = VisualizationContainerType.DATAGRID
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, CStr(VisualizationType.DETAILSTEMPLATE))
WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.DETAILSTEMPLATE)
End Select
NotifyPropertyChanged(NameOf(nSelTab))
End Set
@@ -226,7 +225,7 @@ Public Class EgtManageFileDialogVM
End Set
End Property
' indice di selezione del TabControl che cambia la ListBox/DataGrid
' Indice di selezione del TabControl che cambia la ListBox/DataGrid
Private m_nSelTab As Integer
Public Property nSelTab As Integer
Get
@@ -248,6 +247,7 @@ Public Class EgtManageFileDialogVM
Set(value As Integer)
m_nFilterIndex = value
m_SelFilter = m_FilterList.FirstOrDefault(Function(x) x.nIndexExstension = m_nFilterIndex)
sFileName = Path.GetFileNameWithoutExtension(sFileName) & m_SelFilter.sExstension.Trim("*"c)
End Set
End Property
@@ -281,7 +281,7 @@ Public Class EgtManageFileDialogVM
End Get
Set(value As String)
m_sInitialDirectory = value
If m_sFileName = String.Empty Then m_sSaveFileName = "New.icrs"
If m_sFileName = String.Empty Then m_sSaveFileName = "New.nge"
m_sSelPath = m_sInitialDirectory
Dim DirectoryStart As String() = m_sInitialDirectory.Split("\"c)
@@ -292,17 +292,18 @@ Public Class EgtManageFileDialogVM
m_RootListTmp = m_RootList
For Each directory As String In DirectoryStart
dir = m_RootListTmp.FirstOrDefault(Function(x) x.sName.Trim("\"c) = directory)
dir.IsExpanded = True
currItem = TryCast(dir, EgtFolder)
m_RootListTmp = currItem.FolderList
If count = DirectoryStart.Count Then
dir.IsSelected = True
Else
count += 1
dir = m_RootListTmp.FirstOrDefault(Function(x) x.sName.Trim("\") = directory)
If Not IsNothing(dir) Then
dir.IsExpanded = True
currItem = TryCast(dir, EgtFolder)
m_RootListTmp = currItem.FolderList
If count = DirectoryStart.Count Then
dir.IsSelected = True
Else
count += 1
End If
End If
Next
End Set
End Property
@@ -314,7 +315,7 @@ Public Class EgtManageFileDialogVM
End Get
Set(value As String)
m_sFileName = value
m_sSaveFileName = Path.GetFileName(m_sFileName)
m_sSaveFileName = m_sFileName
End Set
End Property
@@ -360,20 +361,21 @@ Public Class EgtManageFileDialogVM
Public ReadOnly Property FileName_Msg As String
Get
Return If(m_nMode = ModeTypes.FILE, EgtMsg(15065), EgtMsg(15066)) ' File Name Folder Name
' Nome File Nome Cartella
Return If(m_nMode = ModeTypes.FILE, EgtMsg(15065), EgtMsg(15066))
End Get
End Property
#End Region
'Comandi
' Comandi
Private m_cmdCancel As ICommand
Private m_cmdOk As ICommand
Private m_cmdGoBack As ICommand
Private m_cmdDoubleClick As ICommand
Public Event OnCloseWindow(bDialogResult As DialogResult)
Friend Event OnCloseWindow(bDialogResult As Boolean)
#End Region ' FIELDS & PROPERTIES
#End Region ' Fields & Properties
#Region "CONTRUCTORS"
@@ -405,8 +407,7 @@ Public Class EgtManageFileDialogVM
NotifyPropertyChanged(NameOf(SelViewMode))
End Sub
#End Region ' CONTRUCTORS
#End Region ' Constructors
#Region "METHODS"
@@ -417,21 +418,21 @@ Public Class EgtManageFileDialogVM
m_ViewModeList = New ObservableCollection(Of IdNameStruct)
Dim ItemVisualization As New IdNameStruct With {
.Id = 0,
.Name = EgtMsg(15067) ' List Templete
.Name = EgtMsg(15067) ' Elenco
}
m_ViewModeList.Add(ItemVisualization)
ItemVisualization.Id = 3
ItemVisualization.Name = EgtMsg(15068) ' Detalis Templete
ItemVisualization.Name = EgtMsg(15068) ' Dettagli
m_ViewModeList.Add(ItemVisualization)
ItemVisualization.Id = 1
ItemVisualization.Name = EgtMsg(15069) ' Tiles Templete
ItemVisualization.Name = EgtMsg(15069) ' Riquadri
m_ViewModeList.Add(ItemVisualization)
ItemVisualization.Id = 2
ItemVisualization.Name = EgtMsg(15070) ' Content Templete
ItemVisualization.Name = EgtMsg(15070) ' Contenuto
m_ViewModeList.Add(ItemVisualization)
End Sub
#End Region
#End Region ' Methods
#Region "COMMANDS"
@@ -456,7 +457,8 @@ Public Class EgtManageFileDialogVM
If Not IsNothing(CurrItem) And m_bCheckFileExists And m_bValidateNames Then
For Each simbol As String In simbolsCharacter
If m_sSaveFileName.Contains(simbol) Then
If EgtMessageBoxV.Show(System.Windows.Application.Current.MainWindow, EgtMsg(15072), sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.Cancel Then ' Errore file contiene simboli non conformi
' Errore file contiene simboli non conformi
If EgtMessageBoxV.Show(System.Windows.Application.Current.MainWindow, EgtMsg(15072), sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.Cancel Then
sSaveFileName = CurrItem.sName
Return
End If
@@ -467,6 +469,7 @@ Public Class EgtManageFileDialogVM
ElseIf m_bValidateNames = False And m_bOverwritePrompt Then
If Not IsNothing(CurrItem) Then
If m_sFileName.Equals(m_sSaveFileName) OrElse m_sSaveFileName.Equals(CurrItem.sName) Then
' File già esistente. Vuoi sovrascrivere?
If EgtMessageBoxV.Show(System.Windows.Application.Current.MainWindow, EgtMsg(15073), sTitle, MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then
Return
End If
@@ -480,7 +483,8 @@ Public Class EgtManageFileDialogVM
ElseIf nMode = ModeTypes.FOLDER Then
For Each simbol As String In simbolsCharacter
If m_sSaveFileName.Contains(simbol) Then
If EgtMessageBoxV.Show(System.Windows.Application.Current.MainWindow, EgtMsg(15072), sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.Cancel Then ' Errore file contiene simboli non conformi
' Errore file contiene simboli non conformi
If EgtMessageBoxV.Show(System.Windows.Application.Current.MainWindow, EgtMsg(15072), sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.Cancel Then
Return
End If
Else
@@ -488,7 +492,7 @@ Public Class EgtManageFileDialogVM
End If
Next
End If
RaiseEvent OnCloseWindow(DialogResult.OK)
RaiseEvent OnCloseWindow(True)
End Sub
#End Region 'Ok
@@ -529,7 +533,7 @@ Public Class EgtManageFileDialogVM
End Property
Public Sub Cancel()
RaiseEvent OnCloseWindow(DialogResult.Cancel)
RaiseEvent OnCloseWindow(False)
End Sub
#End Region 'Cancel
@@ -551,21 +555,30 @@ Public Class EgtManageFileDialogVM
Dim CurrItemSelected As EgtFolder = DirectCast(m_ItemSelected, EgtFolder)
CurrItemSelected.SetIsSelected(True, True)
m_sSelPath = CurrItemSelected.sFullName
Else
m_ItemSelected.IsSelected = True
ElseIf TypeOf m_ItemSelected Is EgtItem Then
Dim CurrItemSelected As EgtItem = DirectCast(m_ItemSelected, EgtItem)
m_ItemSelected.IsExpanded = False
If File.Exists(CurrItemSelected.sFullName) Then
m_sFileName = CurrItemSelected.sFullName
RaiseEvent OnCloseWindow(True)
Else
EgtOutLog("File Inesistente")
End If
End If
NotifyPropertyChanged(NameOf(sSelPath))
End Sub
#End Region 'DoubleClick
#End Region ' COMMANDS
#End Region ' Commands
End Class
Public Class EgtExstension
Inherits VMBase
#Region "FIELDS & PROPERTIES"
' Indice estensione
Public m_nIndexExstension As Integer
Public Property nIndexExstension As Integer
@@ -578,7 +591,7 @@ Public Class EgtExstension
End Set
End Property
' Nome della stringa Filter Splittata m_sNameExstension = Icarus project
' Nome della stringa Filter Splittata m_sNameExstension = EgtStone3D project
Public m_sNameExstension As String
Public Property sNameExstension As String
Get
@@ -590,7 +603,7 @@ Public Class EgtExstension
End Set
End Property
' Estensione della stringa Filter Splittata m_sExstension = *.icrs
' Estensione della stringa Filter Splittata m_sExstension = *.wme
Public m_sExstension As String
Public Property sExstension As String
Get
@@ -602,6 +615,8 @@ Public Class EgtExstension
End Set
End Property
#End Region ' Fields & Properties
End Class
Public MustInherit Class EgtDirectory
@@ -653,7 +668,7 @@ Public MustInherit Class EgtDirectory
End Set
End Property
#End Region ' FIELDS & PROPERTIES
#End Region ' Fields & Properties
End Class
@@ -754,7 +769,7 @@ Public Class EgtFolder
NotifyPropertyChanged(NameOf(IsSelected))
End Sub
#End Region ' FIELDS & PROPERTIES
#End Region ' Fields & Properties
#Region "CONTRUCTORS"
@@ -770,12 +785,12 @@ Public Class EgtFolder
End If
Catch ex As Exception
End Try
m_ParentFolder = CType(Parent, EgtFolder)
m_ParentFolder = Parent
m_ItemList_View = CType(CollectionViewSource.GetDefaultView(m_FolderList), CollectionView)
m_ItemList_View = CollectionViewSource.GetDefaultView(m_FolderList)
m_ItemList_View.Filter = AddressOf ItemFilter
m_TreeItemList_ViewSource = New CollectionViewSource() With {.Source = m_FolderList}
m_TreeItemList_View = CType(m_TreeItemList_ViewSource.View, CollectionView)
m_TreeItemList_View = m_TreeItemList_ViewSource.View
m_TreeItemList_View.Filter = AddressOf TreeItemListFilter
NotifyPropertyChanged(NameOf(sName))
@@ -786,7 +801,7 @@ Public Class EgtFolder
NotifyPropertyChanged(NameOf(ParentFolder))
End Sub
#End Region ' CONTRUCTORS
#End Region ' Constructors
#Region "METHODS"
@@ -807,9 +822,9 @@ Public Class EgtFolder
Private Function ItemFilter(Item As Object) As Boolean
Dim CurrItem As EgtItem = TryCast(Item, EgtItem)
If Not IsNothing(CurrItem) AndAlso Not IsNothing(m_refEgtManageFileDialogVM.m_SelFilter.m_sExstension) Then
If CurrItem.sTypeItem = m_refEgtManageFileDialogVM.m_SelFilter.m_sExstension.TrimStart("*"c) Then
If CurrItem.sTypeItem = m_refEgtManageFileDialogVM.m_SelFilter.m_sExstension.TrimStart("*") Then
Return True
ElseIf m_refEgtManageFileDialogVM.m_SelFilter.m_sExstension.TrimStart("*"c) = ".*" Then
ElseIf m_refEgtManageFileDialogVM.m_SelFilter.m_sExstension.TrimStart("*") = ".*" Then
Return True
Else
Return False
@@ -825,7 +840,8 @@ Public Class EgtFolder
Dim DirectoryList() As DirectoryInfo
Dim FileList() As FileInfo
Try
DirectoryList = m_DirectoryInfo.GetDirectories().Where(Function(file) (file.Attributes And FileAttributes.Hidden And CType(file.Name <> EgtMsg(15071), Global.System.IO.FileAttributes)) = 0).ToArray() ' ProgramData
' ProgramData
DirectoryList = m_DirectoryInfo.GetDirectories().Where(Function(file) (file.Attributes And FileAttributes.Hidden And file.Name <> EgtMsg(15071)) = 0).ToArray()
FileList = m_DirectoryInfo.GetFiles().Where(Function(file) (file.Attributes And FileAttributes.Hidden) = 0).ToArray()
Catch ex As Exception
DirectoryList = Nothing
@@ -846,7 +862,7 @@ Public Class EgtFolder
End If
End Sub
#End Region
#End Region ' Methods
End Class
@@ -907,7 +923,7 @@ Public Class EgtItem
End Set
End Property
#End Region ' FIELDS & PROPERTIES
#End Region ' Fields & Properties
#Region "CONTRUCTORS"
@@ -921,6 +937,6 @@ Public Class EgtItem
NotifyPropertyChanged(NameOf(sIconSource))
End Sub
#End Region ' CONTRUCTORS
#End Region ' Constructors
End Class