ellipse (mfc, Object.cpp)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "stdafx.h"
#include "Objects.h"
//#include "afxwin.h"
Objects::Objects(void)
{
amount = 0;
for(int i(0); i != MAX; ++i)
{
m_height[i] = 0;
m_width[i] = 0;
m_xcenter[i] = 0;
m_ycenter[i] = 0;
Color[i] = RGB(62,48,158);
}
}
Objects::~Objects(void)
{
}
void Objects::DrawDraft(CDC* pDc)
{
/*CBrush Brush, Wheel, Wind;
Wheel.CreateSolidBrush(RGB(150,97,61));
Wind.CreateSolidBrush(RGB(219,230,23));
Brush.CreateSolidBrush(Color);
pDc->SelectObject(Brush);
*/
CRect Rect[MAX];
CBrush Brush[MAX];
for(int i(0); i != amount; ++i)
{
Brush[i].CreateSolidBrush(Color[i]);
pDc->SelectObject(Brush[i]);
Rect[i].left = m_xcenter[i] - 100 - m_width[i];
Rect[i].top = m_ycenter[i] - 50 - m_height[i];
Rect[i].right = m_xcenter[i] + 100 + m_width[i];
Rect[i].bottom = m_ycenter[i] + 50 + m_height[i];
pDc->RoundRect(Rect[i], CPoint(17, 17));
DeleteObject(Brush[i]);
}
//Dc.SelectObject(Wheel);
//Dc.Ellipse(Rect.left + 20 - m_width, Rect.bottom - 20 - m_height, Rect.left + 60 + m_width, Rect.bottom + 20 + m_height);
//Dc.Ellipse(WheelL);
//Dc.Ellipse(x + 50 - m_width, y + 15 - m_height, x + 80 + m_width, y + 45 + m_height);
//Dc.SelectObject(Wind);
/*Rect.left = x - 10 - m_width;
Rect.top = y - 20 - m_height;
Rect.right = x + 10 + m_width;
Rect.bottom = y + m_height;
Dc.RoundRect(Rect, CPoint(17, 17));
Rect.left = x - 50 - m_width;
Rect.right = x - 30 - m_width;
Dc.RoundRect(Rect, CPoint(17, 17));
Rect.left = x + 30 + m_width;
Rect.right = x + 50 + m_width;
Dc.RoundRect(Rect, CPoint(17, 17));
*/
//DeleteObject(Brush);
//DeleteObject(Wheel);
//DeleteObject(Wind);
}
void Objects::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << amount;
for(int i(0); i!= amount; ++i)
ar << m_xcenter[i] << m_ycenter[i] << m_width[i] << m_height[i] << Color[i];
}
else
{
ar >> amount;
for(int i(0); i!= amount; ++i)
ar >> m_xcenter[i] >> m_ycenter[i] >> m_width[i] >> m_height[i] >> Color[i];
}
}