// EProDlg.h : header file
//

#if !defined(AFX_EPRODLG_H__E4AA3AE9_EEE2_11D7_A019_9806402060C0__INCLUDED_)
#define AFX_EPRODLG_H__E4AA3AE9_EEE2_11D7_A019_9806402060C0__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "IndicButton.h"
#include "Pro.h"
#include "CustomItems.h"
#include "TextProgressCtrl.h"
#include "HotKeyDialog.h"
/////////////////////////////////////////////////////////////////////////////
// CEProDlg dialog
#define Version "Easy Pro 2.0"

BOOL __declspec(dllexport)__stdcall  AddHotkey(HWND,UCHAR key,UCHAR mask);
BOOL __declspec(dllexport)__stdcall  DeleteHotkey(HWND,UCHAR key,UCHAR mask);

struct InfoSave
{
	int m_nProType;
	int m_nSerialPort;
	int m_nBaudSel;
	int m_nIspSpd;
	BOOL m_bDetectBegin;
	BOOL m_bSound;
	BOOL m_bHotKey;
	BOOL m_bAutoOpenFile;
	BOOL m_bAutoErase;
	BOOL m_bAutoWrite;
	BOOL m_bAutoRead;
	BOOL m_bAutoCheck;
	BOOL m_nChipSel;
	BYTE m_byteKey;
	BYTE m_byteMask;
};

class CEProDlg : public CDialog
{
// Construction
public:
	void SetIspSpd(int nSpdSel);
	int GetIspSpd();
	static UINT BeepErrorThread(LPVOID Param);
	static UINT BeepOkThread(LPVOID Param);
	void BeepOk();
	void BeepError();
	void EnableHotKey(BOOL bEn);
	int m_nMsg;
	BOOL CheckData();
	BOOL m_bCheck;
	int m_nWrCount;
	BOOL m_bWorkDetectPro;
	BOOL m_bWorkOpenFile;
	BOOL m_bWorkDetectChip;
	BOOL m_bWorkErase;
	BOOL m_bWorkWrite;
	BOOL m_bWorkRead;
	BOOL m_bWorkCheck;
	BOOL m_bAutoWork;
	
	CFile	m_fileOpen;
	CFile	m_fileSave;
	CString m_strOpenFile,m_strOpenFileExt;
	BOOL OpenFile();

	void EnableCtrl(BOOL bEn);
	void WorkProc(BOOL bWork,BOOL bBeep=TRUE);
	CArray<ChipType*,ChipType*> m_arChips; 
	void SaveInfoSave();
	void ShowMsg(CString strMsg);
	void LoadInfoSave();
	InfoSave m_InfoSave;
	void SetPortSel(int nPortSel);
	int GetPortSel();
	void SetBaudSel(int nBaudSel);
	int GetBaudSel();
	void SetProType(int nProType);
	int GetProType();	

	CXTPropertyGridItem* m_pProSetting;
	CXTPropertyGridItem* m_pSelPro;
	CXTItemConstraints* m_pProList;
	CXTPropertyGridItem* m_pSelPort;
	CXTItemConstraints* m_pPortList;	
	CXTPropertyGridItem* m_pSelBaud;
	CXTItemConstraints* m_pBaudList;
	CXTPropertyGridItem* m_pSelIspSpd;
	CXTItemConstraints* m_pIspSpdList;
	
	CXTPropertyGridItem* m_pSysSetting;
	CXTPropertyGridItem* m_pDetectBegin;	
	CXTPropertyGridItem* m_pSound;
	CXTPropertyGridItem* m_pHotKey;

	int m_nProType;
	int m_nBaudSel;
	int m_nPortSel;
	int m_nIspSpd;
	int m_nWndSel;
	BOOL m_bDetectBegin;
	BOOL m_bSound;
	BOOL m_bHotKey;
	BYTE m_byteKey;
	BYTE m_byteMask;
	CPro m_Pro;
	void SelWnd(int nSel);
	void InitInterface();
	CEProDlg(CWnd* pParent = NULL);	// standard constructor
	CXTPropertyGrid m_Grid;
// Dialog Data
	//{{AFX_DATA(CEProDlg)
	enum { IDD = IDD_EPRO_DIALOG };
	CTextProgressCtrl	m_Progress;
	CListBox	m_listMsg;
	CXTHexEdit	m_editBuf2;
	CXTHexEdit	m_editBuf1;
	CXTTabCtrl		m_Tab;
	CXTHyperLink	m_hlChips;
	CXTFlatComboBox	m_comboLockBits;
	CXTFlatComboBox	m_comboChipType;
	CIndicButton	m_btLock;
	CIndicButton	m_btDetectChip;
	CIndicButton	m_btWrite;
	CIndicButton	m_btSaveFile;
	CIndicButton	m_btRead;
	CIndicButton	m_btOpenFile;
	CIndicButton	m_btErase;
	CIndicButton	m_btCheck;
	CIndicButton	m_btAuto;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CEProDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CEProDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	virtual void OnCancel();
	virtual void OnOK();
	afx_msg	UINT OnTabSelChange(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnGridNotify(WPARAM, LPARAM);
	afx_msg	UINT OnProMsg(WPARAM dwMsg,LPARAM dwMsg2);
	afx_msg void OnButtonOpenfile();
	afx_msg void OnButtonChipdetect();
	afx_msg void OnButtonSavefile();
	afx_msg void OnButtonErase();
	afx_msg void OnButtonWrite();
	afx_msg void OnButtonRead();
	afx_msg void OnButtonCheck();
	afx_msg void OnButtonAuto();
	afx_msg void OnButtonLock();
	afx_msg void OnChips();
	afx_msg void OnDestroy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_EPRODLG_H__E4AA3AE9_EEE2_11D7_A019_9806402060C0__INCLUDED_)
