Condividi tramite


Metodo GraphicsPathIterator::NextSubpath(INT*,INT*,BOOL*) (gdipluspath.h)

Il metodo GraphicsPathIterator::NextSubpath ottiene l'indice iniziale e l'indice finale del sottopercorso successivo (figura) nel percorso associato di questo iteratore.

Sintassi

INT NextSubpath(
  INT  *startIndex,
  INT  *endIndex,
  BOOL *isClosed
);

Parametri

startIndex

Puntatore a un INT che riceve l'indice iniziale.

endIndex

Puntatore a un INT che riceve l'indice finale.

isClosed

Puntatore a un valore BOOL che riceve un valore che indica se la figura ottenuta è chiusa. Se la figura è chiusa, il valore ricevuto è TRUE; in caso contrario, il valore ricevuto è FALSE.

Valore restituito

Questo metodo restituisce il numero di punti dati nella figura successiva. Se nel percorso non sono presenti più cifre, questo metodo restituisce 0.

Commenti

La prima volta che si chiama il metodo GraphicsPathIterator::NextSubpath di un iteratore, ottiene gli indici per la prima figura (sottopercorso) del percorso associato dell'iteratore. La seconda volta ottiene gli indici per la seconda figura e così via. Ogni volta che si chiama GraphicsPathIterator::NextSubpath, viene restituito il numero di punti dati nella figura i cui indici sono stati recuperati. Quando non ci sono cifre rimanenti, restituisce 0.

Esempio

Nell'esempio seguente viene creato un oggetto GraphicsPath e vengono aggiunte cinque figure al percorso. Il codice passa l'indirizzo dell'oggetto GraphicsPath a un costruttore GraphicsPathIterator per creare un iteratore associato al percorso. Il codice chiama il metodo GraphicsPathIterator::NextSubpath dell'iteratore tre volte per ottenere l'indice iniziale e l'indice finale della terza figura del percorso. Il codice chiama quindi il metodo GraphicsPathIterator::CopyData dell'iteratore per recuperare i punti dati della terza figura.

VOID NextSubpathExample2(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a graphics path with five figures (subpaths).
   GraphicsPath path;

   path.AddRectangle(Rect(20, 20, 60, 30));   // Subpath count is 1.

   path.AddLine(100, 20, 160, 50);            // Subpath count is 2.
   path.AddArc(180, 20, 60, 30, 0.0f, 180.0f);

   path.AddRectangle(Rect(260, 20, 60, 30));  // Subpath count is 3.

   path.AddLine(340, 20, 400, 50);            // Subpath count is 4.
   path.AddArc(340, 20, 60, 30, 0.0f, 180.0f);
   path.CloseFigure();
  
   path.AddRectangle(Rect(420, 20, 60, 30));  // Subpath count is 5.

   // Create an iterator, and associate it with the path.
   GraphicsPathIterator iterator(&path);

   // Call NextSubpath three times to get the starting and ending
   // indices for the third figure.
   INT start;
   INT end;
   BOOL isClosed;
   INT count;
   count = iterator.NextSubpath(&start, &end, &isClosed);
   count = iterator.NextSubpath(&start, &end, &isClosed);
   count = iterator.NextSubpath(&start, &end, &isClosed);

   // Get the third figure's data points.
   PointF* points = new PointF[count];
   BYTE* types = new BYTE[count];
   iterator.CopyData(points, types, start, end);

   // Draw the third figure's data points.
   SolidBrush brush(Color(255, 255, 0, 0));
   for(INT j = 0; j < count; ++j)
      graphics.FillEllipse(
         &brush,
         points[j].X - 3.0f,
         points[j].Y - 3.0f,
         6.0f,
         6.0f);

   delete points;
   delete types;
}

Requisiti

   
Intestazione gdipluspath.h

Vedi anche

Costruzione e creazione di percorsi

GraphicsPath::GetPathData

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::CopyData

GraphicsPathIterator::GetSubpathCount

Metodi GraphicsPathIterator::NextMarker

NextSubpath

Percorsi