Fixed gestione inserimento nuovo materiale

This commit is contained in:
NicolaP
2021-09-22 19:13:52 +02:00
parent bf90fd5cee
commit b1e41c36f3
3 changed files with 135 additions and 26 deletions
+31 -9
View File
@@ -71,6 +71,8 @@
<DockPanel>
<UniformGrid Grid.Row="2" Columns="2"
DockPanel.Dock="Bottom">
<Button Content="{Binding NewMatMsg}" Grid.Column="1"
@@ -83,16 +85,36 @@
Margin="2.5,0,0,0"/>
</UniformGrid>
<EgtWPFLib5:EgtTextBox Text="{Binding NewMatName}"
DockPanel.Dock="Bottom" Width="240"
Visibility="{Binding NewMatName_Visibility}"
Margin="0,0,0,5"/>
<Grid DockPanel.Dock="Bottom" Visibility="{Binding NewMatName_Visibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<EgtWPFLib5:EgtTextBox Text="{Binding NewMatName}"
DockPanel.Dock="Bottom"
Margin="0,0,0,5"/>
<Button Content="{Binding OkMsg}" Grid.Column="1"
Command="{Binding OkCommand}"
IsEnabled="{Binding EnableOkNewMat}"
Style="{StaticResource OptionPanel_TextButton}"
Margin="2.5,0,0,2.5"/>
<Button Content="{Binding CancelMsg}" Grid.Column="2"
Command="{Binding CamcelCommand}"
Style="{StaticResource OptionPanel_TextButton}"
Margin="2.5,0,0,2.5"/>
</Grid>
<!--<EgtWPFLib5:EgtTextBox Text="{Binding NewMatName}"
DockPanel.Dock="Bottom" Width="240"
Visibility="{Binding NewMatName_Visibility}"
Margin="0,0,0,5"/>-->
<ListBox ItemsSource="{Binding MaterialList}"
SelectedItem="{Binding SelMaterial}"
Grid.RowSpan="2"
Margin="0,0,0,5"
Height="150"/>
<ListBox ItemsSource="{Binding MaterialList}"
SelectedItem="{Binding SelMaterial}"
Grid.RowSpan="2"
Margin="0,0,0,5"
Height="150"/>
</DockPanel>
+103 -16
View File
@@ -129,22 +129,18 @@ Public Class OptionWindowVM
Set(value As String)
m_NewMatName = value
' Verifico che il nome non sia vuoto
If Not String.IsNullOrWhiteSpace(m_NewMatName) Then
' Verifico che il nome non sia già utilizzato
Dim bNameExist As Boolean = False
For Each Material In m_MaterialList
If Material = m_NewMatName Then
bNameExist = True
Exit For
End If
Next
If Not bNameExist Then
m_MaterialList.Add(m_NewMatName)
End If
End If
' Nascondo textbox per il nome
NewMatName_Visibility = Visibility.Collapsed
m_NewMatName = String.Empty
AddNewMaterial()
NotifyPropertyChanged("EnableOkNewMat")
End Set
End Property
Private m_EnableOkNewMat As Boolean = False
Public Property EnableOkNewMat As Boolean
Get
Return m_EnableOkNewMat
End Get
Set(value As Boolean)
m_EnableOkNewMat = value
End Set
End Property
@@ -221,12 +217,26 @@ Public Class OptionWindowVM
End Get
End Property
Public ReadOnly Property OkMsg As String
Get
Return "Ok"
End Get
End Property
Public ReadOnly Property CancelMsg As String
Get
Return "Cancel"
End Get
End Property
#End Region ' Messages
' Definizione comandi
Private m_cmdNewMat As ICommand
Private m_cmdRemoveMat As ICommand
Private m_cmdBrowse As ICommand
Private m_cmdOk As ICommand
Private m_cmdCanel As ICommand
#End Region ' FIELDS & PROPERTIES
@@ -275,6 +285,29 @@ Public Class OptionWindowVM
End While
End Sub
Private Function AddNewMaterial() As Boolean
If Not String.IsNullOrWhiteSpace(m_NewMatName) Then
' Verifico che il nome non sia già utilizzato
Dim bNameExist As Boolean = False
For Each Material In m_MaterialList
If Material = m_NewMatName Then
bNameExist = True
Exit For
End If
Next
If Not bNameExist Then
'm_MaterialList.Add(m_NewMatName)
m_EnableOkNewMat = True
Return True
End If
End If
' ' Nascondo textbox per il nome
' NewMatName_Visibility = Visibility.Collapsed
' m_NewMatName = String.Empty
m_EnableOkNewMat = False
Return False
End Function
#End Region
#Region "COMMANDS"
@@ -302,6 +335,60 @@ Public Class OptionWindowVM
#End Region ' NewMatCommand
#Region "OkCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property OkCommand As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf OkMat)
End If
Return m_cmdOk
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub OkMat(ByVal param As Object)
' aggiungo il materiale alla lista
m_MaterialList.Add(m_NewMatName)
' Nascondo textbox per il nome
NewMatName_Visibility = Visibility.Collapsed
m_NewMatName = String.Empty
NotifyPropertyChanged("NewMatName")
End Sub
#End Region ' OkCommand
#Region "CancelCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property CamcelCommand As ICommand
Get
If m_cmdCanel Is Nothing Then
m_cmdCanel = New Command(AddressOf CancelMat)
End If
Return m_cmdCanel
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub CancelMat(ByVal param As Object)
' Nascondo textbox per il nome
NewMatName_Visibility = Visibility.Collapsed
m_NewMatName = String.Empty
NotifyPropertyChanged("NewMatName")
End Sub
#End Region ' CancelCommand
#Region "RemoveMatCommand"
''' <summary>
+1 -1
View File
@@ -139,7 +139,7 @@ Module Map
Not IsNothing(LibMap.refSceneHostVM) AndAlso
Not IsNothing(PhotoMap.refOptionPanelVM) AndAlso Not IsNothing(PhotoMap.refListPageVM) AndAlso
Not IsNothing(PhotoMap.refDetailPageVM) AndAlso Not IsNothing(PhotoMap.refSearchPanelVM) AndAlso
PhotoMap.ContninueApplication
PhotoMap.ContinueApplication
End Function
#End Region ' Init