⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 line.cpp

📁 数据库开发
💻 CPP
字号:
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MyDraw.h"
#include "Line.h"
#include "LineProperties.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//IMPLEMENT_DYNAMIC(CLine,CObject)
IMPLEMENT_SERIAL(CLine,CObject,1)

CLine::CLine()
{
}

CLine::~CLine()
{
	
}

void CLine::Serialize(CArchive & ar)
{
	CObject::Serialize(ar);
    if(ar.IsLoading())
    {
		ar>>startX>>startY>>endX>>endY>>MyPen.lopnWidth.x
			>>MyPen.lopnColor>>MyPen.lopnStyle;
    }
	else
	{
        ar<<startX<<startY<<endX<<endY<<MyPen.lopnWidth.x
			<<MyPen.lopnColor<<MyPen.lopnStyle;
    }
}

void CLine::ShowProperties()
{
	CLineProperties LineDlg;
	CString str_LineWidth;
	str_LineWidth.Format("%d",this->MyPen.lopnWidth.x);
	LineDlg.m_LineWidth=str_LineWidth; 
	
	if (this->MyPen.lopnStyle==PS_DASH)
		LineDlg.m_LineStyle="虚线";
	else if (this->MyPen.lopnStyle==PS_DOT)
		LineDlg.m_LineStyle="点线";
	else if(this->MyPen.lopnStyle==PS_DASHDOT)
		LineDlg.m_LineStyle="点划线";
	else
		LineDlg.m_LineStyle="实线";
	
	LineDlg.m_LineColor=this->MyPen.lopnColor;  
	if (LineDlg.DoModal()==IDOK)
	{
		this->MyPen.lopnWidth.x=atoi(LineDlg.m_LineWidth);
		
		if (LineDlg.m_LineStyle=="虚线")
			this->MyPen.lopnStyle=PS_DASH;
		else if (LineDlg.m_LineStyle=="点线")
			this->MyPen.lopnStyle=PS_DOT;
		else if(LineDlg.m_LineStyle=="点划线")
			this->MyPen.lopnStyle=PS_DASHDOT;
		else
			this->MyPen.lopnStyle=PS_SOLID;
		
		this->MyPen.lopnColor=LineDlg.m_LineColor;  
	}
}

void CLine::Draw(CDC *pDC)
{
	CPen cMyPen;
	CPen* pOldPen;
	cMyPen.CreatePenIndirect(&this->MyPen);
	
	pOldPen=pDC->SelectObject(&cMyPen);
	pDC->MoveTo(this->startX,this->startY); 
	pDC->LineTo(this->endX,this->endY); 	
	pDC->SelectObject(pOldPen);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -