void drawTriangle(Trojkat toBeDrawn) { Point A = new Point((int)toBeDrawn.corA.X, (int)toBeDrawn.corA.Y); Point B = new Point((int)toBeDrawn.corB.X, (int)toBeDrawn.corB.Y); Point C = new Point((int)toBeDrawn.corC.X, (int)toBeDrawn.corC.Y); graphics.DrawLine(thePen, A, B); graphics.DrawLine(thePen, B, C); graphics.DrawLine(thePen, C, A); }
private void addButton_Click(object sender, EventArgs e) { switch (typeCombo.SelectedIndex) { case 0: { uint xVal, yVal; if (uint.TryParse(xBox.Text, out xVal) && uint.TryParse(yBox.Text, out yVal)) { Punkt tmp = new Punkt(xVal, yVal); objectEntries.Add(tmp); } break; } case 1: { uint xVal, yVal, radius; if (uint.TryParse(xBox.Text, out xVal) && uint.TryParse(yBox.Text, out yVal) && uint.TryParse(radiusBox.Text, out radius)) { Okrag tmp = new Okrag(new Punkt(xVal, yVal), radius); objectEntries.Add(tmp); } break; } case 2: { List <Punkt> triangleData = trianglePrompt.ShowDialog("Input coordinates for triangle: ", "Triangle creation.", canvasWidth, canvasHeight); if (triangleData != null) { Trojkat tmp = new Trojkat(triangleData[0], triangleData[1], triangleData[2]); objectEntries.Add(tmp); } break; } case 3: { List <Punkt> polygonData = polygonPrompt.ShowDialog("Input coordinates for polygon: ", "Polygon creation.", canvasWidth, canvasHeight); if (polygonData != null) { Wielobok tmp = new Wielobok(polygonData); MessageBox.Show(tmp.Info()); objectEntries.Add(tmp); } break; } } canvas.Refresh(); }