8dd1e8e4b7
-sistemato singolo assemblato
1062 lines
31 KiB
VB.net
1062 lines
31 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.Globalization
|
|
Imports System.IO
|
|
Imports System.Reflection
|
|
Imports System.Windows.Forms
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtBEAMWALL.Optimizer.MainMenuVM
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports Newtonsoft.Json
|
|
|
|
Public Class GeneralParametersStrategyVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Evento per chiusura finestra
|
|
Public Event m_CloseWindow(bDialogResult As Boolean)
|
|
|
|
Private m_GeneralParametersList As New ObservableCollection(Of ProjectParameters)
|
|
Public Property GeneralParametersList As ObservableCollection(Of ProjectParameters)
|
|
Get
|
|
Return m_GeneralParametersList
|
|
End Get
|
|
Set(value As ObservableCollection(Of ProjectParameters))
|
|
m_GeneralParametersList = value
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione Comandi
|
|
Private m_cmdOk_Command As ICommand
|
|
Private m_cmdCloseCommand As ICommand
|
|
|
|
#Region "Messages"
|
|
|
|
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
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
Map.SetRefGeneralParametersStrategyVM(Me)
|
|
Read()
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub Read()
|
|
Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath(Map.refStrategyManagerVM.SelStrategyType.Id)
|
|
Dim sGeneralParametersFilePath As String = sStrategiesDirPath & "\" & GENERALPARAMETERS_FILE & ".json"
|
|
If File.Exists(sGeneralParametersFilePath) Then
|
|
Dim sReadedFiles As String = File.ReadAllText(sGeneralParametersFilePath)
|
|
Dim JsonGeneralParametersList As List(Of JsonGeneralParameters) = JsonConvert.DeserializeObject(Of List(Of JsonGeneralParameters))(sReadedFiles)
|
|
m_GeneralParametersList = New ObservableCollection(Of ProjectParameters)((From JsonGeneralParameter In JsonGeneralParametersList
|
|
Select JsonGeneralParameter.Deserialize(Map.refStrategyManagerVM.SelStrategyType.Id)).ToList())
|
|
|
|
For Each GenericItem As ProjectParameters In m_GeneralParametersList
|
|
Select Case GenericItem.sMinUserLevel
|
|
Case UserLevel.ADVANCED
|
|
Map.refMainMenuVM.UserLevelGenericVisibility(GenericItem, If(Map.refMainMenuVM.UserAdmin_IsChecked, Visibility.Visible, Visibility.Collapsed))
|
|
Case Else
|
|
If Not Map.refMainMenuVM.UserAdmin_IsChecked Then
|
|
Map.refMainMenuVM.UserLevelGenericVisibility(GenericItem, If(GenericItem.sMinUserLevel = UserLevel.USER, Visibility.Visible, Visibility.Collapsed))
|
|
Map.refMainMenuVM.SetUnloackImage("pack://application:,,,/Resources/NewPage/padlock.png")
|
|
End If
|
|
End Select
|
|
Next
|
|
NotifyPropertyChanged(NameOf(GeneralParametersList))
|
|
End If
|
|
|
|
Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(Map.refStrategyManagerVM.SelStrategyType.Id, False)
|
|
|
|
Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & Map.refStrategyManagerVM.SelStrategySetup.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
|
|
Return
|
|
End Try
|
|
|
|
For Each ProjectItem In JsonRoot.GENERAL
|
|
Dim DefaultProject As ProjectParameters = m_GeneralParametersList.FirstOrDefault(Function(x) x.sName = ProjectItem.sName)
|
|
DefaultProject.ReadConfiguration(ProjectItem)
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Ok_Command"
|
|
|
|
Public ReadOnly Property Ok_Command As ICommand
|
|
Get
|
|
If m_cmdOk_Command Is Nothing Then
|
|
m_cmdOk_Command = New Command(AddressOf Ok)
|
|
End If
|
|
Return m_cmdOk_Command
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Ok()
|
|
For Each ProjectItem As ProjectParameters In m_GeneralParametersList
|
|
Select Case ProjectItem.GetType()
|
|
Case GetType(BooleanGenericParameter)
|
|
ProjectItem.sValue = If(DirectCast(ProjectItem, BooleanGenericParameter).bValue, "true", "false")
|
|
Case GetType(DoubleGenericParameter)
|
|
ProjectItem.sValue = DirectCast(ProjectItem, DoubleGenericParameter).sValue
|
|
Case GetType(ComboGenericParameter)
|
|
ProjectItem.sValue = DirectCast(ProjectItem, ComboGenericParameter).SelValue.sValue
|
|
Case GetType(StringGenericParameter)
|
|
ProjectItem.sValue = DirectCast(ProjectItem, StringGenericParameter).sValue
|
|
Case GetType(ListGenericParameter)
|
|
ProjectItem.sValue = DirectCast(ProjectItem, ListGenericParameter).SelValue.sName
|
|
End Select
|
|
Next
|
|
Map.refStrategyManagerVM.Save()
|
|
' Chiudo finestra
|
|
RaiseEvent m_CloseWindow(DialogResult.OK)
|
|
End Sub
|
|
|
|
#End Region ' Ok_Command
|
|
|
|
#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
|
|
|
|
Public Class ParametersProject
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
Private m_nGroup As String
|
|
Public Property nGroup As String
|
|
Get
|
|
Return m_nGroup
|
|
End Get
|
|
Set(value As String)
|
|
m_nGroup = value
|
|
NotifyPropertyChanged(NameOf(nGroup))
|
|
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_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_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_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_sType As String
|
|
Public Property sType As String
|
|
Get
|
|
Return m_sType
|
|
End Get
|
|
Set(value As String)
|
|
m_sType = value
|
|
NotifyPropertyChanged(NameOf(sType))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Choices As New ObservableCollection(Of JsonDefaultComboParameter)
|
|
Public Property Choices As ObservableCollection(Of JsonDefaultComboParameter)
|
|
Get
|
|
Return m_Choices
|
|
End Get
|
|
Set(value As ObservableCollection(Of JsonDefaultComboParameter))
|
|
m_Choices = value
|
|
NotifyPropertyChanged(NameOf(Choices))
|
|
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(JsonProjectParameters As JsonProjectParameters)
|
|
If IsNothing(JsonProjectParameters) Then Return
|
|
m_sName = JsonProjectParameters.sName
|
|
m_sNameNge = JsonProjectParameters.sNameNge
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function Serialize() As JsonParameters
|
|
Dim JsonParameters As New JsonParameters(m_sName, m_sNameNge, m_sValue)
|
|
Return JsonParameters
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public MustInherit Class ProjectParameters
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPETIES"
|
|
|
|
Private m_nGroup As String
|
|
Public Property nGroup As String
|
|
Get
|
|
Return m_nGroup
|
|
End Get
|
|
Set(value As String)
|
|
m_nGroup = value
|
|
NotifyPropertyChanged(NameOf(nGroup))
|
|
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_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_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_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_sType As String
|
|
Public Property sType As String
|
|
Get
|
|
Return m_sType
|
|
End Get
|
|
Set(value As String)
|
|
m_sType = value
|
|
NotifyPropertyChanged(NameOf(sType))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Choices As New ObservableCollection(Of JsonDefaultComboParameter)
|
|
Public Property Choices As ObservableCollection(Of JsonDefaultComboParameter)
|
|
Get
|
|
Return m_Choices
|
|
End Get
|
|
Set(value As ObservableCollection(Of JsonDefaultComboParameter))
|
|
m_Choices = value
|
|
NotifyPropertyChanged(NameOf(Choices))
|
|
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(JsonProjectParameters As JsonProjectParameters)
|
|
If IsNothing(JsonProjectParameters) Then Return
|
|
m_sName = JsonProjectParameters.sName
|
|
m_sNameNge = JsonProjectParameters.sNameNge
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend MustOverride Function Serialize() As JsonParametersHelper
|
|
|
|
Friend Sub ReadConfiguration(ProjectParameters As JsonParameters)
|
|
Dim DefaultProject As ProjectParameters = Map.refGeneralParametersStrategyVM.GeneralParametersList.FirstOrDefault(Function(x) x.sName = ProjectParameters.sName)
|
|
If IsNothing(DefaultProject) Then
|
|
' verifico indici!!
|
|
Else
|
|
Select Case DefaultProject.GetType()
|
|
Case GetType(BooleanGenericParameter)
|
|
DirectCast(DefaultProject, BooleanGenericParameter).SetValue(ProjectParameters.sValue)
|
|
If m_sMinUserLevel = 1 Then
|
|
DirectCast(DefaultProject, BooleanGenericParameter).SetbBooleanVisibility(Visibility.Visible)
|
|
End If
|
|
Case GetType(DoubleGenericParameter)
|
|
DirectCast(DefaultProject, DoubleGenericParameter).SetValue(ProjectParameters.sValue)
|
|
If m_sMinUserLevel = 1 Then
|
|
DirectCast(DefaultProject, DoubleGenericParameter).SetbDoubleVisibility(Visibility.Visible)
|
|
End If
|
|
Case GetType(ComboGenericParameter)
|
|
DirectCast(DefaultProject, ComboGenericParameter).SetSelValue(ProjectParameters.sValue)
|
|
If m_sMinUserLevel = 1 Then
|
|
DirectCast(DefaultProject, ComboGenericParameter).SetbComboBoxVisibility(Visibility.Visible)
|
|
End If
|
|
Case GetType(StringGenericParameter)
|
|
DirectCast(DefaultProject, StringGenericParameter).SetValue(ProjectParameters.sValue)
|
|
If m_sMinUserLevel = 1 Then
|
|
DirectCast(DefaultProject, StringGenericParameter).SetbStringVisibility(Visibility.Visible)
|
|
End If
|
|
Case GetType(ListGenericParameter)
|
|
DirectCast(DefaultProject, ListGenericParameter).SetSelValue(ProjectParameters.sValue)
|
|
DirectCast(DefaultProject, ListGenericParameter).CreateToolsViews()
|
|
DirectCast(DefaultProject, ListGenericParameter).ToolView()
|
|
If DefaultProject.sMinUserLevel = 1 Then
|
|
DirectCast(DefaultProject, ListGenericParameter).SetbListBoxVisibility(Visibility.Visible)
|
|
End If
|
|
End Select
|
|
End If
|
|
End Sub
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class BooleanGenericParameter
|
|
Inherits ProjectParameters
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend m_bValue As Boolean = False
|
|
Public Property bValue As Boolean
|
|
Get
|
|
Return m_bValue
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bValue = value
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
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 Visibility)
|
|
m_bBooleanVisibility = value
|
|
NotifyPropertyChanged(NameOf(bBooleanVisibility))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonProjectParameters As JsonProjectParameters)
|
|
MyBase.New(JsonProjectParameters)
|
|
If IsNothing(JsonProjectParameters) Then Return
|
|
m_bValue = JsonProjectParameters.sValue.ToLower() = "true"
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonParametersHelper
|
|
Dim sValue As String = "false"
|
|
If bValue Then
|
|
sValue = "true"
|
|
End If
|
|
Dim JsonParametersHelper As New JsonParametersHelper(sName, sNameNge, sValue, "b")
|
|
Return JsonParametersHelper
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class DoubleGenericParameter
|
|
Inherits ProjectParameters
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_dValue As Double? = Nothing
|
|
Public Overloads 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
|
|
m_dValue = dValue
|
|
Else
|
|
NotifyPropertyChanged(NameOf(sValue))
|
|
End If
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
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 Visibility)
|
|
m_bDoubleVisibility = value
|
|
NotifyPropertyChanged(NameOf(bDoubleVisibility))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonProjectParameters As JsonProjectParameters)
|
|
MyBase.New(JsonProjectParameters)
|
|
If IsNothing(JsonProjectParameters) Then Return
|
|
If Not StringToDouble(JsonProjectParameters.sValue, m_dValue) Then
|
|
EgtOutLog("Error reading DoubleStrategyParameter " & JsonProjectParameters.sValue)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonParametersHelper
|
|
Dim JsonParametersHelper As New JsonParametersHelper(sName, sNameNge, sValue, "d")
|
|
Return JsonParametersHelper
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class StringGenericParameter
|
|
Inherits ProjectParameters
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_sValue As String = String.Empty
|
|
Public Overloads Property sValue As String
|
|
Get
|
|
Return m_sValue
|
|
End Get
|
|
Set(value As String)
|
|
m_sValue = Nothing
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
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 Visibility)
|
|
m_bStringVisibility = value
|
|
NotifyPropertyChanged(NameOf(bStringVisibility))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonProjectParameters As JsonProjectParameters)
|
|
MyBase.New(JsonProjectParameters)
|
|
If IsNothing(JsonProjectParameters) Then Return
|
|
If Not StringToDouble(JsonProjectParameters.sValue, m_sValue) Then
|
|
EgtOutLog("Error reading StringStrategyParameter " & JsonProjectParameters.sValue)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonParametersHelper
|
|
Dim JsonParametersHelper As New JsonParametersHelper(sName, sNameNge, sValue, "s")
|
|
Return JsonParametersHelper
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class ComboGenericParameter
|
|
Inherits ProjectParameters
|
|
|
|
#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)
|
|
m_SelValue = value
|
|
Map.refStrategyManagerVM.SetbIsModifyStrategy(True)
|
|
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 Visibility)
|
|
m_bComboBoxVisibility = value
|
|
NotifyPropertyChanged(NameOf(bComboBoxVisibility))
|
|
End Sub
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
|
|
End Sub
|
|
|
|
Sub New(JsonProjectParameters As JsonProjectParameters)
|
|
MyBase.New(JsonProjectParameters)
|
|
If IsNothing(JsonProjectParameters) Then Return
|
|
ComboList = JsonProjectParameters.Choices.Select(Function(jsonChoice) New ComboParameter(jsonChoice)).ToList()
|
|
'm_SelValue = m_ComboList.FirstOrDefault(Function(x) x.sValue = JsonProjectParameters.sValue)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Overrides Function Serialize() As JsonParametersHelper
|
|
Dim JsonParametersHelper As New JsonParametersHelper(sName, sNameNge, m_SelValue.sValue, "combo")
|
|
Return JsonParametersHelper
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class ListGenericParameter
|
|
Inherits ProjectParameters
|
|
|
|
#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)
|
|
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 Visibility)
|
|
m_bAvailableToolListVisibility = value
|
|
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 Visibility)
|
|
m_bListBoxVisibility = value
|
|
NotifyPropertyChanged(NameOf(bListBoxVisibility))
|
|
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 JsonParametersHelper
|
|
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 JsonParametersHelper As New JsonParametersHelper(sName, sNameNge, sInfo, "tool")
|
|
Return JsonParametersHelper
|
|
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()
|
|
If m_ActiveToolList_View.IsEmpty Then
|
|
SetActiveToolListIsEnable(False)
|
|
Else
|
|
SetActiveToolListIsEnable(True)
|
|
End If
|
|
If m_AvailableToolList_View.IsEmpty Then
|
|
SetAvailableToolListIsEnable(False)
|
|
Else
|
|
SetAvailableToolListIsEnable(True)
|
|
End If
|
|
|
|
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(Visibility.Visible)
|
|
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(Visibility.Collapsed)
|
|
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
|
|
|
|
Class GroupVisibilityConverter
|
|
Implements IMultiValueConverter
|
|
|
|
Public Function Convert(values() As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IMultiValueConverter.Convert
|
|
Dim items = TryCast(values(0), ReadOnlyObservableCollection(Of Object))
|
|
|
|
If IsNothing(items) OrElse items.Count = 0 Then
|
|
Return Visibility.Collapsed
|
|
End If
|
|
|
|
For Each item In items
|
|
Dim prop As PropertyInfo = item.GetType().GetProperty("sMinUserLevel")
|
|
If Not IsNothing(prop) Then
|
|
Dim levelObj = prop.GetValue(item)
|
|
Dim level As Integer
|
|
If Not IsNothing(levelObj) AndAlso Integer.TryParse(levelObj.ToString(), level) AndAlso level <> 5 Then
|
|
Return Visibility.Visible
|
|
ElseIf Map.refMainMenuVM.UserAdmin_IsChecked Then
|
|
Return Visibility.Visible
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
Return Visibility.Collapsed
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetTypes() As Type, parameter As Object, culture As CultureInfo) As Object() Implements IMultiValueConverter.ConvertBack
|
|
Throw New NotImplementedException()
|
|
End Function
|
|
End Class |