using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Timers;
using System.Windows.Forms;
using QCRPG.Framework;
using QCRPG.TSL.BT.Packets;

namespace QCRPG.TSL.BT;

public class DataTransferUserControl : UserControlBase, QCRPG.Framework.IObserver<PacketBase>
{
	private enum ReceiveState
	{
		NEW,
		RECEIVING_DATA_TRANSFER_CUSTOM_PACKET,
		RECEIVING_FILE_TRANSFER_CUSTOM_PACKET,
		DATA_TRANSFER_INITIATED,
		FILE_TRANSFER_INITIATED
	}

	public int ConnectionHandler;

	public bool IsBTConnection = true;

	private ReceiveState receiveState;

	private Logger logger;

	private BTMainWorkerThread btMainWorkerThread;

	private int btl2CAPMaxLength = 65535;

	private int lel2CAPMaxLength = 27;

	private int channelID = 64;

	private int maxACLLength = 1024;

	private int lemaxACLLength = 27;

	private bool cycleL2CAPSizeEnable;

	private bool l2CAPSequenceNumberingEnable = true;

	private int dataPattern = 85;

	private bool sequentialDataPatternEnable = true;

	private bool checkReceiveDataIntegrityEnable = true;

	private bool continuousDataEnable = true;

	private int numberofL2CAPPackets;

	private int packetDelay;

	private int startDelay;

	private int transmitDelay = 30;

	private int receiveDelay = 15;

	private bool debugWriteEnable;

	private uint address = 2952789772u;

	private uint data = 3735935706u;

	private bool debugToggleEnable;

	private bool highEnable = true;

	private bool lowEnable;

	private bool btFlushEnable = true;

	private bool btNonFlushEnable;

	private bool btBothEnable;

	private bool leFlushEnable;

	private bool leNonFlushEnable = true;

	private bool leBothEnable;

	private double lastL2CAPTotalByteCount;

	private double lastHCITotalByteCount;

	private System.Timers.Timer transmitACLDataRateTimer = new System.Timers.Timer();

	private System.Timers.Timer receiveACLDataTimer = new System.Timers.Timer();

	private System.Timers.Timer receiverACLDataRateTimer = new System.Timers.Timer();

	private System.Timers.Timer transmitACLFileRateTimer = new System.Timers.Timer();

	private System.Timers.Timer receiveACLFileRateTimer = new System.Timers.Timer();

	private int aclPacketQuantity = -1;

	private int aclDataQuantity;

	private int hciDataQuantity;

	private double lastReceiveACLDataQuantity;

	private double lastReceiveHCIDataQuantity;

	private double TxL2CAPPacketCount;

	private double TxL2CAPTotalByteCount;

	private double TxHCITotalByteCount;

	private double currentAvailableBufferCount;

	private int maxACLBufferSize;

	private StopWatch txStopwatch = new StopWatch();

	private StopWatch rxStopwatch = new StopWatch();

	private long dataTransferSoFar;

	private long lastdataTransferSoFar;

	private long lastdataReceivesoFar;

	private long totalDataTransfer;

	private long fileTransferSofar;

	private string fileNametoReceive;

	private int remoteL2CAPMaxLength = 65535;

	private int remoteChannelID = 64;

	private bool remoteCycleL2CAPSizeEnable;

	private bool remoteL2CAPSequenceNumberingEnable = true;

	private int remoteDataPattern = 85;

	private bool useSequentialData = true;

	private bool remoteCheckReceiveDataIntegrityEnable = true;

	private int dataTransferConnHandle;

	private byte dataIntegrityByte;

	private bool aclDataErrorEnable = true;

	private BinaryWriter b;

	private int customPacketSize;

	private List<uint> savedAclData = new List<uint>();

	private IContainer components;

	private GroupBox groupBox1;

	private TextBox transmitHCIDataRateTextBox;

	private TextBox transmitL2CapDataRateTextBox;

	private TextBox transmitL2CapBytesTextBox;

	private TextBox transmitL2CapPacketsTextBox;

	private Label transmitHCIDataRateLabel;

	private Label transmitL2CapDataRateLabel;

	private Label transmiteL2CapBytesLabel;

	private Label transmitL2CapPacketsLabel;

	private GroupBox groupBox2;

	private TextBox receiveHCIDataRateTextBox;

	private TextBox receiveL2CapDataRateTextBox;

	private TextBox receiveL2CapBytesTextBox;

	private TextBox receiveL2CapPacketsTextBox;

	private Label receiveHCIDataRateLabel;

	private Label receiveL2CapDataRateLabel;

	private Label receiveL2CapBytesLabel;

	private Label receiveL2CapPacketsLabel;

	private GroupBox groupBox3;

	private TextBox aclUsedTextBox;

	private Label label2;

	private TextBox aclAllocatedTextBox;

	private Label label1;

	private Button optionsButton;

	private Button startTxButton;

	private Button stopTxButton;

	private GroupBox groupBox4;

	private Button buttonSendFile;

	private TextBox textBoxFileLocation;

	private ProgressBar progressBarFileTransfer;

	private GroupBox groupBox5;

	private TextBox textBoxFileReceive;

	private ProgressBar progressBarFileReceive;

	private Label labelTransmitStatus;

	private Label label3;

	private Label labelReceiveStatus;

	private Label label4;

	private GroupBox groupBox6;

	private TextBox textBoxErrorMessage;

	private LinkLabel LowThroughputLinkLabel;

	public DataTransferUserControl(BTMainWorkerThread btMainWorkerThread, Logger logger)
		: base("Data Transfer")
	{
		InitializeComponent();
		this.btMainWorkerThread = btMainWorkerThread;
		this.logger = logger;
		receiveACLDataTimer.Interval = 1000.0;
		receiveACLDataTimer.Enabled = false;
		receiveACLDataTimer.Elapsed += receiveACLDataTimer_Elapsed;
		receiverACLDataRateTimer.Interval = 1000.0;
		receiverACLDataRateTimer.Enabled = false;
		receiverACLDataRateTimer.Elapsed += receiverACLDataRateTimer_Elapsed;
		transmitACLDataRateTimer.Interval = 1000.0;
		transmitACLDataRateTimer.Enabled = false;
		transmitACLDataRateTimer.Elapsed += transmitACLDataRateTimer_Elapsed;
		transmitACLFileRateTimer.Interval = 1000.0;
		transmitACLFileRateTimer.Enabled = false;
		transmitACLFileRateTimer.Elapsed += transmitACLFileRateTimer_Elapsed;
		receiveACLFileRateTimer.Interval = 1000.0;
		receiveACLFileRateTimer.Enabled = false;
		receiveACLFileRateTimer.Elapsed += receiveACLFileRateTimer_Elapsed;
		btMainWorkerThread.TransmitDataTransferHandler += btMainWorkerThread_TransmitDataTransferHandler;
		btMainWorkerThread.TransmitFileTransferHandler += btMainWorkerThread_TransmitFileTransferHandler;
	}

	private void btMainWorkerThread_TransmitFileTransferHandler(object sender, int connectionHandle, long totalFileData, long sendFileData)
	{
		if (connectionHandle == ConnectionHandler)
		{
			dataTransferSoFar += sendFileData;
			int num = (int)(dataTransferSoFar * 100 / totalFileData);
			UpdateProgressBarView(progressBarFileTransfer, num);
			if (num >= 100)
			{
				transmitACLFileRateTimer.Enabled = false;
			}
		}
	}

	public void UpdateProgressBarView(ProgressBar progressBar, int dataPercent)
	{
		if (progressBar.InvokeRequired)
		{
			progressBar.Invoke((MethodInvoker)delegate
			{
				UpdateProgressBarView(progressBar, dataPercent);
			});
		}
		else
		{
			progressBar.Value = dataPercent;
		}
	}

	private void transmitACLDataRateTimer_Elapsed(object sender, ElapsedEventArgs e)
	{
		double value = TxL2CAPTotalByteCount - lastL2CAPTotalByteCount;
		double value2 = TxHCITotalByteCount - lastHCITotalByteCount;
		double totalMilliseconds = txStopwatch.GetElapsedTime().TotalMilliseconds;
		lastHCITotalByteCount = TxHCITotalByteCount;
		lastL2CAPTotalByteCount = TxL2CAPTotalByteCount;
		txStopwatch.Reset();
		UpdateDataRateView(transmitL2CapDataRateTextBox, value, totalMilliseconds);
		UpdateDataRateView(transmitHCIDataRateTextBox, value2, totalMilliseconds);
		UpdateView(transmitL2CapPacketsTextBox, TxL2CAPPacketCount);
		UpdateView(transmitL2CapBytesTextBox, TxL2CAPTotalByteCount);
		UpdateView(aclAllocatedTextBox, maxACLBufferSize);
		UpdateView(aclUsedTextBox, (double)maxACLBufferSize - currentAvailableBufferCount);
		if (!continuousDataEnable && TxL2CAPPacketCount == (double)numberofL2CAPPackets)
		{
			UpdateView(startTxButton, enabled: true);
			UpdateView(stopTxButton, enabled: false);
			transmitACLDataRateTimer.Enabled = false;
		}
	}

	private void transmitACLFileRateTimer_Elapsed(object sender, ElapsedEventArgs e)
	{
		long dataIncrease = dataTransferSoFar - lastdataTransferSoFar;
		UpdateFileRateView(labelTransmitStatus, "Data transmit at ", dataIncrease, txStopwatch.GetElapsedTime().TotalMilliseconds);
		lastdataTransferSoFar = dataTransferSoFar;
		txStopwatch.Reset();
	}

	private void receiveACLFileRateTimer_Elapsed(object sender, ElapsedEventArgs e)
	{
		long dataIncrease = fileTransferSofar - lastdataReceivesoFar;
		UpdateFileRateView(labelReceiveStatus, "Data receive at ", dataIncrease, rxStopwatch.GetElapsedTime().TotalMilliseconds);
		lastdataReceivesoFar = fileTransferSofar;
		rxStopwatch.Reset();
		int num = (int)(fileTransferSofar * 100 / totalDataTransfer);
		if (num >= 100)
		{
			receiveACLFileRateTimer.Enabled = false;
			num = 100;
		}
		UpdateProgressBarView(progressBarFileReceive, num);
	}

	private void optionsButton_Click(object sender, EventArgs e)
	{
		ChooseUserDataOption chooseUserDataOption = new ChooseUserDataOption();
		if (IsBTConnection)
		{
			chooseUserDataOption.L2CAPMaxLength = btl2CAPMaxLength;
			chooseUserDataOption.FlushEnable = btFlushEnable;
			chooseUserDataOption.NonFlushEnable = btNonFlushEnable;
			chooseUserDataOption.BothEnable = btBothEnable;
			chooseUserDataOption.MaxACLLength = maxACLLength;
		}
		else
		{
			chooseUserDataOption.L2CAPMaxLength = lel2CAPMaxLength;
			chooseUserDataOption.FlushEnable = leFlushEnable;
			chooseUserDataOption.NonFlushEnable = leNonFlushEnable;
			chooseUserDataOption.BothEnable = leBothEnable;
			chooseUserDataOption.MaxACLLength = lemaxACLLength;
		}
		chooseUserDataOption.ChannelID = channelID;
		chooseUserDataOption.CycleL2CAPSizeEnable = cycleL2CAPSizeEnable;
		chooseUserDataOption.L2CAPSequenceNumberingEnable = l2CAPSequenceNumberingEnable;
		chooseUserDataOption.DataPattern = dataPattern;
		chooseUserDataOption.SequentialDataPatternEnable = sequentialDataPatternEnable;
		chooseUserDataOption.CheckReceiveDataIntegrityEnable = checkReceiveDataIntegrityEnable;
		chooseUserDataOption.ContinuousDataEnable = continuousDataEnable;
		chooseUserDataOption.NumberofL2CAPPackets = numberofL2CAPPackets;
		chooseUserDataOption.PacketDelay = packetDelay;
		chooseUserDataOption.StartDelay = startDelay;
		chooseUserDataOption.TransmitDelay = transmitDelay;
		chooseUserDataOption.ReceiveDelay = receiveDelay;
		chooseUserDataOption.DebugWriteEnable = debugWriteEnable;
		chooseUserDataOption.Address = address;
		chooseUserDataOption.Data = data;
		chooseUserDataOption.DebugToggleEnable = debugToggleEnable;
		chooseUserDataOption.HighEnable = highEnable;
		chooseUserDataOption.LowEnable = lowEnable;
		chooseUserDataOption.ShowDialog();
		if (chooseUserDataOption.DialogResult == DialogResult.OK)
		{
			if (IsBTConnection)
			{
				btl2CAPMaxLength = chooseUserDataOption.L2CAPMaxLength;
				btFlushEnable = chooseUserDataOption.FlushEnable;
				btNonFlushEnable = chooseUserDataOption.NonFlushEnable;
				btBothEnable = chooseUserDataOption.BothEnable;
			}
			else
			{
				lel2CAPMaxLength = chooseUserDataOption.L2CAPMaxLength;
				lemaxACLLength = chooseUserDataOption.MaxACLLength;
				leFlushEnable = chooseUserDataOption.FlushEnable;
				leNonFlushEnable = chooseUserDataOption.NonFlushEnable;
				leBothEnable = chooseUserDataOption.BothEnable;
			}
			channelID = chooseUserDataOption.ChannelID;
			maxACLLength = chooseUserDataOption.MaxACLLength;
			cycleL2CAPSizeEnable = chooseUserDataOption.CycleL2CAPSizeEnable;
			l2CAPSequenceNumberingEnable = chooseUserDataOption.L2CAPSequenceNumberingEnable;
			dataPattern = chooseUserDataOption.DataPattern;
			sequentialDataPatternEnable = chooseUserDataOption.SequentialDataPatternEnable;
			checkReceiveDataIntegrityEnable = chooseUserDataOption.CheckReceiveDataIntegrityEnable;
			continuousDataEnable = chooseUserDataOption.ContinuousDataEnable;
			numberofL2CAPPackets = chooseUserDataOption.NumberofL2CAPPackets;
			packetDelay = chooseUserDataOption.PacketDelay;
			startDelay = chooseUserDataOption.StartDelay;
			transmitDelay = chooseUserDataOption.TransmitDelay;
			receiveDelay = chooseUserDataOption.ReceiveDelay;
			debugWriteEnable = chooseUserDataOption.DebugWriteEnable;
			address = chooseUserDataOption.Address;
			data = chooseUserDataOption.Data;
			debugToggleEnable = chooseUserDataOption.DebugToggleEnable;
			highEnable = chooseUserDataOption.HighEnable;
			lowEnable = chooseUserDataOption.LowEnable;
		}
	}

	private void startTxButton_Click(object sender, EventArgs e)
	{
		int num = 65535;
		bool flag = false;
		bool flag2 = false;
		bool flag3 = false;
		btMainWorkerThread.ReadAllBufferSizesHandler();
		if (IsBTConnection)
		{
			num = btl2CAPMaxLength;
			flag = btFlushEnable;
			flag2 = btNonFlushEnable;
			flag3 = btBothEnable;
		}
		else
		{
			num = lel2CAPMaxLength;
			flag = leFlushEnable;
			flag2 = leNonFlushEnable;
			flag3 = leBothEnable;
		}
		btMainWorkerThread.StartDataTransfer(ConnectionHandler, num, channelID, maxACLLength, cycleL2CAPSizeEnable, l2CAPSequenceNumberingEnable, dataPattern, sequentialDataPatternEnable, checkReceiveDataIntegrityEnable, continuousDataEnable, numberofL2CAPPackets, packetDelay, startDelay, data, flag, flag2, flag3, IsBTConnection);
		startTxButton.Enabled = false;
		stopTxButton.Enabled = true;
		lastL2CAPTotalByteCount = 0.0;
		lastHCITotalByteCount = 0.0;
		transmitACLDataRateTimer.Enabled = true;
		txStopwatch.Reset();
		textBoxErrorMessage.Text = "";
	}

	private void stopTxButton_Click(object sender, EventArgs e)
	{
		btMainWorkerThread.StopDataTransfer(ConnectionHandler);
		startTxButton.Enabled = true;
		stopTxButton.Enabled = false;
		transmitACLDataRateTimer.Enabled = false;
	}

	public void StopTxTransferGUIUpdates()
	{
		startTxButton.Enabled = true;
		stopTxButton.Enabled = false;
		transmitACLDataRateTimer.Enabled = false;
		receiverACLDataRateTimer.Enabled = false;
		receiveACLDataTimer.Enabled = false;
	}

	private void DataTransferUserControl_Load(object sender, EventArgs e)
	{
		progressBarFileTransfer.Maximum = 100;
		progressBarFileReceive.Maximum = 100;
	}

	private void receiverACLDataRateTimer_Elapsed(object sender, ElapsedEventArgs e)
	{
		double value = (double)aclDataQuantity - lastReceiveACLDataQuantity;
		double value2 = (double)hciDataQuantity - lastReceiveHCIDataQuantity;
		double totalMilliseconds = rxStopwatch.GetElapsedTime().TotalMilliseconds;
		lastReceiveACLDataQuantity = aclDataQuantity;
		lastReceiveHCIDataQuantity = hciDataQuantity;
		rxStopwatch.Reset();
		UpdateDataRateView(receiveL2CapDataRateTextBox, value, totalMilliseconds);
		UpdateDataRateView(receiveHCIDataRateTextBox, value2, totalMilliseconds);
	}

	private void receiveACLDataTimer_Elapsed(object sender, ElapsedEventArgs e)
	{
		UpdateView(receiveL2CapPacketsTextBox, aclPacketQuantity);
		UpdateView(receiveL2CapBytesTextBox, aclDataQuantity);
	}

	public void NotifyObserver(PacketBase packet)
	{
		if (!(packet is AclData))
		{
			return;
		}
		AclData aclData = (AclData)packet;
		uint handle = aclData._UserFields.Handle;
		if (ConnectionHandler == handle && (receiveState == ReceiveState.FILE_TRANSFER_INITIATED || !ProcessCustomPacket(aclData)))
		{
			if (receiveState == ReceiveState.DATA_TRANSFER_INITIATED)
			{
				ProcessDataTransferAclPacket(aclData);
			}
			else if (receiveState == ReceiveState.FILE_TRANSFER_INITIATED)
			{
				ProcessFileTransferAclPacket(aclData);
			}
		}
	}

	private bool ProcessCustomPacket(AclData aclData)
	{
		uint flags = aclData._UserFields.Flags;
		List<uint> dataList = aclData._UserFields.DataList;
		if (flags == 32 || flags == 0)
		{
			savedAclData.Clear();
		}
		savedAclData.AddRange(dataList);
		if (savedAclData.Count < 4)
		{
			return false;
		}
		if (savedAclData[2] == 204 && savedAclData[3] == 204)
		{
			if (receiveState == ReceiveState.NEW || receiveState == ReceiveState.DATA_TRANSFER_INITIATED)
			{
				receiveState = ReceiveState.RECEIVING_DATA_TRANSFER_CUSTOM_PACKET;
				customPacketSize = (int)((savedAclData[1] << 8) + savedAclData[0]);
			}
		}
		else
		{
			if (savedAclData[2] != 218 || savedAclData[3] != 218)
			{
				savedAclData.Clear();
				customPacketSize = 0;
				return false;
			}
			if (receiveState == ReceiveState.NEW)
			{
				receiveState = ReceiveState.RECEIVING_FILE_TRANSFER_CUSTOM_PACKET;
				customPacketSize = (int)((savedAclData[1] << 8) + savedAclData[0]);
			}
		}
		if (savedAclData.Count < customPacketSize + 2)
		{
			return true;
		}
		if (receiveState == ReceiveState.RECEIVING_DATA_TRANSFER_CUSTOM_PACKET)
		{
			InitializeDataTransferParameters(aclData._UserFields.Handle);
		}
		else if (receiveState == ReceiveState.RECEIVING_FILE_TRANSFER_CUSTOM_PACKET)
		{
			InitializeFileTransferParameters(aclData._UserFields.Handle);
		}
		savedAclData.Clear();
		customPacketSize = 0;
		return true;
	}

	private void InitializeDataTransferParameters(uint packetHandler)
	{
		lastReceiveACLDataQuantity = 0.0;
		lastReceiveHCIDataQuantity = 0.0;
		remoteL2CAPMaxLength = (int)((savedAclData[9] << 8) + savedAclData[8]);
		remoteChannelID = (int)((savedAclData[11] << 8) + savedAclData[10]);
		remoteCycleL2CAPSizeEnable = savedAclData[12] == 1;
		remoteL2CAPSequenceNumberingEnable = savedAclData[13] == 1;
		remoteDataPattern = (int)savedAclData[14];
		useSequentialData = savedAclData[15] == 1;
		remoteCheckReceiveDataIntegrityEnable = (aclDataErrorEnable = savedAclData[16] == 1);
		if (savedAclData[17] == 1)
		{
			StartReceiveDataTransfer(packetHandler);
			receiveState = ReceiveState.DATA_TRANSFER_INITIATED;
		}
		else if (savedAclData[17] == 0)
		{
			EndReceiveDataTransfer();
			receiveState = ReceiveState.NEW;
		}
		else if (savedAclData[17] == 2)
		{
			EndTxDataTransferFromRemote();
			receiveState = ReceiveState.NEW;
		}
	}

	private void InitializeFileTransferParameters(uint packetHandler)
	{
		if (b != null)
		{
			b.Close();
		}
		totalDataTransfer = (int)((savedAclData[7] << 24) + (savedAclData[6] << 16) + (savedAclData[5] << 8) + savedAclData[4]);
		fileNametoReceive = Conversions.ByteArrayToPrintableString((from i in savedAclData.Skip(8)
			select (byte)i).ToArray());
		string text = "C:\\TempLogs\\";
		try
		{
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
		}
		catch
		{
			logger.Enqueue(new LogMessage(LogMessageType.Error, "Can't find C:\\TempLogs folder"));
		}
		try
		{
			b = new BinaryWriter(File.Open(text + fileNametoReceive, FileMode.Create));
		}
		catch (Exception ex)
		{
			string text2 = string.Format("Can't wirte data to file: " + ex);
			logger.Enqueue(new LogMessage(LogMessageType.Error, text2));
			return;
		}
		if (b == null)
		{
			logger.Enqueue(new LogMessage(LogMessageType.Error, "Can't find C:\\TempLogs folder"));
			return;
		}
		fileTransferSofar = 0L;
		progressBarFileReceive.Value = 0;
		receiveACLFileRateTimer.Enabled = true;
		dataTransferConnHandle = (int)packetHandler;
		receiveState = ReceiveState.FILE_TRANSFER_INITIATED;
	}

	private void ProcessDataTransferAclPacket(AclData aclData)
	{
		uint flags = aclData._UserFields.Flags;
		string value = aclData.Info.FieldInfoList[3].Value;
		uint[] array = aclData._UserFields.DataList.ToArray();
		int i = 0;
		bool flag = flags == 32 || flags == 0;
		if (flag)
		{
			aclPacketQuantity++;
		}
		int dataLength = (int)aclData._UserFields.DataLength;
		aclDataQuantity += dataLength;
		hciDataQuantity += dataLength + 2;
		if (!remoteCheckReceiveDataIntegrityEnable)
		{
			return;
		}
		if (flag)
		{
			if (useSequentialData)
			{
				dataIntegrityByte = 0;
			}
			else
			{
				dataIntegrityByte = (byte)remoteDataPattern;
			}
			int num = (remoteL2CAPSequenceNumberingEnable ? 5 : 4);
			i += num;
		}
		for (; i < dataLength; i++)
		{
			if ((byte)array[i] != dataIntegrityByte)
			{
				if (aclDataErrorEnable)
				{
					string text = string.Format("L2CAP Packet Payload Data Error, Expected: {0}, Received: {1}, data packet: {2}", dataIntegrityByte.ToString("X2"), array[i].ToString("X2"), value);
					textBoxErrorMessage.Text = text;
					logger.Enqueue(new LogMessage(LogMessageType.Error, text));
					btMainWorkerThread.StopRemoteDataTransfer(dataTransferConnHandle, remoteL2CAPMaxLength, remoteChannelID, remoteCycleL2CAPSizeEnable, remoteL2CAPSequenceNumberingEnable, remoteDataPattern, remoteCheckReceiveDataIntegrityEnable);
					StopReceiverDataTransfer();
				}
				aclDataErrorEnable = false;
			}
			if (useSequentialData)
			{
				dataIntegrityByte++;
			}
		}
	}

	private void ProcessFileTransferAclPacket(AclData aclData)
	{
		uint flags = aclData._UserFields.Flags;
		List<uint> dataList = aclData._UserFields.DataList;
		bool flag = flags == 32 || flags == 0;
		if (b != null)
		{
			byte[] array = ((!flag) ? dataList.Select((uint i) => (byte)i).ToArray() : (from i in dataList.Skip(4)
				select (byte)i).ToArray());
			b.BaseStream.Write(array, 0, array.Length);
			fileTransferSofar += array.Length;
			if (fileTransferSofar == totalDataTransfer)
			{
				b.Close();
				receiveACLFileRateTimer.Enabled = false;
				string text = $"File {fileNametoReceive} received, saved at C:\\Templogs";
				logger.Enqueue(new LogMessage(LogMessageType.Info, text));
				receiveState = ReceiveState.NEW;
				dataTransferConnHandle = 0;
			}
		}
	}

	private void StopReceiverDataTransfer()
	{
		receiveACLDataTimer.Enabled = false;
		receiverACLDataRateTimer.Enabled = false;
	}

	private void btMainWorkerThread_TransmitDataTransferHandler(object sender, int connectionHandle, double transmitL2CAPByteCount, double transmitL2CAPPktCount, double transmitHCIByteCount, int currentAvailableBufferCount, int maximumBufferAvailable)
	{
		if (connectionHandle != ConnectionHandler)
		{
			return;
		}
		if (sender == null)
		{
			startTxButton.Enabled = true;
			stopTxButton.Enabled = false;
			transmitACLDataRateTimer.Enabled = false;
			return;
		}
		TxL2CAPPacketCount = transmitL2CAPPktCount;
		TxL2CAPTotalByteCount = transmitL2CAPByteCount;
		TxHCITotalByteCount = transmitHCIByteCount;
		this.currentAvailableBufferCount = currentAvailableBufferCount;
		maxACLBufferSize = maximumBufferAvailable;
		if (!transmitACLDataRateTimer.Enabled)
		{
			UpdateView(aclUsedTextBox, maximumBufferAvailable - currentAvailableBufferCount);
		}
	}

	public void UpdateView(Button button, bool enabled)
	{
		if (button.InvokeRequired)
		{
			button.Invoke((MethodInvoker)delegate
			{
				UpdateView(button, enabled);
			});
		}
		button.Enabled = enabled;
	}

	public void UpdateView(TextBox textBox, double value)
	{
		if (textBox.InvokeRequired)
		{
			textBox.Invoke((MethodInvoker)delegate
			{
				UpdateView(textBox, value);
			});
		}
		else
		{
			textBox.Text = value.ToString();
		}
	}

	public void UpdateDataRateView(TextBox textBox, double value, double timeElapse)
	{
		if (textBox.InvokeRequired)
		{
			textBox.Invoke((MethodInvoker)delegate
			{
				UpdateDataRateView(textBox, value, timeElapse);
			});
			return;
		}
		double num = 0.0;
		if (timeElapse != 0.0)
		{
			num = value * 8.0 / timeElapse;
		}
		textBox.Text = num.ToString("F3");
	}

	public void UpdateFileRateView(Label label, string message, long dataIncrease, double timeElapse)
	{
		if (label.InvokeRequired)
		{
			label.Invoke((MethodInvoker)delegate
			{
				UpdateFileRateView(label, message, dataIncrease, timeElapse);
			});
		}
		else
		{
			double num = (double)dataIncrease * 8.0 / timeElapse;
			label.Text = message + num.ToString("F3") + " kbps";
		}
	}

	private void buttonSendFile_Click(object sender, EventArgs e)
	{
		OpenFileDialog openFileDialog = new OpenFileDialog();
		openFileDialog.Filter = "All Files (*.*)|*.*";
		if (openFileDialog.ShowDialog() == DialogResult.OK)
		{
			textBoxFileLocation.Text = openFileDialog.FileName;
			progressBarFileTransfer.Value = 0;
			dataTransferSoFar = 0L;
			fileTransferSofar = 0L;
			transmitACLFileRateTimer.Enabled = true;
			txStopwatch.Reset();
			btMainWorkerThread.ReadAllBufferSizesHandler();
			btMainWorkerThread.ACLDataFileTransfer(ConnectionHandler, openFileDialog.FileName, IsBTConnection);
		}
	}

	private void StartReceiveDataTransfer(uint connectionHandle)
	{
		receiveACLDataTimer.Enabled = true;
		receiverACLDataRateTimer.Enabled = true;
		rxStopwatch.Reset();
		aclPacketQuantity = 0;
		aclDataQuantity = 0;
		hciDataQuantity = 0;
		btMainWorkerThread.SetAclLogMode();
		dataTransferConnHandle = (int)connectionHandle;
		textBoxErrorMessage.Text = "";
	}

	private void EndReceiveDataTransfer()
	{
		receiveACLDataTimer.Enabled = false;
		receiverACLDataRateTimer.Enabled = false;
		dataTransferConnHandle = 0;
	}

	private void EndTxDataTransferFromRemote()
	{
		btMainWorkerThread.StopRemoteDataTransfer(ConnectionHandler);
		transmitACLDataRateTimer.Enabled = false;
		startTxButton.Enabled = true;
		stopTxButton.Enabled = false;
		string text = "Received stop remote data transfer packet, stop transmitting.";
		logger.Enqueue(new LogMessage(LogMessageType.Error, text));
		textBoxErrorMessage.Text = text;
	}

	private void textBoxErrorMessage_TextChanged(object sender, EventArgs e)
	{
		if (textBoxErrorMessage.Text.Length != 0)
		{
			textBoxErrorMessage.TextChanged -= textBoxErrorMessage_TextChanged;
			textBoxErrorMessage.Text = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff") + " - " + textBoxErrorMessage.Text;
			textBoxErrorMessage.TextChanged += textBoxErrorMessage_TextChanged;
		}
	}

	private void LowThroughputLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
	{
		try
		{
			VisitLink();
		}
		catch (Exception)
		{
			MessageBox.Show("Unable to open link that was clicked.");
		}
	}

	private void VisitLink()
	{
		LowThroughputLinkLabel.LinkVisited = true;
		Process.Start("http://qwiki.qualcomm.com/corp-te/Recommended_Serial_Port_Settings_for_QCRPG_in_case_of_Low_Throughput");
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.transmitHCIDataRateTextBox = new System.Windows.Forms.TextBox();
		this.transmitL2CapDataRateTextBox = new System.Windows.Forms.TextBox();
		this.transmitL2CapBytesTextBox = new System.Windows.Forms.TextBox();
		this.transmitL2CapPacketsTextBox = new System.Windows.Forms.TextBox();
		this.transmitHCIDataRateLabel = new System.Windows.Forms.Label();
		this.transmitL2CapDataRateLabel = new System.Windows.Forms.Label();
		this.transmiteL2CapBytesLabel = new System.Windows.Forms.Label();
		this.transmitL2CapPacketsLabel = new System.Windows.Forms.Label();
		this.groupBox2 = new System.Windows.Forms.GroupBox();
		this.receiveHCIDataRateTextBox = new System.Windows.Forms.TextBox();
		this.receiveL2CapDataRateTextBox = new System.Windows.Forms.TextBox();
		this.receiveL2CapBytesTextBox = new System.Windows.Forms.TextBox();
		this.receiveL2CapPacketsTextBox = new System.Windows.Forms.TextBox();
		this.receiveHCIDataRateLabel = new System.Windows.Forms.Label();
		this.receiveL2CapDataRateLabel = new System.Windows.Forms.Label();
		this.receiveL2CapBytesLabel = new System.Windows.Forms.Label();
		this.receiveL2CapPacketsLabel = new System.Windows.Forms.Label();
		this.groupBox3 = new System.Windows.Forms.GroupBox();
		this.aclUsedTextBox = new System.Windows.Forms.TextBox();
		this.label2 = new System.Windows.Forms.Label();
		this.aclAllocatedTextBox = new System.Windows.Forms.TextBox();
		this.label1 = new System.Windows.Forms.Label();
		this.optionsButton = new System.Windows.Forms.Button();
		this.startTxButton = new System.Windows.Forms.Button();
		this.stopTxButton = new System.Windows.Forms.Button();
		this.groupBox4 = new System.Windows.Forms.GroupBox();
		this.labelTransmitStatus = new System.Windows.Forms.Label();
		this.label3 = new System.Windows.Forms.Label();
		this.progressBarFileTransfer = new System.Windows.Forms.ProgressBar();
		this.buttonSendFile = new System.Windows.Forms.Button();
		this.textBoxFileLocation = new System.Windows.Forms.TextBox();
		this.groupBox5 = new System.Windows.Forms.GroupBox();
		this.labelReceiveStatus = new System.Windows.Forms.Label();
		this.label4 = new System.Windows.Forms.Label();
		this.textBoxFileReceive = new System.Windows.Forms.TextBox();
		this.progressBarFileReceive = new System.Windows.Forms.ProgressBar();
		this.groupBox6 = new System.Windows.Forms.GroupBox();
		this.textBoxErrorMessage = new System.Windows.Forms.TextBox();
		this.LowThroughputLinkLabel = new System.Windows.Forms.LinkLabel();
		this.groupBox1.SuspendLayout();
		this.groupBox2.SuspendLayout();
		this.groupBox3.SuspendLayout();
		this.groupBox4.SuspendLayout();
		this.groupBox5.SuspendLayout();
		this.groupBox6.SuspendLayout();
		base.SuspendLayout();
		this.groupBox1.Controls.Add(this.transmitHCIDataRateTextBox);
		this.groupBox1.Controls.Add(this.transmitL2CapDataRateTextBox);
		this.groupBox1.Controls.Add(this.transmitL2CapBytesTextBox);
		this.groupBox1.Controls.Add(this.transmitL2CapPacketsTextBox);
		this.groupBox1.Controls.Add(this.transmitHCIDataRateLabel);
		this.groupBox1.Controls.Add(this.transmitL2CapDataRateLabel);
		this.groupBox1.Controls.Add(this.transmiteL2CapBytesLabel);
		this.groupBox1.Controls.Add(this.transmitL2CapPacketsLabel);
		this.groupBox1.Location = new System.Drawing.Point(4, 4);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Size = new System.Drawing.Size(269, 136);
		this.groupBox1.TabIndex = 0;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "Transmit";
		this.transmitHCIDataRateTextBox.Location = new System.Drawing.Point(177, 99);
		this.transmitHCIDataRateTextBox.Name = "transmitHCIDataRateTextBox";
		this.transmitHCIDataRateTextBox.ReadOnly = true;
		this.transmitHCIDataRateTextBox.Size = new System.Drawing.Size(86, 20);
		this.transmitHCIDataRateTextBox.TabIndex = 7;
		this.transmitHCIDataRateTextBox.Text = "0.000";
		this.transmitHCIDataRateTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.transmitL2CapDataRateTextBox.Location = new System.Drawing.Point(177, 73);
		this.transmitL2CapDataRateTextBox.Name = "transmitL2CapDataRateTextBox";
		this.transmitL2CapDataRateTextBox.ReadOnly = true;
		this.transmitL2CapDataRateTextBox.Size = new System.Drawing.Size(86, 20);
		this.transmitL2CapDataRateTextBox.TabIndex = 6;
		this.transmitL2CapDataRateTextBox.Text = "0.000";
		this.transmitL2CapDataRateTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.transmitL2CapBytesTextBox.Location = new System.Drawing.Point(177, 44);
		this.transmitL2CapBytesTextBox.Name = "transmitL2CapBytesTextBox";
		this.transmitL2CapBytesTextBox.ReadOnly = true;
		this.transmitL2CapBytesTextBox.Size = new System.Drawing.Size(86, 20);
		this.transmitL2CapBytesTextBox.TabIndex = 5;
		this.transmitL2CapBytesTextBox.Text = "0";
		this.transmitL2CapBytesTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.transmitL2CapPacketsTextBox.Location = new System.Drawing.Point(177, 17);
		this.transmitL2CapPacketsTextBox.Name = "transmitL2CapPacketsTextBox";
		this.transmitL2CapPacketsTextBox.ReadOnly = true;
		this.transmitL2CapPacketsTextBox.Size = new System.Drawing.Size(86, 20);
		this.transmitL2CapPacketsTextBox.TabIndex = 4;
		this.transmitL2CapPacketsTextBox.Text = "0";
		this.transmitL2CapPacketsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.transmitHCIDataRateLabel.AutoSize = true;
		this.transmitHCIDataRateLabel.Location = new System.Drawing.Point(6, 102);
		this.transmitHCIDataRateLabel.Name = "transmitHCIDataRateLabel";
		this.transmitHCIDataRateLabel.Size = new System.Drawing.Size(115, 13);
		this.transmitHCIDataRateLabel.TabIndex = 3;
		this.transmitHCIDataRateLabel.Text = "HCI Data Rate (kbps) :";
		this.transmitL2CapDataRateLabel.AutoSize = true;
		this.transmitL2CapDataRateLabel.Location = new System.Drawing.Point(6, 76);
		this.transmitL2CapDataRateLabel.Name = "transmitL2CapDataRateLabel";
		this.transmitL2CapDataRateLabel.Size = new System.Drawing.Size(128, 13);
		this.transmitL2CapDataRateLabel.TabIndex = 2;
		this.transmitL2CapDataRateLabel.Text = "L2Cap Data Rate (kbps) :";
		this.transmiteL2CapBytesLabel.AutoSize = true;
		this.transmiteL2CapBytesLabel.Location = new System.Drawing.Point(6, 51);
		this.transmiteL2CapBytesLabel.Name = "transmiteL2CapBytesLabel";
		this.transmiteL2CapBytesLabel.Size = new System.Drawing.Size(72, 13);
		this.transmiteL2CapBytesLabel.TabIndex = 1;
		this.transmiteL2CapBytesLabel.Text = "L2Cap bytes :";
		this.transmitL2CapPacketsLabel.AutoSize = true;
		this.transmitL2CapPacketsLabel.Location = new System.Drawing.Point(6, 25);
		this.transmitL2CapPacketsLabel.Name = "transmitL2CapPacketsLabel";
		this.transmitL2CapPacketsLabel.Size = new System.Drawing.Size(85, 13);
		this.transmitL2CapPacketsLabel.TabIndex = 0;
		this.transmitL2CapPacketsLabel.Text = "L2Cap packets :";
		this.groupBox2.Controls.Add(this.receiveHCIDataRateTextBox);
		this.groupBox2.Controls.Add(this.receiveL2CapDataRateTextBox);
		this.groupBox2.Controls.Add(this.receiveL2CapBytesTextBox);
		this.groupBox2.Controls.Add(this.receiveL2CapPacketsTextBox);
		this.groupBox2.Controls.Add(this.receiveHCIDataRateLabel);
		this.groupBox2.Controls.Add(this.receiveL2CapDataRateLabel);
		this.groupBox2.Controls.Add(this.receiveL2CapBytesLabel);
		this.groupBox2.Controls.Add(this.receiveL2CapPacketsLabel);
		this.groupBox2.Location = new System.Drawing.Point(279, 4);
		this.groupBox2.Name = "groupBox2";
		this.groupBox2.Size = new System.Drawing.Size(269, 136);
		this.groupBox2.TabIndex = 1;
		this.groupBox2.TabStop = false;
		this.groupBox2.Text = "Receive";
		this.receiveHCIDataRateTextBox.Location = new System.Drawing.Point(177, 99);
		this.receiveHCIDataRateTextBox.Name = "receiveHCIDataRateTextBox";
		this.receiveHCIDataRateTextBox.ReadOnly = true;
		this.receiveHCIDataRateTextBox.Size = new System.Drawing.Size(86, 20);
		this.receiveHCIDataRateTextBox.TabIndex = 11;
		this.receiveHCIDataRateTextBox.Text = "0.000";
		this.receiveHCIDataRateTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.receiveL2CapDataRateTextBox.Location = new System.Drawing.Point(177, 73);
		this.receiveL2CapDataRateTextBox.Name = "receiveL2CapDataRateTextBox";
		this.receiveL2CapDataRateTextBox.ReadOnly = true;
		this.receiveL2CapDataRateTextBox.Size = new System.Drawing.Size(86, 20);
		this.receiveL2CapDataRateTextBox.TabIndex = 10;
		this.receiveL2CapDataRateTextBox.Text = "0.000";
		this.receiveL2CapDataRateTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.receiveL2CapBytesTextBox.Location = new System.Drawing.Point(177, 44);
		this.receiveL2CapBytesTextBox.Name = "receiveL2CapBytesTextBox";
		this.receiveL2CapBytesTextBox.ReadOnly = true;
		this.receiveL2CapBytesTextBox.Size = new System.Drawing.Size(86, 20);
		this.receiveL2CapBytesTextBox.TabIndex = 9;
		this.receiveL2CapBytesTextBox.Text = "0";
		this.receiveL2CapBytesTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.receiveL2CapPacketsTextBox.Location = new System.Drawing.Point(177, 17);
		this.receiveL2CapPacketsTextBox.Name = "receiveL2CapPacketsTextBox";
		this.receiveL2CapPacketsTextBox.ReadOnly = true;
		this.receiveL2CapPacketsTextBox.Size = new System.Drawing.Size(86, 20);
		this.receiveL2CapPacketsTextBox.TabIndex = 8;
		this.receiveL2CapPacketsTextBox.Text = "0";
		this.receiveL2CapPacketsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.receiveHCIDataRateLabel.AutoSize = true;
		this.receiveHCIDataRateLabel.Location = new System.Drawing.Point(6, 102);
		this.receiveHCIDataRateLabel.Name = "receiveHCIDataRateLabel";
		this.receiveHCIDataRateLabel.Size = new System.Drawing.Size(115, 13);
		this.receiveHCIDataRateLabel.TabIndex = 7;
		this.receiveHCIDataRateLabel.Text = "HCI Data Rate (kbps) :";
		this.receiveL2CapDataRateLabel.AutoSize = true;
		this.receiveL2CapDataRateLabel.Location = new System.Drawing.Point(6, 76);
		this.receiveL2CapDataRateLabel.Name = "receiveL2CapDataRateLabel";
		this.receiveL2CapDataRateLabel.Size = new System.Drawing.Size(128, 13);
		this.receiveL2CapDataRateLabel.TabIndex = 6;
		this.receiveL2CapDataRateLabel.Text = "L2Cap Data Rate (kbps) :";
		this.receiveL2CapBytesLabel.AutoSize = true;
		this.receiveL2CapBytesLabel.Location = new System.Drawing.Point(6, 51);
		this.receiveL2CapBytesLabel.Name = "receiveL2CapBytesLabel";
		this.receiveL2CapBytesLabel.Size = new System.Drawing.Size(72, 13);
		this.receiveL2CapBytesLabel.TabIndex = 5;
		this.receiveL2CapBytesLabel.Text = "L2Cap bytes :";
		this.receiveL2CapPacketsLabel.AutoSize = true;
		this.receiveL2CapPacketsLabel.Location = new System.Drawing.Point(6, 25);
		this.receiveL2CapPacketsLabel.Name = "receiveL2CapPacketsLabel";
		this.receiveL2CapPacketsLabel.Size = new System.Drawing.Size(85, 13);
		this.receiveL2CapPacketsLabel.TabIndex = 4;
		this.receiveL2CapPacketsLabel.Text = "L2Cap packets :";
		this.groupBox3.Controls.Add(this.aclUsedTextBox);
		this.groupBox3.Controls.Add(this.label2);
		this.groupBox3.Controls.Add(this.aclAllocatedTextBox);
		this.groupBox3.Controls.Add(this.label1);
		this.groupBox3.Location = new System.Drawing.Point(4, 147);
		this.groupBox3.Name = "groupBox3";
		this.groupBox3.Size = new System.Drawing.Size(544, 51);
		this.groupBox3.TabIndex = 2;
		this.groupBox3.TabStop = false;
		this.groupBox3.Text = "ACL Connection Buffers";
		this.aclUsedTextBox.Location = new System.Drawing.Point(452, 24);
		this.aclUsedTextBox.Name = "aclUsedTextBox";
		this.aclUsedTextBox.ReadOnly = true;
		this.aclUsedTextBox.Size = new System.Drawing.Size(86, 20);
		this.aclUsedTextBox.TabIndex = 10;
		this.aclUsedTextBox.Text = "0";
		this.aclUsedTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(281, 27);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(38, 13);
		this.label2.TabIndex = 9;
		this.label2.Text = "Used :";
		this.aclAllocatedTextBox.Location = new System.Drawing.Point(177, 24);
		this.aclAllocatedTextBox.Name = "aclAllocatedTextBox";
		this.aclAllocatedTextBox.ReadOnly = true;
		this.aclAllocatedTextBox.Size = new System.Drawing.Size(86, 20);
		this.aclAllocatedTextBox.TabIndex = 8;
		this.aclAllocatedTextBox.Text = "0";
		this.aclAllocatedTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
		this.label1.AutoSize = true;
		this.label1.Location = new System.Drawing.Point(6, 27);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(57, 13);
		this.label1.TabIndex = 4;
		this.label1.Text = "Allocated :";
		this.optionsButton.Location = new System.Drawing.Point(93, 213);
		this.optionsButton.Name = "optionsButton";
		this.optionsButton.Size = new System.Drawing.Size(75, 23);
		this.optionsButton.TabIndex = 3;
		this.optionsButton.Text = "Options ...";
		this.optionsButton.UseVisualStyleBackColor = true;
		this.optionsButton.Click += new System.EventHandler(optionsButton_Click);
		this.startTxButton.Location = new System.Drawing.Point(218, 213);
		this.startTxButton.Name = "startTxButton";
		this.startTxButton.Size = new System.Drawing.Size(75, 23);
		this.startTxButton.TabIndex = 4;
		this.startTxButton.Text = "Start Tx";
		this.startTxButton.UseVisualStyleBackColor = true;
		this.startTxButton.Click += new System.EventHandler(startTxButton_Click);
		this.stopTxButton.Enabled = false;
		this.stopTxButton.Location = new System.Drawing.Point(341, 213);
		this.stopTxButton.Name = "stopTxButton";
		this.stopTxButton.Size = new System.Drawing.Size(75, 23);
		this.stopTxButton.TabIndex = 5;
		this.stopTxButton.Text = "Stop Tx";
		this.stopTxButton.UseVisualStyleBackColor = true;
		this.stopTxButton.Click += new System.EventHandler(stopTxButton_Click);
		this.groupBox4.Controls.Add(this.labelTransmitStatus);
		this.groupBox4.Controls.Add(this.label3);
		this.groupBox4.Controls.Add(this.progressBarFileTransfer);
		this.groupBox4.Controls.Add(this.buttonSendFile);
		this.groupBox4.Controls.Add(this.textBoxFileLocation);
		this.groupBox4.Location = new System.Drawing.Point(13, 261);
		this.groupBox4.Name = "groupBox4";
		this.groupBox4.Size = new System.Drawing.Size(291, 117);
		this.groupBox4.TabIndex = 8;
		this.groupBox4.TabStop = false;
		this.groupBox4.Text = "File Transmit";
		this.labelTransmitStatus.AutoSize = true;
		this.labelTransmitStatus.Location = new System.Drawing.Point(65, 16);
		this.labelTransmitStatus.Name = "labelTransmitStatus";
		this.labelTransmitStatus.Size = new System.Drawing.Size(0, 13);
		this.labelTransmitStatus.TabIndex = 12;
		this.label3.AutoSize = true;
		this.label3.Location = new System.Drawing.Point(6, 16);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(40, 13);
		this.label3.TabIndex = 11;
		this.label3.Text = "Status:";
		this.progressBarFileTransfer.Location = new System.Drawing.Point(7, 79);
		this.progressBarFileTransfer.Name = "progressBarFileTransfer";
		this.progressBarFileTransfer.Size = new System.Drawing.Size(185, 23);
		this.progressBarFileTransfer.TabIndex = 10;
		this.buttonSendFile.Location = new System.Drawing.Point(205, 47);
		this.buttonSendFile.Name = "buttonSendFile";
		this.buttonSendFile.Size = new System.Drawing.Size(75, 23);
		this.buttonSendFile.TabIndex = 9;
		this.buttonSendFile.Text = "Send ...";
		this.buttonSendFile.UseVisualStyleBackColor = true;
		this.buttonSendFile.Click += new System.EventHandler(buttonSendFile_Click);
		this.textBoxFileLocation.Location = new System.Drawing.Point(6, 49);
		this.textBoxFileLocation.Name = "textBoxFileLocation";
		this.textBoxFileLocation.Size = new System.Drawing.Size(186, 20);
		this.textBoxFileLocation.TabIndex = 8;
		this.groupBox5.Controls.Add(this.labelReceiveStatus);
		this.groupBox5.Controls.Add(this.label4);
		this.groupBox5.Controls.Add(this.textBoxFileReceive);
		this.groupBox5.Controls.Add(this.progressBarFileReceive);
		this.groupBox5.Location = new System.Drawing.Point(310, 261);
		this.groupBox5.Name = "groupBox5";
		this.groupBox5.Size = new System.Drawing.Size(232, 117);
		this.groupBox5.TabIndex = 11;
		this.groupBox5.TabStop = false;
		this.groupBox5.Text = "File Receive";
		this.labelReceiveStatus.AutoSize = true;
		this.labelReceiveStatus.Location = new System.Drawing.Point(71, 16);
		this.labelReceiveStatus.Name = "labelReceiveStatus";
		this.labelReceiveStatus.Size = new System.Drawing.Size(0, 13);
		this.labelReceiveStatus.TabIndex = 13;
		this.label4.AutoSize = true;
		this.label4.Location = new System.Drawing.Point(6, 16);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(40, 13);
		this.label4.TabIndex = 12;
		this.label4.Text = "Status:";
		this.textBoxFileReceive.Location = new System.Drawing.Point(9, 47);
		this.textBoxFileReceive.Name = "textBoxFileReceive";
		this.textBoxFileReceive.ReadOnly = true;
		this.textBoxFileReceive.Size = new System.Drawing.Size(217, 20);
		this.textBoxFileReceive.TabIndex = 11;
		this.progressBarFileReceive.Location = new System.Drawing.Point(9, 76);
		this.progressBarFileReceive.Name = "progressBarFileReceive";
		this.progressBarFileReceive.Size = new System.Drawing.Size(217, 23);
		this.progressBarFileReceive.TabIndex = 10;
		this.groupBox6.Controls.Add(this.textBoxErrorMessage);
		this.groupBox6.Location = new System.Drawing.Point(554, 4);
		this.groupBox6.Name = "groupBox6";
		this.groupBox6.Size = new System.Drawing.Size(232, 374);
		this.groupBox6.TabIndex = 12;
		this.groupBox6.TabStop = false;
		this.groupBox6.Text = "Status";
		this.textBoxErrorMessage.Dock = System.Windows.Forms.DockStyle.Top;
		this.textBoxErrorMessage.Location = new System.Drawing.Point(3, 16);
		this.textBoxErrorMessage.Multiline = true;
		this.textBoxErrorMessage.Name = "textBoxErrorMessage";
		this.textBoxErrorMessage.ReadOnly = true;
		this.textBoxErrorMessage.Size = new System.Drawing.Size(226, 351);
		this.textBoxErrorMessage.TabIndex = 1;
		this.textBoxErrorMessage.TextChanged += new System.EventHandler(textBoxErrorMessage_TextChanged);
		this.LowThroughputLinkLabel.AutoSize = true;
		this.LowThroughputLinkLabel.Location = new System.Drawing.Point(392, 243);
		this.LowThroughputLinkLabel.Name = "LowThroughputLinkLabel";
		this.LowThroughputLinkLabel.Size = new System.Drawing.Size(141, 13);
		this.LowThroughputLinkLabel.TabIndex = 13;
		this.LowThroughputLinkLabel.TabStop = true;
		this.LowThroughputLinkLabel.Text = "Low Throughput? Click here";
		this.LowThroughputLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(LowThroughputLinkLabel_LinkClicked);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.Controls.Add(this.LowThroughputLinkLabel);
		base.Controls.Add(this.groupBox6);
		base.Controls.Add(this.groupBox5);
		base.Controls.Add(this.groupBox4);
		base.Controls.Add(this.stopTxButton);
		base.Controls.Add(this.startTxButton);
		base.Controls.Add(this.optionsButton);
		base.Controls.Add(this.groupBox3);
		base.Controls.Add(this.groupBox2);
		base.Controls.Add(this.groupBox1);
		base.Name = "DataTransferUserControl";
		base.Size = new System.Drawing.Size(789, 381);
		base.Load += new System.EventHandler(DataTransferUserControl_Load);
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		this.groupBox2.ResumeLayout(false);
		this.groupBox2.PerformLayout();
		this.groupBox3.ResumeLayout(false);
		this.groupBox3.PerformLayout();
		this.groupBox4.ResumeLayout(false);
		this.groupBox4.PerformLayout();
		this.groupBox5.ResumeLayout(false);
		this.groupBox5.PerformLayout();
		this.groupBox6.ResumeLayout(false);
		this.groupBox6.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
