Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        void drawPolygon(Wielobok toBeDrawn)
        {
            uint pointsAmount = (uint)toBeDrawn.points.Count();

            Point[] pointArray = new Point[pointsAmount];

            for (int i = 0; i < pointsAmount; ++i)
            {
                pointArray[i].X = (int)toBeDrawn.points[i].X;
                pointArray[i].Y = (int)toBeDrawn.points[i].Y;
            }
            graphics.DrawPolygon(thePen, pointArray);
        }