
// SilkModuleDlg.h : 头文件
//

#pragma once
class CUserModule;

//#using std namespace;
//#include <GdiPlusColor.h>
#include "resource.h"
#include "DataType.h"
#include "ThreadBase.h"
#include <map>
#define COLOR_RED	RGB(255, 0, 0)
#define COLOR_GREEN RGB(0, 255, 0)
#define COLOR_BLUE  RGB(0, 0, 255)

#define COLOR_YELLOW  RGB(255, 255, 0)  //黄色
#define COLOR_KATRED  RGB(255, 128, 0)	//橘红
#define COLOR_PINK	  RGB(255, 0, 255)	//粉红
#define COLOR_PURPLE  RGB(128, 0, 128)	//紫色
#define COLOR_CYAN    RGB(0, 255, 255)	//青色
// CSilkModuleDlg 对话框
class CSilkModuleDlg : public CDialog, public CThreadBase, public IResultListener
{
// 构造
public:
	CSilkModuleDlg(CWnd* pParent = NULL);	// 标准构造函数

// 对话框数据
	enum { IDD = IDD_SILKMODULE_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持


// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
	CUserModule *m_pUser;
public:
	afx_msg void OnBnClickedButtonConnect();
	afx_msg void OnBnClickedButtonDisconnect();
	afx_msg void OnBnClickedButtonEnroll();
	afx_msg void OnBnClickedButtonEnrollImage();
	afx_msg void OnBnClickedButtonDeleteAllUser();
	afx_msg void OnBnClickedButtonDeleteAllTem();
	afx_msg void OnBnClickedButtonDeleteDb();
	afx_msg void OnBnClickedButtonScanImage();
	afx_msg void OnBnClickedButtonGetTime();
	afx_msg void OnBnClickedButtonSetTime();
	afx_msg void OnBnClickedButtonReadParam();
	afx_msg void OnBnClickedButtonWriteParam();
	afx_msg void OnBnClickedButtonAddUser();
	afx_msg void OnBnClickedButtonReadUser();
	afx_msg void OnBnClickedButtonLoadUser();
	afx_msg void OnBnClickedButtonEnrollTmp();
	afx_msg void OnBnClickedButtonLoadTmp();
	afx_msg void OnBnClickedButtonDelTmp();
	afx_msg void OnBnClickedButtonSaveParam();
	afx_msg void OnBnClickedButtonDelUser();
	afx_msg void OnBnClickedButtonDelLog();
	afx_msg void OnBnClickedButtonLoadLog();
	afx_msg void OnBnClickedButtonPinVerify();
	afx_msg void OnBnClickedButtonImageVerify();
	afx_msg void OnBnClickedButtonReadTmp();
	afx_msg void OnBnClickedButtonUpdata();
	afx_msg void OnBnClickedButtonScanTem();
private:
	//static bool __stdcall Func(OP_Result result, ITP_OPERATION operation, char *data, int len, void *userData);
	virtual void HeartBeat_Imp();
	virtual void DealOneRequestMsg(CInterProtocl *pITP){};
	virtual void DealOneResponseMsg(CInterProtocl *pITP){};

	virtual void onResult(OP_Result result, ITP_OPERATION operation, char *data, int len, int nParam1=0, int nParam2=0, int nParam3=0);
	HANDLE m_hThread;
private:
	void ShowImage(char *image, int width, int height);
	void UpdataList(CString status, COLORREF color);
	int m_ListIndex;
	RGBQUAD m_GrayTable[256];
	CListCtrl *m_pListState;
	FILE *m_errorFile;
	std::map<ITP_OPERATION, CString> m_mapOp;
	std::map<OP_Result, CString> m_mapRe;
	void WriteErrorFile(OP_Result result, ITP_OPERATION operation, char *data, int len, int nParam1=0, int nParam2=0, int nParam3=0);
public:
	afx_msg void OnNMCustomdrawListStatus(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnBnClickedButtonReset();
};
