Entwickler-Ecke

Multimedia / Grafik - DrawPolygon


Bernd95028 - Di 07.02.06 15:45
Titel: DrawPolygon
Hallo,

folgendes Problem: Ich brauche ein Sechseckiges Polygon, das durch Buttoaufruf gezeichnet wird und bei bestimmten Ereignissen eingefärbt werden kann. Meines Erachtens nach müsste dass mit der DrawPolygon und der FillPolygon-Methode machbar sein. Nur wie? Mein Quellcode ist bis dato folgender:

C#-Quelltext
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:
public void DrawPolygonPoint(PaintEventArgs e)
{
//eckolinx/y: die ecke oben links(x/y)
    int eckolinx = 30;
    int eckoliny = 30;
    // Erstelle den Stift
    Pen blackPen = new Pen(Color.Black, 3);
             
    // definiere die Eckpunkte
    Point point1 = new Point(eckolinx,eckoliny);
    Point point2 = new Point(eckolinx + 10, eckoliny);
    Point point3 = new Point(eckolinx + 20, eckoliny - 10);
    Point point4 = new Point(eckolinx + 10, eckoliny - 20);
    Point point5 = new Point(eckolinx  ,eckoliny - 20);
    Point point6 = new Point(eckolinx - 10 , eckoliny - 10 );
    Point[] curvePoints =
             {
                 point1,
                 point2,
                 point3,
                 point4,
                 point5,
                 point6,
             }
    ;             
    // zeichne das Polygon
    e.Graphics.DrawPolygon(blackPen, curvePoints);
}
        private void button2_Click(object sender, EventArgs e)
        {
            DrawPolygonPoint();
        }
               
    }


Nur welche Parameter übergebe ich der DrawPolygonPoint-Methode, also welche DrawEventArgs?

Danke im Voraus, auch wenn die Frage für manche vielleicht arg nach Anfänger klingt;-)

Moderiert von user profile iconGausi: Beitragsformatierung überarbeitet.
Moderiert von user profile iconGausi: Topic aus Job Börse verschoben am Di 07.02.2006 um 15:19


Christian S. - Do 09.02.06 19:52

Hallo!

Du brauchst diese EventArgs eigentlich gar nicht, sondern nur das Graphics-Objekt, in welches Du zeichnen willst. Daher die Frage: Wo soll das Polygon den gezeichnet werden?

Grüße
Christian


Bernd95028 - Di 07.03.06 18:04

Upps, hat sich erledigt, danke.