894 lines
25 KiB
VB.net
894 lines
25 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Windows.Forms
|
|
Imports EgtWPFLib5
|
|
Imports EgtUILib
|
|
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
|
|
|
|
Public Class EgtManageFileDialogVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Enum VisualizationContainerType As Integer
|
|
LISTBOX = 0
|
|
DATAGRID = 1
|
|
End Enum
|
|
|
|
Public Enum VisualizationType As Integer
|
|
SCHEDULETEMPLATE = 0
|
|
DETAILSTEMPLATE = 1
|
|
BOXINGTEMPLATE = 2
|
|
CONTENTTEMPLATE = 3
|
|
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
|
|
|
|
Private m_sFilter As String
|
|
Public Property sFilter As String
|
|
Get
|
|
Return m_sFilter
|
|
End Get
|
|
Set(value As String)
|
|
m_sFilter = value
|
|
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 {.sNameExstension = FilterListSplit(i) & FilterListSplit(i + 1), .sExstension = FilterListSplit(i + 1)}
|
|
m_ListFilter.Add(strExstension)
|
|
End If
|
|
Next
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
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_sUrl_Msg = 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
|
|
|
|
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
|
|
|
|
Public Shared m_sUrl_Msg As String
|
|
Public Property sUrl_Msg As String
|
|
Get
|
|
Return m_sUrl_Msg
|
|
End Get
|
|
Set(value As String)
|
|
m_sUrl_Msg = value
|
|
End Set
|
|
End Property
|
|
|
|
'Private m_sSelListItemView As String
|
|
'Public Property SelListItemView As String
|
|
' Get
|
|
' Return m_sSelListItemView
|
|
' End Get
|
|
' Set(value As String)
|
|
' m_sSelListItemView = value
|
|
' End Set
|
|
'End Property
|
|
|
|
Private m_sSaveFileName As String
|
|
Public Property sSaveFileName As String
|
|
Get
|
|
Return m_sSaveFileName
|
|
End Get
|
|
Set(value As String)
|
|
m_sSaveFileName = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nTaskStatus As Integer
|
|
Public Property nTaskStatus As String
|
|
Get
|
|
Return m_nTaskStatus
|
|
End Get
|
|
Set(value As String)
|
|
m_nTaskStatus = value
|
|
NotifyPropertyChanged(NameOf(nTaskStatus))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nFilterIndex As Integer
|
|
Public Property nFilterIndex As Integer
|
|
Get
|
|
Return m_nFilterIndex
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nFilterIndex = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nSelectView As Integer
|
|
Public Property nSelectView As Integer
|
|
Get
|
|
Return m_nSelectView
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nSelectView = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ListFilter As ObservableCollection(Of EgtExstension)
|
|
Public Property ListFilter As ObservableCollection(Of EgtExstension)
|
|
Get
|
|
Return m_ListFilter
|
|
End Get
|
|
Set(value As ObservableCollection(Of EgtExstension))
|
|
m_ListFilter = value
|
|
End Set
|
|
End Property
|
|
|
|
'Public Shared m_ListItemView As ObservableCollection(Of String)
|
|
'Public Property ListItemView As ObservableCollection(Of String)
|
|
' Get
|
|
' Return m_ListItemView
|
|
' End Get
|
|
' Set(value As ObservableCollection(Of String))
|
|
' m_ListItemView = 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
|
|
|
|
Private m_VisualizationList As ObservableCollection(Of IdNameStruct)
|
|
Public Property VisualizationList As ObservableCollection(Of IdNameStruct)
|
|
Get
|
|
Return m_VisualizationList
|
|
End Get
|
|
Set(value As ObservableCollection(Of IdNameStruct))
|
|
m_VisualizationList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelVisualization As IdNameStruct
|
|
Public Property SelVisualization As IdNameStruct
|
|
Get
|
|
Return m_SelVisualization
|
|
End Get
|
|
Set(value As IdNameStruct)
|
|
m_SelVisualization = value
|
|
Select Case m_SelVisualization.Id
|
|
Case VisualizationType.SCHEDULETEMPLATE
|
|
m_nSelectView = VisualizationContainerType.LISTBOX
|
|
nTaskStatus = 0
|
|
m_UVision_Visibility = Visibility.Visible
|
|
m_ListBox_Visibility = Visibility.Visible
|
|
m_DataGrid_Visibility = Visibility.Collapsed
|
|
Case VisualizationType.DETAILSTEMPLATE
|
|
m_nSelectView = VisualizationContainerType.DATAGRID
|
|
m_UVision_Visibility = Visibility.Collapsed
|
|
m_ListBox_Visibility = Visibility.Collapsed
|
|
m_DataGrid_Visibility = Visibility.Visible
|
|
Case VisualizationType.BOXINGTEMPLATE
|
|
m_nSelectView = VisualizationContainerType.LISTBOX
|
|
nTaskStatus = 1
|
|
m_UVision_Visibility = Visibility.Collapsed
|
|
m_ListBox_Visibility = Visibility.Visible
|
|
m_DataGrid_Visibility = Visibility.Collapsed
|
|
Case VisualizationType.CONTENTTEMPLATE
|
|
m_nSelectView = VisualizationContainerType.LISTBOX
|
|
nTaskStatus = 2
|
|
m_UVision_Visibility = Visibility.Collapsed
|
|
m_ListBox_Visibility = Visibility.Visible
|
|
m_DataGrid_Visibility = Visibility.Collapsed
|
|
End Select
|
|
NotifyPropertyChanged(NameOf(nSelectView))
|
|
NotifyPropertyChanged(NameOf(UVision_Visibility))
|
|
NotifyPropertyChanged(NameOf(DataGrid_Visibility))
|
|
NotifyPropertyChanged(NameOf(ListBox_Visibility))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_DataGrid_Visibility As Visibility
|
|
Public Property DataGrid_Visibility As Visibility
|
|
Get
|
|
Return m_DataGrid_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_DataGrid_Visibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ListBox_Visibility As Visibility
|
|
Public Property ListBox_Visibility As Visibility
|
|
Get
|
|
Return m_ListBox_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_ListBox_Visibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_UVision_Visibility As Visibility
|
|
Public Property UVision_Visibility As Visibility
|
|
Get
|
|
Return m_UVision_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_UVision_Visibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Shared m_SelExstension As EgtExstension
|
|
Public Property SelExstension As EgtExstension
|
|
Get
|
|
Return m_SelExstension
|
|
End Get
|
|
Set(value As EgtExstension)
|
|
m_SelExstension = 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
|
|
|
|
Public Shared 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 UpdateSelRoot(Item As EgtDirectory)
|
|
m_SelTreeItem = Item
|
|
NotifyPropertyChanged(NameOf(SelTreeItem))
|
|
End Sub
|
|
|
|
'Comandi
|
|
Private m_cmdCancel As ICommand
|
|
Private m_cmdOk As ICommand
|
|
Private m_cmdGoBack As ICommand
|
|
Friend Event m_CloseWindow(bDialogResult As MessageBoxResult)
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONTRUCTORS"
|
|
|
|
Sub New()
|
|
m_RootList.Clear()
|
|
EgtDirectory.refUpdateSelRoot = AddressOf UpdateSelRoot
|
|
Dim drives As DriveInfo() = DriveInfo.GetDrives().Where(Function(d) d.IsReady).ToArray()
|
|
|
|
m_ListFilter = New ObservableCollection(Of EgtExstension)
|
|
|
|
For i As Integer = 0 To drives.Count() - 1
|
|
Dim directory As New EgtFolder(drives(i).RootDirectory, Nothing)
|
|
'AddHandler directory.PropertyChanged, AddressOf Directory_PropertyChanged
|
|
m_RootList.Add(directory)
|
|
Next
|
|
|
|
SetVisualizzationList()
|
|
|
|
m_SelVisualization.Id = VisualizationType.SCHEDULETEMPLATE
|
|
m_nSelectView = VisualizationContainerType.LISTBOX
|
|
nTaskStatus = 0
|
|
m_UVision_Visibility = Visibility.Visible
|
|
m_ListBox_Visibility = Visibility.Visible
|
|
m_DataGrid_Visibility = Visibility.Collapsed
|
|
|
|
NotifyPropertyChanged(NameOf(RootList))
|
|
NotifyPropertyChanged(NameOf(ListFilter))
|
|
NotifyPropertyChanged(NameOf(VisualizationList))
|
|
End Sub
|
|
|
|
#End Region ' CONTRUCTORS
|
|
|
|
#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 Shared ReadOnly Property Folder_Msg As String
|
|
Get
|
|
Return EgtMsg(15064)
|
|
End Get
|
|
End Property
|
|
|
|
Public Shared ReadOnly Property FileName_Msg As String
|
|
Get
|
|
Return EgtMsg(15065)
|
|
End Get
|
|
End Property
|
|
|
|
Public Shared ReadOnly Property Schedule_Msg As String
|
|
Get
|
|
Return EgtMsg(15067)
|
|
End Get
|
|
End Property
|
|
|
|
Public Shared ReadOnly Property Details_Msg As String
|
|
Get
|
|
Return EgtMsg(15068)
|
|
End Get
|
|
End Property
|
|
|
|
Public Shared ReadOnly Property Boxing_Msg As String
|
|
Get
|
|
Return EgtMsg(15069)
|
|
End Get
|
|
End Property
|
|
|
|
Public Shared ReadOnly Property Content_Msg As String
|
|
Get
|
|
Return EgtMsg(15070)
|
|
End Get
|
|
End Property
|
|
|
|
Public Shared ReadOnly Property DataFolder_Msg As String
|
|
Get
|
|
Return EgtMsg(15071)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <summary>
|
|
''' Inizializza la ComboBox per la scelta dei template
|
|
''' </summary>
|
|
Private Sub SetVisualizzationList()
|
|
m_VisualizationList = New ObservableCollection(Of IdNameStruct)
|
|
Dim ItemVisualization As New IdNameStruct With {
|
|
.Id = 0,
|
|
.Name = Schedule_Msg
|
|
}
|
|
m_VisualizationList.Add(ItemVisualization)
|
|
ItemVisualization.Id = 1
|
|
ItemVisualization.Name = Details_Msg
|
|
m_VisualizationList.Add(ItemVisualization)
|
|
ItemVisualization.Id = 2
|
|
ItemVisualization.Name = Boxing_Msg
|
|
m_VisualizationList.Add(ItemVisualization)
|
|
ItemVisualization.Id = 3
|
|
ItemVisualization.Name = Content_Msg
|
|
m_VisualizationList.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 "Command 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(EgtFolder.m_ItemSelected, EgtItem)
|
|
If Not IsNothing(CurrItem) Then
|
|
m_sFileName = m_SelTreeItem.InfoDir.FullName & "\" & CurrItem.sName
|
|
Else
|
|
m_sFileName = m_SelTreeItem.InfoDir.FullName & "\" & m_sSaveFileName
|
|
End If
|
|
RaiseEvent m_CloseWindow(DialogResult.OK)
|
|
End Sub
|
|
#End Region 'Command Ok
|
|
|
|
#Region "Command 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()
|
|
m_SelTreeItem = EgtFolder.m_ParentFolder
|
|
m_SelTreeItem.IsSelected = True
|
|
m_sUrl_Msg = ""
|
|
m_sUrl_Msg = m_SelTreeItem.InfoDir.FullName
|
|
EgtDirectory.m_sIconSource = "\Resources\EgtDialog\Folder.png"
|
|
NotifyPropertyChanged(NameOf(sUrl_Msg))
|
|
End Sub
|
|
#End Region 'Command GoBack
|
|
|
|
#Region "Command 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 'Command Cancel
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class EgtExstension
|
|
Inherits VMBase
|
|
|
|
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
|
|
|
|
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 Class EgtDirectory
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend Shared refUpdateSelRoot As Action(Of EgtDirectory)
|
|
|
|
Private m_bIsSelected As Boolean
|
|
Public Overridable Property IsSelected As Boolean
|
|
Get
|
|
Return m_bIsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bIsSelected = value
|
|
refUpdateSelRoot(Me)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bIsExpanded As Boolean
|
|
Public Overridable Property IsExpanded As Boolean
|
|
Get
|
|
Return m_bIsExpanded
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bIsExpanded = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_InfoDir As DirectoryInfo
|
|
Public Property InfoDir As DirectoryInfo
|
|
Get
|
|
Return m_InfoDir
|
|
End Get
|
|
Set(value As DirectoryInfo)
|
|
m_InfoDir = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property sName As String
|
|
Get
|
|
Try
|
|
Return If(Not IsNothing(m_InfoDir), m_InfoDir.Name, "")
|
|
Catch ex As Exception
|
|
Return ""
|
|
End Try
|
|
End Get
|
|
End Property
|
|
|
|
Public Shared m_sIconSource As String
|
|
Public Property sIconSource As String
|
|
Get
|
|
Return m_sIconSource
|
|
End Get
|
|
Set(value As String)
|
|
m_sIconSource = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property sTypeItem As String
|
|
Get
|
|
Try
|
|
Return If(Not IsNothing(m_InfoDir), m_InfoDir.Extension, "")
|
|
Catch ex As Exception
|
|
Return ""
|
|
End Try
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property dLastModifyDate As Date
|
|
Get
|
|
Try
|
|
Return If(Not IsNothing(m_InfoDir), m_InfoDir.LastAccessTime.ToString("dd/MM/yyyy HH:mm:ss"), Date.UtcNow.ToString("dd/MM/yyyy HH:mm:ss"))
|
|
Catch ex As Exception
|
|
Return Date.UtcNow.ToString("dd/MM/yyyy HH:mm:ss")
|
|
End Try
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sDimension As Integer
|
|
Get
|
|
Try
|
|
Return If(Not IsNothing(m_InfoDir), m_InfoDir.EnumerateDirectories().Count, 0)
|
|
Catch ex As Exception
|
|
Return 0
|
|
End Try
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
End Class
|
|
|
|
Public Class EgtFolder
|
|
Inherits EgtDirectory
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Shared m_ItemList_View As CollectionView = Nothing
|
|
|
|
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 Shared m_ItemSelected As EgtDirectory
|
|
Public Property ItemSelected As EgtDirectory
|
|
Get
|
|
Return m_ItemSelected
|
|
End Get
|
|
Set(value As EgtDirectory)
|
|
m_ItemSelected = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sName As String
|
|
Public Overloads Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sTypeItem As String
|
|
Public Overloads Property sTypeItem As String
|
|
Get
|
|
Return m_sTypeItem
|
|
End Get
|
|
Set(value As String)
|
|
m_sTypeItem = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dLastModifyDate As Date
|
|
Public Overloads Property dLastModifyDate As String
|
|
Get
|
|
Return m_dLastModifyDate
|
|
End Get
|
|
Set(value As String)
|
|
m_dLastModifyDate = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Shared 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
|
|
|
|
Private m_bIsExpanded As Boolean
|
|
Public Overrides Property IsExpanded As Boolean
|
|
Get
|
|
Return m_bIsExpanded
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bIsExpanded = value
|
|
NotifyPropertyChanged(NameOf(IsExpanded))
|
|
Dim DirectoryList() As DirectoryInfo
|
|
Dim FileList() As FileInfo
|
|
Try
|
|
DirectoryList = m_InfoDir.GetDirectories().Where(Function(file) (file.Attributes And FileAttributes.Hidden And file.Name <> EgtManageFileDialogVM.DataFolder_Msg) = 0).ToArray()
|
|
FileList = m_InfoDir.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) 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 Set
|
|
End Property
|
|
|
|
Private m_bIsSelected As Boolean
|
|
Public Overrides Property IsSelected As Boolean
|
|
Get
|
|
Return m_bIsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bIsSelected = value
|
|
refUpdateSelRoot(Me)
|
|
Dim DirectoryList() As DirectoryInfo
|
|
Dim FileList() As FileInfo
|
|
Try
|
|
DirectoryList = m_InfoDir.GetDirectories().Where(Function(file) (file.Attributes And FileAttributes.Hidden And file.Name <> EgtManageFileDialogVM.DataFolder_Msg) = 0).ToArray()
|
|
FileList = m_InfoDir.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) 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 Set
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONTRUCTORS"
|
|
|
|
Sub New(InfoDir As DirectoryInfo, Folder As EgtFolder)
|
|
|
|
m_InfoDir = InfoDir
|
|
m_sName = InfoDir.Name
|
|
m_dLastModifyDate = InfoDir.LastWriteTime.ToString("dd/MM/yyyy HH:mm:ss")
|
|
If InfoDir.Extension <> "" Then
|
|
m_sTypeItem = "File " & InfoDir.Extension.ToUpper()
|
|
m_sIconSource = "\Resources\EgtDialog\New.png"
|
|
Else
|
|
m_sTypeItem = EgtManageFileDialogVM.Folder_Msg
|
|
m_sIconSource = "\Resources\EgtDialog\Folder.png"
|
|
End If
|
|
m_FolderList.Add(New EgtDirectory())
|
|
EgtManageFileDialogVM.m_SelExstension = New EgtExstension()
|
|
m_ParentFolder = Folder
|
|
m_ItemSelected = New EgtDirectory()
|
|
|
|
|
|
m_ItemList_View = CollectionViewSource.GetDefaultView(m_FolderList)
|
|
m_ItemList_View.Filter = AddressOf ItemFilter
|
|
|
|
NotifyPropertyChanged(NameOf(sName))
|
|
NotifyPropertyChanged(NameOf(dLastModifyDate))
|
|
NotifyPropertyChanged(NameOf(sTypeItem))
|
|
NotifyPropertyChanged(NameOf(sIconSource))
|
|
NotifyPropertyChanged(NameOf(FolderList))
|
|
End Sub
|
|
|
|
#End Region ' CONTRUCTORS
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Function ItemFilter(Item As Object) As Boolean
|
|
Dim CurrItem As EgtItem = TryCast(Item, EgtItem)
|
|
|
|
If Not IsNothing(CurrItem) AndAlso Not IsNothing(EgtManageFileDialogVM.m_SelExstension.m_sExstension) Then
|
|
'Return CurrItem.TypeItem = EgtOpenDialogVM.m_SelExstension.s_Exstension.TrimStart("*")
|
|
If CurrItem.sTypeItem.Substring(5).ToLower() = EgtManageFileDialogVM.m_SelExstension.m_sExstension.TrimStart("*") Then
|
|
'EgtManageFileDialogVM.m_ListItemView.Add(m_InfoDir.FullName & "\" & CurrItem.sName)
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End If
|
|
|
|
Return True
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
End Class
|
|
|
|
Public Class EgtItem
|
|
Inherits EgtDirectory
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_sName As String
|
|
Public Overloads Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sTypeItem As String
|
|
Public Overloads Property sTypeItem As String
|
|
Get
|
|
Return m_sTypeItem
|
|
End Get
|
|
Set(value As String)
|
|
m_sTypeItem = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sDimension As String
|
|
Public Overloads Property sDimension As String
|
|
Get
|
|
Return m_sDimension
|
|
End Get
|
|
Set(value As String)
|
|
m_sDimension = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dLastModifyDate As Date
|
|
Public Overloads Property dLastModifyDate As String
|
|
Get
|
|
Return m_dLastModifyDate
|
|
End Get
|
|
Set(value As String)
|
|
m_dLastModifyDate = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bIsSelected As Boolean
|
|
Public Overrides Property IsSelected As Boolean
|
|
Get
|
|
Return m_bIsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bIsSelected = value
|
|
'm_sIconSource = "\Resources\EgtDialog\New.png"
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONTRUCTORS"
|
|
|
|
Sub New(InfoDir As FileInfo)
|
|
|
|
m_sName = InfoDir.Name
|
|
m_sDimension = String.Format("{0:#,##0.00}", InfoDir.Length / 1024) & " Kb"
|
|
m_dLastModifyDate = InfoDir.LastWriteTime.ToString("dd/MM/yyyy HH:mm:ss")
|
|
If InfoDir.Extension <> "" Then
|
|
m_sTypeItem = "File " & InfoDir.Extension.ToUpper()
|
|
m_sIconSource = "\Resources\EgtDialog\New.png"
|
|
Else
|
|
m_sTypeItem = ""
|
|
End If
|
|
|
|
NotifyPropertyChanged(NameOf(sName))
|
|
NotifyPropertyChanged(NameOf(sDimension))
|
|
NotifyPropertyChanged(NameOf(dLastModifyDate))
|
|
NotifyPropertyChanged(NameOf(sTypeItem))
|
|
NotifyPropertyChanged(NameOf(sIconSource))
|
|
End Sub
|
|
|
|
#End Region ' CONTRUCTORS
|
|
|
|
End Class
|
|
|