- miglioramenti e correzioni StrategyManager
This commit is contained in:
@@ -561,11 +561,6 @@ Public Class MainMenuVM
|
||||
Private Function InitCONFIG() As Boolean
|
||||
Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage))
|
||||
Map.refMainMenuVM.NotifyPropertyChanged(NameOf(Map.refMainMenuVM.SendFeedbackIsEnabled))
|
||||
If Not IsNothing(Map.refStrategyManagerVM) AndAlso Not IsNothing(Map.refStrategyManagerVM.sSelectedAISetUp) Then
|
||||
Map.refStrategyManagerVM.ReadAvailableStrategyJson(Map.refStrategyManagerVM.sSelectedAISetUp)
|
||||
Else
|
||||
Map.refStrategyManagerVM.ReadAvailableStrategyJson(CUSTOMERCONFIG_FILE)
|
||||
End If
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
Margin="5,10,0,0"
|
||||
Style="{StaticResource OnlyProd_ScrollViewer}">
|
||||
<ItemsControl ItemsSource="{Binding SelectedStrategyParamList.ParameterList}"
|
||||
<ItemsControl ItemsSource="{Binding SelTreeItem.SelParamStrategy.ParameterList}"
|
||||
Foreground="Black">
|
||||
<ItemsControl.Resources>
|
||||
<DataTemplate DataType="{x:Type Optmizer:GenericParameter}">
|
||||
|
||||
@@ -1,85 +1,89 @@
|
||||
<Grid x:Class="StrategyManagerV"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Optmizer="clr-namespace:EgtBEAMWALL.Optimizer">
|
||||
|
||||
xmlns:Optimizer="clr-namespace:EgtBEAMWALL.Optimizer">
|
||||
<Grid.Resources>
|
||||
<Optimizer:StrategyTypeToFocusableConverter x:Key="StrategyTypeToFocusableConverter"/>
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TreeView Grid.RowSpan="3"
|
||||
Width="300"
|
||||
Height="900"
|
||||
ItemsSource="{Binding AvailableStrategyList}">
|
||||
<TreeView.Resources>
|
||||
<HierarchicalDataTemplate DataType="{x:Type Optmizer:StrategyFeature}"
|
||||
ItemsSource="{Binding TopologyList}">
|
||||
<StackPanel Style="{StaticResource OnlyProdPartManager_StackPanel}">
|
||||
<TextBlock Text="{Binding sName}" Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
<TextBlock Text="{Binding nGRP}" Style="{StaticResource DialogWindow_TextBlock}" Margin="5,0,0,0"/>
|
||||
<TextBlock Text="{Binding nPRC}" Style="{StaticResource DialogWindow_TextBlock}" Margin="0,0,5,0"/>
|
||||
</StackPanel>
|
||||
</HierarchicalDataTemplate>
|
||||
<DataTemplate DataType="{x:Type Optmizer:Topology}">
|
||||
<TextBlock Text="{Binding sName}" Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</DataTemplate>
|
||||
</TreeView.Resources>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
|
||||
<UniformGrid Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Columns="2"
|
||||
Height="50">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center">
|
||||
<Button Command="{Binding OpenFileNameCustomConfigCommand}"
|
||||
ToolTip="{Binding SaveAsToolTip}"
|
||||
Margin="0,0,10,0"
|
||||
Style="{StaticResource SaveOptionPanel_Button}">
|
||||
<Image Source="/Resources/NewPage/+.png" Stretch="Uniform"/>
|
||||
</Button>
|
||||
<ComboBox ItemsSource="{Binding sAISetUpList}"
|
||||
SelectedItem="{Binding sSelectedAISetUp}"
|
||||
Style="{StaticResource Strategy_ComboBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center">
|
||||
<ComboBox ItemsSource="{Binding StrategySetupList}"
|
||||
SelectedItem="{Binding SelStrategySetup}"
|
||||
DisplayMemberPath="sName"
|
||||
Style="{StaticResource Strategy_ComboBox}"/>
|
||||
<Button Command="{Binding OpenFileNameCustomConfigCommand}"
|
||||
ToolTip="{Binding SaveAsToolTip}"
|
||||
Margin="0,0,10,0"
|
||||
Style="{StaticResource SaveOptionPanel_Button}">
|
||||
<Image Source="/Resources/NewPage/+.png" Stretch="Uniform"/>
|
||||
</Button>
|
||||
<Button Command="{Binding SaveCommand}"
|
||||
ToolTip="{Binding SaveToolTip}"
|
||||
Style="{StaticResource SaveStrategy_Button}">
|
||||
ToolTip="{Binding SaveToolTip}"
|
||||
Style="{StaticResource SaveStrategy_Button}">
|
||||
<Image Source="{Binding SaveImage}" Stretch="Uniform"/>
|
||||
</Button>
|
||||
</UniformGrid>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Optmizer:StrategyV Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2"/>
|
||||
<TreeView Grid.RowSpan="3"
|
||||
Width="300"
|
||||
Height="900"
|
||||
ItemsSource="{Binding SelStrategySetup.StrategyFeatureList}">
|
||||
<TreeView.Resources>
|
||||
<HierarchicalDataTemplate DataType="{x:Type Optimizer:StrategyFeature}"
|
||||
ItemsSource="{Binding TopologyList}">
|
||||
<StackPanel Style="{StaticResource OnlyProdPartManager_StackPanel}">
|
||||
<TextBlock Text="{Binding sName}" Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
<TextBlock Text="{Binding nGRP}" Style="{StaticResource DialogWindow_TextBlock}" Margin="5,0,0,0"/>
|
||||
<TextBlock Text="{Binding nPRC}" Style="{StaticResource DialogWindow_TextBlock}" Margin="0,0,5,0"/>
|
||||
</StackPanel>
|
||||
</HierarchicalDataTemplate>
|
||||
<DataTemplate DataType="{x:Type Optimizer:Topology}">
|
||||
<TextBlock Text="{Binding sName}" Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</DataTemplate>
|
||||
</TreeView.Resources>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
|
||||
<Setter Property="Focusable" Value="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource StrategyTypeToFocusableConverter}}"/>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
|
||||
<GroupBox Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Foreground="Black"
|
||||
BorderThickness="2"
|
||||
Margin="0,-11,0,0"
|
||||
BorderBrush="{StaticResource BeamWall_Glacier}">
|
||||
<GroupBox.Header>
|
||||
<TextBlock Text="{Binding SelectedStrategyParamList.sStrategyID}"
|
||||
FontWeight="Bold"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</GroupBox.Header>
|
||||
<Optmizer:ParameterStrategyV/>
|
||||
</GroupBox>
|
||||
<Optimizer:StrategyV Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2"/>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Width="900"/>
|
||||
</Grid>
|
||||
<GroupBox Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Foreground="Black"
|
||||
BorderThickness="2"
|
||||
Margin="0,-11,0,0"
|
||||
BorderBrush="{StaticResource BeamWall_Glacier}">
|
||||
<GroupBox.Header>
|
||||
<TextBlock Text="{Binding SelectedStrategyParamList.sStrategyID}"
|
||||
FontWeight="Bold"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</GroupBox.Header>
|
||||
<Optimizer:ParameterStrategyV/>
|
||||
</GroupBox>
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Width="900"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
@@ -4,12 +4,32 @@ Imports Newtonsoft.Json
|
||||
Imports System.IO
|
||||
Imports EgtBEAMWALL.Core
|
||||
Imports EgtUILib
|
||||
Imports System.ComponentModel
|
||||
|
||||
Public Class StrategyManagerVM
|
||||
Inherits VMBase
|
||||
|
||||
#Region "FIELDS & PROPERTIES"
|
||||
|
||||
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)
|
||||
m_SelStrategySetup = value
|
||||
m_SelStrategySetup.Read()
|
||||
NotifyPropertyChanged(NameOf(SelStrategySetup))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#Region "bMatchingJson"
|
||||
|
||||
' Controllo se le due liste sono uguali
|
||||
@@ -357,26 +377,16 @@ Public Class StrategyManagerVM
|
||||
Sub New()
|
||||
' Setto riferimento
|
||||
Map.SetRefStrategyManagerVM(Me)
|
||||
' Recupero i file contenti nella Cartella AISetup
|
||||
m_sAISetUpList = GetFileNamesAISetup(Map.refMainWindowVM.MainWindowM.GetAISetupDirPath())
|
||||
' Controllo se la lista sAISetUpList non è vuota
|
||||
If m_sAISetUpList.Count > 0 Then
|
||||
' Controllo se l'ultimo file json utilizzato è presente
|
||||
If Not String.IsNullOrEmpty(m_sLastCustomConfigJson) Then
|
||||
' Se si lo apro
|
||||
m_sSelectedAISetUp = m_sLastCustomConfigJson
|
||||
Else
|
||||
' Se no apro il primo
|
||||
m_sSelectedAISetUp = m_sAISetUpList(0)
|
||||
End If
|
||||
' leggo cartella dei setup delle strategie
|
||||
Dim AISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath()
|
||||
Dim AISetupPaths As String() = Directory.GetFiles(AISetupDirPath)
|
||||
For Each AiSetup In AISetupPaths
|
||||
m_StrategySetupList.Add(New StrategySetup(Path.GetFileNameWithoutExtension(AiSetup)))
|
||||
Next
|
||||
If m_StrategySetupList.Count > 0 Then
|
||||
SelStrategySetup = m_StrategySetupList(0)
|
||||
End If
|
||||
' Leggo file json strategie
|
||||
If Not IsNothing(m_sSelectedAISetUp) Then
|
||||
ReadAvailableStrategyJson(m_sSelectedAISetUp)
|
||||
Else
|
||||
ReadAvailableStrategyJson(CUSTOMERCONFIG_FILE)
|
||||
End If
|
||||
' Aggiorno elemento selezionato dall'albero
|
||||
' Assegno riferimento funzione per aggiornare elemento selezionato dall'albero
|
||||
Topology.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem
|
||||
End Sub
|
||||
|
||||
@@ -392,7 +402,7 @@ Public Class StrategyManagerVM
|
||||
' ------------------------------- Carico DefaultConfiguration --------------------------------------------
|
||||
' Recupero file AvailableStrategyPathJson
|
||||
Dim sAvailableStrategyPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath() & "\" & AVAILABLESTRATEGYLIST_FILE & ".json"
|
||||
' Controllo se il file esisite
|
||||
' Controllo se il file esiste
|
||||
If File.Exists(sAvailableStrategyPath) Then
|
||||
' Leggo il contenuto del file JSON
|
||||
Dim sAvailableStrategyPathJson As String = File.ReadAllText(sAvailableStrategyPath)
|
||||
@@ -941,6 +951,90 @@ Public Class StrategyManagerVM
|
||||
|
||||
End Class
|
||||
|
||||
'----------- Classe che rappresenta un file di setup delle strategie -----------
|
||||
Public Class StrategySetup
|
||||
Inherits VMBase
|
||||
|
||||
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
|
||||
Sub New(sName As String)
|
||||
m_sName = sName
|
||||
End Sub
|
||||
|
||||
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
|
||||
|
||||
Friend Sub Read()
|
||||
' carico default
|
||||
Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath()
|
||||
Dim sAvailableStrategiesFilePath As String = sStrategiesDirPath & "\" & AVAILABLESTRATEGYLIST_FILE & ".json"
|
||||
If File.Exists(sAvailableStrategiesFilePath) Then
|
||||
Dim sReadedFile As String = File.ReadAllText(sAvailableStrategiesFilePath)
|
||||
Dim JsonStrategyFeatureList As List(Of JsonStrategyFeature) = JsonConvert.DeserializeObject(Of List(Of JsonStrategyFeature))(sReadedFile)
|
||||
m_StrategyFeatureList = New ObservableCollection(Of StrategyFeature)((From JsonStrategyFeature In JsonStrategyFeatureList
|
||||
Select New StrategyFeature(JsonStrategyFeature)).ToList())
|
||||
' NotifyPropertyChanged(NameOf(StrategyFeatureList))
|
||||
|
||||
End If
|
||||
' carico custom
|
||||
Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath()
|
||||
Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sName & ".json"
|
||||
If File.Exists(sStrategyConfigurationFilePath) Then
|
||||
Dim sReadedFile As String = File.ReadAllText(sStrategyConfigurationFilePath)
|
||||
Dim JsonStrategyFeatureList As List(Of JsonStrategyFeature) = JsonConvert.DeserializeObject(Of List(Of JsonStrategyFeature))(sReadedFile)
|
||||
For Each Feature 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??'
|
||||
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
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
'----------- Classe che fa riferimento alle Feature -----------
|
||||
Public Class StrategyFeature
|
||||
Inherits VMBase
|
||||
@@ -1034,31 +1128,28 @@ Public Class Topology
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_bIsSelected = value
|
||||
Map.refStrategyManagerVM.ActiveStrategyList.Clear()
|
||||
Map.refStrategyManagerVM.DeactivateStrategyList.Clear()
|
||||
refUpdateSelTreeItem(Me)
|
||||
Dim ActiveStrategies As IEnumerable(Of Strategy) = Me.StrategyList.Where(Function(s) s.bActive)
|
||||
Dim InactiveStrategies As IEnumerable(Of Strategy) = Me.StrategyList.Where(Function(s) Not s.bActive)
|
||||
For Each strategy In ActiveStrategies
|
||||
Map.refStrategyManagerVM.ActiveStrategyList.Add(strategy)
|
||||
Next
|
||||
For Each strategy In InactiveStrategies
|
||||
Map.refStrategyManagerVM.DeactivateStrategyList.Add(strategy)
|
||||
Next
|
||||
NotifyPropertyChanged(NameOf(IsSelected))
|
||||
If Not value Then
|
||||
SelActiveStrategy = Nothing
|
||||
SelAvailableStrategy = Nothing
|
||||
End If
|
||||
m_AvailableStrategyList_View.Refresh()
|
||||
m_ActiveStrategyList_View.Refresh()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Seleziona l'elemento della lista StrategyList
|
||||
Public m_SelectedStrategy As Strategy
|
||||
Public Property SelectedStrategy As Strategy
|
||||
Private m_AvailableStrategyList_View As ICollectionView = Nothing
|
||||
Public ReadOnly Property AvailableStrategyList_View As ICollectionView
|
||||
Get
|
||||
Return m_SelectedStrategy
|
||||
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
|
||||
Set(value As Strategy)
|
||||
m_SelectedStrategy = value
|
||||
NotifyPropertyChanged(NameOf(SelectedStrategy))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_StrategyList As New ObservableCollection(Of Strategy)
|
||||
@@ -1072,6 +1163,39 @@ Public Class Topology
|
||||
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"
|
||||
@@ -1080,11 +1204,23 @@ Public Class Topology
|
||||
If IsNothing(JsonTopology) Then Return
|
||||
m_sName = JsonTopology.sName
|
||||
m_StrategyList = New ObservableCollection(Of Strategy)(JsonTopology.StrategyList.Select(Function(jsonStrategy) New Strategy(Me, 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
|
||||
|
||||
Private Function AvailableStrategyFilter(Strategy As Object) As Boolean
|
||||
Return DirectCast(Strategy, Strategy).nIndexInList < 0
|
||||
End Function
|
||||
|
||||
Private Function ActiveStrategyFilter(Strategy As Object) As Boolean
|
||||
Return DirectCast(Strategy, Strategy).nIndexInList >= 0
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
'----------- Classe che fa alle Strategie delle Topologie delle Feature -----------
|
||||
@@ -1166,12 +1302,43 @@ Public Class Strategy
|
||||
m_sStrategyID = JsonStrategy.sStrategyID
|
||||
m_nIndexInList = JsonStrategy.nIndexInList
|
||||
m_bActive = JsonStrategy.bActive
|
||||
m_ParameterList = New ObservableCollection(Of GenericParameter)(JsonStrategy.ParameterList.Select(Function(jsonParam) New GenericParameter(jsonParam)))
|
||||
NotifyPropertyChanged(NameOf(ParameterList))
|
||||
ReadConfigurationStrategyJson()
|
||||
'NotifyPropertyChanged(NameOf(ParameterList))
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructor
|
||||
|
||||
''' <summary>
|
||||
''' Funzione che legge il file json delle strategie
|
||||
''' </summary>
|
||||
Private Sub ReadConfigurationStrategyJson()
|
||||
' Recupero file StrategyJson
|
||||
Dim StrategyPath As String = Map.refMainWindowVM.MainWindowM.GetStandardDirPath() & "\" & 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 JsonStrategy = JsonConvert.DeserializeObject(Of JsonStrategy)(StrategyJson)
|
||||
' Assegno ParamList per poter visualizzarla da interfaccia econtrollo di che tipo è se Strategy o JsonStrategy
|
||||
m_ParameterList = New ObservableCollection(Of GenericParameter)(strategyConfig.ParameterList.Select(Function(p) New GenericParameter(p)).ToList())
|
||||
End Sub
|
||||
|
||||
Friend Sub ReadConfiguration(ConfigurationStrategy As JsonStrategy)
|
||||
m_nIndexInList = ConfigurationStrategy.nIndexInList
|
||||
NotifyPropertyChanged(NameOf(nIndexInList))
|
||||
'm_ParentTopology.NotifyPropertyChanged(NameOf(m_ParentTopology.AvailableStrategyList_View))
|
||||
'm_ParentTopology.NotifyPropertyChanged(NameOf(m_ParentTopology.ActiveStrategyList_View))
|
||||
For Each Parameter In ConfigurationStrategy.ParameterList
|
||||
Dim DefaultParameter As GenericParameter = m_ParameterList.FirstOrDefault(Function(x) x.sNameNge = Parameter.sNameNge)
|
||||
If IsNothing(DefaultParameter) Then
|
||||
m_ParameterList.Add(New GenericParameter(Parameter))
|
||||
' verifico indici!!
|
||||
Else
|
||||
DefaultParameter.sValue = Parameter.sValue
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
'----------- Classe che fa riferimento ai parametri delle Strategie -----------
|
||||
@@ -1694,4 +1861,23 @@ Public Class JsonChoiceParameter
|
||||
End Set
|
||||
End Property
|
||||
|
||||
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
|
||||
@@ -14,7 +14,30 @@
|
||||
|
||||
<Border Margin="2,0,2,0"
|
||||
Style="{StaticResource OnlyProdPage_Border}">
|
||||
<Optmizer:DeactivateStrategyListBoxV/>
|
||||
<ListBox ItemsSource="{Binding SelTreeItem.AvailableStrategyList_View}"
|
||||
SelectedItem="{Binding SelTreeItem.SelAvailableStrategy}"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
Style="{StaticResource NewAddFeature_ListBox}">
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type Optmizer:Strategy}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="{Binding sImageStrategy}"
|
||||
Stretch="Uniform"
|
||||
Width="100"
|
||||
Height="100"/>
|
||||
<TextBlock Text="{Binding sStrategyID}"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<EventSetter Event="PreviewMouseDown" Handler="AvailableStrategyList_PreviewMouseDown"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Column="1"
|
||||
@@ -31,7 +54,30 @@
|
||||
<Border Grid.Column="2"
|
||||
Margin="2,0,2,0"
|
||||
Style="{StaticResource OnlyProdPage_Border}">
|
||||
<Optmizer:ActiveStrategyListBoxV/>
|
||||
<ListBox ItemsSource="{Binding SelTreeItem.ActiveStrategyList_View}"
|
||||
SelectedItem="{Binding SelTreeItem.SelActiveStrategy}"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
Style="{StaticResource NewAddFeature_ListBox}">
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type Optmizer:Strategy}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="{Binding sImageStrategy}"
|
||||
Stretch="Uniform"
|
||||
Width="100"
|
||||
Height="100"/>
|
||||
<TextBlock Text="{Binding sStrategyID}"
|
||||
Style="{StaticResource DialogWindow_TextBlock}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<EventSetter Event="PreviewMouseDown" Handler="ActiveStrategyList_PreviewMouseDown"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Column="3"
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
Public Class StrategyV
|
||||
|
||||
''' <summary>
|
||||
''' Funzione che permette di riselezionare l'elemento ActiveStrategyList della lista già selezionato
|
||||
''' </summary>
|
||||
''' <param name="sender"></param>
|
||||
''' <param name="e"></param>
|
||||
Private Sub AvailableStrategyList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
|
||||
If TypeOf sender IsNot ListBoxItem Then Return
|
||||
Dim Item As ListBoxItem = DirectCast(sender, ListBoxItem)
|
||||
If Not IsNothing(Item) AndAlso Item.IsSelected Then
|
||||
Map.refStrategyManagerVM.SelTreeItem.SelAvailableStrategy = Map.refStrategyManagerVM.SelTreeItem.SelAvailableStrategy
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ActiveStrategyList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
|
||||
If TypeOf sender IsNot ListBoxItem Then Return
|
||||
Dim Item As ListBoxItem = DirectCast(sender, ListBoxItem)
|
||||
If Not IsNothing(Item) AndAlso Item.IsSelected Then
|
||||
Map.refStrategyManagerVM.SelTreeItem.SelActiveStrategy = Map.refStrategyManagerVM.SelTreeItem.SelActiveStrategy
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user