//---------------------------------------------------------------------------

#ifndef MicSetFormUnitH
#define MicSetFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ComCtrls.hpp>
#include <Vcl.ExtCtrls.hpp>

#include "GeneralDialogPanel.h"
#include "GlobalUnit.h"
#include "CapButton.h"
#include "ComboBoxComponent.h"
#include "MessageDef.h"
#include "SkinTrackBar.h"
#include "TextButton.h"
#include "CKBox.h"
#include "MenuUnit.h"
#include "RadioBtn.h"


typedef struct tagDeviceInfo{
	int iDevice;
	char name[256];	// description
	DWORD flags;

	tagDeviceInfo(){
		memset( this, 0, sizeof(tagDeviceInfo) );
	}

	tagDeviceInfo( tagDeviceInfo* src ){
		memcpy( this, src, sizeof(tagDeviceInfo) );
	}
} IO_DEVICE_INFO;

//---------------------------------------------------------------------------
class TMicSetForm : public TForm
{
__published:	// IDE-managed Components
	TGeneralDialogPanel *m_panGeneral;
	TLabel *m_lblVolume;
	TLabel *m_lblPlayback;
	TLabel *m_lblInput;
	TLabel *m_lblLatencyTime;
	TLabel *m_lblHint;
	TLabel *m_lblHintMsg;
	TLabel *m_lblLatency;
	TComboBoxComponent *m_cbPlayDev;
	TComboBoxComponent *m_cbOutput;
	TComboBoxComponent *m_cbRecDev;
	TComboBoxComponent *m_cbInput;
	TTextButton *m_btnOk;
	TTextButton *m_btnCanel;
	TCKBox *m_ckAuto;
	TCKBox *m_ckMoniter;
	TSkinTrackBar *m_tbVolume;
	TLabel *m_lblOutput;
	TLabel *m_lblASIO;
	TLabel *m_lblRecord;
	TLabel *m_lblType;
	TRadioBtn *m_rbCommon;
	TRadioBtn *m_rbASIO;
	TRadioBtn *m_rbWASAPI;
	TCKBox *m_ckMIDI;

	void __fastcall VolumeChange(TObject *Sender);
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall OkClick(TObject *Sender);
	void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
	void __fastcall AutoChange(TObject *Sender);
	void __fastcall MoniterChange(TObject *Sender);
	void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
	void __fastcall PlayDevChange(TComboBoxItem *Sender, int Index);
	void __fastcall InputChange(TComboBoxItem *Sender, int Index);
	void __fastcall OutputChange(TComboBoxItem *Sender, int Index);
	void __fastcall RecDevChange(TComboBoxItem *Sender, int Index);
	void __fastcall MIDIInputClick(TObject *Sender);
	void __fastcall DevTypeClick(TObject *Sender);
	void __fastcall ASIOClick(TObject *Sender);


private:	// User declarations
	TTimer *m_pTimerLatency;	//Timer

	TMenuPanel *m_PopupMenu;          //弹出菜单

	int m_iCurrPlaybackDevice, m_iCurrOutput,
		m_iCurrRecordDevice, m_iCurrInput;
	vector<IO_DEVICE_INFO*> m_aCommonPb, m_aCommonRc,
						m_aWasapiPb, m_aWasapiRc,
						m_aAsioPb, m_aMidiRc;

	void ReloadPlayDev();
	void ReloadRecDev();
	void ReloadOutput();
	void ReloadInput();
	void BeginRecordTest(bool bStart=true);
	void ShowErrorMessage( int err );

	void __fastcall DoShowPanel(TObject* Sender);
	void __fastcall DoRestart(TObject* Sender);
	void __fastcall LatencyTimerProc(TObject* Sender);         //Timer回调函数
	void __fastcall PanelClick(String Sender,int PanelType,int MenuType);

	MESSAGE void __fastcall UMRecordVolJust(TMessage &Message);
	BEGIN_MESSAGE_MAP
		MESSAGE_HANDLER(MSG_RECORD_VOLJUST, TMessage, UMRecordVolJust)
	END_MESSAGE_MAP(TForm)

public:		// User declarations

	__fastcall TMicSetForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMicSetForm *MicSetForm;
//---------------------------------------------------------------------------
#endif
