📄 ellipse.cpp
字号:
// Ellipse.cpp: implementation of the CEllipse class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyDraw.h"
#include "Ellipse.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#include "EllipseProperties.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//IMPLEMENT_DYNAMIC(CEllipse,CObject)
IMPLEMENT_SERIAL(CEllipse,CObject,1)
CEllipse::CEllipse()
{
}
CEllipse::~CEllipse()
{
}
void CEllipse::Serialize(CArchive & ar)
{
CObject::Serialize(ar);
if(ar.IsLoading())
{
ar>>startX>>startY>>endX>>endY>>
MyPen.lopnWidth.x>>MyPen.lopnColor>>MyPen.lopnStyle>>
MyBrush.lbColor>>MyBrush.lbHatch>>MyBrush.lbStyle;
}
else
{
ar<<startX<<startY<<endX<<endY<<MyPen.lopnWidth.x<<
MyPen.lopnColor<<MyPen.lopnStyle<<
MyBrush.lbColor<<MyBrush.lbHatch<<MyBrush.lbStyle;
}
}
void CEllipse::ShowProperties()
{
CEllipseProperties EllipseDlg;
CString str_LineWidth;
str_LineWidth.Format("%d",this->MyPen.lopnWidth.x);
EllipseDlg.m_LineWidth=str_LineWidth;
if (this->MyPen.lopnStyle==PS_DASH)
EllipseDlg.m_LineStyle="虚线";
else if (this->MyPen.lopnStyle==PS_DOT)
EllipseDlg.m_LineStyle="点线";
else if(this->MyPen.lopnStyle==PS_DASHDOT)
EllipseDlg.m_LineStyle="点划线";
else
EllipseDlg.m_LineStyle="实线";
EllipseDlg.m_LineColor=this->MyPen.lopnColor;
EllipseDlg.m_BrushColor=this->MyBrush.lbColor;
if(this->MyBrush.lbHatch==HS_BDIAGONAL)
EllipseDlg.m_HatchStyle= "HS_BDIAGONAL";
else if(this->MyBrush.lbHatch==HS_CROSS)
EllipseDlg.m_HatchStyle= "HS_CROSS";
else if(this->MyBrush.lbHatch==HS_DIAGCROSS)
EllipseDlg.m_HatchStyle= "HS_DIAGCROSS";
else if(this->MyBrush.lbHatch==HS_FDIAGONAL)
EllipseDlg.m_HatchStyle= "HS_FDIAGONAL";
else if(this->MyBrush.lbHatch==HS_HORIZONTAL)
EllipseDlg.m_HatchStyle= "HS_HORIZONTAL";
else
EllipseDlg.m_HatchStyle= "HS_VERTICAL";
if(this->MyBrush.lbStyle==BS_HATCHED)
EllipseDlg.m_BrushStyle= "BS_HATCHED";
else if(this->MyBrush.lbStyle==BS_NULL)
EllipseDlg.m_BrushStyle= "BS_NULL";
else
EllipseDlg.m_BrushStyle= "BS_SOLID";
if (EllipseDlg.DoModal()==IDOK)
{
this->MyPen.lopnWidth.x=atoi(EllipseDlg.m_LineWidth);
if (EllipseDlg.m_LineStyle=="虚线")
this->MyPen.lopnStyle=PS_DASH;
else if (EllipseDlg.m_LineStyle=="点线")
this->MyPen.lopnStyle=PS_DOT;
else if(EllipseDlg.m_LineStyle=="点划线")
this->MyPen.lopnStyle=PS_DASHDOT;
else
this->MyPen.lopnStyle=PS_SOLID;
this->MyPen.lopnColor=EllipseDlg.m_LineColor;
this->MyBrush.lbColor=EllipseDlg.m_BrushColor;
if(EllipseDlg.m_HatchStyle== "HS_BDIAGONAL")
this->MyBrush.lbHatch=HS_BDIAGONAL;
else if(EllipseDlg.m_HatchStyle== "HS_CROSS")
this->MyBrush.lbHatch=HS_CROSS;
else if(EllipseDlg.m_HatchStyle== "HS_DIAGCROSS")
this->MyBrush.lbHatch=HS_DIAGCROSS;
else if(EllipseDlg.m_HatchStyle== "HS_FDIAGONAL")
this->MyBrush.lbHatch=HS_FDIAGONAL;
else if(EllipseDlg.m_HatchStyle== "HS_HORIZONTAL")
this->MyBrush.lbHatch=HS_HORIZONTAL;
else
this->MyBrush.lbHatch=HS_VERTICAL;
if(EllipseDlg.m_BrushStyle=="BS_HATCHED")
this->MyBrush.lbStyle=BS_HATCHED;
else if(EllipseDlg.m_BrushStyle=="BS_NULL")
this->MyBrush.lbStyle=BS_NULL;
else
this->MyBrush.lbStyle=BS_SOLID;
}
}
void CEllipse::Draw(CDC *pDC)
{
CPen cMyPen;
CPen* pOldPen;
cMyPen.CreatePenIndirect(&this->MyPen);
pOldPen=pDC->SelectObject(&cMyPen);
CBrush cMyBrush;
CBrush* pOldBrush;
cMyBrush.CreateBrushIndirect(&this->MyBrush);
pOldBrush=pDC->SelectObject(&cMyBrush);
pDC->Ellipse(this->startX,this->startY,this->endX,this->endY);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -