using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using DebugToolInstrumentInterface;
using QC.QMSLPhone;
using QSC_Params_File_Helper;
using Qualcomm_ModemRFA;

namespace QFDT_Components;

public partial class FTM_RF_Tx_QSC : UserControl, IComponentConnector
{
	public delegate void SendDebugMessage(MessageLevel level, string message);

	public SendDebugMessage DebugMessageCB;

	public string TableName = "TestingTable";

	public Phone phone;

	public bool bContinueRunFlag = true;

	public ISpectrumAnalyzer pSA;

	public TechAndBandCombine m_curSelBand;

	public string m_cfgQSCXML;

	public QSC_Tx_Override_Params m_TxOverrideParams;

	private Thread thread;

	public void Register_DebugMessageCB(SendDebugMessage me)
	{
		DebugMessageCB = me;
	}

	public void PassDebugMessageCB(RFPathAndRadioConfiguration.SendDebugMessage me)
	{
		QSC_Path_RadioConfig.DebugMessageCB = me;
	}

	public FTM_RF_Tx_QSC()
	{
		InitializeComponent();
		SetLanguageDictionary();
		m_TxOverrideParams = new QSC_Tx_Override_Params();
		QSC_Path_RadioConfig.m_RFType = DebugRFType.TX;
		QSC_Path_RadioConfig.BandSelMessageCB = UpdateTxComponents;
		phone = null;
		m_curSelBand = null;
		AccessComponentInThreadHelper.SetEnableOrVisibility(this, TxOff, SetAttribute.IsEnable, bEnableOrVisbile: false);
		RefreshSARelatedComponent();
	}

	private void SetLanguageDictionary()
	{
		ResourceDictionary resourceDictionary = new ResourceDictionary();
		string text = Thread.CurrentThread.CurrentCulture.ToString();
		try
		{
			resourceDictionary.Source = new Uri(Thread.GetDomain().BaseDirectory + "..\\Resources\\UI_" + text + ".xaml", UriKind.Absolute);
		}
		catch
		{
		}
		base.Resources.MergedDictionaries.Add(resourceDictionary);
	}

	public void SetLanguage(string culture)
	{
		ResourceDictionary resourceDictionary = new ResourceDictionary();
		try
		{
			resourceDictionary.Source = new Uri(Thread.GetDomain().BaseDirectory + "\\Resources\\UI_" + culture + ".xaml", UriKind.Absolute);
		}
		catch
		{
			resourceDictionary.Source = new Uri(Thread.GetDomain().BaseDirectory + "..\\Resources\\UI_en-US.xaml", UriKind.Absolute);
		}
		base.Resources.MergedDictionaries.Clear();
		base.Resources.MergedDictionaries.Add(resourceDictionary);
		QSC_Path_RadioConfig.SetLanguage(culture);
	}

	public void passPhoneHandle(Phone phone)
	{
		QSC_Path_RadioConfig.phone = phone;
	}

	public void UpdateUIviaXML(string calQSCXML, bool beHeForward = false)
	{
		if (beHeForward)
		{
			QSC_Path_RadioConfig.SetPlatform(Platform.HE);
		}
		else
		{
			QSC_Path_RadioConfig.SetPlatform(Platform.AT);
		}
		m_cfgQSCXML = calQSCXML;
		string strLog = "";
		if (!QSC_Path_RadioConfig.UpdateUIviaXML(calQSCXML, ref strLog))
		{
			DebugMessageCB(MessageLevel.EXCEPTION, strLog);
		}
		AccessComponentInThreadHelper.SetText(this, Channel, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, ChanInMHz, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, State, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, RGI, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, Bias, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, ICQ, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, MaxLinPower, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, MinLinPower, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, txtMeasuredTxPwr, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetText(this, txtPathLoss, SetAttribute.Text, "");
	}

	private void ChannelValueChanged(object sender, TextChangedEventArgs e)
	{
		if (Channel.Text.Length > 0 && phone != null && m_curSelBand != null)
		{
			ushort iBand = TechAndBandCombine.ChangeToBandHelperBandClass(m_curSelBand.tech, m_curSelBand.band);
			double num = phone.Band_Helper_CalculateULFrequency(iBand, Convert.ToUInt16(Channel.Text));
			ChanInMHz.Text = num + " MHz";
		}
	}

	public void UpdateTxComponents(TechAndBandCombine selBand)
	{
		string text = null;
		string text2 = null;
		string text3 = null;
		string text4 = null;
		string text5 = null;
		string text6 = null;
		string text7 = null;
		m_curSelBand = selBand;
		string text8;
		string text9;
		string text10;
		string text11;
		string text12;
		string text13;
		string text14;
		if (m_curSelBand.tech != "GSM")
		{
			text8 = QSCXMLHelper.GetTxChannelList(selBand.tech, selBand.band, selBand.subband, m_cfgQSCXML);
			text = QSCXMLHelper.getMiddleChan(text8);
			text9 = QSCXMLHelper.GetTxLinearizerCalParamsList(selBand.tech, selBand.band, selBand.subband, m_cfgQSCXML, QSC_Param_Query.TxLineaizerCalParameterType.PA_State_List);
			text2 = QSCXMLHelper.getFirstElementFromList(text9);
			text10 = QSCXMLHelper.GetTxLinearizerCalParamsList(selBand.tech, selBand.band, selBand.subband, m_cfgQSCXML, QSC_Param_Query.TxLineaizerCalParameterType.Max_Lin_Power_List);
			text3 = QSCXMLHelper.getFirstElementFromList(text10);
			text11 = QSCXMLHelper.GetTxLinearizerCalParamsList(selBand.tech, selBand.band, selBand.subband, m_cfgQSCXML, QSC_Param_Query.TxLineaizerCalParameterType.Min_Lin_Power_List);
			text4 = QSCXMLHelper.getFirstElementFromList(text11);
			text12 = QSCXMLHelper.GetTxLinearizerCalParamsList(selBand.tech, selBand.band, selBand.subband, m_cfgQSCXML, QSC_Param_Query.TxLineaizerCalParameterType.RGI_List);
			string firstElementFromList = QSCXMLHelper.getFirstElementFromList(text12, ';');
			string paramsList = firstElementFromList.Substring(4, firstElementFromList.Length - 5);
			text5 = QSCXMLHelper.getFirstElementFromList(paramsList);
			text13 = QSCXMLHelper.GetTxLinearizerCalParamsList(selBand.tech, selBand.band, selBand.subband, m_cfgQSCXML, QSC_Param_Query.TxLineaizerCalParameterType.Bias_List);
			text6 = QSCXMLHelper.getFirstElementFromList(text13);
			if (text6 == null || text6 == "")
			{
				text6 = "3400";
			}
			text14 = QSCXMLHelper.GetTxLinearizerCalParamsList(selBand.tech, selBand.band, selBand.subband, m_cfgQSCXML, QSC_Param_Query.TxLineaizerCalParameterType.ICQ_List);
			text7 = QSCXMLHelper.getFirstElementFromList(text14);
			if (text7 == null || text7 == "")
			{
				text7 = "127";
			}
		}
		else
		{
			text8 = TechAndBandCombine.GSMBandChanDefaultMap[m_curSelBand.band];
			text = QSCXMLHelper.getMiddleChan(text8);
			text9 = "2";
			text2 = "2";
			text10 = "38";
			text3 = "38";
			text11 = "23";
			text4 = "23";
			text12 = "31";
			text5 = "31";
			text13 = "3400";
			text6 = "3400";
			text14 = "127";
			text7 = "127";
		}
		AccessComponentInThreadHelper.SetText(this, Channel, SetAttribute.Text, text);
		AccessComponentInThreadHelper.SetText(this, State, SetAttribute.Text, text2);
		AccessComponentInThreadHelper.SetText(this, MaxLinPower, SetAttribute.Text, text3);
		AccessComponentInThreadHelper.SetText(this, MinLinPower, SetAttribute.Text, text4);
		AccessComponentInThreadHelper.SetText(this, RGI, SetAttribute.Text, text5);
		AccessComponentInThreadHelper.SetText(this, Bias, SetAttribute.Text, text6);
		AccessComponentInThreadHelper.SetText(this, ICQ, SetAttribute.Text, text7);
		AccessComponentInThreadHelper.SetText(this, Channel, SetAttribute.ToolTip, text8);
		AccessComponentInThreadHelper.SetText(this, State, SetAttribute.ToolTip, text9);
		AccessComponentInThreadHelper.SetText(this, MaxLinPower, SetAttribute.ToolTip, text10);
		AccessComponentInThreadHelper.SetText(this, MinLinPower, SetAttribute.ToolTip, text11);
		AccessComponentInThreadHelper.SetText(this, RGI, SetAttribute.ToolTip, text12);
		AccessComponentInThreadHelper.SetText(this, Bias, SetAttribute.ToolTip, text13);
		AccessComponentInThreadHelper.SetText(this, ICQ, SetAttribute.ToolTip, text14);
		AccessComponentInThreadHelper.SetText(this, txtMeasuredTxPwr, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetColor(this, txtMeasuredTxPwr, SetAttribute.BGColor, UserDefinedColorType.DEFAULT);
	}

	private void JudgeMeasuredPower(double power)
	{
		if (m_TxOverrideParams != null && (m_TxOverrideParams.max_lin_pwr.HasValue || m_TxOverrideParams.min_lin_pwr.HasValue))
		{
			bool flag = false;
			if (m_TxOverrideParams.max_lin_pwr.HasValue && power > m_TxOverrideParams.max_lin_pwr.Value)
			{
				flag = true;
				DebugMessageCB(MessageLevel.FAIL, "The power is above the upper limit");
				AccessComponentInThreadHelper.SetColor(this, txtMeasuredTxPwr, SetAttribute.BGColor, UserDefinedColorType.RED);
			}
			if (m_TxOverrideParams.min_lin_pwr.HasValue && power < m_TxOverrideParams.min_lin_pwr.Value)
			{
				flag = true;
				DebugMessageCB(MessageLevel.FAIL, "The power is below the lower limit");
				AccessComponentInThreadHelper.SetColor(this, txtMeasuredTxPwr, SetAttribute.BGColor, UserDefinedColorType.RED);
			}
			if (!flag)
			{
				AccessComponentInThreadHelper.SetColor(this, txtMeasuredTxPwr, SetAttribute.BGColor, UserDefinedColorType.GREEN);
			}
		}
		else
		{
			AccessComponentInThreadHelper.SetColor(this, txtMeasuredTxPwr, SetAttribute.BGColor, UserDefinedColorType.DEFAULT);
		}
	}

	private void GetTxOverrideParamsFromUI()
	{
		m_TxOverrideParams.reset();
		if (uint.TryParse(AccessComponentInThreadHelper.GetText(this, Channel, SetAttribute.Text), out var result))
		{
			m_TxOverrideParams.ULChannel = result;
		}
		if (uint.TryParse(AccessComponentInThreadHelper.GetText(this, State, SetAttribute.Text), out result))
		{
			m_TxOverrideParams.pa_state = result;
		}
		if (uint.TryParse(AccessComponentInThreadHelper.GetText(this, RGI, SetAttribute.Text), out result))
		{
			m_TxOverrideParams.rgi = result;
		}
		if (uint.TryParse(AccessComponentInThreadHelper.GetText(this, Bias, SetAttribute.Text), out result))
		{
			m_TxOverrideParams.bias = result;
		}
		if (uint.TryParse(AccessComponentInThreadHelper.GetText(this, ICQ, SetAttribute.Text), out result))
		{
			m_TxOverrideParams.icq = result;
		}
		if (double.TryParse(AccessComponentInThreadHelper.GetText(this, MaxLinPower, SetAttribute.Text), out var result2))
		{
			m_TxOverrideParams.max_lin_pwr = result2;
		}
		if (double.TryParse(AccessComponentInThreadHelper.GetText(this, MinLinPower, SetAttribute.Text), out result2))
		{
			m_TxOverrideParams.min_lin_pwr = result2;
		}
		if (double.TryParse(AccessComponentInThreadHelper.GetText(this, txtPathLoss, SetAttribute.Text), out result2))
		{
			m_TxOverrideParams.pathLoss = result2;
		}
	}

	private FTM_RF_Debug_Property_Struct GenTxOverrideReqStruct(bool bEnable)
	{
		FTM_RF_Debug_Property_Struct result = default(FTM_RF_Debug_Property_Struct);
		List<FTM_RF_Debug_Property_Date_Type> ps = new List<FTM_RF_Debug_Property_Date_Type>();
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["Tx Enable"], bEnable ? 1 : 0);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["Path Index"], 0L);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["Signal Path"], QSC_Path_RadioConfig.m_curPath.TxPath.Sig_Path);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["RFM Device"], QSC_Path_RadioConfig.m_curPath.TxPath.RFM_Device);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["Antenna Path"], QSC_Path_RadioConfig.m_curPath.TxPath.Ant_Path);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["XPT Mode"], PropertyValueMap.Tx_Override_XPTMode_Map["APT"]);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["IQ Gain Action Type"], PropertyValueMap.Tx_Override_GainType_Map["Use Sw Default value"]);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["TxFE Gain Action Type"], PropertyValueMap.Tx_Override_GainType_Map["Use Sw Default value"]);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["Env Scale Action Type"], PropertyValueMap.Tx_Override_GainType_Map["Use Sw Default value"]);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["RGI"], m_TxOverrideParams.rgi.Value);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["PA Bias"], m_TxOverrideParams.bias.Value);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["PA State"], m_TxOverrideParams.pa_state.Value);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["PA Current"], m_TxOverrideParams.icq.Value);
		PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["Delat Action Type"], PropertyValueMap.Tx_Override_DelayType_Map["Use Sw Default value"]);
		if (RFPathAndRadioConfiguration.m_platform == Platform.HE)
		{
			PropertyValueMap.AddOnePropertyToList(ref ps, PropertyValueMap.Tx_Override_Property_Type_Map["PLL_ID"], QSC_Path_RadioConfig.m_curPath.TxPath.PLL_ID);
		}
		result.num_properties = (uint)ps.Count;
		result.properties = new FTM_RF_Debug_Property_Date_Type[ps.Count];
		for (int i = 0; i < ps.Count; i++)
		{
			ref FTM_RF_Debug_Property_Date_Type reference = ref result.properties[i];
			reference = ps[i];
		}
		return result;
	}

	private bool DoTxOverride(bool bEnable)
	{
		FTM_RF_Debug_Property_Struct req_struct = GenTxOverrideReqStruct(bEnable);
		FTM_RF_Debug_Property_Struct rsp_struct = default(FTM_RF_Debug_Property_Struct);
		uint error_code = 0u;
		uint specific_err_code = 0u;
		string text = (bEnable ? "Tx Enable" : "Tx Disable");
		if (phone != null)
		{
			try
			{
				phone.FTM_RF_DEBUG_CMD_TX_OVERRIDE(PropertyValueMap.FTM_RF_Debug_Tech_Map[m_curSelBand.tech], ref req_struct, ref rsp_struct, ref error_code, ref specific_err_code);
				if (error_code == 0 && specific_err_code == 0)
				{
					DebugMessageCB(MessageLevel.SUCCESS, "QLIB_FTM_RF_DEBUG_CMD_TX_OVERRIDE " + text + " success");
					return true;
				}
				DebugMessageCB(MessageLevel.FAIL, text + " fail, return error code != 0");
				return false;
			}
			catch (PhoneException ex)
			{
				DebugMessageCB(MessageLevel.EXCEPTION, "PhoneException " + ex.Message);
				return false;
			}
			catch (Exception ex2)
			{
				DebugMessageCB(MessageLevel.EXCEPTION, "Unknown Exception " + ex2.Message);
				return false;
			}
		}
		MessageBox.Show("Invalid phone handle");
		return false;
	}

	private void AddEntry(double Frequency)
	{
		if (pSA == null)
		{
			return;
		}
		string text = AccessComponentInThreadHelper.GetText(this, txtPathLoss, SetAttribute.Text);
		if (string.IsNullOrWhiteSpace(text))
		{
			DebugMessageCB(MessageLevel.FAIL, base.Resources["PathLossCorrection"].ToString());
			return;
		}
		try
		{
			bool flag = false;
			double.TryParse(text, out var result);
			if (pSA.SetPathLoss(Frequency, result, TableName) && result != 0.0)
			{
				DebugMessageCB(MessageLevel.SUCCESS, base.Resources["PathLossApplied"].ToString());
				pSA.SetPathLoss(TableName, "1", "1");
			}
		}
		catch (Exception ex)
		{
			DebugMessageCB(MessageLevel.EXCEPTION, "Unknown exception: " + ex.Message);
		}
	}

	private void SetupTechAndSpan()
	{
		if (m_curSelBand.tech == "LTE")
		{
			pSA.SetupMeasurement(Technology.LTE);
			pSA.SetSpan(10.0);
		}
		else if (m_curSelBand.tech == "WCDMA")
		{
			pSA.SetupMeasurement(Technology.WCDMA);
			pSA.SetSpan(5.0);
		}
		else if (m_curSelBand.tech == "TDSCDMA")
		{
			pSA.SetupMeasurement(Technology.TDSCDMA);
			pSA.SetSpan(5.0);
		}
		else if (m_curSelBand.tech == "CDMA")
		{
			pSA.SetupMeasurement(Technology.CDMA);
			pSA.SetSpan(2.0);
		}
		else if (m_curSelBand.tech == "GSM")
		{
			pSA.SetupMeasurement(Technology.GSM);
			pSA.SetSpan(10.0);
		}
	}

	private void MeasuredBySA()
	{
		ushort iBand = TechAndBandCombine.ChangeToBandHelperBandClass(m_curSelBand.tech, m_curSelBand.band);
		double num = phone.Band_Helper_CalculateULFrequency(iBand, m_TxOverrideParams.ULChannel.Value);
		AddEntry(num);
		pSA.SetCenterFrequency(num);
		double referenceLevel = (m_TxOverrideParams.max_lin_pwr.HasValue ? m_TxOverrideParams.max_lin_pwr.Value : 30.0);
		pSA.SetReferenceLevel(referenceLevel);
		if (m_curSelBand.tech == "GSM")
		{
			pSA.SetTriggerType(TriggerType.IF);
		}
		string power = pSA.GetPower();
		AccessComponentInThreadHelper.SetText(this, txtMeasuredTxPwr, SetAttribute.Text, power);
		JudgeMeasuredPower(double.Parse(power));
	}

	private void RunTxOverrideOn()
	{
		GetTxOverrideParamsFromUI();
		if (m_curSelBand == null || QSC_Path_RadioConfig.m_curPath == null || !m_TxOverrideParams.CheckValid())
		{
			DebugMessageCB(MessageLevel.FAIL, "Invalid params, please check");
			return;
		}
		AccessComponentInThreadHelper.SetEnableOrVisibility(this, TxOn, SetAttribute.IsEnable, bEnableOrVisbile: false);
		AccessComponentInThreadHelper.SetEnableOrVisibility(this, TxOff, SetAttribute.IsEnable, bEnableOrVisbile: true);
		AccessComponentInThreadHelper.SetEnableOrVisibility(this, spPathInfo, SetAttribute.IsEnable, bEnableOrVisbile: false);
		if (QSC_Path_RadioConfig.SetupRadioConfiguration(m_TxOverrideParams.ULChannel.Value, PropertyValueMap.Radio_Cfg_WFM_Value_Map["LTE_PUSCH"], PropertyValueMap.Radio_Cfg_BW_Map["10MHz"], 50, 0, IsTearDown: false) && DoTxOverride(bEnable: true) && m_TxOverrideParams.bCtrlSA && pSA != null)
		{
			SetupTechAndSpan();
			bContinueRunFlag = true;
			while (bContinueRunFlag)
			{
				MeasuredBySA();
				Thread.Sleep(200);
			}
		}
	}

	private void TxOverrideOn_Click(object sender, RoutedEventArgs e)
	{
		AccessComponentInThreadHelper.SetText(this, txtMeasuredTxPwr, SetAttribute.Text, "");
		AccessComponentInThreadHelper.SetColor(this, txtMeasuredTxPwr, SetAttribute.BGColor, UserDefinedColorType.DEFAULT);
		thread = new Thread(RunTxOverrideOn);
		thread.Name = "Meas Tx - QSC";
		thread.Start();
	}

	public void FTM_RF_Tx_QSC_Unloaded(object sender, RoutedEventArgs e)
	{
		bContinueRunFlag = false;
	}

	private void RunTxOverrideOff()
	{
		bContinueRunFlag = false;
		DoTxOverride(bEnable: false);
		Thread.Sleep(1000);
		QSC_Path_RadioConfig.SetupRadioConfiguration(0u, 0, 0, 0, 0, IsTearDown: true);
		AccessComponentInThreadHelper.SetEnableOrVisibility(this, TxOff, SetAttribute.IsEnable, bEnableOrVisbile: false);
		AccessComponentInThreadHelper.SetEnableOrVisibility(this, TxOn, SetAttribute.IsEnable, bEnableOrVisbile: true);
		AccessComponentInThreadHelper.SetEnableOrVisibility(this, spPathInfo, SetAttribute.IsEnable, bEnableOrVisbile: true);
	}

	private void TxOverrideOff_Click(object sender, RoutedEventArgs e)
	{
		thread = new Thread(RunTxOverrideOff);
		thread.Name = "Meas Tx Off - QSC";
		thread.Start();
	}

	private void RefreshSARelatedComponent()
	{
		m_TxOverrideParams.bCtrlSA = AccessComponentInThreadHelper.getIsChecked(this, cbxCtrlSA, SetAttribute.IsChecked);
		if (m_TxOverrideParams.bCtrlSA)
		{
			AccessComponentInThreadHelper.SetEnableOrVisibility(this, spCtrlSAParamsAndResult, SetAttribute.Visibility, bEnableOrVisbile: true);
		}
		else
		{
			AccessComponentInThreadHelper.SetEnableOrVisibility(this, spCtrlSAParamsAndResult, SetAttribute.Visibility, bEnableOrVisbile: false);
		}
	}

	private void SA_Enable_Checked(object sender, RoutedEventArgs e)
	{
		RefreshSARelatedComponent();
	}

	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[DebuggerNonUserCode]
	internal Delegate _CreateDelegate(Type delegateType, string handler)
	{
		return Delegate.CreateDelegate(delegateType, this, handler);
	}
}
