private void ListOfCommands_SelectionChanged()

in TpmRcDecoder/TpmRcDecoder.Universal/CommandCodes.xaml.cs [3278:3307]


        private void ListOfCommands_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ListOfCommands.SelectedIndex == -1)
            {
                return;
            }

            uint commandCode = ~0u;
            string description = "";
            string commandName = "";
            if (ListOfCommands.SelectedIndex < m_TPM12Commands.Length)
            {
                // TPM 1.2
                commandCode = m_TPM12Commands[ListOfCommands.SelectedIndex].Ordinal;
                description = m_TPM12Commands[ListOfCommands.SelectedIndex].Description;
                commandName = m_TPM12Commands[ListOfCommands.SelectedIndex].Name;
            }
            else if (ListOfCommands.SelectedIndex - m_TPM12Commands.Length < m_TPM20Commands.Length)
            {
                // TPM 2.0
                commandCode = m_TPM20Commands[ListOfCommands.SelectedIndex - m_TPM12Commands.Length].Ordinal;
                description = m_TPM20Commands[ListOfCommands.SelectedIndex - m_TPM12Commands.Length].Description;
                commandName = m_TPM20Commands[ListOfCommands.SelectedIndex - m_TPM12Commands.Length].Name;
            }

            CommandCode.TextChanged -= CommandCode_TextChanged;
            CommandCode.Text = string.Format("0x{0:x}", commandCode);
            Description.Text = string.Format("{0} (0x{1:x})\n\n", commandName, commandCode) + description;
            CommandCode.TextChanged += CommandCode_TextChanged;
        }