UCanCode
Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database
workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!
"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"
|
GDI Example:
Add
and Draw US flag with E-XD++, five
star shape
|
With E-XD++
you can create any diagram
quickly and easily, for example,
if you want to create a new diagram
like below, E-XD++ will be the best component
to build and UML Diagram Drawing
Tool:
It is tested
on Visual Studio 6.0, Visual
Studio.net 2013 and Visual Studio.net 2022.
Example
codes as below:
CFORectShape *CTestMDIView::AddRect(CRect rc)
{
CFORectShape *pRect = new CFORectShape;
pRect->AddRef();
pRect->Create(rc, "");
pRect->UpdateComp();
GetCurrentModel()->GetShapes()->AddTail(pRect);
pRect->Release();
return pRect;
}
CFOFiveStarShape *CTestMDIView::AddStar(CRect rc)
{
CFOFiveStarShape *pStar = new CFOFiveStarShape;
pStar->AddRef();
pStar->Create(rc, "");
pStar->UpdateComp();
GetCurrentModel()->GetShapes()->AddTail(pStar);
pStar->Release();
return pStar;
}
#define SIN72 0.95106
#define COS72 0.30902
#define SIN144 0.58779
#define COS144 -0.80902
#define STARSIZE 0.67 // scale factor for the size of the stars
void CTestMDIView::GenUSFlag(RECT * pRect)
{
int x0 = pRect->left;
int y0 = pRect->top;
int x1 = pRect->right;
int y1 = pRect->bottom;
int cx = x1 - x0;
int cy = y1 - y0;
int i, j, x, y, xx, yy;
int cxStarBox, cyStarBox;
CRect rc(x0, y0, x1 + 1, y1 + 1);
AddRect(rc);
// Draw the seven red stripes.
for (i = 0; i < 13; i++)
{
if ((i & 1) == 0)
{
rc = CRect(x0,
y0 + (i * cy) / 13,
x1 + 1,
y0 + ((i + 1) * cy) / 13 + 1);
CFORectShape *pRectShape = AddRect(rc);
pRectShape->SetBkColor(RGB(255,0,0));
}
}
// Draw blue box.
// Size it so that it covers two fifths of the flag length and
// the top seven stripes vertically.
cxStarBox = (2 * cx) / 5;
cyStarBox = (7 * cy) / 13 + 1;
rc = CRect(x0,
y0,
x0 + cxStarBox,
y0 + cyStarBox);
CFORectShape *pRectShape = AddRect(rc);
pRectShape->SetBkColor(RGB(0, 0, 128));
// Shrink the blue box rect a bit to give some border around the stars.
x0 += cxStarBox / 25;
y0 += cyStarBox / 25;
cxStarBox *= 23;
cxStarBox /= 25;
cyStarBox *= 23;
cyStarBox /= 25;
y = y0;
// Now, divide the box into a grid of 11 x 9 squares and place a star
// in every other square, like on a checker board.
for (j = 1; j <= 9; j++)
{
yy = y0 + (j * cyStarBox) / 9;
x = x0;
for (i = 1; i <= 11; i++)
{
xx = x0 + (i * cxStarBox) / 11;
// Determine 'black' or 'white' square status by checking to see
// if the sum of 'i' and 'j' is odd or even.
// This ensures that the square colors of each row are always
// staggered regardless of whether there is an odd or even number
// of squares in each row.
if (((i + j) & 1) == 0)
{
// Get the width and height of the current square.
int w = xx - x;
int h = yy - y;
// Use the smaller of the two (width or height) as a basis
// for the radius of the star.
double r = (w < h) ? (double)w * STARSIZE : (double)h * STARSIZE;
// Find the center of the current square.
int centerX = (x + xx) / 2;
int centerY = (y + yy) / 2;
POINT pts[5];
// Calculate the actual points for the stars by rotating the
// radius around the center point using the pre-computed
// sines & cosines.
pts[0].x = centerX;
pts[0].y = centerY - (int)(r);
pts[1].x = centerX + (int)(r * SIN144);
pts[1].y = centerY - (int)(r * COS144);
pts[2].x = centerX - (int)(r * SIN72);
pts[2].y = centerY - (int)(r * COS72);
pts[3].x = centerX + (int)(r * SIN72);
pts[3].y = pts[2].y;
pts[4].x = centerX - (int)(r * SIN144);
pts[4].y = pts[1].y;
rc = CFODrawHelper::GetBoundRect(pts, 5);
// Finally, draw the filled polygon.
AddStar(rc);
}
x = xx;
}
y = yy;
}
}
void CTestMDIView::OnInitialUpdate()
{
SetCurrentModel(GetDocument()->m_pDataModel);
CFODrawView::OnInitialUpdate();
CRect rc = GetCurrentModel()->GetPagePosition();
rc.bottom = rc.right;
rc.DeflateRect(20,20,20,20);
// AddRect(rc);
GenUSFlag(&rc);
}
|