c986f46861
- migliorato caricamento strategie
204 lines
6.0 KiB
VB.net
204 lines
6.0 KiB
VB.net
Imports EgtWPFLib5
|
|
Imports System.Windows.Forms
|
|
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
|
|
Public Class SaveAsStrategyVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Evento per chiusura finestra
|
|
Public Event m_CloseWindow(bDialogResult As DialogResult)
|
|
|
|
' 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
|
|
|
|
' 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
|
|
|
|
' Lista dei file json presenti nella cartella AISetUp
|
|
Public ReadOnly Property StrategySetupList As ObservableCollection(Of StrategySetup)
|
|
Get
|
|
Return Map.refStrategyManagerVM.StrategySetupList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelStrategySetup As StrategySetup = Map.refStrategyManagerVM.SelStrategySetup
|
|
Public Property SelStrategySetup As StrategySetup
|
|
Get
|
|
Return Map.refStrategyManagerVM.SelStrategySetup
|
|
End Get
|
|
Set(value As StrategySetup)
|
|
m_SelStrategySetup = value
|
|
CheckJsonFile()
|
|
NotifyPropertyChanged(NameOf(SelStrategySetup))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bOpen_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property bOpen_Visibility As Visibility
|
|
Get
|
|
Return m_bOpen_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbOpen_Visibility(value As Visibility)
|
|
m_bOpen_Visibility = value
|
|
NotifyPropertyChanged(NameOf(bOpen_Visibility))
|
|
End Sub
|
|
|
|
Private m_bSave_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property bSave_Visibility As Visibility
|
|
Get
|
|
Return m_bSave_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbSave_Visibility(value As Visibility)
|
|
m_bSave_Visibility = value
|
|
NotifyPropertyChanged(NameOf(bSave_Visibility))
|
|
End Sub
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property NewToolTip As String
|
|
Get
|
|
Return EgtMsg(30501)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SaveAsToolTip As String
|
|
Get
|
|
Return EgtMsg(62572)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' 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
|
|
Dim fileExists As Boolean = False
|
|
For Each ItemSetUp As StrategySetup In StrategySetupList
|
|
If ItemSetUp.sName = m_sFileNameCustomConfig Then
|
|
fileExists = True
|
|
End If
|
|
Next
|
|
' Imposta il messaggio di errore e la visibilità in base alla presenza del file
|
|
SetErrorMsg(If(fileExists, "FILE GIA' PRESENTE", String.Empty))
|
|
' Abilito o Disabilito pulsante saveas
|
|
SetSaveAsIsEnable(Not fileExists)
|
|
' Rendo visibile o invisibile textblock messaggio
|
|
SetErrorMsgVisibility(If(fileExists, Visibility.Visible, Visibility.Collapsed))
|
|
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()
|
|
Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(ProjectManagerVM.CurrProd.nType, False)
|
|
Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sFileNameCustomConfig & ".json"
|
|
Dim Strategy As New StrategySetup(sFileNameCustomConfig)
|
|
Map.refStrategyManagerVM.SelStrategySetup = Strategy
|
|
Map.refStrategyManagerVM.StrategySetupList.Add(Strategy)
|
|
If m_bSave_Visibility = Visibility.Visible Then
|
|
Map.refStrategyManagerVM.SelStrategySetup.Write()
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(False)
|
|
Else
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
End If
|
|
NotifyPropertyChanged(NameOf(StrategySetupList))
|
|
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
|