CXTPChartSolidSplinePolygonDeviceCommand::CXTPChartSolidSplinePolygonDeviceCommand(const CXTPChartPoints& points, const CXTPChartColor& color, BOOL bTwoSides)
{
	m_color = color;

	if (!bTwoSides)
	{
		GpPath* pGpPath = 0;
		GdipCreatePath(FillModeAlternate, &pGpPath);
		GdipStartPathFigure(pGpPath);

		int nCount = (int)points.GetSize();

		GdipAddPathLine(pGpPath, points[0].X, points[0].Y, points[1].X, points[1].Y);
		GdipAddPathCurve(pGpPath, (PointF*)points.GetData() + 1, nCount - 2);
		GdipAddPathLine(pGpPath, points[nCount - 2].X, points[nCount - 2].Y, points[nCount - 1].X, points[nCount - 1].Y);

		GdipClosePathFigures(pGpPath);

		m_pGpPath = pGpPath;
	}
	else
	{

		GpPath* pGpPath = 0;
		GdipCreatePath(FillModeAlternate, &pGpPath);
		GdipStartPathFigure(pGpPath);

		int nCount = (int)points.GetSize();

		GdipAddPathCurve(pGpPath, (PointF*)points.GetData(), nCount / 2);
		GdipAddPathLine(pGpPath, points[nCount / 2].X, points[nCount / 2].Y, points[nCount / 2 + 1].X, points[nCount / 2 + 1].Y);

		GdipAddPathCurve(pGpPath, (PointF*)points.GetData() + nCount / 2, nCount / 2);

		GdipAddPathLine(pGpPath, points[nCount - 1].X, points[nCount - 1].Y, points[0].X, points[0].Y);

		GdipClosePathFigures(pGpPath);

		m_pGpPath = pGpPath;

	}
}
CXTPChartClipRegionDeviceCommand::CXTPChartClipRegionDeviceCommand(const CXTPChartPoints& points)
{
	GpPath* pGpPath = NULL;
	GdipCreatePath(FillModeAlternate, &pGpPath);
	GdipAddPathPolygon(pGpPath, (GpPointF*)points.GetData(), (int)points.GetSize());

	m_pGpClip = NULL;
	GdipCreateRegionPath(pGpPath, &m_pGpClip);

	m_pGpState = NULL;
	GdipCreateRegion(&m_pGpState);

	GdipDeletePath(pGpPath);
}