Exemple #1
0
        private void CanvasDrawPolygonEnd(PointF MouseLocate)
        {
            if (DrawCutter)
            {
                if (CurrentCutter.Count() > 2)
                {
                    CanvasDrawLine(CurrentCutter.GetPeak(0), MouseLocate, CutterColor);

                    CutterExists = true;

                    CurrentCutter.ConvexCheck();
                    ButtonPolygonDrawEnabled();
                }
            }
            else
            {
                if (CurrentPolygon.Count() > 2)
                {
                    CanvasDrawLine(CurrentPolygon.GetPeak(0), MouseLocate, PolygonColor);

                    CurrentPolygon.AddPeak(CurrentPolygon.GetPeak(0));

                    if (CurrentCutter.IsConvex())
                    {
                        Pen     PolygonPen = new Pen(ResultColor, 3);
                        Polygon Result     = CurrentCutter.CutPolygon(CurrentPolygon);
                        Canvas.DrawPolygon(PolygonPen, Result.ToArray());
                    }
                    else
                    {
                        MessageBox.Show("Отсекатель должен быть выпуклым", "Ошибка", MessageBoxButtons.OK);
                    }
                }
            }
        }
Exemple #2
0
        // Отсечение
        private void buttonCut_Click(object sender, EventArgs e)
        {
            cutter.Finish();
            g.DrawLine(pen_cutter, cutter.GetVertex(0), cutter.GetVertex(-1));
            if (!cutter.IsConvex())
            {
                MessageBox.Show("Многоугольник не выпуклый.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <PointF> tmp = cutter.CutSutherlandHodgman(polygon);

            if (checkBoxFill.Checked)
            {
                g.FillPolygon(Brushes.Blue, tmp.ToArray());
            }
            g.DrawPolygon(pen_highlight, tmp.ToArray());

            canvasBase.Refresh();
        }