59253eb4de
- Cambiata gestione tipo progetto e macchina associata
360 lines
12 KiB
VB.net
360 lines
12 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports System.Windows
|
|
Imports System.Windows.Controls
|
|
Imports System.Windows.Data
|
|
Imports System.Windows.Input
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtBEAMWALL.Core.ConstBeam
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public MustInherit Class OpenProjectFileDialogVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend Event m_CloseWindow(bDialogResult As Boolean)
|
|
|
|
Protected m_ProjectColumns As New ObservableCollection(Of EgtDataGridColumn)
|
|
Public Property ProjectColumns As ObservableCollection(Of EgtDataGridColumn)
|
|
Get
|
|
Return m_ProjectColumns
|
|
End Get
|
|
Set(value As ObservableCollection(Of EgtDataGridColumn))
|
|
m_ProjectColumns = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_ProjectType As ProjectType
|
|
|
|
Protected m_sFilter As String
|
|
Public Property Filter As String
|
|
Get
|
|
Return m_sFilter
|
|
End Get
|
|
Set(value As String)
|
|
m_sFilter = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_sFileNameFilter As Predicate(Of String)
|
|
Public Property FileNameFilter As Predicate(Of String)
|
|
Get
|
|
Return m_sFileNameFilter
|
|
End Get
|
|
Set(value As Predicate(Of String))
|
|
m_sFileNameFilter = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_sExtensions As New List(Of String)
|
|
Public ReadOnly Property Extensions As List(Of String)
|
|
Get
|
|
Return m_sExtensions
|
|
End Get
|
|
End Property
|
|
|
|
Public m_ProjectList_View As CollectionView = Nothing
|
|
Protected m_ProjectList As New ObservableCollection(Of ProjectFileVM)
|
|
Public ReadOnly Property ProjectList As ObservableCollection(Of ProjectFileVM)
|
|
Get
|
|
Return m_ProjectList
|
|
End Get
|
|
End Property
|
|
|
|
Protected m_SelProject As ProjectFileVM
|
|
Public Property SelProject As ProjectFileVM
|
|
Get
|
|
Return m_SelProject
|
|
End Get
|
|
Set(value As ProjectFileVM)
|
|
m_SelProject = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_FileName As String
|
|
Public Property FileName As String
|
|
Get
|
|
Return m_FileName
|
|
End Get
|
|
Set(value As String)
|
|
m_FileName = value
|
|
End Set
|
|
End Property
|
|
|
|
' lista campi per ricerca testuale e con datepicker
|
|
Protected m_SearchColumnList As New ObservableCollection(Of IdNameStruct)
|
|
Public ReadOnly Property SearchColumnList As ObservableCollection(Of IdNameStruct)
|
|
Get
|
|
Return m_SearchColumnList
|
|
End Get
|
|
End Property
|
|
|
|
Protected m_SelSearchColumn As IdNameStruct = Nothing
|
|
Public Property SelSearchColumn As IdNameStruct
|
|
Get
|
|
Return m_SelSearchColumn
|
|
End Get
|
|
Set(value As IdNameStruct)
|
|
' resetto il contenuto della barra di ricerca testuale
|
|
m_SearchText = ""
|
|
NotifyPropertyChanged(NameOf(SearchText))
|
|
' resetto le selezioni sul calendario
|
|
If Not IsNothing(SearchDate) Then SearchDate.Clear()
|
|
' setto il Tipo Filtro a NULL e refresho la lista dei progetti (in modo da averli visibili tutti)
|
|
m_SelSearchColumn = m_SearchColumnList(0)
|
|
m_ProjectList_View.Refresh()
|
|
' ora setto il valore scelto come Tipo Filtro
|
|
m_SelSearchColumn = value
|
|
Select Case m_SelSearchColumn.Id
|
|
Case OpenProjFileColumn.ID, OpenProjFileColumn.BTLFILENAME, OpenProjFileColumn.LISTNAME
|
|
SearchText_Visibility = Visibility.Visible
|
|
SearchDate_Visibility = Visibility.Collapsed
|
|
Case OpenProjFileColumn.EXPORTDATE, OpenProjFileColumn.CREATEDATE
|
|
SearchText_Visibility = Visibility.Collapsed
|
|
SearchDate_Visibility = Visibility.Visible
|
|
Case Else
|
|
SearchText_Visibility = Visibility.Collapsed
|
|
SearchDate_Visibility = Visibility.Collapsed
|
|
End Select
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_SearchText As String = ""
|
|
Public Property SearchText As String
|
|
Get
|
|
Return m_SearchText
|
|
End Get
|
|
Set(value As String)
|
|
m_SearchText = value
|
|
m_ProjectList_View.Refresh()
|
|
End Set
|
|
End Property
|
|
|
|
Friend m_SearchDate As SelectedDatesCollection = Nothing
|
|
Public ReadOnly Property SearchDate As SelectedDatesCollection
|
|
Get
|
|
Return m_SearchDate
|
|
End Get
|
|
End Property
|
|
|
|
Protected m_SearchText_Visibility As Visibility = Visibility.Collapsed
|
|
Public Property SearchText_Visibility As Visibility
|
|
Get
|
|
Return m_SearchText_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_SearchText_Visibility = value
|
|
NotifyPropertyChanged(NameOf(SearchText_Visibility))
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_SearchDate_Visibility As Visibility = Visibility.Collapsed
|
|
Public Property SearchDate_Visibility As Visibility
|
|
Get
|
|
Return m_SearchDate_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_SearchDate_Visibility = value
|
|
NotifyPropertyChanged(NameOf(SearchDate_Visibility))
|
|
End Set
|
|
End Property
|
|
|
|
Public Enum OpenProjFileColumn As Integer
|
|
NULL = 0
|
|
ID = 1
|
|
BTLFILENAME = 2
|
|
LISTNAME = 3
|
|
EXPORTDATE = 4
|
|
CREATEDATE = 5
|
|
End Enum
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property FilterType_Msg As String
|
|
Get
|
|
Return EgtMsg(61836)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property Search_Msg As String
|
|
Get
|
|
Return EgtMsg(61837)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Id_Msg As String
|
|
Get
|
|
Return EgtMsg(61815)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property BTLFileName_Msg As String
|
|
Get
|
|
Return EgtMsg(61819)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ListName_Msg As String
|
|
Get
|
|
Return EgtMsg(61820)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ExportDate_Msg As String
|
|
Get
|
|
Return EgtMsg(61821)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property CreateDate_Msg As String
|
|
Get
|
|
Return EgtMsg(61822)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property Name_Msg As String
|
|
Get
|
|
Return EgtMsg(61808)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Open_Msg As String
|
|
Get
|
|
Return EgtMsg(30006)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property Delete_Msg As String
|
|
Get
|
|
Return EgtMsg(61823)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property Cancel_Msg As String
|
|
Get
|
|
Return EgtMsg(30002)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
' Definizione comandi
|
|
Private m_cmdProjectDoubleClick As ICommand
|
|
Private m_cmdDelete As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "METHODS"
|
|
|
|
Public MustOverride Function Init(ProjectType As ProjectType, Optional CurrProjectList As List(Of ProjectFileVM) = Nothing) As Boolean?
|
|
|
|
Protected Sub LoadColumns(ProjectType As ProjectType)
|
|
If ProjectType = ProjectType.PROJ Then
|
|
' carico le colonne della datagrid
|
|
GetPrivateProfileColumns(S_OPENPROJFILEDLG_PROJ, ProjectColumns)
|
|
' carico campi su cui eseguire il filtro di ricerca
|
|
m_SearchColumnList = New ObservableCollection(Of IdNameStruct)({New IdNameStruct(OpenProjFileColumn.NULL, ""),
|
|
New IdNameStruct(OpenProjFileColumn.ID, Id_Msg),
|
|
New IdNameStruct(OpenProjFileColumn.BTLFILENAME, BTLFileName_Msg),
|
|
New IdNameStruct(OpenProjFileColumn.LISTNAME, ListName_Msg),
|
|
New IdNameStruct(OpenProjFileColumn.EXPORTDATE, ExportDate_Msg),
|
|
New IdNameStruct(OpenProjFileColumn.CREATEDATE, CreateDate_Msg)})
|
|
ElseIf ProjectType = ProjectType.PROD Then
|
|
' carico le colonne della datagrid
|
|
GetPrivateProfileColumns(S_OPENPROJFILEDLG_PROD, ProjectColumns)
|
|
' carico campi su cui eseguire il filtro di ricerca
|
|
m_SearchColumnList = New ObservableCollection(Of IdNameStruct)({New IdNameStruct(OpenProjFileColumn.NULL, ""),
|
|
New IdNameStruct(OpenProjFileColumn.ID, Id_Msg),
|
|
New IdNameStruct(OpenProjFileColumn.BTLFILENAME, BTLFileName_Msg),
|
|
New IdNameStruct(OpenProjFileColumn.CREATEDATE, CreateDate_Msg)})
|
|
End If
|
|
End Sub
|
|
|
|
Friend Function VerifySelected() As Boolean
|
|
If IsNothing(SelProject) Then Return False
|
|
Dim AllFilesInDir As IEnumerable(Of String)
|
|
If m_ProjectType = Core.ConstBeam.ProjectType.PROJ Then
|
|
' verifico se esiste ProdId
|
|
AllFilesInDir = IO.Directory.EnumerateFiles(SelProject.sProjDirPath)
|
|
ElseIf m_ProjectType = Core.ConstBeam.ProjectType.PROD Then
|
|
AllFilesInDir = IO.Directory.EnumerateFiles(SelProject.sProdDirPath)
|
|
End If
|
|
For Each File In AllFilesInDir
|
|
If Path.GetExtension(File).ToLower() = ".nge" Then
|
|
Return True
|
|
End If
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
Protected Function ProjectFilter(Proj As Object) As Boolean
|
|
Dim bProjectOk As Boolean = True
|
|
If m_ProjectType = ProjectType.PROJ Then
|
|
Dim CurrProj As ProjFileVM = DirectCast(Proj, ProjFileVM)
|
|
If m_SelSearchColumn.Id <> OpenProjFileColumn.NULL AndAlso (
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.EXPORTDATE AndAlso Not SearchDate.Contains(CurrProj.dtExportDate.Date)) OrElse
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.CREATEDATE AndAlso Not SearchDate.Contains(CurrProj.dtCreateDate.Date))) Then bProjectOk = False
|
|
If m_SelSearchColumn.Id <> OpenProjFileColumn.NULL AndAlso m_SearchText <> String.Empty AndAlso (
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.ID AndAlso CurrProj.sProjId.ToString.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0) OrElse
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.BTLFILENAME AndAlso CurrProj.sBTLFileName.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0) OrElse
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.LISTNAME AndAlso CurrProj.sListName.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0)) Then bProjectOk = False
|
|
ElseIf m_ProjectType = ProjectType.PROD Then
|
|
Dim CurrProj As ProdFileVM = DirectCast(Proj, ProdFileVM)
|
|
If m_SelSearchColumn.Id <> OpenProjFileColumn.NULL AndAlso (
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.CREATEDATE AndAlso Not SearchDate.Contains(CurrProj.dtCreateDate.Date))) Then bProjectOk = False
|
|
If m_SelSearchColumn.Id <> OpenProjFileColumn.NULL AndAlso m_SearchText <> String.Empty AndAlso (
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.ID AndAlso CurrProj.sProdId.ToString.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0) OrElse
|
|
(m_SelSearchColumn.Id = OpenProjFileColumn.BTLFILENAME AndAlso CurrProj.sBTLFileName.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0)) Then bProjectOk = False
|
|
End If
|
|
Return bProjectOk
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ProjectDoubleClick"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do New.
|
|
''' </summary>
|
|
Public ReadOnly Property ProjectDoubleClick_Command As ICommand
|
|
Get
|
|
If m_cmdProjectDoubleClick Is Nothing Then
|
|
m_cmdProjectDoubleClick = New Command(AddressOf ProjDoubleClick)
|
|
End If
|
|
Return m_cmdProjectDoubleClick
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the New. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Friend Sub ProjDoubleClick()
|
|
If VerifySelected() Then
|
|
RaiseEvent m_CloseWindow(True)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' ProjectDoubleClick
|
|
|
|
#Region "Delete"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do New.
|
|
''' </summary>
|
|
Public ReadOnly Property Delete_Command As ICommand
|
|
Get
|
|
If m_cmdDelete Is Nothing Then
|
|
m_cmdDelete = New Command(AddressOf Delete)
|
|
End If
|
|
Return m_cmdDelete
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the New. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Overridable Sub Delete()
|
|
End Sub
|
|
|
|
#End Region ' Delete
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|