📄 arc.cpp
字号:
// Arc.cpp: implementation of the CArc class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyDraw.h"
#include "Arc.h"
#include "LineProperties.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CArc,CObject,1)
CArc::CArc()
{
Direction=0;
}
CArc::~CArc()
{
}
void CArc::Serialize(CArchive & ar)
{
CObject::Serialize(ar);
if(ar.IsLoading())
{
ar>>startX>>startY>>endX>>endY>>Direction>>
MyPen.lopnWidth.x>>MyPen.lopnColor>>MyPen.lopnStyle;
}
else
{
ar<<startX<<startY<<endX<<endY<<Direction<<
MyPen.lopnWidth.x<<MyPen.lopnColor<<MyPen.lopnStyle;
}
}
void CArc::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 CArc::Draw(CDC *pDC)
{
CPen cMyPen;
CPen* pOldPen;
cMyPen.CreatePenIndirect(&this->MyPen);
pOldPen=pDC->SelectObject(&cMyPen);
if(this->Direction)
{
pDC->Arc(this->startX,this->startY,this->endX,this->endY,
this->startX,this->startY,this->endX,this->endY);
}
else
{
pDC->Arc(this->endX,this->endY,this->startX,this->startY,
this->endX,this->endY,this->startX,this->startY);
}
pDC->SelectObject(pOldPen);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -