9c9b00d661
-aggiunto salvataggio, salvataggio con nome
183 lines
5.0 KiB
VB.net
183 lines
5.0 KiB
VB.net
Imports EgtWPFLib5
|
|
Imports EgtBEAMWALL.Core
|
|
Imports System.Windows.Forms
|
|
Imports System.Collections.ObjectModel
|
|
|
|
Public Class SaveAsStrategyVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Evento per chiusura finestra
|
|
Public Event m_CloseWindow(bDialogResult As DialogResult)
|
|
|
|
#Region "FileNameCustomConfig"
|
|
|
|
' Nome file json customconfig
|
|
Private m_sFileNameCustomConfig As String
|
|
Public Property sFileNameCustomConfig As String
|
|
Get
|
|
Return m_sFileNameCustomConfig
|
|
End Get
|
|
Set(value As String)
|
|
m_sFileNameCustomConfig = value
|
|
CheckJsonFile()
|
|
NotifyPropertyChanged(NameOf(sFileNameCustomConfig))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' FileNameCustomConfig
|
|
|
|
#Region "SaveAsProperty"
|
|
|
|
' Usato per gestire il fatto di non sovrascrivere il file
|
|
Private m_bSaveAsIsEnable As Boolean = True
|
|
Public ReadOnly Property bSaveAsIsEnable As Boolean
|
|
Get
|
|
Return m_bSaveAsIsEnable
|
|
End Get
|
|
End Property
|
|
Friend Sub SetSaveAsIsEnable(value As Boolean)
|
|
m_bSaveAsIsEnable = value
|
|
NotifyPropertyChanged(NameOf(bSaveAsIsEnable))
|
|
End Sub
|
|
|
|
' Usato per visualizzare messaggio di errore
|
|
Private m_ErrorMsgVisibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property ErrorMsgVisibility As Visibility
|
|
Get
|
|
Return m_ErrorMsgVisibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetErrorMsgVisibility(value As Visibility)
|
|
m_ErrorMsgVisibility = value
|
|
NotifyPropertyChanged(NameOf(ErrorMsgVisibility))
|
|
End Sub
|
|
|
|
' Messaggio di errore
|
|
Private m_sErrorMsg As String = String.Empty
|
|
Public ReadOnly Property sErrorMsg As String
|
|
Get
|
|
Return m_sErrorMsg
|
|
End Get
|
|
End Property
|
|
Friend Sub SetErrorMsg(value As String)
|
|
m_sErrorMsg = value
|
|
NotifyPropertyChanged(NameOf(sErrorMsg))
|
|
End Sub
|
|
|
|
#End Region ' SaveAsProperty
|
|
|
|
#Region "AISetup"
|
|
|
|
' Lista dei file json presenti nella cartella AISetUp
|
|
Public ReadOnly Property sAISetUpList As ObservableCollection(Of String)
|
|
Get
|
|
Return Map.refStrategyManagerVM.sAISetUpList
|
|
End Get
|
|
End Property
|
|
|
|
' File selezionato dalla lista AISetUpList
|
|
Private m_sSelectedAISetUp As String
|
|
Public Property sSelectedAISetUp As String
|
|
Get
|
|
Return m_sSelectedAISetUp
|
|
End Get
|
|
Set(value As String)
|
|
m_sSelectedAISetUp = value
|
|
If Not String.IsNullOrEmpty(m_sSelectedAISetUp) Then
|
|
m_sFileNameCustomConfig = m_sSelectedAISetUp
|
|
CheckJsonFile()
|
|
End If
|
|
NotifyPropertyChanged(NameOf(sSelectedAISetUp))
|
|
NotifyPropertyChanged(NameOf(sFileNameCustomConfig))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' AISetup
|
|
|
|
' Definizione Comandi
|
|
Private m_SaveAsCommand As ICommand
|
|
Private m_cmdCloseCommand As ICommand
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <summary>
|
|
''' Funzione che controlla se il file json è già presente
|
|
''' </summary>
|
|
Private Sub CheckJsonFile()
|
|
' Controllo se il nome del file è stato scritto
|
|
If sAISetUpList.Contains(m_sFileNameCustomConfig) Then
|
|
' Se si scrivo messaggio di errore
|
|
SetErrorMsg("FILE GIA' PRESENTE")
|
|
' Disabilito pulsante saveas
|
|
SetSaveAsIsEnable(False)
|
|
' Rendo visibile textblock messaggio
|
|
SetErrorMsgVisibility(Visibility.Visible)
|
|
Else
|
|
' Metto messaggio di errore a vuoto
|
|
SetErrorMsg(String.Empty)
|
|
' Riattivo pulsante saveas
|
|
SetSaveAsIsEnable(True)
|
|
' Rendo invisibile textblock messaggio
|
|
SetErrorMsgVisibility(Visibility.Collapsed)
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "SaveAsCommand"
|
|
|
|
Public ReadOnly Property SaveAsCommand As ICommand
|
|
Get
|
|
If m_SaveAsCommand Is Nothing Then
|
|
m_SaveAsCommand = New Command(AddressOf SaveAs)
|
|
End If
|
|
Return m_SaveAsCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che salva il file json CustomerConfig
|
|
''' </summary>
|
|
Public Sub SaveAs()
|
|
' Controllo se il file non è vuoto
|
|
If Not String.IsNullOrEmpty(m_sFileNameCustomConfig) Then
|
|
' Se si creo nuovo file json con nuovo nome
|
|
Map.refStrategyManagerVM.CreateCustumerConfigJsonFile(m_sFileNameCustomConfig)
|
|
Else
|
|
' Se no do nome di default CustomerConfing
|
|
Map.refStrategyManagerVM.CreateCustumerConfigJsonFile(CUSTOMERCONFIG_FILE)
|
|
End If
|
|
RaiseEvent m_CloseWindow(DialogResult.Cancel)
|
|
End Sub
|
|
|
|
#End Region ' SaveAsCommand
|
|
|
|
#Region "CloseCommand"
|
|
|
|
Public ReadOnly Property CloseCommand As ICommand
|
|
Get
|
|
If m_cmdCloseCommand Is Nothing Then
|
|
m_cmdCloseCommand = New Command(AddressOf Close)
|
|
End If
|
|
Return m_cmdCloseCommand
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Close()
|
|
' Chiudo finestra senza fare niente
|
|
RaiseEvent m_CloseWindow(DialogResult.Cancel)
|
|
End Sub
|
|
|
|
#End Region ' CloseCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|