// PSATDlg.h : header file
//

#if !defined(AFX_PSATDLG_H__F1247B04_6CC5_4584_8973_5B6CC65D7A5D__INCLUDED_)
#define AFX_PSATDLG_H__F1247B04_6CC5_4584_8973_5B6CC65D7A5D__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CPSATDlg dialog

#define WINDOW_POSITION_SET 1
#include "Math.h"

class CPSATDlg : public CDialog
{
// Construction
public:
	CPSATDlg(CWnd* pParent = NULL);	// standard constructor
	CString ImportKeyValue( CString strPath, int nFlag, BOOL bFlag = FALSE );
	BOOL ConnectServer();
	void SendData( KPacket* pData );
	void SocketClose();
	int	KMessageBox( CString strMessage, CString strTitle, UINT nType = MB_OK );

	void SetAllResourceHide();
	void SetAllResourceEmpty();
	
	void SearchPathDirectory();
	void SearchPathFile();
	void SearchPathRegDirectory();
	void SearchPathRegFile();

	void KeyMakingDlgMake();
	void KeyMakingDlgDestory();

	void ReportRegister( CString strKey, CString strContents );
	void ReportList( CString strKey );
	void ReportRemove( unsigned int nId );

	void ReplyRegister( CString strKey, CString strContents );
	void ReplyList( CString strKey );
	void ReplyRemove( unsigned int nId );

	void ProcessJoinMemberAck( KJoinMemberAck* pPacket );
	void ProcessLoginAck( KLoginAck* pPacket ); 
	void ProcessVerificationAck( KVerificationAck* pPacket ); 
	void ProcessProgramRegisterAck( KProgramRegisterAck* pPacket ); 
	void ProcessReportList( KReportListPacket* pPacket ); 
	void ProcessReportRegisterAck( KReportRegisterAck* pPacket ); 
	void ProcessReportRemoveAck( KReportRemoveAck* pPacket );
	void ProcessReplytList( KReplyListPacket* pPacket ); 
	void ProcessReplyRegisterAck( KReplyRegisterAck* pPacket );
	void ProcessReplyRemoveAck( KReplyRemoveAck* pPacket );

	void DrawBackground ( CDC* pDC );
	void DrawReliability ( CDC* pDC );
	int MyRound( double i );

// Dialog Data
//	CRect			mk_OrgMsie;
//	CRect			mk_OrgMain;
	char*			m_pCursor;
	CPoint			m_ptWindowMove;
	CPoint			m_ptWindowPosition;
	int				m_nMouseState;

	int				m_nSubBackgroundState;
	int				m_nPaintState;
	int				m_nMemberReliability;
	int				m_nGuestReliability;
	int				m_nTotalReliability;

	COLORREF		m_rgbGuestProgressStart;
	COLORREF		m_rgbUserProgressStart;

	CRect			m_rtTitleBar;
	CRect			m_rtTooltip;
	CPPToolTip 		m_cTooltip;
	BOOL			m_bTooltipView;

	CLoginDlg		m_cLoginDlg;
	CKeyMakingDlg	m_cKeyMakingDlg;
	CReplyListDlg	m_cReplyListDlg; 
	CReportListDlg	m_cReportListDlg; 
	CClientSocket	m_cClientSocket;
	CCheckSoftware	m_cChecker;
	CCheckReliability m_cReliabilityCheck;

	HWND			m_pHwnd;
	BOOL			m_bLoginCheck; 
	BOOL			m_bLogining;
	TCITEM			m_tabControlItem1;
	TCITEM			m_tabControlItem2;
	CString			m_strLoginId; 
	CString			m_strLoginPassword; 
	CString			m_strProgramKey; 
	CString			m_strPrevPath;
	CString	m_strProgram;
	CString	m_strCompany;
	CString	m_strVersion;
	CString	m_strAddContent;

	KLoginPacket	m_LoginPacket;
	KPacket*		m_pWaitPacket;

	BOOL			m_bWaitLoginPacket;

	CBitmap			m_bmBackground;
	CBitmap			m_bmSubBackHome;
	CBitmap			m_bmSubBackVertification;
	CBitmap			m_bmSubBackRegister;
	CBitmap			m_bmReliabilityCount[10];
	CBitmap			m_bmReliabilityBar[3];
	//{{AFX_DATA(CPSATDlg)
	enum { IDD = IDD_PSAT_DIALOG };
	CStatic	m_staticMemberPer;
	CStatic	m_staticGuestPer;
	CStatic	m_staticMemberState;
	CStatic	m_staticGuestState;
	YButton	m_btnLogout;
	YButton	m_btnLogin;
	YButton	m_btnMinimam;
	YButton	m_btnExit;
	YButton	m_btnMainMenuRegister;
	YButton	m_btnMainMenuVertification;
	YButton	m_btnMainMenuHome;
	YButton	m_btnInfomation;
	YButton	m_btnRegSearchPath;
	YButton	m_btnReg;
	YButton	m_btnRewrite;
	CComboBox	m_cbRegFileDirectory;
	CEdit	m_edtRegPath;
	CEdit	m_edtRegProgram;
	CEdit	m_edtRegCompany;
	CEdit	m_edtRegVersion;
	CEdit	m_edtRegAddContent;
	CString	m_strRegPath;
	CString	m_strRegAddContent;
	CString	m_strRegCompany;
	CString	m_strRegProgram;
	CString	m_strRegVersion;
	YButton	m_btnCheck;
	YButton	m_btnReport;
	YButton	m_btnSearchPath;
	YButton	m_btnViewReply;
	YButton	m_btnViewReport;
	CComboBox	m_cbFileDirectory;
	CEdit	m_edtFilePath;
	CEdit	m_edtProgram;
	CEdit	m_edtCompany;
	CEdit	m_edtVersion;
	CEdit	m_edtAddContent;
	CString	m_strFilePath;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPSATDlg)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL
//	CHtmlView* adsf;
// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CPSATDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	virtual void OnCancel();
	afx_msg void OnButtonLogin();
	afx_msg void OnButtonRewrite();
	afx_msg void OnButtonReg();
	afx_msg void OnButtonCheck();
	afx_msg void OnClose();
	afx_msg void OnButtonReport();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnButtonSearchPath();
	afx_msg void OnButtonRegSearchPath();
	afx_msg void OnButtonViewReply();
	afx_msg void OnButtonMenuHome();
	afx_msg void OnButtonMenuRegister();
	afx_msg void OnButtonMenuVertification();
	afx_msg void OnButtonLogout();
	afx_msg void OnButtonExit();
	afx_msg void OnButtonMinimam();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnButtonInfo();
	afx_msg void OnButtonViewReport();
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	//}}AFX_MSG
	afx_msg LONG OnSocketReceivedData ( UINT wParam , LONG lParam );
	afx_msg long OnSocketConnected ( WPARAM wParam , LPARAM lParam );
	afx_msg long OnSocketDisconnected ( WPARAM wParam , LPARAM lParam );
	afx_msg void OnReceivedKeyProgress( WPARAM wParam , LPARAM lParam );
	afx_msg void OnOtherDlgReceivedData (WPARAM wParam, LPARAM lParam );

	DECLARE_MESSAGE_MAP()
};

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

#endif // !defined(AFX_PSATDLG_H__F1247B04_6CC5_4584_8973_5B6CC65D7A5D__INCLUDED_)
