Imports System.Collections.ObjectModel Imports System.IO Imports System.Windows.Forms Imports EgtWPFLib5 Imports EgtUILib Imports System.Data Public Class EgtManageFileDialogVM Inherits VMBase #Region "FIELDS & PROPERTIES" Public Enum VisualizationContainerType As Integer LISTBOX = 0 DATAGRID = 1 End Enum Public Enum VisualizationType As Integer LISTTEMPLATE = 0 TILESTEMPLATE = 1 CONTENTTEMPLATE = 2 DETAILSTEMPLATE = 3 End Enum Public Enum ModeTypes As Integer FILE = 1 FOLDER = 2 End Enum Private m_sTitle As String Public Property sTitle As String Get Return m_sTitle End Get Set(value As String) m_sTitle = value End Set End Property ' Scelta della modalità di salvataggio 1 = file 2 = folder Private m_nMode As Integer Public Property nMode As Integer Get Return m_nMode End Get Set(value As Integer) m_nMode = value End Set End Property Private m_bCheckFileExists As Boolean Public Property bCheckFileExists As Boolean Get Return m_bCheckFileExists End Get Set(value As Boolean) m_bCheckFileExists = value End Set End Property Private m_bValidateNames As Boolean Public Property bValidateNames As Boolean Get Return m_bValidateNames End Get Set(value As Boolean) m_bValidateNames = value End Set End Property Private m_bOverwritePrompt As Boolean Public Property bOverwritePrompt As Boolean Get Return m_bOverwritePrompt End Get Set(value As Boolean) m_bOverwritePrompt = value End Set End Property Private m_RootList As New ObservableCollection(Of EgtDirectory) Public Property RootList As ObservableCollection(Of EgtDirectory) Get Return m_RootList End Get Set(value As ObservableCollection(Of EgtDirectory)) m_RootList = value End Set End Property Public m_SelTreeItem As EgtDirectory Public Property SelTreeItem As EgtDirectory Get Return m_SelTreeItem End Get Set(value As EgtDirectory) m_SelTreeItem = value NotifyPropertyChanged(NameOf(SelTreeItem)) End Set End Property Friend Sub UpdateSelTreeItem(Item As EgtDirectory) m_SelTreeItem = Item NotifyPropertyChanged(NameOf(SelTreeItem)) End Sub Public m_ItemSelected As EgtDirectory Public Property ItemSelected As EgtDirectory Get Return m_ItemSelected End Get Set(value As EgtDirectory) m_ItemSelected = value Dim Item As EgtItem = TryCast(m_ItemSelected, EgtItem) If Not IsNothing(Item) Then sSaveFileName = Item.sName Else Dim Folder As EgtFolder = TryCast(m_ItemSelected, EgtFolder) If Not IsNothing(Folder) Then sSaveFileName = Folder.sName End If End If End Set End Property Friend Sub SetItemSelected(value As EgtDirectory) m_ItemSelected = value NotifyPropertyChanged(NameOf(ItemSelected)) End Sub ' Percorso del file o della cartella Private m_sSelPath As String Public Overloads Property sSelPath As String Get Return m_sSelPath End Get Set(value As String) m_sSelPath = value NotifyPropertyChanged(NameOf(sSelPath)) End Set End Property ' Textbox per visualizzare il file o la folder selezionata Private m_sSaveFileName As String Public Property sSaveFileName As String Get Return m_sSaveFileName End Get Set(value As String) m_sSaveFileName = value NotifyPropertyChanged(NameOf(sSaveFileName)) End Set End Property ' Lista filtri estensione Private m_FilterList As ObservableCollection(Of EgtExstension) Public Property FilterList As ObservableCollection(Of EgtExstension) Get Return m_FilterList End Get Set(value As ObservableCollection(Of EgtExstension)) m_FilterList = value End Set End Property ' Scelta filtro estensione per visualizzazione Public m_SelFilter As EgtExstension Public Property SelFilter As EgtExstension Get Return m_SelFilter End Get Set(value As EgtExstension) m_SelFilter = value Dim CurrItem As EgtFolder = TryCast(m_SelTreeItem, EgtFolder) If Not IsNothing(CurrItem) Then CollectionViewSource.GetDefaultView(CurrItem.FolderList).Refresh() End If End Set End Property ' Lista modalita' di visualizzazione Private m_ViewModeList As ObservableCollection(Of IdNameStruct) Public Property ViewModeList As ObservableCollection(Of IdNameStruct) Get Return m_ViewModeList End Get Set(value As ObservableCollection(Of IdNameStruct)) m_ViewModeList = value End Set End Property ' Scelta modalita' di visualizzazione Private m_SelViewMode As IdNameStruct Public Property SelViewMode As IdNameStruct Get Return m_SelViewMode End Get Set(value As IdNameStruct) m_SelViewMode = value Select Case m_SelViewMode.Id Case VisualizationType.LISTTEMPLATE m_nSelTab = VisualizationContainerType.LISTBOX nSelTempleteListView = 0 WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.LISTTEMPLATE) Case VisualizationType.TILESTEMPLATE m_nSelTab = VisualizationContainerType.LISTBOX nSelTempleteListView = 1 WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.TILESTEMPLATE) Case VisualizationType.CONTENTTEMPLATE m_nSelTab = VisualizationContainerType.LISTBOX nSelTempleteListView = 2 WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.CONTENTTEMPLATE) Case VisualizationType.DETAILSTEMPLATE m_nSelTab = VisualizationContainerType.DATAGRID WriteMainPrivateProfileString(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationType.DETAILSTEMPLATE) End Select NotifyPropertyChanged(NameOf(nSelTab)) End Set End Property ' Indice modalita' di visualizzazione Private m_nSelViewModeIndex As Integer Public Property nSelViewModeIndex As Integer Get Return m_nSelViewModeIndex End Get Set(value As Integer) m_nSelViewModeIndex = value End Set End Property ' Indice di selezione del TabControl che cambia la ListBox/DataGrid Private m_nSelTab As Integer Public Property nSelTab As Integer Get Return m_nSelTab End Get Set(value As Integer) m_nSelTab = value End Set End Property #Region "Initial data from window opening" ' Indice del filtro estensione impostato durante creazione finestra Private m_nFilterIndex As Integer Public Property nFilterIndex As Integer Get Return m_nFilterIndex End Get 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 ' lista delle estensioni impostata durante creazione finestra Private m_sFilter As String Public Property sFilter As String Get Return m_sFilter End Get Set(value As String) m_sFilter = value Dim nIndex As Integer = 1 If Not IsNothing(sFilter) Then Dim FilterListSplit As String() = sFilter.Split("|"c) For i As Integer = 0 To FilterListSplit.Count - 1 If i Mod 2 = 0 Then Dim strExstension As New EgtExstension() With {.m_nIndexExstension = nIndex, .m_sNameExstension = FilterListSplit(i), .m_sExstension = FilterListSplit(i + 1)} m_FilterList.Add(strExstension) nIndex += 1 End If Next End If End Set End Property ' Path della cartella iniziale impostata durante creazione finestra Private m_sInitialDirectory As String Public Property sInitialDirectory As String Get Return m_sInitialDirectory End Get Set(value As String) m_sInitialDirectory = value If m_sFileName = String.Empty Then m_sSaveFileName = "New.nge" m_sSelPath = m_sInitialDirectory Dim DirectoryStart As String() = m_sInitialDirectory.Split("\"c) Dim m_RootListTmp As New ObservableCollection(Of EgtDirectory) Dim dir As EgtDirectory Dim count As Integer = 1 Dim currItem As EgtFolder m_RootListTmp = m_RootList For Each directory As String In DirectoryStart 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 ' Nome del file iniziale impostato durante creazione finestra Private m_sFileName As String Public Property sFileName As String Get Return m_sFileName End Get Set(value As String) m_sFileName = value m_sSaveFileName = m_sFileName End Set End Property #End Region ' Initial data from window opening ' Scelta per la visualizzazione del templete della lista Private m_nSelTempleteListView As Integer Public Property nSelTempleteListView As Integer Get Return m_nSelTempleteListView End Get Set(value As Integer) m_nSelTempleteListView = value NotifyPropertyChanged(NameOf(nSelTempleteListView)) End Set End Property #Region "Messages" Public ReadOnly Property Name_Msg As String Get Return EgtMsg(15060) ' Nome End Get End Property Public ReadOnly Property LastModify_Msg As String Get Return EgtMsg(15061) ' Ultima Modifica End Get End Property Public ReadOnly Property Type_Msg As String Get Return EgtMsg(15062) ' Tipo End Get End Property Public ReadOnly Property Dimension_Msg As String Get Return EgtMsg(15063) ' Dimensione End Get End Property Public ReadOnly Property FileName_Msg As String Get ' Nome File Nome Cartella Return If(m_nMode = ModeTypes.FILE, EgtMsg(15065), EgtMsg(15066)) End Get End Property #End Region ' Comandi Private m_cmdCancel As ICommand Private m_cmdOk As ICommand Private m_cmdGoBack As ICommand Private m_cmdDoubleClick As ICommand Friend Event m_CloseWindow(bDialogResult As DialogResult) #End Region ' Fields & Properties #Region "CONTRUCTORS" Sub New() m_RootList.Clear() EgtDirectory.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem Dim drives As DriveInfo() = DriveInfo.GetDrives().Where(Function(d) d.IsReady).ToArray() m_FilterList = New ObservableCollection(Of EgtExstension) EgtFolder.SetEgtManageFileDialogVM(Me) For i As Integer = 0 To drives.Count() - 1 Dim directory As New EgtFolder(drives(i).RootDirectory, Nothing, "\Resources\EgtDialog\Root.png") m_RootList.Add(directory) Next m_SelFilter = New EgtExstension() SetVisualizzationList() Dim IndexTemplete As Integer = GetMainPrivateProfileInt(S_TEMPLETESEL, K_CURRTEMPLETESEL, VisualizationContainerType.DATAGRID) SelViewMode = m_ViewModeList.FirstOrDefault(Function(x) x.Id = IndexTemplete) NotifyPropertyChanged(NameOf(RootList)) NotifyPropertyChanged(NameOf(FilterList)) NotifyPropertyChanged(NameOf(ViewModeList)) NotifyPropertyChanged(NameOf(FileName_Msg)) NotifyPropertyChanged(NameOf(SelViewMode)) End Sub #End Region ' Constructors #Region "METHODS" ''' ''' Inizializza la ComboBox per la scelta dei template ''' Private Sub SetVisualizzationList() m_ViewModeList = New ObservableCollection(Of IdNameStruct) Dim ItemVisualization As New IdNameStruct With { .Id = 0, .Name = EgtMsg(15067) ' Elenco } m_ViewModeList.Add(ItemVisualization) ItemVisualization.Id = 3 ItemVisualization.Name = EgtMsg(15068) ' Dettagli m_ViewModeList.Add(ItemVisualization) ItemVisualization.Id = 1 ItemVisualization.Name = EgtMsg(15069) ' Riquadri m_ViewModeList.Add(ItemVisualization) ItemVisualization.Id = 2 ItemVisualization.Name = EgtMsg(15070) ' Contenuto m_ViewModeList.Add(ItemVisualization) End Sub #End Region ' Methods #Region "COMMANDS" #Region "Ok" Public ReadOnly Property Ok_Command As ICommand Get If m_cmdOk Is Nothing Then m_cmdOk = New Command(AddressOf Ok) End If Return m_cmdOk End Get End Property Public Sub Ok() Dim CurrItem As EgtItem = TryCast(m_ItemSelected, EgtItem) Dim simbolsCharacter As String() = {"<"c, ">"c, ":"c, "'"c, "/"c, "\"c, "|"c, "?"c, "*"c, "CON", "PRN", "AUX", "NUL", "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"} If nMode = ModeTypes.FILE Then If Not IsNothing(CurrItem) And m_bCheckFileExists And m_bValidateNames Then For Each simbol As String In simbolsCharacter If m_sSaveFileName.Contains(simbol) Then ' Errore file contiene simboli non conformi If EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(15072), sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.Cancel Then sSaveFileName = CurrItem.sName Return End If Else m_sFileName = m_SelTreeItem.sFullName & "\" & m_sSaveFileName End If Next 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 EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(15073), sTitle, MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then Return End If End If Else m_sFileName = m_SelTreeItem.sFullName & "\" & m_sSaveFileName End If Else m_sFileName = m_SelTreeItem.sFullName & "\" & m_sSaveFileName End If ElseIf nMode = ModeTypes.FOLDER Then For Each simbol As String In simbolsCharacter If m_sSaveFileName.Contains(simbol) Then ' Errore file contiene simboli non conformi If EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(15072), sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.Cancel Then Return End If Else m_sFileName = m_SelTreeItem.sFullName End If Next End If RaiseEvent m_CloseWindow(DialogResult.OK) End Sub #End Region 'Ok #Region "GoBack" Public ReadOnly Property GoBack_Command As ICommand Get If m_cmdGoBack Is Nothing Then m_cmdGoBack = New Command(AddressOf GoBack) End If Return m_cmdGoBack End Get End Property Public Sub GoBack() If Not IsNothing(m_SelTreeItem) AndAlso Not IsNothing(m_SelTreeItem.m_ParentFolder) Then If TypeOf m_SelTreeItem.m_ParentFolder Is EgtFolder Then Dim CurrParentFolder As EgtFolder = DirectCast(m_SelTreeItem.m_ParentFolder, EgtFolder) CurrParentFolder.SetIsSelected(True, False) End If m_sSelPath = DirectCast(m_SelTreeItem, EgtFolder).sFullName NotifyPropertyChanged(NameOf(sSelPath)) End If End Sub #End Region 'GoBack #Region "Cancel" Public ReadOnly Property Cancel_Command As ICommand Get If m_cmdCancel Is Nothing Then m_cmdCancel = New Command(AddressOf Cancel) End If Return m_cmdCancel End Get End Property Public Sub Cancel() RaiseEvent m_CloseWindow(DialogResult.Cancel) End Sub #End Region 'Cancel #Region "DoubleClick" Public ReadOnly Property DoubleClick_Command As ICommand Get If m_cmdDoubleClick Is Nothing Then m_cmdDoubleClick = New Command(AddressOf MouseDoubleClick) End If Return m_cmdDoubleClick End Get End Property Public Sub MouseDoubleClick() m_ItemSelected.IsExpanded = True If TypeOf m_ItemSelected Is EgtFolder Then Dim CurrItemSelected As EgtFolder = DirectCast(m_ItemSelected, EgtFolder) CurrItemSelected.SetIsSelected(True, True) m_sSelPath = CurrItemSelected.sFullName Else m_ItemSelected.IsSelected = True End If NotifyPropertyChanged(NameOf(sSelPath)) End Sub #End Region 'DoubleClick #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 Get Return m_nIndexExstension End Get Set(value As Integer) m_nIndexExstension = value NotifyPropertyChanged(NameOf(nIndexExstension)) End Set End Property ' Nome della stringa Filter Splittata m_sNameExstension = EgtStone3D project Public m_sNameExstension As String Public Property sNameExstension As String Get Return m_sNameExstension End Get Set(value As String) m_sNameExstension = value NotifyPropertyChanged(NameOf(sNameExstension)) End Set End Property ' Estensione della stringa Filter Splittata m_sExstension = *.wme Public m_sExstension As String Public Property sExstension As String Get Return m_sExstension End Get Set(value As String) m_sExstension = value NotifyPropertyChanged(NameOf(sExstension)) End Set End Property #End Region ' Fields & Properties End Class Public MustInherit Class EgtDirectory Inherits VMBase #Region "FIELDS & PROPERTIES" Friend Shared refUpdateSelTreeItem As Action(Of EgtDirectory) Friend Shared m_refEgtManageFileDialogVM As EgtManageFileDialogVM Friend Shared Sub SetEgtManageFileDialogVM(EgtManageFileDialogVM As EgtManageFileDialogVM) m_refEgtManageFileDialogVM = EgtManageFileDialogVM End Sub Protected m_bIsSelected As Boolean Public MustOverride Property IsSelected As Boolean Protected m_bIsExpanded As Boolean Public Overridable Property IsExpanded As Boolean Public MustOverride ReadOnly Property sFullName As String Protected m_sName As String Public MustOverride ReadOnly Property sName As String Protected m_sIconSource As String Public Overridable ReadOnly Property sIconSource As String Get Return m_sIconSource End Get End Property Protected m_sTypeItem As String Public MustOverride ReadOnly Property sTypeItem As String Protected m_ghTypeItem As String Public Overridable ReadOnly Property ghTypeItem As String Protected m_dtLastModifyDate As Date Public MustOverride ReadOnly Property sLastModifyDate As String Public m_ParentFolder As EgtFolder Public Property ParentFolder As EgtFolder Get Return m_ParentFolder End Get Set(value As EgtFolder) m_ParentFolder = value End Set End Property #End Region ' Fields & Properties End Class Public Class EgtFolder Inherits EgtDirectory #Region "FIELDS & PROPERTIES" Private m_ItemList_View As CollectionView = Nothing Private m_TreeItemList_ViewSource As CollectionViewSource = Nothing Private m_TreeItemList_View As CollectionView = Nothing Public ReadOnly Property TreeItemList_View As CollectionView Get Return m_TreeItemList_View End Get End Property Private m_DirectoryInfo As DirectoryInfo Private m_FolderList As New ObservableCollection(Of EgtDirectory) Public Property FolderList As ObservableCollection(Of EgtDirectory) Get Return m_FolderList End Get Set(value As ObservableCollection(Of EgtDirectory)) m_FolderList = value End Set End Property Public Overrides ReadOnly Property sFullName As String Get Return m_DirectoryInfo.FullName End Get End Property Public Overrides ReadOnly Property sName As String Get Return m_DirectoryInfo.Name End Get End Property Public Overrides ReadOnly Property sTypeItem As String Get Return EgtMsg(15064) ' Cartella di File End Get End Property Public Overrides ReadOnly Property sLastModifyDate As String Get Return m_DirectoryInfo.LastWriteTime.ToString("dd/MM/yyyy HH:mm:ss") End Get End Property Public Overrides Property IsExpanded As Boolean Get Return m_bIsExpanded End Get Set(value As Boolean) m_bIsExpanded = value NotifyPropertyChanged(NameOf(IsExpanded)) If m_bIsExpanded Then SetFolderList() End If End Set End Property Public Overrides Property IsSelected As Boolean Get Return m_bIsSelected End Get Set(value As Boolean) m_bIsSelected = value m_refEgtManageFileDialogVM.sSelPath = m_DirectoryInfo.FullName If m_bIsSelected Then SetFolderList() refUpdateSelTreeItem(Me) NotifyPropertyChanged(NameOf(IsSelected)) End If End Set End Property Friend Sub SetIsSelected(value As Boolean, bRefreshList As Boolean) Dim sSelListItemPath As String = "" If Not IsNothing(m_refEgtManageFileDialogVM.SelTreeItem) Then sSelListItemPath = m_refEgtManageFileDialogVM.SelTreeItem.sFullName End If m_bIsSelected = value m_refEgtManageFileDialogVM.sSelPath = m_DirectoryInfo.FullName If m_bIsSelected Then If bRefreshList Then SetFolderList() refUpdateSelTreeItem(Me) End If If Not IsNothing(sSelListItemPath) Then Dim SelFolderItem As EgtDirectory = m_FolderList.FirstOrDefault(Function(x) x.sFullName = sSelListItemPath) If Not IsNothing(SelFolderItem) Then m_refEgtManageFileDialogVM.SetItemSelected(SelFolderItem) End If End If NotifyPropertyChanged(NameOf(IsSelected)) End Sub #End Region ' Fields & Properties #Region "CONTRUCTORS" Sub New() End Sub Sub New(DirectoryInfo As DirectoryInfo, Parent As EgtDirectory, Optional IconSource As String = "\Resources\EgtDialog\Folder.png") m_DirectoryInfo = DirectoryInfo m_sIconSource = IconSource Try If DirectoryInfo.EnumerateDirectories.Count > 0 Then m_FolderList.Add(New EgtFolder()) End If Catch ex As Exception End Try m_ParentFolder = Parent 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 = m_TreeItemList_ViewSource.View m_TreeItemList_View.Filter = AddressOf TreeItemListFilter NotifyPropertyChanged(NameOf(sName)) NotifyPropertyChanged(NameOf(sLastModifyDate)) NotifyPropertyChanged(NameOf(sTypeItem)) NotifyPropertyChanged(NameOf(sIconSource)) NotifyPropertyChanged(NameOf(FolderList)) NotifyPropertyChanged(NameOf(ParentFolder)) End Sub #End Region ' Constructors #Region "METHODS" ''' ''' Funzione per la visualizzazione delle sole cartelle nell'albero TreeView ''' ''' ''' Private Function TreeItemListFilter(CurrItem As Object) As Boolean Return TypeOf CurrItem Is EgtFolder End Function ''' ''' Funzione per il controllo del filtro per i singoli Item se l'estensione scelta e' .icrs verrano visualizzati tutti i file con l'estensione .icrs ''' ''' ''' 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("*") Then Return True ElseIf m_refEgtManageFileDialogVM.m_SelFilter.m_sExstension.TrimStart("*") = ".*" Then Return True Else Return False End If End If Return True End Function ''' ''' Funzione per popolare la lista FolderList ''' Private Sub SetFolderList() Dim DirectoryList() As DirectoryInfo Dim FileList() As FileInfo Try ' 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 FileList = Nothing End Try m_FolderList.Clear() If Not IsNothing(DirectoryList) AndAlso m_FolderList.Count = 0 Then For Each subDir As DirectoryInfo In DirectoryList Dim directory As New EgtFolder(subDir, Me) m_FolderList.Add(directory) Next End If If Not IsNothing(FileList) Then For Each files As FileInfo In FileList Dim file As New EgtItem(files) m_FolderList.Add(file) Next End If End Sub #End Region ' Methods End Class Public Class EgtItem Inherits EgtDirectory #Region "FIELDS & PROPERTIES" Private m_FileInfo As FileInfo Public Overrides ReadOnly Property sFullName As String Get Return m_FileInfo.FullName End Get End Property Public Overrides ReadOnly Property sName As String Get Return m_FileInfo.Name End Get End Property Public Overrides ReadOnly Property sTypeItem As String Get If Not IsNothing(m_FileInfo) AndAlso Not IsNothing(m_FileInfo.Extension) AndAlso Not String.IsNullOrWhiteSpace(m_FileInfo.Extension) Then Return m_FileInfo.Extension Else Return "" End If End Get End Property Public Overrides ReadOnly Property ghTypeItem As String Get Return If(Not String.IsNullOrWhiteSpace(sTypeItem), "File " & sTypeItem.ToUpper(), "") End Get End Property Public ReadOnly Property sDimension As String Get Return If(m_FileInfo.Length / 1024 / 1024 > 1, String.Format("{0:#,##0.00}", m_FileInfo.Length / 1024 / 1024) & " Mb", String.Format("{0:#,##0.00}", m_FileInfo.Length / 1024) & " Kb") End Get End Property Public Overrides ReadOnly Property sLastModifyDate As String Get Return m_FileInfo.LastWriteTime.ToString("dd/MM/yyyy HH:mm:ss") End Get End Property Public Overrides Property IsSelected As Boolean Get Return m_bIsSelected End Get Set(value As Boolean) m_bIsSelected = value refUpdateSelTreeItem(Me) End Set End Property #End Region ' Fields & Properties #Region "CONTRUCTORS" Sub New(FileInfo As FileInfo) m_FileInfo = FileInfo m_sIconSource = "\Resources\EgtDialog\New.png" NotifyPropertyChanged(NameOf(sName)) NotifyPropertyChanged(NameOf(sDimension)) NotifyPropertyChanged(NameOf(sLastModifyDate)) NotifyPropertyChanged(NameOf(sTypeItem)) NotifyPropertyChanged(NameOf(sIconSource)) End Sub #End Region ' Constructors End Class