示例#1
0
        private void scanLineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool   b = true;
            String id;

            if (lvPoligonos.SelectedItems.Count > 0)
            {
                ColorDialog colorPicker = new ColorDialog();

                id = lvPoligonos.SelectedItems[0].Text;
                if (colorPicker.ShowDialog() == DialogResult.OK)
                {
                    corpintura = colorPicker.Color;
                    for (int i = 0; i < poligonos.Count && b; i++)
                    {
                        if (id.Equals(poligonos[i].getId().ToString()))
                        {
                            FiltroM.scanLine(poligonos[i], corpintura, this.b);
                            pbsegmentos.Image = this.b;
                            b = false;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Selecione um Polígono!", "Nenhum Polígono Selecionado", MessageBoxButtons.OK);
            }
        }
示例#2
0
 private void pbsegmentos_Click(object sender, EventArgs e)
 {
     if (modoseg.Equals("po"))
     {
         if (x1 == 0 && y1 == 0)
         {
             polatual = new Poligono(idpol++);
             x1       = (e as MouseEventArgs).X;
             y1       = (e as MouseEventArgs).Y;
             polatual.addAtuais(new Ponto(x1, y1));
             polatual.addOriginais(new Ponto(x2, y2));
             x1pol = x1;
             y1pol = y1;
         }
         else
         {
             x1 = x2;
             y1 = y2;
             if (Math.Abs(x2 - x1pol) < 10 && Math.Abs(y2 - y1pol) < 10)
             {
                 x1 = 0;
                 y1 = 0;
                 poligonos.Add(polatual);
                 lvPoligonos.Items.Add(polatual.getId().ToString());
                 ctrlZ(b);
             }
             else
             {
                 polatual.addAtuais(new Ponto(x2, y2));
                 polatual.addOriginais(new Ponto(x2, y2));
             }
         }
         aux = b;
     }
     else if (modoseg.Equals("fo"))
     {
         pbsegmentos.Cursor = Cursors.Cross;
         FiltroM.floodFill((e as MouseEventArgs).X, (e as MouseEventArgs).Y, corpintura, b);
         pbsegmentos.Image = b;
         modoseg           = "";
     }
 }
示例#3
0
        private void pbsegmentos_MouseMove(object sender, MouseEventArgs e)
        {
            x2 = e.X;
            y2 = e.Y;
            b  = (Bitmap)aux.Clone();

            double dx = x2 - x1;
            double dy = y2 - y1;

            if (x1 != 0 && y1 != 0 && modoseg.Equals("po"))
            {
                bresenham(dx, dy, b);
            }
            else if (mstatus)
            {
                switch (modoseg)
                {
                case "er":
                    if (dx != 0)
                    {
                        double m = dy / dx;

                        if (x1 < x2)
                        {
                            FiltroV.EqGeralRetaQ1(m, x1, y1, dx, b, 1);
                        }
                        else
                        {
                            dx *= -1;
                            FiltroV.EqGeralRetaQ1(m, x1, y1, dx, b, -1);
                        }
                        if (y1 < y2)
                        {
                            FiltroV.EqGeralRetaQ2(m, x1, y1, dy, b, 1);
                        }
                        else
                        {
                            dy *= -1;
                            FiltroV.EqGeralRetaQ2(m, x1, y1, dy, b, -1);
                        }
                        pbsegmentos.Image = b;
                    }
                    break;

                case "dr":
                    if (dx != 0)
                    {
                        if (x1 > x2)
                        {
                            FiltroM.retaDda(b, x2, x1, y2, y1, Color.Black);
                        }
                        else
                        {
                            FiltroM.retaDda(b, x1, x2, y1, y2, Color.Black);
                        }
                        pbsegmentos.Image = b;
                    }
                    break;

                case "br":
                    bresenham(dx, dy, b);
                    break;

                case "ec":
                    FiltroC.EqGeralCircunferencia(x1, y1, x2, y2, b);
                    pbsegmentos.Image = b;
                    break;

                case "tr":
                    FiltroM.circTrigonometria(x1, y1, x2, y2, b);
                    pbsegmentos.Image = b;
                    break;

                case "pm":
                    FiltroM.circPontomedio(x1, y1, x2, y2, b);
                    pbsegmentos.Image = b;
                    break;

                case "el":
                    FiltroM.elipse(Math.Abs(x2 - x1), Math.Abs(y2 - y1), x1, y1, b);
                    pbsegmentos.Image = b;
                    break;
                }
            }
        }