Public Class ViewStructureForm
Private Current As [Structure]
Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
If Current Is Nothing Then
MessageBox.Show("Selezionare una struttura dalla lista prima!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Dim Bytes() As Byte = My.Forms.Form1.hexBytes.SelectedBytes
lstStructure.Items.Clear()
'Try
Current.Read(Bytes)
For Each M As [Structure].StructureMember In Current.Members
Dim L As New ListViewItem(New String() {M.Name, M.FormattedValue})
lstStructure.Items.Add(L)
Next
'Catch ex As Exception
' MessageBox.Show("Errore di lettura! Controllare che la dimensione dell'array di byte selezionato sia coerente con la struttura!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'End Try
End Sub
Private Sub ViewStructureForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each File As String In IO.
Directory.
GetFiles(Application.
StartupPath,
"*.struct")
Dim S
As [Structure] = [Structure].
Load(File)
If S IsNot Nothing Then
cmbStructures.Items.Add(S)
End If
Next
End Sub
Private Sub cmbStructures_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbStructures.SelectedIndexChanged
If cmbStructures.SelectedIndex < 0 Then
Exit Sub
End If
Current = cmbStructures.SelectedItem
End Sub
End Class