// Rule.h: interface for the CMyRule class.
//
//////////////////////////////////////////////////////////////////////
#include "VSNETStructDef.h"

#if !defined(AFX_RULE_H__8820FCE3_138E_4E60_8103_922826F192BD__INCLUDED_)
#define AFX_RULE_H__8820FCE3_138E_4E60_8103_922826F192BD__INCLUDED_

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

typedef enum
{
    RULE_TYPE_SINGLELINE = 0,           /*  单线规则     */
    RULE_TYPE_DOUBLELINE,               /*  双线规则     */
    RULE_TYPE_REGION                    /*  区域规则     */
};

typedef enum
{
    LINE_DRC_LEFT        = 0,           /* 单线向左     */
    LINE_DRC_RIGHT,                     /* 单线向右     */
    LINE_DRC_DOUBLE,                    /* 单线两个方向 */
};

typedef enum
{
    REGION_DRC_ENTER     = 0,
    REGION_DRC_EXIT,
    REGION_DRC_HORVER,
};
typedef enum
{
    STATE_NONE           = 0,
    STATE_NEAR,
    STATE_SELECT
};

typedef VSNETVADOUBLELINERULE DBLineAlarm;
typedef VSNETVAMULTILINERULE  MlLineAlarm;
typedef VSNETVAREGIONERULE    RegionAlarm;
typedef VSNETVASINGLELINERULE SGLineAlarm;

class CMyRulesStatic;
class CMyRule  
{
public:
	CMyRule();
	virtual ~CMyRule();
public:
    int         m_ruleType;                      // 规则类型
	CString     m_ruleTypeName;                  // 规则类型名称
	CString     m_ruleName;                      // 规则名称
	BOOL        m_bEnable;                       // 是否启用规则
public:
	virtual void DrawRule(CDC* pDC, CMyRulesStatic* pWnd) = 0;
    virtual void MoveRule(int offset_x, int offset_y) = 0;
};

typedef enum
{
    SINGLELINE_HOTPOINT_NONE  = 0,
    SINGLELINE_HOTPOINT_BEGIN,
    SINGLELINE_HOTPOINT_END
};
class CSingleLineRule : public CMyRule
{
public:
    CSingleLineRule();
    CSingleLineRule(CSingleLineRule* pCopyRule);
    virtual ~CSingleLineRule();

public:
    SGLineAlarm         m_Rule;
    BOOL                m_bMultiSegment;
    CSingleLineRule*    m_pNextLine;
    CSingleLineRule*    m_pHotPointLine;
    int                 m_hotPoint;
    BOOL                m_bInitDraw;
	BOOL                m_bFinish;
public:
	void             FinishDraw();
	void             Reset();
    void             SetRule(VSNETVAMULTILINERULE* pRule);
	void             SetRule(VSNETVASINGLELINERULE* pRule);
	void             CheckMultiLineRule(BOOL bCheck);
	int              GetLineCount();
	CSingleLineRule* GetLastSegment();
	void             SetDirection(int direction);
	BOOL             CheckHotPoint(CPoint point);
	void             EditSingleLineRule(int offset_x, int offset_y, int editActionType);
	virtual void     DrawRule(CDC* pDC, CMyRulesStatic* pWnd);
    virtual void     MoveRule(int offset_x, int offset_y);
};

class CDoubleLineRule : public CMyRule
{
public:
    CDoubleLineRule();
    virtual ~CDoubleLineRule();

public:
    DBLineAlarm     m_Rule;
public:
	void SetRule(VSNETVADOUBLELINERULE *pRule);
	virtual void DrawRule(CDC* pDC, CMyRulesStatic* pWnd);
    virtual void MoveRule(int offset_x, int offset_y);
};

class CRegionRule : public CMyRule
{
public:
    CRegionRule(int regionDrc);
    virtual ~CRegionRule();

public:
    RegionAlarm     m_Rule;
    int             m_regionDrc;
    CRgn            m_rgn;
public:
	void         GetRuleFromRgn(UINT* pDst);
	void         CreateRgnFromRule();
	void         SetRule(VSNETVAREGIONERULE *pRule);
	void         AddPolygon(LPPOINT lpPoint,int nCount);
	void         AddRect(LPCRECT lpRect);
	void         CleanAllRegion();
	void         DelRegion(LPCRECT lpRect);
	void         AddRegion(LPCRECT lpRect);
	virtual void DrawRule(CDC* pDC, CMyRulesStatic* pWnd);
    virtual void MoveRule(int offset_x, int offset_y);
};
#endif // !defined(AFX_RULE_H__8820FCE3_138E_4E60_8103_922826F192BD__INCLUDED_)
