// CDrawPoly.cpp : 구현 파일입니다.
//

#include "stdafx.h"
#include "paint.h"
#include "paintDoc.h"
#include "DrawPoly.h"
#include "paintView.h"

// CDrawPoly

IMPLEMENT_DYNCREATE(CDrawPoly, CData)

CDrawPoly::CDrawPoly()
{
	m_bFirst = TRUE;
	m_bLbuttonDown = FALSE;
	m_penRGB = RGB(0,0,0);
	m_brush = RGB(255,255,255);
	m_nCount = 0;
	for(int i = 0; i<MAX_POLY;i++)
	{
		m_ptData[i]=0;
	}
	
}
CDrawPoly::~CDrawPoly()
{
}

BEGIN_MESSAGE_MAP(CDrawPoly, CData)
END_MESSAGE_MAP()


// CDrawPoly 그리기입니다.

void CDrawPoly::OnDraw(CDC *pDC)
{

		pDC->Polyline(m_ptData,m_nCount);

} 
	

void CDrawPoly::Serialize(CArchive &ar)
{
	ar << POLYLINE;
	// save class data	
	ar << m_Dtype;
	ar << m_ptStartPt;
	ar << m_ptPoly;
	ar << m_nlineCnt;
	ar << m_penRGB;
	ar << m_LineSize;
	ar << m_bFirst;

		for (int i=0; i<MAX_POLY;i++)
		{
			ar << m_ptData[i];
		}
		
}//Serialize()

void CDrawPoly::Deserialize(CArchive &ar)
{
	CPoint point;
	ar >> m_Dtype;
	ar >> m_ptStartPt;
	ar >> m_ptPoly;
	ar >> m_nlineCnt;
	ar >> m_penRGB;
	ar >> m_LineSize;
	ar >> m_bFirst;


		for (int i =0; i<MAX_POLY;i++)
		{
			ar>>m_ptData[i];
		}

}//Serialize()


void CDrawPoly::OnLBDN(CPoint point)
{
	if (m_bFirst)
	{
			m_ptStartPt = m_ptPoly = 0;
			m_bFirst = TRUE;
			m_nCount = 0;
			for(int i = 0; i<MAX_POLY;i++)
			{
				m_ptData[i]=0;
			}
//			Invalidate(TRUE);
	}
	
	if(m_bFirst)
	{
		m_bFirst = FALSE;
	}
	m_ptStartPt = m_ptPoly = point;
	m_ptData[m_nCount] = point;
	m_nCount++;
}
void CDrawPoly::OnLBMV(CPoint point)
{	
	


}
void CDrawPoly::OnLBDC(CPoint point )
{
	if(m_bFirst)
	{
		m_ptData[m_nCount]=point;
		m_nCount++;
		m_bFirst = TRUE;
		ReleaseCapture();
		::ClipCursor(NULL);
		Invalidate();
	}	
}


void CDrawPoly::Attri(int m_LineSize2)
{
	m_LineSize = m_LineSize2;
}

void CDrawPoly::m_RGB(COLORREF m_penRGB2,COLORREF m_brush2)
{
	m_penRGB = m_penRGB2;
	m_brush = m_brush2;
}

