#if !defined(AFX_DLGRULESET_H__82D6DEE9_735A_4160_8B6B_8CC09F8942E5__INCLUDED_)
#define AFX_DLGRULESET_H__82D6DEE9_735A_4160_8B6B_8CC09F8942E5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgRuleSet.h : header file
//
#include "RulesBackgroundStatic.h"
#include "VSNETStructDef.h"
#include "DlgWizardFirst.h"
#include "XListCtrl/XListCtrl.h"
/////////////////////////////////////////////////////////////////////////////
// CDlgSmartBasicSet dialog

typedef enum
{
	    LINERULE = 0    ,
		REGIONINRULE    ,
		REGIONOUTRULE   ,
		REGIONHOVERRULE ,
		THINGLEAVEDRULE ,
		THINGMOVERULE   ,
		THINGSTEALEDRULE,
		ILLEGALPARKRULE ,
		NUMCOUNTRULE  
};

typedef struct TYPEPOS 
{
	int ruletype;
	int pos;
}RULETYPEPOS;//规则类型及其位置

typedef enum
{
	ADDRULE = 0 ,
    DELTULE     ,
	COPYRULE    ,
    EDITRULE  
};//添加、删除、复制、编辑一条规则

class CDlgSmartBasicSet : public CDialog
{
// Construction
public:
	void * m_pRule;
	CMutex m_mutex;
	CDlgSmartBasicSet(CWnd* pParent = NULL);   // standard constructor
    BOOL SaveParamToServer();
	int  GetRuleCounts(CString ruleType);
	int  GetCurCopyNum(CString copyedrulename, int index);
	void GetAllowedAddRules(BYTE* allowedrules, int index = -1);
	BOOL GetPreventState(TIMELIST timelist);
	void SetBtnState(BOOL bAllowedOperate = TRUE);
	BOOL GetOperateState();
	BOOL GetCurEditRule();
	BOOL SaveAllParam();
	void UpdataModify();
	void CreateList();
	BOOL IsRuleNameSame(CString temp);
	void GetRulesStartState(BOOL icurstate = FALSE);
	BOOL CompareModify();
	void SetRulesEnableModify();
	void ShowRuleContents();
	void SetState();
	// Dialog Data
	//{{AFX_DATA(CDlgSmartBasicSet)
	enum { IDD = IDD_DLG_SMABSISET };
	CSliderCtrl	m_tracksensi;
	CXListCtrl	m_myrulelist;
	CSliderCtrl	m_hSliderLineWidth;
	CToolTipCtrl    m_toolTip;
	CMyRulesStatic	m_rulesStatic; 
	CTreeCtrl       m_ruletree;
	UINT            m_prevItemID;
	UINT	m_object_max_area;
	UINT	m_object_min_area;
	int		m_tracktype;
	//}}AFX_DATA
	CImageList      m_hImageList;
public:
	CDlgWizardFirst* m_dlgWizardFirst;//向导第一步
	int  m_ioperatestate;             //当前操作0:增加规则,1:删除规则,2:复制规则,3:编辑规则
	int  m_proselectline;             //刷新列表前选中的规则
	RULETYPEPOS m_cureditrule;        //当前选中规则的索引，如果ruletype = -1 为无此规则 
	VSNETSMREGIONINOUT m_regionInRule;
	VSNETSMREGIONINOUT m_regionOutRule;
	VSNETSMREGIONHOVER m_regionHoverRule;
	VSNETSMALARMLINES  m_singleRules;
	BYTE m_allowedrules[9];          //允许增加的规则
    CPtrArray m_ptrsetways;          //向导对话框指针数组
	BYTE m_preRuleStartFlags[20];    //先前规则启用标志集合
	BYTE m_curRuleStartFlags[20];    //当前规则启用标志集合
	CRect m_prodlgpos;               //向导框拖动后的位置

	CString	m_sername;
	CString	m_url;
	int		m_port;
	CString	m_password;
	CString	m_username;
public:
	void        Stop();
    void        OnEditBtnClicked(int nBtnID);
	void        OnObjectMaxAreaChange(int areaVal);
	void        OnObjectMinAreaChange(int areaVal);
	void        AddRule(int index,CMyRule* pRule);
	void        ChangeSelRule(int index,BOOL bRegionMsk = FALSE);
	BOOL        LoadRulesSettings(); 
	BOOL        LoadVAParam();
	int         GetTypeByName(CString ruleName);
	CString     GetNameByType(int ruleType);
	HTREEITEM	FindRootItem(CTreeCtrl& tree,CString ItemText);
	int         GetChildItemCount(CTreeCtrl& tree,HTREEITEM root);
	BOOL        IsAllChildCheck(CTreeCtrl& tree,HTREEITEM root);
	void        DeleteChildItem(CTreeCtrl& tree,HTREEITEM root);
	BOOL        IsRootItem(CTreeCtrl& tree,HTREEITEM hItem);
	void        UpdateRuleIndex(CTreeCtrl& tree,HTREEITEM hItem,int index = 0);
	void        UpdateRuleIndex(CTreeCtrl& tree,int index = 0);
	void        ChangeBtnStatus(HTREEITEM hItem);
	BOOL        GetRuleInfo();
	void	    InitialRuleList();
	void        GetRuleInfobyIndex(int index,RULETYPEPOS& ruletypepos);
	void        OperateRules(int operatortype,RULETYPEPOS& ruletypepos, CString typerulename = _T(""));
	BOOL        SetCopyedRuleName(int index, CString& curcopyedname);
	BOOL		LoadTrackType();  // 检测类型
	BOOL		SaveTrackType();
	BOOL		LoadTrackSensitivity(); // 检测灵敏度
	BOOL		SaveTrackSensitivity();
	void		SetServerParam(CString sername, CString url, WORD port, CString user, CString psw)
	{
		m_sername = sername;
		m_url = url;
		m_port = port;
		m_username = user;
		m_password = psw;
		m_rulesStatic.SetCameraLinkParam(sername,url,0,port,user,psw);
	}
protected:
	BOOL        m_bIsEditStatus;
	CEdit       *m_pEditTree;
    CString     m_szAlarmMsg;
	BOOL        m_bShowAlarmMsg;
	HICON       m_hIcon;

    HICON       m_hIcon_single_left;
    HICON       m_hIcon_single_right;
    HICON       m_hIcon_single_double;

    HICON       m_hIcon_multi_left;
    HICON       m_hIcon_multi_right;
    HICON       m_hIcon_multi_double;

    HICON       m_hIcon_region_fill;
    HICON       m_hIcon_region_pencil;
    HICON       m_hIcon_region_line;
    HICON       m_hIcon_region_erase;
    HICON       m_hIcon_region_rect;
    HICON       m_hIcon_region_cleanall;

    HICON       m_hIcon_select;
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDlgSmartBasicSet)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CDlgSmartBasicSet)
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	virtual void OnCancel();
	afx_msg void OnBtnNewRule();
	afx_msg void OnBtnDelRule();
	afx_msg void OnBtnCopyRule();
	afx_msg void OnBtnApplay();  
	afx_msg void OnBtnGetrule();
	afx_msg void OnBtnSetShieldMsk();
	afx_msg void OnBtnGetvaparam();
	afx_msg void OnBtnSetvaparam();
	afx_msg void OnCustomdrawSliderLineWidth(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSelchangedRuleTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnClickRuleTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnRClickRuleTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBeginEditRuleTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEndEditRuleTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEditTreeLabel();
	afx_msg void OnBtnHighpara();
	afx_msg void OnBtnTure();
	afx_msg void OnBtnCancel();
	afx_msg void OnPaint();
	afx_msg void OnDestroy();
	afx_msg void OnClickListRules(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBtnEndset();
	afx_msg void OnBtnGet();
	afx_msg void OnDelAllWizardDlg(WPARAM,LPARAM);
	afx_msg void OnBtnSave();
	afx_msg void OnCustomdrawSliderSensi(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnRadioAll();
	afx_msg void OnRadioCar();
	afx_msg void OnRadioPerson();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
	void BtnNewRule(int index = -1);
};

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

#endif // !defined(AFX_DLGRULESET_H__82D6DEE9_735A_4160_8B6B_8CC09F8942E5__INCLUDED_)
