예제 #1
0
        public MainForm()
        {
            InitializeComponent();
            ManagerDraw = new ManagerDraw(pbCanvas, pbLineColor, pbCutterColor, pbCuttedLine);
            Cutter      = new Cutter();

            ManagerDraw.Cutter.Points.Add(new Point(200, 400));
            ManagerDraw.Cutter.Points.Add(new Point(200, 100));
            ManagerDraw.Cutter.Points.Add(new Point(400, 400));
            ManagerDraw.DrawCutter();

            /*var l = new Line();
             * l.Pen = ManagerDraw.PenLine;
             * l.A = new Point(500, 400);
             * l.B = l.A;//new Point(300, 100);
             * ManagerDraw.Lines.Add(l);
             *
             * l = new Line();
             * l.Pen = ManagerDraw.PenLine;
             * l.A = new Point(300, 400);
             * l.B = l.A;//new Point(100, 100);
             * ManagerDraw.Lines.Add(l);
             *
             * ManagerDraw.DrawLines();*/
        }
예제 #2
0
        private void pbCanvas_Click(object sender, EventArgs e)
        {
            Point mousePos = pbCanvas.PointToClient(MousePosition);

            if (checkBoxPolygon.Checked)
            {
                if (((MouseEventArgs)e).Button == MouseButtons.Left)
                {
                    ManagerDraw.InputPolygon(mousePos, ModifierKeys == Keys.Shift);
                }
                else if (((MouseEventArgs)e).Button == MouseButtons.Right)
                {
                    ManagerDraw.ClosePolygon();
                }
            }
            else
            {
                if (((MouseEventArgs)e).Button == MouseButtons.Left)
                {
                    ManagerDraw.InputCutter(mousePos, ModifierKeys == Keys.Shift);
                }
                else if (((MouseEventArgs)e).Button == MouseButtons.Right)
                {
                    ManagerDraw.CloseCutter();
                }
            }
        }
예제 #3
0
        public MainForm()
        {
            InitializeComponent();
            ManagerDraw = new ManagerDraw(pbCanvas, pbLineColor, pbCutterColor, pbCuttedLine);
            Cutter      = new Cutter();

            ManagerDraw.Cutter.Points.Add(new Point(100, 200));
            ManagerDraw.Cutter.Points.Add(new Point(100, 400));
            ManagerDraw.Cutter.Points.Add(new Point(600, 400));
            ManagerDraw.Cutter.Points.Add(new Point(600, 200));
            ManagerDraw.DrawCutter();

            ManagerDraw.Polygon.Points.Add(new Point(86, 122));
            ManagerDraw.Polygon.Points.Add(new Point(13, 250));
            ManagerDraw.Polygon.Points.Add(new Point(144, 152));

            /*ManagerDraw.Polygon.Points.Add(new Point(258, 278));
            *  ManagerDraw.Polygon.Points.Add(new Point(193, 116));
            *  ManagerDraw.Polygon.Points.Add(new Point(284, 66));
            *  ManagerDraw.Polygon.Points.Add(new Point(620, 87));
            *  ManagerDraw.Polygon.Points.Add(new Point(730, 258));
            *  ManagerDraw.Polygon.Points.Add(new Point(600, 237));
            *  ManagerDraw.Polygon.Points.Add(new Point(599, 201));
            *  ManagerDraw.Polygon.Points.Add(new Point(340, 201));
            *  ManagerDraw.Polygon.Points.Add(new Point(288, 136));*/
            ManagerDraw.DrawPolygon();
        }
예제 #4
0
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            Point mousePos = Canvas.PointToClient(MousePosition);

            if (IsInputVertHorLine())
            {
                mousePos = ManagerDraw.GetPointHorVertLine(mousePos);
            }

            ManagerDraw.DrawMovingEdge(mousePos);
        }
예제 #5
0
        private void pbCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            Point mousePos = pbCanvas.PointToClient(MousePosition);

            if (ManagerDraw.IsInputCutter)
            {
                ManagerDraw.DrawMovingCutter(mousePos, ModifierKeys == Keys.Shift);
            }
            else if (ManagerDraw.IsInputLine)
            {
                ManagerDraw.DrawMovingLine(mousePos, ModifierKeys == Keys.Shift);
            }
        }
예제 #6
0
        private void pbCanvas_Click(object sender, EventArgs e)
        {
            Point mousePos = pbCanvas.PointToClient(MousePosition);

            if (((MouseEventArgs)e).Button == MouseButtons.Left)
            {
                ManagerDraw.InputLine(mousePos, ModifierKeys == Keys.Shift);
            }

            else if (((MouseEventArgs)e).Button == MouseButtons.Right)
            {
                ManagerDraw.InputCutter(mousePos);
            }
        }
예제 #7
0
        private void btnCut_Click(object sender, EventArgs e)
        {
            Cutter.SetAB(ManagerDraw.Cutter.A, ManagerDraw.Cutter.B);
            ManagerDraw.DrawCutter();

            foreach (var line in ManagerDraw.Lines)
            {
                var points = Cutter.Cut(line.A, line.B);
                if (points != null)
                {
                    ManagerDraw.DrawCuttedLine(points[0], points[1]);
                }
            }
            pbCanvas.Refresh();
        }
예제 #8
0
        private void Cut()
        {
            try
            {
                Cutter.Points = new List <Point>(ManagerDraw.Cutter);

                foreach (var line in ManagerDraw.Lines)
                {
                    var points = Cutter.Cut(line.A, line.B);
                    if (points != null)
                    {
                        ManagerDraw.DrawCuttedLine(points[0], points[1]);
                    }
                }
            }
            catch (NoConvexCutterException e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #9
0
        private void Cut()
        {
            try
            {
                Cutter.Points = new List <Point>(ManagerDraw.Cutter);

                var points = Cutter.Cut(ManagerDraw.Polygon.Points);
                if (points != null)
                {
                    for (int i = 1; i < points.Count(); i++)
                    {
                        ManagerDraw.DrawCuttedLine(points[i - 1], points[i]);
                    }

                    ManagerDraw.DrawCuttedLine(points.Last(), points.First());
                }
            }
            catch (NoConvexCutterException e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #10
0
        private void Canvas_Click(object sender, EventArgs e)
        {
            Point mousePos = Canvas.PointToClient(MousePosition);

            if (((MouseEventArgs)e).Button == MouseButtons.Left)
            {
                if (IsInputVertHorLine())
                {
                    ManagerDraw.AddHorVertLinePolygon(mousePos);
                }

                else if (isInputSeed())
                {
                    ManagerDraw.ClearCanvas();
                    ManagerDraw.DrawPolygons();
                    if (numericUpDownDelay.Value != 0)
                    {
                        FillingSeed.FillAreaWithDelay(ManagerDraw.Canvas, ManagerDraw.PenFill.Color, ManagerDraw.PenEdges.Color, mousePos, Canvas, (int)numericUpDownDelay.Value);
                    }
                    else
                    {
                        FillingSeed.FillArea(ManagerDraw.Canvas, ManagerDraw.PenFill.Color, ManagerDraw.PenEdges.Color, mousePos);
                    }
                    Canvas.Refresh();
                }
                else
                {
                    ManagerDraw.AddPointPolygon(mousePos);
                }
            }

            if (((MouseEventArgs)e).Button == MouseButtons.Right)
            {
                ManagerDraw.ClosePolygon();
            }
        }
예제 #11
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     ManagerDraw.ClearPolygons();
 }
예제 #12
0
 public MainForm()
 {
     InitializeComponent();
     ManagerDraw = new ManagerDraw(Canvas, pictureBoxFillColor);
     FillingSeed = new LineSeedAlgorithm();
 }
예제 #13
0
 private void btnCut_Click(object sender, EventArgs e)
 {
     ManagerDraw.DrawCutter();
     Cut();
     pbCanvas.Refresh();
 }
예제 #14
0
 public MainForm()
 {
     InitializeComponent();
     ManagerDraw = new ManagerDraw(pbCanvas, pbLineColor, pbCutterColor, pbCuttedLine);
     Cutter      = new CutterCohenSutherland();
 }