e23497b4e5
-aggiunto controllo Isenabled per feature quando si procude una barra -aggiunto controllo isenabled per pulsanti
2135 lines
69 KiB
VB.net
2135 lines
69 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.Globalization
|
|
Imports System.IO
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports Newtonsoft.Json
|
|
|
|
Public Class StrategyManagerVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private SAVE_IMAGE As String = "pack://application:,,,/Resources/NewPage/diskette.png"
|
|
Private MODIFY_IMAGE As String = "pack://application:,,,/Resources/NewPage/SaveModify.png"
|
|
|
|
Private m_StrategyTypeList As New List(Of IdNameStruct)({New IdNameStruct(BWType.BEAM, "Beam"), New IdNameStruct(BWType.WALL, "Wall")})
|
|
Public ReadOnly Property StrategyTypeList As List(Of IdNameStruct)
|
|
Get
|
|
Return m_StrategyTypeList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelStrategyType As IdNameStruct
|
|
Public Property SelStrategyType As IdNameStruct
|
|
Get
|
|
Return m_SelStrategyType
|
|
End Get
|
|
Set(value As IdNameStruct)
|
|
m_SelStrategyType = value
|
|
' deseleziono eventuale strategia selezionata
|
|
If Not IsNothing(m_SelTreeItem) Then
|
|
m_SelTreeItem.IsSelected = False
|
|
End If
|
|
NotifyPropertyChanged(NameOf(SelStrategyType))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StrategySetupList As New ObservableCollection(Of StrategySetup)
|
|
Public ReadOnly Property StrategySetupList As ObservableCollection(Of StrategySetup)
|
|
Get
|
|
Return m_StrategySetupList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelStrategySetup As StrategySetup
|
|
Public Property SelStrategySetup As StrategySetup
|
|
Get
|
|
Return m_SelStrategySetup
|
|
End Get
|
|
Set(value As StrategySetup)
|
|
' deseleziono eventuale strategia precedentemente selezionata
|
|
If Not IsNothing(m_SelTreeItem) Then
|
|
m_SelTreeItem.IsSelected = False
|
|
m_SelTreeItem.StrategyList.Clear()
|
|
End If
|
|
m_SelStrategySetup = value
|
|
Dim sDefaultConfigFile As String = String.Empty
|
|
If Not IsNothing(m_SelStrategySetup) Then
|
|
If EgtUILib.GetPrivateProfileString(S_STRATEGY, K_DEFAULTCONFIG, "", sDefaultConfigFile, Map.refMainWindowVM.MainWindowM.sDefaultConfig) <> 0 Then
|
|
If Not m_SelStrategySetup.sName.Equals(sDefaultConfigFile) Then
|
|
SetDefaultConfig_IsChecked(False)
|
|
Else
|
|
SetDefaultConfig_IsChecked(True)
|
|
End If
|
|
End If
|
|
m_SelStrategySetup.Read()
|
|
End If
|
|
SetSaveImage(MODIFY_IMAGE)
|
|
NotifyPropertyChanged(NameOf(SelStrategySetup))
|
|
End Set
|
|
End Property
|
|
Friend Sub SetSelStrategySetup(value As StrategySetup)
|
|
m_SelStrategySetup = value
|
|
If Not IsNothing(m_SelStrategySetup) Then
|
|
' Scrivo file defaultconfig nell'ini
|
|
EgtUILib.WritePrivateProfileString(S_STRATEGY, K_DEFAULTCONFIG, m_SelStrategySetup.sName, Map.refMainWindowVM.MainWindowM.sDefaultConfig)
|
|
m_SelStrategySetup.Read()
|
|
End If
|
|
NotifyPropertyChanged(NameOf(SelStrategySetup))
|
|
End Sub
|
|
|
|
' Permette di selezionare l'elemento dell'albero
|
|
Public m_SelTreeItem As Topology
|
|
Public Property SelTreeItem As Topology
|
|
Get
|
|
Return m_SelTreeItem
|
|
End Get
|
|
Set(value As Topology)
|
|
m_SelTreeItem = value
|
|
NotifyPropertyChanged(NameOf(SelTreeItem))
|
|
End Set
|
|
End Property
|
|
''' <summary>
|
|
''' Funzione che aggiorna la selezione dell'elemento dell'albero
|
|
''' </summary>
|
|
''' <param name="Item">Elemento dell'albero</param>
|
|
Friend Sub UpdateSelTreeItem(Item As Topology)
|
|
Dim ImageRoot As String = String.Empty
|
|
Dim TmpImage As String = String.Empty
|
|
If Not File.Exists(Item.sImage) Then
|
|
ImageRoot = If(m_SelStrategyType.Id = BWType.BEAM, Map.refMainWindowVM.MainWindowM.sBeamRoot, Map.refMainWindowVM.MainWindowM.sWallRoot) & "\Images\"
|
|
TmpImage = ImageRoot & Item.sImage
|
|
Item.sImage = TmpImage
|
|
End If
|
|
m_SelTreeItem = Item
|
|
NotifyPropertyChanged(NameOf(SelTreeItem))
|
|
End Sub
|
|
|
|
' Utilizzato per indicare che viene effettuata una modifica
|
|
Private m_bIsModifyStrategy As Boolean = False
|
|
Public ReadOnly Property bIsModifyStrategy As Boolean
|
|
Get
|
|
Return m_bIsModifyStrategy
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbIsModifyStrategy(value As Boolean)
|
|
m_bIsModifyStrategy = value
|
|
If m_bIsModifyStrategy Then
|
|
SetSaveImage(MODIFY_IMAGE)
|
|
Else
|
|
SetSaveImage(SAVE_IMAGE)
|
|
End If
|
|
NotifyPropertyChanged(NameOf(bIsModifyStrategy))
|
|
End Sub
|
|
|
|
' Immagine SaveCommand
|
|
Private m_SaveImage As String = SAVE_IMAGE
|
|
Public ReadOnly Property SaveImage As String
|
|
Get
|
|
Return m_SaveImage
|
|
End Get
|
|
End Property
|
|
Friend Sub SetSaveImage(value As String)
|
|
m_SaveImage = value
|
|
NotifyPropertyChanged(NameOf(SaveImage))
|
|
End Sub
|
|
|
|
' Lista che contiene le strategie filtrate
|
|
Private m_StrategyProductionList As New ObservableCollection(Of Strategy)
|
|
Public Property StrategyProductionList As ObservableCollection(Of Strategy)
|
|
Get
|
|
Return m_StrategyProductionList
|
|
End Get
|
|
Set(value As ObservableCollection(Of Strategy))
|
|
m_StrategyProductionList = value
|
|
NotifyPropertyChanged(NameOf(StrategyProductionList))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StrategyProductionPath As String = String.Empty
|
|
Public ReadOnly Property StrategyProductionPath As String
|
|
Get
|
|
Return m_StrategyProductionPath
|
|
End Get
|
|
End Property
|
|
Friend Sub SetStrategyProductionPath(value As String)
|
|
m_StrategyProductionPath = value
|
|
NotifyPropertyChanged(NameOf(StrategyProductionPath))
|
|
End Sub
|
|
|
|
Public ReadOnly Property StrategyType_Visibility As Visibility
|
|
Get
|
|
Return If(CurrentMachine.nType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed)
|
|
End Get
|
|
End Property
|
|
|
|
Private m_StrategyManager_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property StrategyManager_Visibility As Visibility
|
|
Get
|
|
Return m_StrategyManager_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetStrategyManager_Visibility(value As Visibility)
|
|
m_StrategyManager_Visibility = value
|
|
NotifyPropertyChanged(NameOf(StrategyManager_Visibility))
|
|
End Sub
|
|
|
|
Private m_bOK As Boolean = False
|
|
Public ReadOnly Property bOK As Boolean
|
|
Get
|
|
Return m_bOK
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbOk(value As Boolean)
|
|
m_bOK = value
|
|
NotifyPropertyChanged(NameOf(bOK))
|
|
End Sub
|
|
|
|
Private m_bDefaultConfig_IsChecked As Boolean = False
|
|
Public Property DefaultConfig_IsChecked As Boolean
|
|
Get
|
|
Return m_bDefaultConfig_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bDefaultConfig_IsChecked = value
|
|
If m_bDefaultConfig_IsChecked Then
|
|
EgtUILib.WritePrivateProfileString(S_STRATEGY, K_DEFAULTCONFIG, m_SelStrategySetup.sName, Map.refMainWindowVM.MainWindowM.sDefaultConfig)
|
|
End If
|
|
SetSaveImage(MODIFY_IMAGE)
|
|
NotifyPropertyChanged(NameOf(DefaultConfig_IsChecked))
|
|
End Set
|
|
End Property
|
|
Friend Sub SetDefaultConfig_IsChecked(value As Boolean)
|
|
m_bDefaultConfig_IsChecked = value
|
|
NotifyPropertyChanged(NameOf(DefaultConfig_IsChecked))
|
|
End Sub
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property SaveToolTip As String
|
|
Get
|
|
Return EgtMsg(62571)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SaveAsToolTip As String
|
|
Get
|
|
Return EgtMsg(62572)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NewToolTip As String
|
|
Get
|
|
Return EgtMsg(30501)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property UserMsg As String
|
|
Get
|
|
Return EgtMsg(61748)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property AdvanceMsg As String
|
|
Get
|
|
Return EgtMsg(61749)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' Definizione Comandi
|
|
Private m_AddSelectedStrategyCommand As ICommand
|
|
Private m_RemoveSelectedStrategyCommand As ICommand
|
|
Private m_NewCommand As ICommand
|
|
Private m_SaveCommand As ICommand
|
|
Private m_OpenFileNameCustomConfigCommand As ICommand
|
|
Private m_MoveUpSelectedStrategyCommand As ICommand
|
|
Private m_MoveDownSelectedStrategyCommand As ICommand
|
|
Private m_cmdOk As ICommand
|
|
Private m_cmdCancel As ICommand
|
|
Private m_cmdConfigurationParametersCommand As ICommand
|
|
|
|
#End Region ' Field & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Setto riferimento
|
|
Map.SetRefStrategyManagerVM(Me)
|
|
' Assegno riferimento funzione per aggiornare elemento selezionato dall'albero
|
|
Topology.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <summary>
|
|
''' Funzione che salva il file customconfig se sono presenti modifiche
|
|
''' </summary>
|
|
Friend Sub SaveCustomConfigJson()
|
|
' Controlla se il file JSON è stato modificato
|
|
If Not m_bIsModifyStrategy Then Return
|
|
' Chiede conferma per il salvataggio
|
|
If EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62580), EgtMsg(15003), MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then
|
|
m_SelStrategySetup.Write(Map.refGeneralParametersStrategyVM.GeneralParametersList, False)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub Update()
|
|
m_StrategySetupList.Clear()
|
|
' imposto Type a primo della lista per default
|
|
Select Case Map.refMachinePanelVM.SelectedMachine.nType
|
|
Case MachineType.BEAM
|
|
m_SelStrategyType = m_StrategyTypeList.FirstOrDefault(Function(x) x.Id = BWType.BEAM)
|
|
Case MachineType.WALL
|
|
m_SelStrategyType = m_StrategyTypeList.FirstOrDefault(Function(x) x.Id = BWType.WALL)
|
|
Case MachineType.BOTH
|
|
If Not IsNothing(ProjectManagerVM.CurrProd) Then
|
|
m_SelStrategyType = m_StrategyTypeList.FirstOrDefault(Function(x) x.Id = ProjectManagerVM.CurrProd.nType)
|
|
Else
|
|
m_SelStrategyType = m_StrategyTypeList.FirstOrDefault(Function(x) x.Id = BWType.BEAM)
|
|
End If
|
|
End Select
|
|
NotifyPropertyChanged(NameOf(SelStrategyType))
|
|
NotifyPropertyChanged(NameOf(StrategyType_Visibility))
|
|
' leggo cartella dei setup delle strategie
|
|
Dim AISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(SelStrategyType.Id, False)
|
|
Dim AISetupPaths As String() = Directory.GetFiles(AISetupDirPath).Where(Function(f) Path.GetExtension(f).ToLower() <> ".ini").ToArray()
|
|
Dim sDefaultConfigFile As String = String.Empty
|
|
Dim DefaultConfigFile As StrategySetup = Nothing
|
|
' leggo file default config
|
|
Map.refMainWindowVM.MainWindowM.GetDefaultConfigDirPath(SelStrategyType.Id, False)
|
|
For Each AiSetup In AISetupPaths
|
|
m_StrategySetupList.Add(New StrategySetup(Path.GetFileNameWithoutExtension(AiSetup)))
|
|
Next
|
|
If m_StrategySetupList.Count > 0 Then
|
|
' Controllo se presente file default config
|
|
If EgtUILib.GetPrivateProfileString(S_STRATEGY, K_DEFAULTCONFIG, "", sDefaultConfigFile, Map.refMainWindowVM.MainWindowM.sDefaultConfig) <> 0 Then
|
|
SetDefaultConfig_IsChecked(True)
|
|
DefaultConfigFile = m_StrategySetupList.FirstOrDefault(Function(x) x.sName = sDefaultConfigFile)
|
|
End If
|
|
If Not IsNothing(DefaultConfigFile) Then
|
|
SetSelStrategySetup(DefaultConfigFile)
|
|
Else
|
|
' restituisce la lista dei file presenti nella cartella con le relative informazioni
|
|
Dim StrategySetupListFile As List(Of FileInfo) = m_StrategySetupList.Where(Function(f) File.Exists(AISetupDirPath & "\" & f.sName & ".json")).
|
|
Select(Function(f) New FileInfo(AISetupDirPath & "\" & f.sName & ".json")).
|
|
OrderByDescending(Function(fi) fi.LastWriteTime).ToList()
|
|
' restituisce l'ultimo file modificato
|
|
If StrategySetupListFile.Any() Then
|
|
sDefaultConfigFile = Path.GetFileNameWithoutExtension(StrategySetupListFile.First().Name)
|
|
End If
|
|
DefaultConfigFile = m_StrategySetupList.FirstOrDefault(Function(x) x.sName = sDefaultConfigFile)
|
|
SetSelStrategySetup(DefaultConfigFile)
|
|
End If
|
|
SetDefaultConfig_IsChecked(True)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "AddSelectedStrategyCommand"
|
|
|
|
Public ReadOnly Property AddSelectedStrategyCommand As ICommand
|
|
Get
|
|
If m_AddSelectedStrategyCommand Is Nothing Then
|
|
m_AddSelectedStrategyCommand = New Command(AddressOf AddSelectedStrategyToActiveStrategy)
|
|
End If
|
|
Return m_AddSelectedStrategyCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di aggiungere la strategia da StrategyList a ActiveStrategyList
|
|
''' </summary>
|
|
Public Sub AddSelectedStrategyToActiveStrategy()
|
|
' Controllo se SelectedStrategy se è nullo esco
|
|
If IsNothing(m_SelTreeItem.SelAvailableStrategy) Then Return
|
|
' Setto a true booleano per modifica
|
|
SetbIsModifyStrategy(True)
|
|
' Setto indice per capire che la strategia è stata spostata in ActiveStrategyList
|
|
m_SelTreeItem.SelAvailableStrategy.nIndexInList = 0
|
|
' Aggiorno le liste
|
|
m_SelTreeItem.AvailableStrategyList_View.Refresh()
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
End Sub
|
|
|
|
#End Region ' AddSelectedStrategyCommand
|
|
|
|
#Region "RemoveSelectedStrategyCommand"
|
|
|
|
Public ReadOnly Property RemoveSelectedStrategyCommand As ICommand
|
|
Get
|
|
If m_RemoveSelectedStrategyCommand Is Nothing Then
|
|
m_RemoveSelectedStrategyCommand = New Command(AddressOf RemoveSelectedStrategyToActiveStrategy)
|
|
End If
|
|
Return m_RemoveSelectedStrategyCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che rimuove la strategia da ActiveStrategyList e la riaggiunge a StrategyList
|
|
''' </summary>
|
|
Public Sub RemoveSelectedStrategyToActiveStrategy()
|
|
' Controllo se SelectedActiveStrategy se è nullo esco
|
|
If IsNothing(m_SelTreeItem.SelActiveStrategy) Then Return
|
|
' Setto a true booleano per modifica
|
|
SetbIsModifyStrategy(True)
|
|
' Setto indice per capire che la strategia è stata spostata in StrategyList
|
|
m_SelTreeItem.SelActiveStrategy.nIndexInList = -1
|
|
' Aggiorno le liste
|
|
m_SelTreeItem.AvailableStrategyList_View.Refresh()
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
End Sub
|
|
|
|
#End Region ' RemoveSelectedStrategyCommand
|
|
|
|
#Region "OpenFileNameCustomConfigCommand"
|
|
|
|
Public ReadOnly Property OpenFileNameCustomConfigCommand As ICommand
|
|
Get
|
|
If m_OpenFileNameCustomConfigCommand Is Nothing Then
|
|
m_OpenFileNameCustomConfigCommand = New Command(AddressOf OpenFileNameCustomConfig)
|
|
End If
|
|
Return m_OpenFileNameCustomConfigCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che visualizza la textbox
|
|
''' </summary>
|
|
Public Sub OpenFileNameCustomConfig()
|
|
Dim SaveAsStrategyVM As New SaveAsStrategyVM()
|
|
SaveAsStrategyVM.SetbSave_Visibility(True)
|
|
Dim SaveAsStrategyWnd As New SaveAsStrategyV With {
|
|
.DataContext = SaveAsStrategyVM,
|
|
.Owner = Application.Current.MainWindow
|
|
}
|
|
SaveAsStrategyWnd.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' OpenFileNameCustomConfigCommand
|
|
|
|
#Region "New"
|
|
|
|
Public ReadOnly Property New_Command As ICommand
|
|
Get
|
|
If m_NewCommand Is Nothing Then
|
|
m_NewCommand = New Command(AddressOf NewAiSetup)
|
|
End If
|
|
Return m_NewCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione apre un nuovo il file json CustomerConfig
|
|
''' </summary>
|
|
Public Sub NewAiSetup()
|
|
SetDefaultConfig_IsChecked(False)
|
|
Dim NewStrategyVM As New SaveAsStrategyVM()
|
|
NewStrategyVM.SetbOpen_Visibility(True)
|
|
Dim NewStrategyWnd As New SaveAsStrategyV With {
|
|
.DataContext = NewStrategyVM,
|
|
.Owner = Application.Current.MainWindow
|
|
}
|
|
NewStrategyWnd.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' New
|
|
|
|
#Region "SaveCommand"
|
|
|
|
Public ReadOnly Property SaveCommand As ICommand
|
|
Get
|
|
If m_SaveCommand Is Nothing Then
|
|
m_SaveCommand = New Command(AddressOf Save)
|
|
End If
|
|
Return m_SaveCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che salva il file json CustomerConfig
|
|
''' </summary>
|
|
Public Sub Save(GeneralParametersList As ObservableCollection(Of ProjectParameters))
|
|
If IsNothing(m_SelStrategySetup) Then
|
|
OpenFileNameCustomConfig()
|
|
End If
|
|
If IsNothing(GeneralParametersList) Then
|
|
Dim GeneralParametersVM As New GeneralParametersStrategyVM()
|
|
GeneralParametersList = GeneralParametersVM.GeneralParametersList
|
|
End If
|
|
m_SelStrategySetup.Write(GeneralParametersList, False)
|
|
SetbIsModifyStrategy(False)
|
|
End Sub
|
|
|
|
#End Region ' SaveCommand
|
|
|
|
#Region "MoveUpSelectedStrategyCommand"
|
|
|
|
Public ReadOnly Property MoveUpSelectedStrategyCommand As ICommand
|
|
Get
|
|
If m_MoveUpSelectedStrategyCommand Is Nothing Then
|
|
m_MoveUpSelectedStrategyCommand = New Command(AddressOf MoveUpSelectedStrategy)
|
|
End If
|
|
Return m_MoveUpSelectedStrategyCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di spostare in alto la strategia selezionata
|
|
''' </summary>
|
|
Public Sub MoveUpSelectedStrategy()
|
|
' Controllo se SelectedActiveStrategy se è nullo esco
|
|
If IsNothing(m_SelTreeItem.SelActiveStrategy) Then Return
|
|
' Recupero indice elemento selezionato in lista
|
|
Dim IndexActiveStrategy As Integer = m_SelTreeItem.StrategyList.IndexOf(m_SelTreeItem.SelActiveStrategy)
|
|
' Recupero indice elemento selezionato in lista
|
|
Dim NewIndexActiveStrategy As Integer = IndexActiveStrategy - 1
|
|
' Se l'indice è maggiore di 0
|
|
If IndexActiveStrategy > 0 Then
|
|
' Muovo l'elemento selezionato sopra di 1
|
|
m_SelTreeItem.StrategyList.Move(IndexActiveStrategy, NewIndexActiveStrategy)
|
|
End If
|
|
' Setto a true booleano per modifica
|
|
SetbIsModifyStrategy(True)
|
|
' Aggiorno la lista
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
End Sub
|
|
|
|
#End Region ' MoveUpSelectedStrategyCommand
|
|
|
|
#Region "MoveDownSelectedStrategyCommand"
|
|
|
|
Public ReadOnly Property MoveDownSelectedStrategyCommand As ICommand
|
|
Get
|
|
If m_MoveDownSelectedStrategyCommand Is Nothing Then
|
|
m_MoveDownSelectedStrategyCommand = New Command(AddressOf MoveDownSelectedStrategy)
|
|
End If
|
|
Return m_MoveDownSelectedStrategyCommand
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione che permette di spostare in basso la strategia selezionata
|
|
''' </summary>
|
|
Public Sub MoveDownSelectedStrategy()
|
|
If IsNothing(m_SelTreeItem.SelActiveStrategy) Then Return
|
|
' Recupero indice elemento selezionato in lista
|
|
Dim IndexActiveStrategy As Integer = m_SelTreeItem.StrategyList.IndexOf(m_SelTreeItem.SelActiveStrategy)
|
|
' Recupero indice elemento selezionato in lista
|
|
Dim NewIndexActiveStrategy As Integer = IndexActiveStrategy + 1
|
|
' Se l'indice è maggiore di 0
|
|
If IndexActiveStrategy >= 0 Then
|
|
' Muovo l'elemento selezionato sopra di 1
|
|
m_SelTreeItem.StrategyList.Move(IndexActiveStrategy, NewIndexActiveStrategy)
|
|
End If
|
|
' Setto a true booleano per modifica
|
|
SetbIsModifyStrategy(True)
|
|
' Aggiorno la lista
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
End Sub
|
|
|
|
#End Region ' MoveDownSelectedStrategyCommand
|
|
|
|
#Region "Ok_Command"
|
|
|
|
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()
|
|
Map.refProjectVM.SetSelManagerTab(ProjectVM.StrategyManagerTab.RAWPARTMANAGER)
|
|
' Abilito LeftPanel
|
|
Map.refProjectVM.SetLeftPanel_IsEnabled(True)
|
|
Map.refProjectVM.SetLeftPanel_Opacity(1)
|
|
End Sub
|
|
|
|
#End Region ' Ok_Command
|
|
|
|
#Region "Cancel_Command"
|
|
|
|
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()
|
|
Map.refProjectVM.SetSelManagerTab(ProjectVM.StrategyManagerTab.RAWPARTMANAGER)
|
|
' Abilito LeftPanel
|
|
Map.refProjectVM.SetLeftPanel_IsEnabled(True)
|
|
Map.refProjectVM.SetLeftPanel_Opacity(1)
|
|
End Sub
|
|
|
|
#End Region ' Cancel_Command
|
|
|
|
#Region "ConfigurationParametersCommand"
|
|
|
|
Public ReadOnly Property ConfigurationParametersCommand As ICommand
|
|
Get
|
|
If m_cmdConfigurationParametersCommand Is Nothing Then
|
|
m_cmdConfigurationParametersCommand = New Command(AddressOf ConfigurationParameters)
|
|
End If
|
|
Return m_cmdConfigurationParametersCommand
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ConfigurationParameters()
|
|
Map.refBTLDataWndVM.SetIsBTLDataWnd(False)
|
|
Dim GeneralParametersStrategyVM = New GeneralParametersStrategyVM()
|
|
Dim GeneralParametersStrategyWnd As New GeneralParametersStrategyV(Application.Current.MainWindow, GeneralParametersStrategyVM)
|
|
GeneralParametersStrategyWnd.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' ConfigurationParametersCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|
|
|
|
'----------- Classe che rappresenta un file di setup delle strategie -----------
|
|
Public Class StrategySetup
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_sName As String
|
|
Public Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_StrategyFeatureList As New ObservableCollection(Of StrategyFeature)
|
|
Public Property StrategyFeatureList As ObservableCollection(Of StrategyFeature)
|
|
Get
|
|
Return m_StrategyFeatureList
|
|
End Get
|
|
Set(value As ObservableCollection(Of StrategyFeature))
|
|
m_StrategyFeatureList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelStrategyFeature As StrategyFeature
|
|
Public Property SelStrategyFeature As StrategyFeature
|
|
Get
|
|
Return m_SelStrategyFeature
|
|
End Get
|
|
Set(value As StrategyFeature)
|
|
m_SelStrategyFeature = value
|
|
NotifyPropertyChanged(NameOf(SelStrategyFeature))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(sName As String)
|
|
m_sName = sName
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub Read()
|
|
' carico default
|
|
Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath(Map.refStrategyManagerVM.SelStrategyType.Id)
|
|
Dim sAvailableStrategiesFilePath As String = sStrategiesDirPath & "\" & AVAILABLESTRATEGYLIST_FILE & ".json"
|
|
GetDefaultJsonStrategy(sAvailableStrategiesFilePath)
|
|
' carico custom
|
|
Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(Map.refStrategyManagerVM.SelStrategyType.Id, False)
|
|
Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sName & ".json"
|
|
If File.Exists(sStrategyConfigurationFilePath) Then
|
|
Dim sReadedFile As String = File.ReadAllText(sStrategyConfigurationFilePath)
|
|
|
|
Dim JsonRoot As CustomJsonRoot = Nothing
|
|
Try
|
|
JsonRoot = JsonConvert.DeserializeObject(Of CustomJsonRoot)(sReadedFile)
|
|
Catch ex As Exception
|
|
JsonRoot = Nothing
|
|
End Try
|
|
Dim JsonStrategyFeatureList As ObservableCollection(Of JsonStrategyFeature) = Nothing
|
|
If Not IsNothing(JsonRoot) Then
|
|
JsonStrategyFeatureList = JsonRoot.FEATURE
|
|
Else
|
|
If IsNothing(JsonRoot) Then
|
|
EgtOutLog("JSON ERRATO: Il file Json importato non è nel formato corretto")
|
|
GetDefaultJsonStrategy(sAvailableStrategiesFilePath)
|
|
Return
|
|
Else
|
|
JsonStrategyFeatureList = JsonConvert.DeserializeObject(Of ObservableCollection(Of JsonStrategyFeature))(sReadedFile)
|
|
End If
|
|
End If
|
|
|
|
For Each Feature As JsonStrategyFeature In JsonStrategyFeatureList
|
|
Dim DefaultFeature As StrategyFeature = m_StrategyFeatureList.FirstOrDefault(Function(x) x.nPrc = Feature.nPrc AndAlso x.nGrp = Feature.nGrp)
|
|
' gestire caso non venga trovata perchè non esiste più in default??'
|
|
If Not IsNothing(DefaultFeature) Then
|
|
For Each Topology In Feature.TopologyList
|
|
Dim DefaultTopology As Topology = DefaultFeature.TopologyList.FirstOrDefault(Function(x) x.sName = Topology.sName)
|
|
' gestire caso non venga trovata perchè non esiste più in default??'
|
|
If Not IsNothing(DefaultTopology) Then
|
|
For Each Strategy In Topology.StrategyList
|
|
Dim DefaultStrategy As Strategy = DefaultTopology.StrategyList.FirstOrDefault(Function(x) x.sStrategyId = Strategy.sStrategyId)
|
|
If IsNothing(DefaultStrategy) Then
|
|
' DefaultTopology.StrategyList.Add(New Strategy(DefaultTopology, Strategy))
|
|
' verifico indici!!
|
|
Else
|
|
DefaultStrategy.ReadConfiguration(Strategy)
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GetDefaultJsonStrategy(sAvailableStrategiesFilePath As String)
|
|
If File.Exists(sAvailableStrategiesFilePath) Then
|
|
Dim sReadedFile As String = File.ReadAllText(sAvailableStrategiesFilePath)
|
|
Dim JsonStrategyFeatureList As List(Of JsonAvailableStrategyFeature) = JsonConvert.DeserializeObject(Of List(Of JsonAvailableStrategyFeature))(sReadedFile)
|
|
m_StrategyFeatureList = New ObservableCollection(Of StrategyFeature)((From JsonStrategyFeature In JsonStrategyFeatureList
|
|
Select JsonStrategyFeature.Deserialize(Map.refStrategyManagerVM.SelStrategyType.Id)).ToList())
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub Write(GeneralParametersStrategyList As ObservableCollection(Of ProjectParameters), bProdPage As Boolean)
|
|
Dim JsonFromStrategyManager As New List(Of JsonStrategyFeature)
|
|
For Each StrategyFeature In m_StrategyFeatureList
|
|
JsonFromStrategyManager.Add(StrategyFeature.Serialize())
|
|
Next
|
|
|
|
Dim JsonProjectParameters As New List(Of JsonParametersHelper)
|
|
For Each ParamItem In GeneralParametersStrategyList
|
|
JsonProjectParameters.Add(ParamItem.Serialize())
|
|
Next
|
|
|
|
Dim CombinedJson = New With {.GENERAL = JsonProjectParameters,
|
|
.FEATURE = JsonFromStrategyManager}
|
|
|
|
Dim JsonFromGenericParameters As String = JsonConvert.SerializeObject(CombinedJson, Formatting.Indented)
|
|
|
|
Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(Map.refStrategyManagerVM.SelStrategyType.Id, bProdPage)
|
|
Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sName & ".json"
|
|
File.WriteAllText(sStrategyConfigurationFilePath, JsonFromGenericParameters)
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class CustomJsonRoot
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
Private m_GENERAL As New ObservableCollection(Of JsonParameters)
|
|
Public Property GENERAL As ObservableCollection(Of JsonParameters)
|
|
Get
|
|
Return m_GENERAL
|
|
End Get
|
|
Set(value As ObservableCollection(Of JsonParameters))
|
|
m_GENERAL = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_FEATURE As New ObservableCollection(Of JsonStrategyFeature)
|
|
Public Property FEATURE As ObservableCollection(Of JsonStrategyFeature)
|
|
Get
|
|
Return m_FEATURE
|
|
End Get
|
|
Set(value As ObservableCollection(Of JsonStrategyFeature))
|
|
m_FEATURE = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Propeties
|
|
|
|
End Class
|
|
|
|
'----------- Classe che fa riferimento alle Feature -----------
|
|
Public Class StrategyFeature
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
Private m_sName As String
|
|
Public Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
NotifyPropertyChanged(NameOf(sName))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nPrc As Integer
|
|
Public Property nPrc As Integer
|
|
Get
|
|
Return m_nPrc
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nPrc = value
|
|
NotifyPropertyChanged(NameOf(nPrc))
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property nPrcDesc As String
|
|
Get
|
|
Return m_nPrc.ToString("000")
|
|
End Get
|
|
End Property
|
|
|
|
Private m_nGrp As Integer
|
|
Public Property nGrp As Integer
|
|
Get
|
|
Return m_nGrp
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nGrp = value
|
|
NotifyPropertyChanged(NameOf(nGrp))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TopologyList As New ObservableCollection(Of Topology)
|
|
Public Property TopologyList As ObservableCollection(Of Topology)
|
|
Get
|
|
Return m_TopologyList
|
|
End Get
|
|
Set(value As ObservableCollection(Of Topology))
|
|
m_TopologyList = value
|
|
NotifyPropertyChanged(NameOf(TopologyList))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bIsExpanded As Boolean
|
|
Public Property IsExpanded As Boolean
|
|
Get
|
|
Return m_bIsExpanded
|
|
End Get
|
|
Set(value As Boolean)
|
|
If Not value AndAlso m_TopologyList.Any(Function(x) x.IsSelected) Then
|
|
Else
|
|
m_bIsExpanded = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Propeties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonStrategyFeature As JsonAvailableStrategyFeature)
|
|
If IsNothing(JsonStrategyFeature) Then Return
|
|
m_sName = JsonStrategyFeature.sName
|
|
m_nPrc = JsonStrategyFeature.nPrc
|
|
m_nGrp = JsonStrategyFeature.nGrp
|
|
m_TopologyList = New ObservableCollection(Of Topology)(JsonStrategyFeature.TopologyList.Select(Function(jsonTopology) New Topology(jsonTopology)))
|
|
NotifyPropertyChanged(NameOf(TopologyList))
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function Serialize() As JsonStrategyFeature
|
|
Dim JsonStrategyFeature As New JsonStrategyFeature(m_sName, m_nPrc, m_nGrp)
|
|
For Each Topology In m_TopologyList
|
|
JsonStrategyFeature.TopologyList.Add(Topology.Serialize())
|
|
Next
|
|
Return JsonStrategyFeature
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
'----------- Classe che fa riferimento alle Topologie delle Feature -----------
|
|
Public Class Topology
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
Friend Shared refUpdateSelTreeItem As Action(Of Topology)
|
|
|
|
Private m_sName As String
|
|
Public Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
NotifyPropertyChanged(NameOf(sName))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sImage As String
|
|
Public Property sImage As String
|
|
Get
|
|
Return m_sImage
|
|
End Get
|
|
Set(value As String)
|
|
m_sImage = value
|
|
NotifyPropertyChanged(NameOf(sImage))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bIsSelected As Boolean
|
|
Public Property IsSelected As Boolean
|
|
Get
|
|
Return m_bIsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bIsSelected = value
|
|
If value Then
|
|
refUpdateSelTreeItem(Me)
|
|
Else
|
|
m_SelActiveStrategy = Nothing
|
|
m_SelAvailableStrategy = Nothing
|
|
End If
|
|
m_AvailableStrategyList_View.Refresh()
|
|
m_ActiveStrategyList_View.Refresh()
|
|
End Set
|
|
End Property
|
|
|
|
Private m_AvailableStrategyList_View As ICollectionView = Nothing
|
|
Public ReadOnly Property AvailableStrategyList_View As ICollectionView
|
|
Get
|
|
Return m_AvailableStrategyList_View
|
|
End Get
|
|
End Property
|
|
|
|
Private m_ActiveStrategyList_View As ICollectionView = Nothing
|
|
Public ReadOnly Property ActiveStrategyList_View As ICollectionView
|
|
Get
|
|
Return m_ActiveStrategyList_View
|
|
End Get
|
|
End Property
|
|
|
|
Private m_StrategyList As New ObservableCollection(Of Strategy)
|
|
Public Property StrategyList As ObservableCollection(Of Strategy)
|
|
Get
|
|
Return m_StrategyList
|
|
End Get
|
|
Set(value As ObservableCollection(Of Strategy))
|
|
m_StrategyList = value
|
|
NotifyPropertyChanged(NameOf(StrategyList))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelActiveStrategy As Strategy
|
|
Public Property SelActiveStrategy As Strategy
|
|
Get
|
|
Return m_SelActiveStrategy
|
|
End Get
|
|
Set(value As Strategy)
|
|
m_SelActiveStrategy = value
|
|
SelParamStrategy = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelAvailableStrategy As Strategy
|
|
Public Property SelAvailableStrategy As Strategy
|
|
Get
|
|
Return m_SelAvailableStrategy
|
|
End Get
|
|
Set(value As Strategy)
|
|
m_SelAvailableStrategy = value
|
|
SelParamStrategy = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelParamStrategy As Strategy
|
|
Public Property SelParamStrategy As Strategy
|
|
Get
|
|
Return m_SelParamStrategy
|
|
End Get
|
|
Set(value As Strategy)
|
|
m_SelParamStrategy = value
|
|
NotifyPropertyChanged(NameOf(SelParamStrategy))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Propeties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonTopology As JsonAvailableTopology)
|
|
If IsNothing(JsonTopology) Then Return
|
|
m_sName = JsonTopology.sName
|
|
m_sImage = JsonTopology.sImage
|
|
m_StrategyList = New ObservableCollection(Of Strategy)(JsonTopology.StrategyList.Select(Function(jsonStrategy) New Strategy(jsonStrategy)))
|
|
m_AvailableStrategyList_View = New ListCollectionView(StrategyList)
|
|
m_AvailableStrategyList_View.Filter = AddressOf AvailableStrategyFilter
|
|
m_ActiveStrategyList_View = New ListCollectionView(StrategyList)
|
|
m_ActiveStrategyList_View.Filter = AddressOf ActiveStrategyFilter
|
|
NotifyPropertyChanged(NameOf(StrategyList))
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function AvailableStrategyFilter(Strategy As Object) As Boolean
|
|
Return DirectCast(Strategy, Strategy).nIndexInList < 0
|
|
End Function
|
|
|
|
Friend Function ActiveStrategyFilter(Strategy As Object) As Boolean
|
|
Return DirectCast(Strategy, Strategy).nIndexInList >= 0
|
|
End Function
|
|
|
|
Friend Sub CreateStrategyViews()
|
|
m_AvailableStrategyList_View = New ListCollectionView(StrategyList)
|
|
m_AvailableStrategyList_View.Filter = AddressOf AvailableStrategyFilter
|
|
m_ActiveStrategyList_View = New ListCollectionView(StrategyList)
|
|
m_ActiveStrategyList_View.Filter = AddressOf ActiveStrategyFilter
|
|
End Sub
|
|
|
|
Friend Function Serialize() As JsonTopology
|
|
Dim JsonTopology As New JsonTopology(m_sName)
|
|
For Each Strategy In m_StrategyList
|
|
JsonTopology.StrategyList.Add(Strategy.Serialize())
|
|
Next
|
|
Return JsonTopology
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
'----------- Classe che fa alle Strategie delle Topologie delle Feature -----------
|
|
Public Class Strategy
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
Private STRATEGY_IMAGE As String = "pack://application:,,,/Resources/NewPage/LogoProvaStrategy.png"
|
|
|
|
Private m_sStrategyId As String
|
|
Public Property sStrategyId As String
|
|
Get
|
|
Return m_sStrategyId
|
|
End Get
|
|
Set(value As String)
|
|
m_sStrategyId = value
|
|
NotifyPropertyChanged(NameOf(sStrategyId))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sStrategyName As String
|
|
Public Property sStrategyName As String
|
|
Get
|
|
Return m_sStrategyName
|
|
End Get
|
|
Set(value As String)
|
|
m_sStrategyName = value
|
|
NotifyPropertyChanged(NameOf(sStrategyName))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nIndexInList As Integer = -1
|
|
Public Property nIndexInList As Integer
|
|
Get
|
|
Return m_nIndexInList
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nIndexInList = value
|
|
NotifyPropertyChanged(NameOf(nIndexInList))
|
|
End Set
|
|
End Property
|
|
Friend Sub SetIndexList(value As Integer)
|
|
m_nIndexInList = value
|
|
NotifyPropertyChanged(NameOf(nIndexInList))
|
|
End Sub
|
|
|
|
Private m_sStrategyImagePath As String = STRATEGY_IMAGE
|
|
Public Property sStrategyImagePath As String
|
|
Get
|
|
Return m_sStrategyImagePath
|
|
End Get
|
|
Set(value As String)
|
|
m_sStrategyImagePath = value
|
|
NotifyPropertyChanged(NameOf(sStrategyImagePath))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ParameterList As New ObservableCollection(Of StrategyParameter)
|
|
Public Property ParameterList As ObservableCollection(Of StrategyParameter)
|
|
Get
|
|
Return m_ParameterList
|
|
End Get
|
|
Set(value As ObservableCollection(Of StrategyParameter))
|
|
m_ParameterList = value
|
|
NotifyPropertyChanged(NameOf(ParameterList))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bIsStrategyModify As Boolean = False
|
|
Public ReadOnly Property bIsStrategyModify As Boolean
|
|
Get
|
|
Return m_bIsStrategyModify
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbIsStrategyModify(value As Boolean)
|
|
m_bIsStrategyModify = value
|
|
NotifyPropertyChanged(NameOf(bIsStrategyModify))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Propeties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonStrategy As JsonAvailableStrategy)
|
|
If IsNothing(JsonStrategy) Then Return
|
|
m_sStrategyId = JsonStrategy.sStrategyId
|
|
ReadConfigurationStrategyJson()
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <summary>
|
|
''' Funzione che legge il file json delle strategie
|
|
''' </summary>
|
|
Friend Sub ReadConfigurationStrategyJson()
|
|
' Recupero file StrategyJson
|
|
Dim StrategyPath As String = Map.refMainWindowVM.MainWindowM.GetStandardDirPath(Map.refStrategyManagerVM.SelStrategyType.Id) & "\" & sStrategyId & "\" & sStrategyId & ".json"
|
|
' Controllo se il file esiste
|
|
If Not File.Exists(StrategyPath) Then Return
|
|
' Leggo il contenuto del file JSON e deserializzo
|
|
Dim StrategyJson As String = File.ReadAllText(StrategyPath)
|
|
Dim strategyConfig As JsonAvailableStrategy = JsonConvert.DeserializeObject(Of JsonAvailableStrategy)(StrategyJson)
|
|
End Sub
|
|
|
|
Friend Sub ReadConfiguration(ConfigurationStrategy As JsonStrategy)
|
|
m_nIndexInList = ConfigurationStrategy.nIndexInList
|
|
NotifyPropertyChanged(NameOf(nIndexInList))
|
|
For Each Parameter In ConfigurationStrategy.ParameterList
|
|
Dim DefaultParameter As StrategyParameter = m_ParameterList.FirstOrDefault(Function(x) x.sName = Parameter.sName)
|
|
If IsNothing(DefaultParameter) Then
|
|
' verifico indici!!
|
|
Else
|
|
Select Case DefaultParameter.GetType()
|
|
Case GetType(BooleanStrategyParameter)
|
|
DirectCast(DefaultParameter, BooleanStrategyParameter).SetValue(Parameter.sValue)
|
|
If Parameter.sMinUserLevel = 1 Then
|
|
DirectCast(DefaultParameter, BooleanStrategyParameter).SetbBooleanVisibility(True)
|
|
End If
|
|
Case GetType(DoubleStrategyParameter)
|
|
DirectCast(DefaultParameter, DoubleStrategyParameter).SetValue(Parameter.sValue)
|
|
If Parameter.sMinUserLevel = 1 Then
|
|
DirectCast(DefaultParameter, DoubleStrategyParameter).SetbDoubleVisibility(True)
|
|
End If
|
|
Case GetType(ComboStrategyParameter)
|
|
DirectCast(DefaultParameter, ComboStrategyParameter).SetSelValue(Parameter.sValue)
|
|
If Parameter.sMinUserLevel = 1 Then
|
|
DirectCast(DefaultParameter, ComboStrategyParameter).SetbComboBoxVisibility(True)
|
|
End If
|
|
Case GetType(StringStrategyParameter)
|
|
DirectCast(DefaultParameter, StringStrategyParameter).SetValue(Parameter.sValue)
|
|
If Parameter.sMinUserLevel = 1 Then
|
|
DirectCast(DefaultParameter, StringStrategyParameter).SetbStringVisibility(True)
|
|
End If
|
|
Case GetType(ListStrategyParameter)
|
|
DirectCast(DefaultParameter, ListStrategyParameter).SetSelValue(Parameter.sValue)
|
|
DirectCast(DefaultParameter, ListStrategyParameter).CreateToolsViews()
|
|
DirectCast(DefaultParameter, ListStrategyParameter).ToolView()
|
|
If Parameter.sMinUserLevel = 1 Then
|
|
DirectCast(DefaultParameter, ListStrategyParameter).SetbListBoxVisibility(True)
|
|
End If
|
|
End Select
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Friend Function Serialize() As JsonStrategy
|
|
Dim JsonStrategy As New JsonStrategy(m_sStrategyId, m_nIndexInList)
|
|
For Each Parameter In m_ParameterList
|
|
JsonStrategy.ParameterList.Add(Parameter.Serialize())
|
|
Next
|
|
Return JsonStrategy
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
'----------- Classe che fa riferimento ai parametri delle Strategie -----------
|
|
Public MustInherit Class StrategyParameter
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
Private m_sName As String
|
|
Public Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
NotifyPropertyChanged(NameOf(sName))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sNameNge As String
|
|
Public Property sNameNge As String
|
|
Get
|
|
Return m_sNameNge
|
|
End Get
|
|
Set(value As String)
|
|
m_sNameNge = value
|
|
NotifyPropertyChanged(NameOf(sNameNge))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sSubType As String
|
|
Public Property sSubType As String
|
|
Get
|
|
Return m_sSubType
|
|
End Get
|
|
Set(value As String)
|
|
m_sSubType = value
|
|
NotifyPropertyChanged(NameOf(sSubType))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sSource As String
|
|
Public Property sSource As String
|
|
Get
|
|
Return m_sSource
|
|
End Get
|
|
Set(value As String)
|
|
m_sSource = value
|
|
NotifyPropertyChanged(NameOf(sSource))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sDescriptionShort As String
|
|
Public Property sDescriptionShort As String
|
|
Get
|
|
Return m_sDescriptionShort
|
|
End Get
|
|
Set(value As String)
|
|
m_sDescriptionShort = value
|
|
NotifyPropertyChanged(NameOf(sDescriptionShort))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sDescriptionLong As String
|
|
Public Property sDescriptionLong As String
|
|
Get
|
|
Return m_sDescriptionLong
|
|
End Get
|
|
Set(value As String)
|
|
m_sDescriptionLong = value
|
|
NotifyPropertyChanged(NameOf(sDescriptionLong))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sMessageId As String
|
|
Public Property sMessageId As String
|
|
Get
|
|
Return m_sMessageId
|
|
End Get
|
|
Set(value As String)
|
|
m_sMessageId = value
|
|
NotifyPropertyChanged(NameOf(sMessageId))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sMinUserLevel As Integer
|
|
Public Property sMinUserLevel As Integer
|
|
Get
|
|
Return m_sMinUserLevel
|
|
End Get
|
|
Set(value As Integer)
|
|
m_sMinUserLevel = value
|
|
NotifyPropertyChanged(NameOf(sMinUserLevel))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Propeties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonGenericParameter As JsonDefaultStrategyParameter)
|
|
If IsNothing(JsonGenericParameter) Then Return
|
|
m_sName = JsonGenericParameter.sName
|
|
m_sNameNge = JsonGenericParameter.sNameNge
|
|
m_sSource = JsonGenericParameter.sSource
|
|
m_sSubType = JsonGenericParameter.sSubType
|
|
m_sDescriptionShort = JsonGenericParameter.sDescriptionShort
|
|
m_sDescriptionLong = JsonGenericParameter.sDescriptionLong
|
|
m_sMessageId = JsonGenericParameter.sMessageId
|
|
m_sMinUserLevel = JsonGenericParameter.sMinUserLevel
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend MustOverride Function Serialize() As JsonStrategyParameter
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class BooleanStrategyParameter
|
|
Inherits StrategyParameter
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend m_bValue As Boolean = False
|
|
Public Property bValue As Boolean
|
|
Get
|
|
Return m_bValue
|
|
End Get
|
|
Set(value As Boolean)
|
|
If m_bValue <> value Then
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
SetbIsBooleanModify(True)
|
|
End If
|
|
m_bValue = value
|
|
End Set
|
|
End Property
|
|
Friend Sub SetValue(bValue As Boolean)
|
|
m_bValue = bValue
|
|
End Sub
|
|
Friend Sub SetValue(sValue As String)
|
|
m_bValue = sValue.ToLower() = "true"
|
|
End Sub
|
|
|
|
Private m_bBooleanVisibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property bBooleanVisibility As Visibility
|
|
Get
|
|
Return m_bBooleanVisibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbBooleanVisibility(value As Boolean)
|
|
m_bBooleanVisibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(bBooleanVisibility))
|
|
End Sub
|
|
|
|
Private m_bIsBooleanModify As Boolean = False
|
|
Public ReadOnly Property bIsBooleanModify As Boolean
|
|
Get
|
|
Return m_bIsBooleanModify
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbIsBooleanModify(value As Boolean)
|
|
m_bIsBooleanModify = value
|
|
If m_bIsBooleanModify Then
|
|
If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then
|
|
Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SetbStrategy_Visibility(True)
|
|
ElseIf Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM) Then
|
|
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.SetbStrategy_Visibility(True)
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged(NameOf(bIsBooleanModify))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonGenericParameter As JsonDefaultStrategyParameter)
|
|
MyBase.New(JsonGenericParameter)
|
|
If IsNothing(JsonGenericParameter) Then Return
|
|
m_bValue = JsonGenericParameter.sValue.ToLower() = "true"
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonStrategyParameter
|
|
Dim sValue As String = If(bValue, "true", "false")
|
|
Dim JsonStrategyParameter As New JsonStrategyParameter(sName, sNameNge, sValue, "b", If(Not String.IsNullOrEmpty(sSubType), sSubType, ""), sMinUserLevel)
|
|
Return JsonStrategyParameter
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class DoubleStrategyParameter
|
|
Inherits StrategyParameter
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_dValue As Double? = Nothing
|
|
Public Property sValue As String
|
|
Get
|
|
Return If(Not IsNothing(m_dValue), DoubleToString(m_dValue, 2), "")
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
If String.IsNullOrWhiteSpace(value) Then
|
|
m_dValue = Nothing
|
|
ElseIf StringToDouble(value, dValue) Then
|
|
If m_dValue <> dValue Then
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
SetbIsDoubleModify(True)
|
|
End If
|
|
m_dValue = dValue
|
|
Else
|
|
NotifyPropertyChanged(NameOf(sValue))
|
|
End If
|
|
End Set
|
|
End Property
|
|
Friend Sub SetValue(dValue As Double)
|
|
m_dValue = dValue
|
|
End Sub
|
|
Friend Sub SetValue(sValue As String)
|
|
Dim dValue As Double
|
|
If String.IsNullOrWhiteSpace(sValue) Then
|
|
m_dValue = Nothing
|
|
ElseIf StringToDouble(sValue, dValue) Then
|
|
m_dValue = dValue
|
|
Else
|
|
NotifyPropertyChanged(NameOf(sValue))
|
|
EgtOutLog("Error reading DoubleStrategyParameter " & sValue)
|
|
End If
|
|
End Sub
|
|
|
|
Private m_bDoubleVisibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property bDoubleVisibility As Visibility
|
|
Get
|
|
Return m_bDoubleVisibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbDoubleVisibility(value As Boolean)
|
|
m_bDoubleVisibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(bDoubleVisibility))
|
|
End Sub
|
|
|
|
Private m_bIsDoubleModify As Boolean = False
|
|
Public ReadOnly Property bIsDoubleModify As Boolean
|
|
Get
|
|
Return m_bIsDoubleModify
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbIsDoubleModify(value As Boolean)
|
|
m_bIsDoubleModify = value
|
|
If m_bIsDoubleModify Then
|
|
If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then
|
|
Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SetbStrategy_Visibility(True)
|
|
ElseIf Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM) Then
|
|
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.SetbStrategy_Visibility(True)
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged(NameOf(bIsDoubleModify))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonGenericParameter As JsonDefaultStrategyParameter)
|
|
MyBase.New(JsonGenericParameter)
|
|
If IsNothing(JsonGenericParameter) Then Return
|
|
If Not StringToDouble(JsonGenericParameter.sValue, m_dValue) Then
|
|
EgtOutLog("Error reading DoubleStrategyParameter " & JsonGenericParameter.sValue)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonStrategyParameter
|
|
Dim JsonStrategyParameter As New JsonStrategyParameter(sName, sNameNge, sValue, "d", If(Not String.IsNullOrEmpty(sSubType), sSubType, ""), sMinUserLevel)
|
|
Return JsonStrategyParameter
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class StringStrategyParameter
|
|
Inherits StrategyParameter
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_sValue As String = String.Empty
|
|
Public Property sValue As String
|
|
Get
|
|
Return m_sValue
|
|
End Get
|
|
Set(value As String)
|
|
If m_sValue <> value Then
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
SetbIsStringModify(True)
|
|
End If
|
|
m_sValue = value
|
|
End Set
|
|
End Property
|
|
Friend Sub SetValue(dValue As String)
|
|
m_sValue = dValue
|
|
End Sub
|
|
|
|
Private m_bStringVisibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property bStringVisibility As Visibility
|
|
Get
|
|
Return m_bStringVisibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbStringVisibility(value As Boolean)
|
|
m_bStringVisibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(bStringVisibility))
|
|
End Sub
|
|
|
|
Private m_bIsStringModify As Boolean = False
|
|
Public ReadOnly Property bIsStringModify As Boolean
|
|
Get
|
|
Return m_bIsStringModify
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbIsStringModify(value As Boolean)
|
|
m_bIsStringModify = value
|
|
If m_bIsStringModify Then
|
|
If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then
|
|
Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SetbStrategy_Visibility(True)
|
|
ElseIf Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM) Then
|
|
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.SetbStrategy_Visibility(True)
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged(NameOf(bIsStringModify))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonGenericParameter As JsonDefaultStrategyParameter)
|
|
MyBase.New(JsonGenericParameter)
|
|
If IsNothing(JsonGenericParameter) Then Return
|
|
If Not StringToDouble(JsonGenericParameter.sValue, m_sValue) Then
|
|
EgtOutLog("Error reading StringStrategyParameter " & JsonGenericParameter.sValue)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonStrategyParameter
|
|
Dim JsonStrategyParameter As New JsonStrategyParameter(sName, sNameNge, sValue, "s", If(Not String.IsNullOrEmpty(sSubType), sSubType, ""), sMinUserLevel)
|
|
Return JsonStrategyParameter
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class ComboStrategyParameter
|
|
Inherits StrategyParameter
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_ComboList As New List(Of ComboParameter)
|
|
Public Property ComboList As List(Of ComboParameter)
|
|
Get
|
|
Return m_ComboList
|
|
End Get
|
|
Set(value As List(Of ComboParameter))
|
|
m_ComboList = value
|
|
End Set
|
|
End Property
|
|
|
|
' Seleziona elemento nella combobox Choices
|
|
Private m_SelValue As ComboParameter
|
|
Public Property SelValue As ComboParameter
|
|
Get
|
|
Return m_SelValue
|
|
End Get
|
|
Set(value As ComboParameter)
|
|
If Not IsNothing(value) AndAlso Not IsNothing(m_SelValue) Then
|
|
If m_SelValue.sValue <> value.sValue Then
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
SetbIsComboBoxModify(True)
|
|
End If
|
|
End If
|
|
m_SelValue = value
|
|
End Set
|
|
End Property
|
|
Friend Sub SetSelValue(sValue As String)
|
|
m_SelValue = m_ComboList.FirstOrDefault(Function(x) x.sValue = sValue)
|
|
End Sub
|
|
|
|
Private m_bComboBoxVisibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property bComboBoxVisibility As Visibility
|
|
Get
|
|
Return m_bComboBoxVisibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbComboBoxVisibility(value As Boolean)
|
|
m_bComboBoxVisibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(bComboBoxVisibility))
|
|
End Sub
|
|
|
|
Private m_bIsComboBoxModify As Boolean = False
|
|
Public ReadOnly Property bIsComboBoxModify As Boolean
|
|
Get
|
|
Return m_bIsComboBoxModify
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbIsComboBoxModify(value As Boolean)
|
|
m_bIsComboBoxModify = value
|
|
If m_bIsComboBoxModify Then
|
|
If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then
|
|
Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SetbStrategy_Visibility(True)
|
|
ElseIf Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM) Then
|
|
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.SetbStrategy_Visibility(True)
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged(NameOf(bIsComboBoxModify))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonGenericParameter As JsonDefaultStrategyParameter)
|
|
MyBase.New(JsonGenericParameter)
|
|
If IsNothing(JsonGenericParameter) Then Return
|
|
ComboList = JsonGenericParameter.Choices.Select(Function(jsonChoice) New ComboParameter(jsonChoice)).ToList()
|
|
m_SelValue = m_ComboList.FirstOrDefault(Function(x) x.sValue = JsonGenericParameter.sValue)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonStrategyParameter
|
|
Dim JsonStrategyParameter As New JsonStrategyParameter(sName, sNameNge, m_SelValue.sValue, "combo", If(Not String.IsNullOrEmpty(sSubType), sSubType, ""), sMinUserLevel)
|
|
Return JsonStrategyParameter
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class ListStrategyParameter
|
|
Inherits StrategyParameter
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_ListValue As New List(Of ToolParameter)
|
|
Public Property ListValue As List(Of ToolParameter)
|
|
Get
|
|
Return m_ListValue
|
|
End Get
|
|
Set(value As List(Of ToolParameter))
|
|
m_ListValue = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelValue As ToolParameter
|
|
Public Property SelValue As ToolParameter
|
|
Get
|
|
Return m_SelValue
|
|
End Get
|
|
Set(value As ToolParameter)
|
|
If Not IsNothing(value) AndAlso Not IsNothing(m_SelValue) Then
|
|
If m_SelValue.sUUID <> value.sUUID Then
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
SetbIsListModify(True)
|
|
End If
|
|
End If
|
|
m_SelValue = value
|
|
NotifyPropertyChanged(NameOf(SelValue))
|
|
End Set
|
|
End Property
|
|
Friend Sub SetSelValue(sValue As String)
|
|
Dim sTrimValue As String = sValue.TrimEnd(";"c)
|
|
Dim sTmpValue As String() = sTrimValue.Split(";"c)
|
|
Dim sSplitValue As String()
|
|
For Each ItemValue As String In sTmpValue
|
|
sSplitValue = ItemValue.Split(","c)
|
|
For Each ItemTool As ToolParameter In m_ListValue
|
|
If sSplitValue(0) = ItemTool.sUUID AndAlso sSplitValue(1) = ItemTool.sName Then
|
|
ItemTool.bIsActive = True
|
|
End If
|
|
Next
|
|
Next
|
|
End Sub
|
|
|
|
Private m_AvailableToolList_View As ICollectionView = Nothing
|
|
Public ReadOnly Property AvailableToolList_View As ICollectionView
|
|
Get
|
|
Return m_AvailableToolList_View
|
|
End Get
|
|
End Property
|
|
|
|
Private m_ActiveToolList_View As ICollectionView = Nothing
|
|
Public ReadOnly Property ActiveToolList_View As ICollectionView
|
|
Get
|
|
Return m_ActiveToolList_View
|
|
End Get
|
|
End Property
|
|
|
|
Private m_bAvailableToolListVisibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property AvailableToolListVisibility As Visibility
|
|
Get
|
|
Return m_bAvailableToolListVisibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetAvailableToolListVisibility(value As Boolean)
|
|
m_bAvailableToolListVisibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(AvailableToolListVisibility))
|
|
End Sub
|
|
|
|
Private m_bOpenToolListIsEnable As Boolean = True
|
|
Public ReadOnly Property OpenToolListIsEnable As Boolean
|
|
Get
|
|
Return m_bOpenToolListIsEnable
|
|
End Get
|
|
End Property
|
|
Friend Sub SetOpenToolListIsEnable(value As Boolean)
|
|
m_bOpenToolListIsEnable = value
|
|
NotifyPropertyChanged(NameOf(OpenToolListIsEnable))
|
|
End Sub
|
|
|
|
Private m_bActiveToolListIsEnable As Boolean
|
|
Public ReadOnly Property ActiveToolListIsEnable As Boolean
|
|
Get
|
|
Return m_bActiveToolListIsEnable
|
|
End Get
|
|
End Property
|
|
Friend Sub SetActiveToolListIsEnable(value As Boolean)
|
|
m_bActiveToolListIsEnable = value
|
|
NotifyPropertyChanged(NameOf(ActiveToolListIsEnable))
|
|
End Sub
|
|
|
|
Private m_bAvailableToolListIsEnable As Boolean
|
|
Public ReadOnly Property AvailableToolListIsEnable As Boolean
|
|
Get
|
|
Return m_bAvailableToolListIsEnable
|
|
End Get
|
|
End Property
|
|
Friend Sub SetAvailableToolListIsEnable(value As Boolean)
|
|
m_bAvailableToolListIsEnable = value
|
|
NotifyPropertyChanged(NameOf(AvailableToolListIsEnable))
|
|
End Sub
|
|
|
|
Private m_bListBoxVisibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property bListBoxVisibility As Visibility
|
|
Get
|
|
Return m_bListBoxVisibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbListBoxVisibility(value As Boolean)
|
|
m_bListBoxVisibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(bListBoxVisibility))
|
|
End Sub
|
|
|
|
Private m_bIsListModify As Boolean = False
|
|
Public ReadOnly Property bIsListModify As Boolean
|
|
Get
|
|
Return m_bIsListModify
|
|
End Get
|
|
End Property
|
|
Friend Sub SetbIsListModify(value As Boolean)
|
|
m_bIsListModify = value
|
|
If m_bIsListModify Then
|
|
If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then
|
|
Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SetbStrategy_Visibility(True)
|
|
ElseIf Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM) Then
|
|
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.SetbStrategy_Visibility(True)
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged(NameOf(bIsListModify))
|
|
End Sub
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property SelectAllToolTip As String
|
|
Get
|
|
Return EgtMsg(63034)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeselectAllToolTip As String
|
|
Get
|
|
Return EgtMsg(63035)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OpenToolListToolTip As String
|
|
Get
|
|
Return EgtMsg(63036)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CloseToolListToolTip As String
|
|
Get
|
|
Return EgtMsg(63037)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' Definizione comandi
|
|
Private m_cmdDeselectAll As ICommand
|
|
Private m_cmdSelectAll As ICommand
|
|
Private m_cmdOpenToolList As ICommand
|
|
Private m_cmdCloseToolList As ICommand
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(sSubType As String)
|
|
' Recupero lista utensili per sottotipo
|
|
Dim nSubType As Integer = 0
|
|
Dim nType As Integer = 0
|
|
Dim sName As String = String.Empty
|
|
Dim sUUID As String = String.Empty
|
|
Dim sInfo As String = String.Empty
|
|
|
|
StringToInt(sSubType, nSubType)
|
|
Dim bNext As Boolean = EgtTdbGetFirstTool(nSubType, sName, nType)
|
|
While bNext
|
|
EgtTdbSetCurrTool(sName)
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sUUID)
|
|
m_ListValue.Add(New ToolParameter(sUUID, sName, Me))
|
|
bNext = EgtTdbGetNextTool(nSubType, sName, nType)
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonStrategyParameter
|
|
Dim sInfo As String = String.Empty
|
|
If Not IsNothing(sSubType) Then
|
|
For Each ItemTool As ToolParameter In m_ListValue
|
|
If ItemTool.bIsActive Then
|
|
sInfo &= ItemTool.sUUID & "," & ItemTool.sName & ";"
|
|
End If
|
|
Next
|
|
End If
|
|
Dim JsonStrategyParameter As New JsonStrategyParameter(sName, sNameNge, sInfo, "tool", If(Not String.IsNullOrEmpty(sSubType), sSubType, ""), sMinUserLevel)
|
|
Return JsonStrategyParameter
|
|
End Function
|
|
|
|
Friend Function AvailableToolFilter(Strategy As Object) As Boolean
|
|
Return DirectCast(Strategy, ToolParameter).bIsActive = False
|
|
End Function
|
|
|
|
Friend Function ActiveToolFilter(Strategy As Object) As Boolean
|
|
Return DirectCast(Strategy, ToolParameter).bIsActive = True
|
|
End Function
|
|
|
|
Friend Sub CreateToolsViews()
|
|
m_AvailableToolList_View = New ListCollectionView(m_ListValue)
|
|
m_AvailableToolList_View.Filter = AddressOf AvailableToolFilter
|
|
m_ActiveToolList_View = New ListCollectionView(m_ListValue)
|
|
m_ActiveToolList_View.Filter = AddressOf ActiveToolFilter
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Funzione per visualizzare le liste available e active tool
|
|
''' </summary>
|
|
Friend Sub ToolView()
|
|
SetActiveToolListIsEnable(If(m_ActiveToolList_View.IsEmpty, False, True))
|
|
SetAvailableToolListIsEnable(If(m_AvailableToolList_View.IsEmpty, False, True))
|
|
End Sub
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "OpenToolListCommand"
|
|
|
|
Public ReadOnly Property OpenToolListCommand As ICommand
|
|
Get
|
|
If m_cmdOpenToolList Is Nothing Then
|
|
m_cmdOpenToolList = New Command(AddressOf OpenToolList)
|
|
End If
|
|
Return m_cmdOpenToolList
|
|
End Get
|
|
End Property
|
|
|
|
Friend Sub OpenToolList()
|
|
SetAvailableToolListVisibility(True)
|
|
SetOpenToolListIsEnable(False)
|
|
End Sub
|
|
|
|
#End Region ' OpenToolListCommand
|
|
|
|
#Region "CloseToolListCommand"
|
|
|
|
Public ReadOnly Property CloseToolListCommand As ICommand
|
|
Get
|
|
If m_cmdCloseToolList Is Nothing Then
|
|
m_cmdCloseToolList = New Command(AddressOf CloseToolList)
|
|
End If
|
|
Return m_cmdCloseToolList
|
|
End Get
|
|
End Property
|
|
|
|
Friend Sub CloseToolList()
|
|
SetAvailableToolListVisibility(True)
|
|
SetOpenToolListIsEnable(True)
|
|
End Sub
|
|
|
|
#End Region ' CloseToolListCommand
|
|
|
|
#Region "SelectAllCommand"
|
|
|
|
Public ReadOnly Property SelectAllCommand As ICommand
|
|
Get
|
|
If m_cmdSelectAll Is Nothing Then
|
|
m_cmdSelectAll = New Command(AddressOf SelectAll)
|
|
End If
|
|
Return m_cmdSelectAll
|
|
End Get
|
|
End Property
|
|
|
|
Friend Sub SelectAll()
|
|
If Not IsNothing(sSubType) Then
|
|
For Each ItemTool As ToolParameter In m_ListValue
|
|
ItemTool.bIsActive = True
|
|
Next
|
|
End If
|
|
SetAvailableToolListIsEnable(False)
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
End Sub
|
|
|
|
#End Region ' SelectAllCommand
|
|
|
|
#Region "DeselectAllCommand"
|
|
|
|
Public ReadOnly Property DeselectAllCommand As ICommand
|
|
Get
|
|
If m_cmdDeselectAll Is Nothing Then
|
|
m_cmdDeselectAll = New Command(AddressOf DeselectAll)
|
|
End If
|
|
Return m_cmdDeselectAll
|
|
End Get
|
|
End Property
|
|
|
|
Friend Sub DeselectAll()
|
|
If Not IsNothing(sSubType) Then
|
|
For Each ItemTool As ToolParameter In m_ListValue
|
|
ItemTool.bIsActive = False
|
|
Next
|
|
End If
|
|
SetActiveToolListIsEnable(False)
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
End Sub
|
|
|
|
#End Region ' DeselectAllCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|
|
|
|
'----------- Classe che fa riferimento ai parametri delle Scelte -----------
|
|
Public Class ComboParameter
|
|
Inherits VMBase
|
|
|
|
#Region "FIELD & PROPERTIES"
|
|
|
|
Private m_sValue As String
|
|
Public Property sValue As String
|
|
Get
|
|
Return m_sValue
|
|
End Get
|
|
Set(value As String)
|
|
m_sValue = value
|
|
NotifyPropertyChanged(NameOf(sValue))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sDescriptionShort As String
|
|
Public Property sDescriptionShort As String
|
|
Get
|
|
Return m_sDescriptionShort
|
|
End Get
|
|
Set(value As String)
|
|
m_sDescriptionShort = value
|
|
NotifyPropertyChanged(NameOf(sDescriptionShort))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sDescriptionLong As String
|
|
Public Property sDescriptionLong As String
|
|
Get
|
|
Return m_sDescriptionLong
|
|
End Get
|
|
Set(value As String)
|
|
m_sDescriptionLong = value
|
|
NotifyPropertyChanged(NameOf(sDescriptionLong))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sMessageId As String
|
|
Public Property sMessageId As String
|
|
Get
|
|
Return m_sMessageId
|
|
End Get
|
|
Set(value As String)
|
|
m_sMessageId = value
|
|
NotifyPropertyChanged(NameOf(sMessageId))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonChoiceParameter As JsonDefaultComboParameter)
|
|
If Not IsNothing(JsonChoiceParameter) Then
|
|
m_sValue = JsonChoiceParameter.sValue
|
|
m_sDescriptionShort = JsonChoiceParameter.sDescriptionShort
|
|
m_sDescriptionLong = JsonChoiceParameter.sDescriptionLong
|
|
m_sMessageId = JsonChoiceParameter.sMessageId
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
End Class
|
|
|
|
Public Class ToolParameter
|
|
Inherits VMBase
|
|
|
|
#Region "FIELD & PROPERTIES"
|
|
|
|
Private m_ParentList As ListStrategyParameter
|
|
|
|
Private m_bIsActive As Boolean
|
|
Public Property bIsActive As Boolean
|
|
Get
|
|
Return m_bIsActive
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bIsActive = value
|
|
If Not IsNothing(m_ParentList.AvailableToolList_View) AndAlso Not IsNothing(m_ParentList.ActiveToolList_View) Then
|
|
m_ParentList.AvailableToolList_View.Refresh()
|
|
m_ParentList.ActiveToolList_View.Refresh()
|
|
m_ParentList.SetActiveToolListIsEnable(True)
|
|
m_ParentList.SetAvailableToolListIsEnable(True)
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
End If
|
|
NotifyPropertyChanged(NameOf(bIsActive))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sName As String
|
|
Public Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
NotifyPropertyChanged(NameOf(sName))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_sUUID As String
|
|
Public Property sUUID As String
|
|
Get
|
|
Return m_sUUID
|
|
End Get
|
|
Set(value As String)
|
|
m_sUUID = value
|
|
NotifyPropertyChanged(NameOf(sUUID))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(sUUID As String, sName As String, ParentList As ListStrategyParameter)
|
|
m_sUUID = sUUID
|
|
m_sName = sName
|
|
m_ParentList = ParentList
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
End Class
|
|
|
|
Public Class StrategyTypeToFocusableConverter
|
|
Implements IValueConverter
|
|
|
|
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
|
|
If TypeOf value IsNot TreeViewItem Then Return True
|
|
Select Case DirectCast(value, TreeViewItem).DataContext.GetType()
|
|
Case GetType(Topology)
|
|
Return True
|
|
Case Else ' GetType(StrategyFeature)
|
|
Return False
|
|
End Select
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Throw New NotImplementedException()
|
|
End Function
|
|
|
|
End Class |