3ef8843b1d
-Aggiornamento indice estensione
883 lines
26 KiB
VB.net
883 lines
26 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports System.Windows.Forms
|
|
Imports EgtWPFLib5
|
|
Imports EgtUILib
|
|
|
|
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_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)
|
|
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, .sNameExstension = FilterListSplit(i), .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
|
|
m_sSaveFileName = "New.icrs"
|
|
m_sSelPath = m_sInitialDirectory
|
|
Dim DirectoryStart As String() = m_sInitialDirectory.Split("\"c)
|
|
|
|
For i As Integer = 0 To m_RootList.Count - 1
|
|
If m_RootList(i).sName.Trim("\") = DirectoryStart(0) Then
|
|
m_RootList(i).IsExpanded = True
|
|
Dim CurrItem As EgtFolder = TryCast(m_RootList(i), EgtFolder)
|
|
If Not IsNothing(CurrItem) Then
|
|
For j As Integer = 0 To CurrItem.FolderList.Count - 1
|
|
If CurrItem.FolderList(j).sName = DirectoryStart(1) Then
|
|
CurrItem.FolderList(j).IsExpanded = True
|
|
Dim ItemFolder As EgtFolder = TryCast(CurrItem.FolderList(j), EgtFolder)
|
|
If Not IsNothing(ItemFolder) Then
|
|
For y As Integer = 0 To ItemFolder.FolderList.Count - 1
|
|
If ItemFolder.FolderList(y).sName = DirectoryStart(2) Then
|
|
ItemFolder.FolderList(y).IsExpanded = True
|
|
ItemFolder.FolderList(y).IsSelected = True
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
Next
|
|
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 String
|
|
Get
|
|
Return m_nSelTempleteListView
|
|
End Get
|
|
Set(value As String)
|
|
m_nSelTempleteListView = value
|
|
NotifyPropertyChanged(NameOf(nSelTempleteListView))
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property Name_Msg As String
|
|
Get
|
|
Return EgtMsg(15060)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property LastModify_Msg As String
|
|
Get
|
|
Return EgtMsg(15061)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Type_Msg As String
|
|
Get
|
|
Return EgtMsg(15062)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Dimension_Msg As String
|
|
Get
|
|
Return EgtMsg(15063)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property FileName_Msg As String
|
|
Get
|
|
Return If(m_nMode = ModeTypes.FILE, EgtMsg(15065), EgtMsg(15066)) ' File Name Folder Name
|
|
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 MessageBoxResult)
|
|
|
|
#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)
|
|
'If IndexTemplete = 3 Then
|
|
' m_nSelTab = VisualizationContainerType.DATAGRID
|
|
'Else
|
|
' nSelTempleteListView = IndexTemplete
|
|
'End If
|
|
|
|
NotifyPropertyChanged(NameOf(RootList))
|
|
NotifyPropertyChanged(NameOf(FilterList))
|
|
NotifyPropertyChanged(NameOf(ViewModeList))
|
|
NotifyPropertyChanged(NameOf(FileName_Msg))
|
|
NotifyPropertyChanged(NameOf(SelViewMode))
|
|
End Sub
|
|
|
|
#End Region ' CONTRUCTORS
|
|
|
|
|
|
#Region "METHODS"
|
|
|
|
'Private Function RootListFilter(CurrItem As Object) As Boolean
|
|
' Return TypeOf CurrItem Is EgtFolder
|
|
'End Function
|
|
|
|
''' <summary>
|
|
''' Inizializza la ComboBox per la scelta dei template
|
|
''' </summary>
|
|
Private Sub SetVisualizzationList()
|
|
m_ViewModeList = New ObservableCollection(Of IdNameStruct)
|
|
Dim ItemVisualization As New IdNameStruct With {
|
|
.Id = 0,
|
|
.Name = EgtMsg(15067) 'List Templete
|
|
}
|
|
m_ViewModeList.Add(ItemVisualization)
|
|
ItemVisualization.Id = 3
|
|
ItemVisualization.Name = EgtMsg(15068) 'Detalis Templete
|
|
m_ViewModeList.Add(ItemVisualization)
|
|
ItemVisualization.Id = 1
|
|
ItemVisualization.Name = EgtMsg(15069) 'Tiles Templete
|
|
m_ViewModeList.Add(ItemVisualization)
|
|
ItemVisualization.Id = 2
|
|
ItemVisualization.Name = EgtMsg(15070) 'Content Templete
|
|
m_ViewModeList.Add(ItemVisualization)
|
|
End Sub
|
|
|
|
'Private Sub Directory_PropertyChanged(sender As Object, e As PropertyChangedEventArgs)
|
|
' If e.PropertyName = "IsSelected" Then
|
|
' 'UpdateSelRoot()
|
|
' End If
|
|
'End Sub
|
|
|
|
#End Region
|
|
|
|
#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)
|
|
If nMode = ModeTypes.FILE Then
|
|
If Not IsNothing(CurrItem) Then
|
|
m_sFileName = m_SelTreeItem.sFullName
|
|
Else
|
|
m_sFileName = m_SelTreeItem.sFullName & "\" & m_sSaveFileName
|
|
End If
|
|
ElseIf nMode = ModeTypes.FOLDER Then
|
|
m_sFileName = m_SelTreeItem.sFullName
|
|
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
|
|
|
|
' 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 = Icarus 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 = *.icrs
|
|
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 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)
|
|
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 ' CONTRUCTORS
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <summary>
|
|
''' Funzione per la visualizzazione delle sole cartelle nell'albero TreeView
|
|
''' </summary>
|
|
''' <param name="CurrItem"></param>
|
|
''' <returns></returns>
|
|
Private Function TreeItemListFilter(CurrItem As Object) As Boolean
|
|
Return TypeOf CurrItem Is EgtFolder
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' 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
|
|
''' </summary>
|
|
''' <param name="Item"></param>
|
|
''' <returns></returns>
|
|
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
|
|
Else
|
|
Return False
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Funzione per popolare la lista FolderList
|
|
''' </summary>
|
|
Private Sub SetFolderList()
|
|
Dim DirectoryList() As DirectoryInfo
|
|
Dim FileList() As FileInfo
|
|
Try
|
|
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
|
|
|
|
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 ' CONTRUCTORS
|
|
|
|
End Class
|
|
|