private string ReadPacket(PacketReader p) { string convert; switch (comboBox1.SelectedIndex) { case 0: convert = p.ReadByte().ToString(CultureInfo.InvariantCulture); break; case 1: convert = p.ReadShort().ToString(CultureInfo.InvariantCulture); break; case 2: convert = p.ReadInt().ToString(CultureInfo.InvariantCulture); break; case 3: convert = p.ReadLong().ToString(CultureInfo.InvariantCulture); break; case 4: convert = p.ReadString((int)numericUpDown1.Value); break; case 5: convert = p.ReadMapleString(); break; case 6: convert = p.Length + " Byte(s)"; break; default: convert = String.Format("Unhandled Type: [ {0} ] with Index: {1}", comboBox1.SelectedItem, comboBox1.SelectedIndex); break; } return convert; }
private void button1_Click(object sender, EventArgs e) { try { using (var p = new PacketReader(AbstractPacket.StringToByteArray(richTextBox1.Text))) richTextBox2.Text = ReadPacket(p); } catch (Exception ex) { richTextBox2.Text = ex.Message; } }