private void textBoxHex_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (_preventTextBoxEvents)
            {
                return;
            }
            _preventTextBoxEvents = true;
            try
            {
                try
                {
                    switch (comboBoxType.SelectedItem.ToString())
                    {
                    case "byte": textBoxValue.Text = TeraPacketWithData.toByte(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "sbyte": textBoxValue.Text = TeraPacketWithData.toSByte(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "ushort": textBoxValue.Text = TeraPacketWithData.toUInt16(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "short": textBoxValue.Text = TeraPacketWithData.toInt16(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "uint": textBoxValue.Text = TeraPacketWithData.toUInt32(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "int": textBoxValue.Text = TeraPacketWithData.toInt32(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "ulong": textBoxValue.Text = TeraPacketWithData.toUInt64(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "long": textBoxValue.Text = TeraPacketWithData.toInt64(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "float": textBoxValue.Text = TeraPacketWithData.toSingle(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "double": textBoxValue.Text = TeraPacketWithData.toDouble(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "singleChar": textBoxValue.Text = TeraPacketWithData.toSingleChar(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "doubleChar": textBoxValue.Text = TeraPacketWithData.toDoubleChar(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "singleString": textBoxValue.Text = TeraPacketWithData.toSingleString(TeraPacketWithData.fromHex(textBoxHex.Text), 0, 10000); break;

                    case "doubleString": textBoxValue.Text = TeraPacketWithData.toDoubleString(TeraPacketWithData.fromHex(textBoxHex.Text), 0, 10000); break;

                    case "bool": textBoxValue.Text = TeraPacketWithData.toBoolean(TeraPacketWithData.fromHex(textBoxHex.Text), 0).ToString(); break;

                    case "hex": textBoxValue.Text = TeraPacketWithData.toHex(TeraPacketWithData.fromHex(textBoxHex.Text)); break;
                    }
                }
                catch { textBoxValue.Text = "ERROR"; }
            }
            catch { }
            _preventTextBoxEvents = false;
        }
        public object addElement(string name, int start, string type, int end = 0)
        {
            object val;

            switch (type)
            {
            case "byte": val = packet.toByte(start); break;

            case "sbyte": val = packet.toSByte(start); break;

            case "ushort": val = packet.toUInt16(start); break;

            case "short": val = packet.toInt16(start); break;

            case "uint": val = packet.toUInt32(start); break;

            case "int": val = packet.toInt32(start); break;

            case "ulong": val = packet.toUInt64(start); break;

            case "long": val = packet.toInt64(start); break;

            case "float": val = packet.toSingle(start); break;

            case "double": val = packet.toDouble(start); break;

            case "singleChar": val = packet.toSingleChar(start); break;

            case "doubleChar": val = packet.toDoubleChar(start); break;

            case "singleString": val = packet.toSingleString(start, end); break;

            case "doubleString": val = packet.toDoubleString(start, end); break;

            case "bool": val = packet.toBoolean(start); break;

            case "hex": val = packet.toHex(start, end); break;

            default: val = "[UNKNOWN]"; break;
            }
            elements.Add(new PacketElement(name, (ushort)start, type, val, (ushort)end));
            if (val is string)
            {
                return((val as string).Length);
            }
            return(val);
        }