using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class DeleteStoredLinkKeyInfo : PacketInfoBase
{
	public override string Name => "Delete Stored Link Key";

	public override string DisplayGroup => "Host Control and Baseband";

	public DeleteStoredLinkKeyInfo(DeleteStoredLinkKey packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		DeleteStoredLinkKey deleteStoredLinkKey = (DeleteStoredLinkKey)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("BD Address", "BD_ADDR for the link key to be deleted.", 48, FormatValue(deleteStoredLinkKey.UserFields.BdAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Delete All Flag", DeleteStoredLinkKey.UserFieldsWrapper.DeleteAllFlagInfo.DeleteAllFlagToDescription(), 8, FormatValue(deleteStoredLinkKey.UserFields.DeleteAllFlag, 8), DeleteStoredLinkKey.UserFieldsWrapper.DeleteAllFlagInfo.DeleteAllFlagToString(DeleteStoredLinkKey.UserFieldsWrapper.DeleteAllFlagInfo.ValueToDeleteAllFlag(deleteStoredLinkKey.UserFields.DeleteAllFlag)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		DeleteStoredLinkKey deleteStoredLinkKey = (DeleteStoredLinkKey)packet;
		int num = -1;
		if (index == ++num)
		{
			deleteStoredLinkKey.UserFields.BdAddress = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			deleteStoredLinkKey.UserFields.DeleteAllFlag = Convert.ToUInt32(value, 16);
		}
	}
}
