This commit is contained in:
Annamaria Sassi
2025-08-06 19:09:02 +02:00
2 changed files with 208 additions and 24 deletions
+24 -3
View File
@@ -1,9 +1,14 @@
<Grid x:Class="ManageWindowV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:EgtWindowMaker">
<Grid.Resources>
<local:AreaToSplitPageConverter x:Key="AreaToSplitPageConverter"/>
<local:OptionTypeToVisibilityConverter x:Key="OptionTypeToVisibilityConverter"/>
<sys:Double x:Key="Text">1</sys:Double>
<sys:Double x:Key="Lenght">2</sys:Double>
<sys:Double x:Key="Combo">3</sys:Double>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400"/>
@@ -87,6 +92,18 @@
<TextBox Text="{Binding SelArea.BottomRailQty}"/>
</UniformGrid>
</Expander>
<GroupBox Header="Threshold"
Padding="10,5"
Margin="0,0,0,10">
<StackPanel>
<ComboBox ItemsSource="{Binding DataContext.CurrWindow.ThresholdTypeList, RelativeSource={RelativeSource AncestorType={x:Type local:ManageWindowV}}}"
SelectedItem="{Binding SelThresholdType}"
Margin="0,5"/>
<ComboBox ItemsSource="{Binding DataContext.CurrWindow.ThresholdList, RelativeSource={RelativeSource AncestorType={x:Type local:ManageWindowV}}}"
SelectedItem="{Binding SelThreshold}"
Margin="0,5"/>
</StackPanel>
</GroupBox>
<Button Content="Calcola"
Command="{Binding ApplyFrame_Command}"
Style="{StaticResource Button.ManageWindow.LeftBar}"/>
@@ -277,9 +294,13 @@
<ComboBox Grid.Column="1"
ItemsSource="{Binding ValueList}"
SelectedValue="{Binding sValue}"
DisplayMemberPath="sDescription"/>
<!--<TextBox Grid.Column="1"
Text="{Binding sValue}"/>-->
DisplayMemberPath="sDescription"
Visibility="{Binding Type, Converter={StaticResource OptionTypeToVisibilityConverter},
ConverterParameter={StaticResource Combo}}"/>
<TextBox Grid.Column="1"
Text="{Binding sValue}"
Visibility="{Binding Type, Converter={StaticResource OptionTypeToVisibilityConverter},
ConverterParameter={StaticResource Text}}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
+184 -21
View File
@@ -1309,9 +1309,75 @@ Public Class Window
End Get
Set(value As String)
m_sProfilePath = value
' salvo soglia precedente
Dim PrevSelThresholdTypeList As New List(Of Integer)
Dim PrevSelThresholdList As New List(Of String)
For Each Area In AreaList
If Area.AreaType = AreaTypes.FRAME Then
PrevSelThresholdTypeList.Add(Area.SelThresholdType.Id)
PrevSelThresholdList.Add(Area.SelThreshold.Name)
End If
Next
' carico soglie
Dim gf = EgtLuaCreateGlobTable("WDG")
Dim kk = EgtLuaSetGlobStringVar("WDG.PROFILE", m_sProfilePath)
Dim ke = EgtLuaCallFunction("GetProfileThresholdsList")
Dim bFound As Boolean = True
Dim nType As Integer = 0
Dim sName As String = ""
Dim nIndex = 1
While bFound
bFound = EgtLuaGetGlobIntVar("WDG.THRESHOLDSLIST." & nIndex & ".nType", nType)
If bFound Then
EgtLuaGetGlobStringVar("WDG.THRESHOLDSLIST." & nIndex & ".sName", sName)
m_ThresholdList.Add(New IdNameStruct(nType, sName))
nIndex += 1
End If
End While
Dim ThresholdTypes = (From Threshold In m_ThresholdList
Select Threshold.Id
Order By Id).Distinct()
For Each Threshold In ThresholdTypes
m_ThresholdTypeList.Add(New IdNameStruct(Threshold, GetThresholdTypeNameFromId(Threshold)))
Next
Dim ud = EgtLuaResetGlobVar("WDG")
' aggiorno lista soglie filtrate per tipo
m_ThresholdList_View.Refresh()
' provo a ripristinare soglia precedente
Dim nThresholdIndex As Integer = 0
For Each Area In AreaList
If Area.AreaType = AreaTypes.FRAME Then
If PrevSelThresholdTypeList.Count >= nThresholdIndex Then
Dim SelThresholdType As IdNameStruct = m_ThresholdTypeList.First(Function(x) x.Id)
If Not IsNothing(SelThresholdType) Then
Area.SelThresholdType = SelThresholdType
End If
Dim SelThreshold As IdNameStruct = m_ThresholdList.First(Function(x) x.Name)
If Not IsNothing(SelThreshold) Then
Area.SelThreshold = SelThreshold
End If
End If
nThresholdIndex += 1
End If
Next
End Set
End Property
Private m_ThresholdTypeList As New List(Of IdNameStruct)
Public ReadOnly Property ThresholdTypeList As List(Of IdNameStruct)
Get
Return m_ThresholdTypeList
End Get
End Property
Private m_ThresholdList_View As CollectionView = Nothing
Private m_ThresholdList As New ObservableCollection(Of IdNameStruct)
Public ReadOnly Property ThresholdList As ObservableCollection(Of IdNameStruct)
Get
Return m_ThresholdList
End Get
End Property
Private m_AreaList As New ObservableCollection(Of Frame)
Public Property AreaList As ObservableCollection(Of Frame)
Get
@@ -1322,6 +1388,23 @@ Public Class Window
End Set
End Property
Sub New()
m_ThresholdList_View = CollectionViewSource.GetDefaultView(ThresholdList)
End Sub
Private Function GetThresholdTypeNameFromId(Id As Integer) As String
Select Case Id
Case 1
Return "Soglia"
Case 2
Return "Legno"
Case 3
Return "Gocciolatoio in alluminio"
Case Else
Return ""
End Select
End Function
Friend Function Serialize() As JsonWindow
Dim JsonWindow As New JsonWindow(m_sProfilePath)
For Each Area In m_AreaList
@@ -1678,6 +1761,28 @@ Public Class Frame
m_nBottomRailQty = nBottomRailQty
End Sub
Private m_SelThresholdType As IdNameStruct
Public Property SelThresholdType As IdNameStruct
Get
Return m_SelThresholdType
End Get
Set(value As IdNameStruct)
m_SelThresholdType = value
End Set
End Property
Private m_ThresholdList_View As CollectionView = Nothing
Private m_SelThreshold As IdNameStruct
Public Property SelThreshold As IdNameStruct
Get
Return m_SelThreshold
End Get
Set(value As IdNameStruct)
m_SelThreshold = value
End Set
End Property
Private m_Outline As ObservableCollection(Of Curve)
Public Property Outline As ObservableCollection(Of Curve)
Get
@@ -1690,8 +1795,14 @@ Public Class Frame
Sub New(ParentArea As Area)
MyBase.New(ParentArea)
m_ThresholdList_View = CollectionViewSource.GetDefaultView(Map.refManageWindowVM.CurrWindow.ThresholdList)
m_ThresholdList_View.Filter = AddressOf ThresholdTypeFilter
End Sub
Private Function ThresholdTypeFilter(ThresholdType As Object) As Boolean
Return m_SelThresholdType.Id = ThresholdType.id
End Function
Friend Shared Function CreateFrame(Window As Window) As Area
Dim NewFrame As New Frame(Nothing)
NewFrame.SetAreaType(AreaTypes.FRAME)
@@ -2016,7 +2127,12 @@ Public Class Sash
If Not IsNothing(HwdOptions) Then
m_HwdOptionList.Clear()
For Each HdwOption In HwdOptions.Items
m_HwdOptionList.Add(New AGBOption(HdwOption))
Select Case HdwOption.Tipo
Case "Text"
m_HwdOptionList.Add(New AGBOptionText(HdwOption))
Case "List"
m_HwdOptionList.Add(New AGBOptionCombo(HdwOption))
End Select
Next
NotifyPropertyChanged(NameOf(HwdOptionList))
End If
@@ -2361,7 +2477,15 @@ Public Class Sash
Dim sOptions As String = ""
For OptionIndex = 0 To m_HwdOptionList.Count - 1
Dim HdwOption = m_HwdOptionList(OptionIndex)
sOptions &= HdwOption.sName & "=" & HdwOption.sValue.sValue & If(OptionIndex < m_HwdOptionList.Count - 1, ",", "")
Select Case HdwOption.Type
Case AGBOption.HDWOPTIONTYPES.TEXT
Dim HdwOptionText As AGBOptionText = HdwOption
sOptions &= HdwOption.sName & "=" & HdwOptionText.sValue
Case AGBOption.HDWOPTIONTYPES.COMBO
Dim HdwOptionCombo As AGBOptionCombo = HdwOption
sOptions &= HdwOption.sName & "=" & HdwOptionCombo.sValue.sValue
End Select
sOptions &= If(OptionIndex < m_HwdOptionList.Count - 1, ",", "")
Next
EgtSetInfo(m_nAreaId, LUA_WIN_HDW_OPTIONS, sOptions)
End If
@@ -2431,7 +2555,7 @@ Public Class AGBOption
COMBO = 3
End Enum
Private m_Type As HDWOPTIONTYPES
Protected m_Type As HDWOPTIONTYPES
Public ReadOnly Property Type As HDWOPTIONTYPES
Get
Return m_Type
@@ -2452,6 +2576,24 @@ Public Class AGBOption
End Get
End Property
Private m_OptVisibility As Visibility
Public ReadOnly Property OptVisibility As Visibility
Get
Return m_OptVisibility
End Get
End Property
Sub New(HdwOptionParam As ParametriOpzioniParametri)
m_sName = HdwOptionParam.NomeParametro
m_sDescription = HdwOptionParam.DescrizioneParametro
m_OptVisibility = Visibility.Visible 'If(HdwOptionParam.Visible.ToLower = "true", Visibility.Visible, Visibility.Collapsed)
End Sub
End Class
Public Class AGBOptionCombo
Inherits AGBOption
Private m_ValueList As New List(Of AGBOptionParameter)
Public ReadOnly Property ValueList As List(Of AGBOptionParameter)
Get
@@ -2469,26 +2611,13 @@ Public Class AGBOption
End Set
End Property
Private m_OptVisibility As Visibility
Public ReadOnly Property OptVisibility As Visibility
Get
Return m_OptVisibility
End Get
End Property
Sub New(HdwOptionParam As ParametriOpzioniParametri)
If HdwOptionParam.Opzioni.Count > 0 Then
m_Type = HDWOPTIONTYPES.COMBO
For Each Value In HdwOptionParam.Opzioni
m_ValueList.Add(New AGBOptionParameter(Value.Valore, Value.DescrizioneOpzione))
Next
Else
m_Type = HDWOPTIONTYPES.TEXT
End If
m_sName = HdwOptionParam.NomeParametro
m_sDescription = HdwOptionParam.DescrizioneParametro
MyBase.New(HdwOptionParam)
m_Type = HDWOPTIONTYPES.COMBO
For Each Value In HdwOptionParam.Opzioni
m_ValueList.Add(New AGBOptionParameter(Value.Valore, Value.DescrizioneOpzione))
Next
m_sValue = m_ValueList.FirstOrDefault(Function(x) x.sValue = HdwOptionParam.ValoreCorrente)
m_OptVisibility = Visibility.Visible 'If(HdwOptionParam.Visible.ToLower = "true", Visibility.Visible, Visibility.Collapsed)
End Sub
End Class
@@ -2517,6 +2646,27 @@ Public Class AGBOptionParameter
End Class
Public Class AGBOptionText
Inherits AGBOption
Private m_sValue As String
Public Property sValue As String
Get
Return m_sValue
End Get
Set(value As String)
m_sValue = value
End Set
End Property
Sub New(HdwOptionParam As ParametriOpzioniParametri)
MyBase.New(HdwOptionParam)
m_Type = HDWOPTIONTYPES.TEXT
m_sValue = HdwOptionParam.ValoreCorrente
End Sub
End Class
Public Class Split
Inherits Area
@@ -3045,4 +3195,17 @@ Public Class AreaToSplitPageConverter
Throw New NotImplementedException()
End Function
End Class
Public Class OptionTypeToVisibilityConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
Return If(parameter = value, Visibility.Visible, Visibility.Collapsed)
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