-creato strategymanagerVm
-sistemato codice
This commit is contained in:
@@ -5,7 +5,6 @@ Imports EgtWPFLib5
|
||||
Imports EgtBEAMWALL.Core
|
||||
Imports MS.Internal
|
||||
Imports Ionic.Zip
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Public Class ConfigurationPageVM
|
||||
Inherits VMBase
|
||||
@@ -356,56 +355,6 @@ Public Class ConfigurationPageVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_AvailableStrategyList As New ObservableCollection(Of AvailableStrategy)
|
||||
Public Property AvailableStrategyList As ObservableCollection(Of AvailableStrategy)
|
||||
Get
|
||||
Return m_AvailableStrategyList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of AvailableStrategy))
|
||||
m_AvailableStrategyList = value
|
||||
NotifyPropertyChanged(NameOf(AvailableStrategyList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
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
|
||||
Friend Sub UpdateSelTreeItem(Item As Topology)
|
||||
m_SelTreeItem = Item
|
||||
NotifyPropertyChanged(NameOf(SelTreeItem))
|
||||
End Sub
|
||||
|
||||
Public m_SelectedStrategy As Strategy
|
||||
Public Property SelectedStrategy As Strategy
|
||||
Get
|
||||
Return m_SelectedStrategy
|
||||
End Get
|
||||
Set(value As Strategy)
|
||||
m_SelectedStrategy = value
|
||||
ReadConfigurationStrategyJson(m_SelectedStrategy.sStrategyID)
|
||||
NotifyPropertyChanged(NameOf(SelectedStrategy))
|
||||
NotifyPropertyChanged(NameOf(StrategyConfigurationList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_StrategyConfigurationList As New ObservableCollection(Of StrategyConfiguration)
|
||||
Public Property StrategyConfigurationList As ObservableCollection(Of StrategyConfiguration)
|
||||
Get
|
||||
Return m_StrategyConfigurationList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of StrategyConfiguration))
|
||||
m_StrategyConfigurationList = value
|
||||
NotifyPropertyChanged(NameOf(StrategyConfigurationList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Definizione comandi
|
||||
Private m_cmdSave As ICommand
|
||||
Private m_cmdChooseExternalBackupFolderPath As ICommand
|
||||
@@ -703,10 +652,10 @@ Public Class ConfigurationPageVM
|
||||
' Setto la datagrid non visibile
|
||||
SetProgramVersionListVisibility(Visibility.Hidden)
|
||||
NotifyPropertyChanged(NameOf(bExternalBackupActive))
|
||||
' Leggo file json strategie
|
||||
ReadAvailableStrategyJson()
|
||||
'' Leggo file json strategie
|
||||
'ReadAvailableStrategyJson()
|
||||
|
||||
Topology.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem
|
||||
'Topology.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructor
|
||||
@@ -966,34 +915,6 @@ Public Class ConfigurationPageVM
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub ReadAvailableStrategyJson()
|
||||
Dim percorsoFile As String = Map.refMainWindowVM.MainWindowM.sBeamNewRoot & "\Strategies\AvailableStrategyList.json"
|
||||
|
||||
' Leggi il contenuto del file JSON
|
||||
Dim contenutoJson As String = File.ReadAllText(percorsoFile)
|
||||
|
||||
' Deserializza il JSON in un oggetto
|
||||
m_AvailableStrategyList = JsonConvert.DeserializeObject(Of ObservableCollection(Of AvailableStrategy))(contenutoJson)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadConfigurationStrategyJson(SelectedStrategyID As String)
|
||||
Dim percorsoFile As String = Map.refMainWindowVM.MainWindowM.sBeamNewRoot & "\Strategies\Standard\" & SelectedStrategyID & "\" & SelectedStrategyID & ".json"
|
||||
|
||||
' Leggi il contenuto del file JSON
|
||||
Dim contenutoJson As String = File.ReadAllText(percorsoFile)
|
||||
|
||||
If contenutoJson.StartsWith("{"c) Then
|
||||
contenutoJson = "[" & contenutoJson
|
||||
End If
|
||||
|
||||
If contenutoJson.EndsWith("}"c) Then
|
||||
contenutoJson &= "]"
|
||||
End If
|
||||
|
||||
' Deserializza il JSON in un oggetto
|
||||
m_StrategyConfigurationList = JsonConvert.DeserializeObject(Of ObservableCollection(Of StrategyConfiguration))(contenutoJson)
|
||||
End Sub
|
||||
|
||||
#End Region ' Methods
|
||||
|
||||
#Region "COMMANDS"
|
||||
@@ -1590,252 +1511,6 @@ Public Class MachTable
|
||||
|
||||
End Class
|
||||
|
||||
Public Class AvailableStrategy
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
#End Region ' Fields & Propeties
|
||||
|
||||
End Class
|
||||
|
||||
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_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_bIsSelected As Boolean
|
||||
Public Property IsSelected As Boolean
|
||||
Get
|
||||
Return m_bIsSelected
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bIsSelected = value
|
||||
refUpdateSelTreeItem(Me)
|
||||
NotifyPropertyChanged(NameOf(IsSelected))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region ' Fields & Propeties
|
||||
|
||||
End Class
|
||||
|
||||
Public Class Strategy
|
||||
Inherits VMBase
|
||||
|
||||
#Region "FIELDS & PROPETIES"
|
||||
|
||||
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
|
||||
|
||||
#End Region ' Fields & Propeties
|
||||
|
||||
End Class
|
||||
|
||||
Public Class StrategyConfiguration
|
||||
Inherits VMBase
|
||||
|
||||
#Region "FIELDS & PROPETIES"
|
||||
|
||||
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_ParameterList As New ObservableCollection(Of GenericParameter)
|
||||
Public Property ParameterList As ObservableCollection(Of GenericParameter)
|
||||
Get
|
||||
Return m_ParameterList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of GenericParameter))
|
||||
m_ParameterList = value
|
||||
NotifyPropertyChanged(NameOf(ParameterList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region ' Fields & Propeties
|
||||
|
||||
End Class
|
||||
|
||||
Public Class GenericParameter
|
||||
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_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_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_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
|
||||
|
||||
End Class
|
||||
|
||||
' Tipo parametro nel file di configurazione Macchina
|
||||
Public Enum MachParamType As Integer
|
||||
DOUBLE_ = 1
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<TabItem.Content>
|
||||
<EgtBEAMWALL:StrategyManagerV/>
|
||||
<EgtBEAMWALL:StrategyManagerV DataContext="{StaticResource StrategyManagerVM}"/>
|
||||
</TabItem.Content>
|
||||
</TabItem>
|
||||
<TabItem>
|
||||
|
||||
@@ -211,9 +211,10 @@
|
||||
<Compile Include="StatusBar\StatusBarV.xaml.vb">
|
||||
<DependentUpon>StatusBarV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Strategy\StrategyManagerV.xaml.vb">
|
||||
<Compile Include="StrategyManager\StrategyManagerV.xaml.vb">
|
||||
<DependentUpon>StrategyManagerV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="StrategyManager\StrategyManagerVM.vb" />
|
||||
<Compile Include="SupervisorCommThread\SupervisorComm.vb" />
|
||||
<Compile Include="SupervisorCommThread\SupervisorCommThread.vb" />
|
||||
<Compile Include="ToolsDbWindow\MyToolDbWindowVM.vb" />
|
||||
@@ -674,7 +675,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Strategy\StrategyManagerV.xaml">
|
||||
<Page Include="StrategyManager\StrategyManagerV.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
||||
+19
-23
@@ -2,7 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Optmizer="clr-namespace:EgtBEAMWALL.Optimizer">
|
||||
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -54,7 +54,7 @@
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
Style="{StaticResource NewAddFeature_ListBox}">
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type Optmizer:Strategy}">
|
||||
<DataTemplate DataType="{x:Type Optmizer:StrategyConfiguration}">
|
||||
<TextBlock Text="{Binding sStrategyID}"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</DataTemplate>
|
||||
@@ -64,45 +64,41 @@
|
||||
<StackPanel Grid.Column="1"
|
||||
Orientation="Vertical"
|
||||
Background="White"
|
||||
Width="100">
|
||||
<Button Content="→"/>
|
||||
<Button Content="←"/>
|
||||
Width="100"
|
||||
VerticalAlignment="Center">
|
||||
<Button Content="→"
|
||||
Command="{Binding AddSelectedStrategyCommand}"/>
|
||||
<Button Content="←"
|
||||
Command="{Binding RemoveSelectedStrategyCommand}"/>
|
||||
</StackPanel>
|
||||
|
||||
<ListBox Grid.Column="2"
|
||||
ItemsSource="{Binding SelTreeItem.StrategyList, Mode=TwoWay}"
|
||||
SelectedItem="{Binding SelectedStrategy, Mode=TwoWay}"
|
||||
ItemsSource="{Binding ActiveStrategyList, Mode=TwoWay}"
|
||||
SelectedItem="{Binding SelectedActiveStrategy, Mode=TwoWay}"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
Style="{StaticResource NewAddFeature_ListBox}">
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type Optmizer:Strategy}">
|
||||
<DataTemplate DataType="{x:Type Optmizer:StrategyConfiguration}">
|
||||
<TextBlock Text="{Binding sStrategyID}"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
</ListBox>
|
||||
|
||||
</Grid>
|
||||
|
||||
<ItemsControl Grid.Column="2" Foreground="Black"
|
||||
Width="900"
|
||||
ItemsSource="{Binding StrategyConfigurationList, Mode=TwoWay}">
|
||||
ItemsSource="{Binding SelectedStrategy.ParameterList}">
|
||||
<ItemsControl.Resources>
|
||||
<DataTemplate DataType="{x:Type Optmizer:StrategyConfiguration}">
|
||||
<ItemsControl ItemsSource="{Binding ParameterList}">
|
||||
<ItemsControl.Resources>
|
||||
<DataTemplate DataType="{x:Type Optmizer:GenericParameter}">
|
||||
<UniformGrid Columns="2">
|
||||
<TextBlock Text="{Binding sName}" HorizontalAlignment="Left"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
<TextBox Text="{Binding sValue}"
|
||||
Style="{StaticResource ColorPicker_TextBox}"/>
|
||||
</UniformGrid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.Resources>
|
||||
</ItemsControl>
|
||||
<DataTemplate DataType="{x:Type Optmizer:GenericParameter}">
|
||||
<UniformGrid Columns="2">
|
||||
<TextBlock Text="{Binding sName}" HorizontalAlignment="Left"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
<TextBox Text="{Binding sValue}"
|
||||
Style="{StaticResource ColorPicker_TextBox}"/>
|
||||
</UniformGrid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.Resources>
|
||||
</ItemsControl>
|
||||
@@ -0,0 +1,459 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports EgtWPFLib5
|
||||
Imports Newtonsoft.Json
|
||||
Imports System.IO
|
||||
|
||||
Public Class StrategyManagerVM
|
||||
Inherits VMBase
|
||||
|
||||
#Region "FIELDS & PROPERTIES"
|
||||
|
||||
Private m_AvailableStrategyList As New ObservableCollection(Of AvailableStrategy)
|
||||
Public Property AvailableStrategyList As ObservableCollection(Of AvailableStrategy)
|
||||
Get
|
||||
Return m_AvailableStrategyList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of AvailableStrategy))
|
||||
m_AvailableStrategyList = value
|
||||
NotifyPropertyChanged(NameOf(AvailableStrategyList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
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
|
||||
Friend Sub UpdateSelTreeItem(Item As Topology)
|
||||
m_SelTreeItem = Item
|
||||
Dim bStrategyList As StrategyConfiguration = m_SelTreeItem.StrategyList.FirstOrDefault(Function(x) x.bActive = True)
|
||||
m_ActiveStrategyList.Add(bStrategyList)
|
||||
'm_ActiveStrategyList.Clear()
|
||||
NotifyPropertyChanged(NameOf(SelTreeItem))
|
||||
NotifyPropertyChanged(NameOf(ActiveStrategyList))
|
||||
NotifyPropertyChanged(NameOf(m_SelTreeItem.StrategyList))
|
||||
End Sub
|
||||
|
||||
Public m_SelectedStrategy As StrategyConfiguration
|
||||
Public Property SelectedStrategy As StrategyConfiguration
|
||||
Get
|
||||
Return m_SelectedStrategy
|
||||
End Get
|
||||
Set(value As StrategyConfiguration)
|
||||
m_SelectedStrategy = value
|
||||
NotifyPropertyChanged(NameOf(SelectedStrategy))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public m_SelectedActiveStrategy As StrategyConfiguration
|
||||
Public Property SelectedActiveStrategy As StrategyConfiguration
|
||||
Get
|
||||
Return m_SelectedActiveStrategy
|
||||
End Get
|
||||
Set(value As StrategyConfiguration)
|
||||
m_SelectedActiveStrategy = value
|
||||
NotifyPropertyChanged(NameOf(SelectedActiveStrategy))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_ActiveStrategyList As New ObservableCollection(Of StrategyConfiguration)
|
||||
Public Property ActiveStrategyList As ObservableCollection(Of StrategyConfiguration)
|
||||
Get
|
||||
Return m_ActiveStrategyList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of StrategyConfiguration))
|
||||
m_ActiveStrategyList = value
|
||||
NotifyPropertyChanged(NameOf(ActiveStrategyList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Definizione Comandi
|
||||
Private m_AddSelectedStrategyCommand As ICommand
|
||||
Private m_RemoveSelectedStrategyCommand As ICommand
|
||||
|
||||
#End Region ' Field & Properties
|
||||
|
||||
#Region "CONSTRUCTOR"
|
||||
|
||||
Sub New()
|
||||
' Setto riferimento
|
||||
Map.SetRefStrategyManagerVM(Me)
|
||||
' Leggo file json strategie
|
||||
ReadAvailableStrategyJson()
|
||||
|
||||
Topology.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructor
|
||||
|
||||
#Region "METHODS"
|
||||
|
||||
Private Sub ReadAvailableStrategyJson()
|
||||
' Recupero file AvailableStrategyPathJson
|
||||
Dim AvailableStrategyPath As String = Map.refMainWindowVM.MainWindowM.sBeamNewRoot & "\Strategies\AvailableStrategyList.json"
|
||||
' Controllo se il file esisite
|
||||
If File.Exists(AvailableStrategyPath) Then
|
||||
' Leggo il contenuto del file JSON
|
||||
Dim AvailableStrategyPathJson As String = File.ReadAllText(AvailableStrategyPath)
|
||||
' Deserializza il JSON in un oggetto
|
||||
m_AvailableStrategyList = JsonConvert.DeserializeObject(Of ObservableCollection(Of AvailableStrategy))(AvailableStrategyPathJson)
|
||||
|
||||
For Each AvailableStrategy As AvailableStrategy In m_AvailableStrategyList
|
||||
For Each TopologyStrategy As Topology In AvailableStrategy.TopologyList
|
||||
For Each StrategyItem As StrategyConfiguration In TopologyStrategy.StrategyList
|
||||
ReadConfigurationStrategyJson(StrategyItem)
|
||||
Next
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ReadConfigurationStrategyJson(SelectedStrategyItem As StrategyConfiguration)
|
||||
' Recupero file StrategyJson
|
||||
Dim StrategyPath As String = Map.refMainWindowVM.MainWindowM.sBeamNewRoot & "\Strategies\Standard\" & SelectedStrategyItem.sStrategyID & "\" & SelectedStrategyItem.sStrategyID & ".json"
|
||||
' Controllo se il file esiste
|
||||
If File.Exists(StrategyPath) Then
|
||||
' Leggo il contenuto del file JSON
|
||||
Dim StrategyJson As String = File.ReadAllText(StrategyPath)
|
||||
' Deserializza il JSON in un oggetto
|
||||
Dim strategy As StrategyConfiguration = JsonConvert.DeserializeObject(Of StrategyConfiguration)(StrategyJson)
|
||||
' Assegno ParamList
|
||||
SelectedStrategyItem.ParameterList = strategy.ParameterList
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' Methods
|
||||
|
||||
#Region "COMMANDS"
|
||||
|
||||
#Region "AddSelectedStrategyCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do Save.
|
||||
''' </summary>
|
||||
Public ReadOnly Property AddSelectedStrategyCommand As ICommand
|
||||
Get
|
||||
If m_AddSelectedStrategyCommand Is Nothing Then
|
||||
m_AddSelectedStrategyCommand = New Command(AddressOf AddSelectedStrategy)
|
||||
End If
|
||||
Return m_AddSelectedStrategyCommand
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the Save. This method is invoked by the SaveCommand.
|
||||
''' </summary>
|
||||
Public Sub AddSelectedStrategy()
|
||||
If Not IsNothing(m_SelectedStrategy) Then
|
||||
' Aggiungo a ActiveStrategyList strategia selezionata
|
||||
m_ActiveStrategyList.Add(m_SelectedStrategy)
|
||||
m_SelectedStrategy.nIndexInList = m_ActiveStrategyList.Count - 1
|
||||
' Rimuovo da StrategyList la strategia precedentemente selezionata
|
||||
m_SelTreeItem.StrategyList.Remove(m_SelectedStrategy)
|
||||
NotifyPropertyChanged(NameOf(SelectedStrategy))
|
||||
NotifyPropertyChanged(NameOf(ActiveStrategyList))
|
||||
NotifyPropertyChanged(NameOf(SelTreeItem))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' AddSelectedStrategyCommand
|
||||
|
||||
#Region "RemoveSelectedStrategyCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do Save.
|
||||
''' </summary>
|
||||
Public ReadOnly Property RemoveSelectedStrategyCommand As ICommand
|
||||
Get
|
||||
If m_RemoveSelectedStrategyCommand Is Nothing Then
|
||||
m_RemoveSelectedStrategyCommand = New Command(AddressOf RemoveSelectedStrategy)
|
||||
End If
|
||||
Return m_RemoveSelectedStrategyCommand
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the Save. This method is invoked by the SaveCommand.
|
||||
''' </summary>
|
||||
Public Sub RemoveSelectedStrategy()
|
||||
If Not IsNothing(m_SelectedActiveStrategy) Then
|
||||
' Aggiungo a ActiveStrategyList strategia selezionata
|
||||
m_SelTreeItem.StrategyList.Add(m_SelectedActiveStrategy)
|
||||
m_SelectedActiveStrategy.nIndexInList = -1
|
||||
' Rimuovo da StrategyList la strategia precedentemente selezionata
|
||||
m_ActiveStrategyList.Remove(m_SelectedActiveStrategy)
|
||||
NotifyPropertyChanged(NameOf(SelectedActiveStrategy))
|
||||
NotifyPropertyChanged(NameOf(ActiveStrategyList))
|
||||
NotifyPropertyChanged(NameOf(SelTreeItem))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' RemoveSelectedStrategyCommand
|
||||
|
||||
#End Region ' Commands
|
||||
|
||||
End Class
|
||||
|
||||
Public Class AvailableStrategy
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
#End Region ' Fields & Propeties
|
||||
|
||||
End Class
|
||||
|
||||
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_bIsSelected As Boolean
|
||||
Public Property IsSelected As Boolean
|
||||
Get
|
||||
Return m_bIsSelected
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bIsSelected = value
|
||||
refUpdateSelTreeItem(Me)
|
||||
NotifyPropertyChanged(NameOf(IsSelected))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_StrategyList As New ObservableCollection(Of StrategyConfiguration)
|
||||
Public Property StrategyList As ObservableCollection(Of StrategyConfiguration)
|
||||
Get
|
||||
Return m_StrategyList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of StrategyConfiguration))
|
||||
m_StrategyList = value
|
||||
NotifyPropertyChanged(NameOf(StrategyList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region ' Fields & Propeties
|
||||
|
||||
#Region "CONSTRUCTOR"
|
||||
|
||||
Sub New()
|
||||
' Setto riferimento
|
||||
Map.SetRefTopology(Me)
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructor
|
||||
|
||||
End Class
|
||||
|
||||
Public Class StrategyConfiguration
|
||||
Inherits VMBase
|
||||
|
||||
#Region "FIELDS & PROPETIES"
|
||||
|
||||
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_nIndexInList As Integer = -1
|
||||
Public Property nIndexInList As Integer
|
||||
Get
|
||||
Return m_nIndexInList
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
m_nIndexInList = value
|
||||
If nIndexInList > -1 Then
|
||||
m_bActive = True
|
||||
Else
|
||||
m_bActive = False
|
||||
End If
|
||||
NotifyPropertyChanged(NameOf(nIndexInList))
|
||||
NotifyPropertyChanged(NameOf(bActive))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_bActive As Boolean
|
||||
Public ReadOnly Property bActive As Boolean
|
||||
Get
|
||||
Return m_bActive
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_ParameterList As New ObservableCollection(Of GenericParameter)
|
||||
Public Property ParameterList As ObservableCollection(Of GenericParameter)
|
||||
Get
|
||||
Return m_ParameterList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of GenericParameter))
|
||||
m_ParameterList = value
|
||||
NotifyPropertyChanged(NameOf(ParameterList))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region ' Fields & Propeties
|
||||
|
||||
End Class
|
||||
|
||||
Public Class GenericParameter
|
||||
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_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_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_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
|
||||
|
||||
End Class
|
||||
@@ -51,6 +51,7 @@
|
||||
<EgtBEAMWALL:FeatureListManagerVM x:Key="FeatureListManagerVM"/>
|
||||
<EgtBEAMWALL:RawPartManagerVM x:Key="RawPartManagerVM"/>
|
||||
<EgtBEAMWALL:SpecialPanelVM x:Key="SpecialPanelVM"/>
|
||||
<EgtBEAMWALL:StrategyManagerVM x:Key="StrategyManagerVM"/>
|
||||
|
||||
<!--#endregion Panel ViewModel-->
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ Module Map
|
||||
Private m_refRawPartManagerVM As RawPartManagerVM
|
||||
Private m_refFeatureListManagerVM As FeatureListManagerVM
|
||||
Private m_refSpecialPanelVM As SpecialPanelVM
|
||||
Private m_refStrategyManagerVM As StrategyManagerVM
|
||||
|
||||
Private m_refTopology As Topology
|
||||
|
||||
#Region "Get"
|
||||
|
||||
@@ -260,6 +263,18 @@ Module Map
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property refStrategyManagerVM As StrategyManagerVM
|
||||
Get
|
||||
Return m_refStrategyManagerVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property refTopology As Topology
|
||||
Get
|
||||
Return m_refTopology
|
||||
End Get
|
||||
End Property
|
||||
|
||||
#End Region ' Get
|
||||
|
||||
#Region "Set"
|
||||
@@ -444,6 +459,16 @@ Module Map
|
||||
Return Not IsNothing(m_refSpecialPanelVM)
|
||||
End Function
|
||||
|
||||
Friend Function SetRefStrategyManagerVM(StrategyManagerVM As StrategyManagerVM) As Boolean
|
||||
m_refStrategyManagerVM = StrategyManagerVM
|
||||
Return Not IsNothing(m_refStrategyManagerVM)
|
||||
End Function
|
||||
|
||||
Friend Function SetRefTopology(Topology As Topology) As Boolean
|
||||
m_refTopology = Topology
|
||||
Return Not IsNothing(m_refTopology)
|
||||
End Function
|
||||
|
||||
#End Region ' Set
|
||||
|
||||
#Region "Init"
|
||||
@@ -470,6 +495,7 @@ Module Map
|
||||
Not IsNothing(m_refSpecialPanelVM) AndAlso Not IsNothing(m_refOnlyProdManagerVM) AndAlso
|
||||
Not IsNothing(m_refBTLPartManagerVM) AndAlso Not IsNothing(m_refRawPartManagerVM) AndAlso
|
||||
Not IsNothing(m_refFeatureListManagerVM) AndAlso Not IsNothing(m_refSpecialPanelVM) AndAlso
|
||||
Not IsNothing(m_refStrategyManagerVM) AndAlso Not IsNothing(m_refTopology) AndAlso
|
||||
LibMap.EndInit()
|
||||
End Function
|
||||
|
||||
|
||||
Reference in New Issue
Block a user