Esempio n. 1
0
        private void scene_design(DrawingArea area, Cairo.Context cr)
        {
            area.AddEvents((int)Gdk.EventMask.ButtonPressMask);
            area.ButtonPressEvent += delegate(object o, ButtonPressEventArgs arg) {
                area.GetPointer(out xo, out yo);
                pressed = true;
            };

            area.AddEvents((int)Gdk.EventMask.ButtonReleaseMask);
            area.ButtonReleaseEvent += delegate(object o, ButtonReleaseEventArgs args) {
                pressed = false;
                UpdateViewSurface();
            };


            if (pressed)
            {
                area.GetPointer(out xt, out yt);
                if (ventana.circulo.Active)
                {
                    cr.LineWidth = 2;
                    cr.SetSourceRGBA(0, 0, 1, 0.5);
                    cr.Arc(xo, yo, Constantes.distancia(xt, xo), 0, Math.PI * 2);
                    cr.Stroke();
                }
                else if (ventana.linea.Active)
                {
                    cr.LineWidth = 2;
                    cr.SetSourceRGBA(0, 1, 0, 0.5);
                    cr.MoveTo(xo, yo);
                    cr.LineTo(xt, yt);
                    cr.Stroke();
                }
                else if (ventana.rectangulo.Active)
                {
                    cr.LineWidth = 2;
                    cr.SetSourceRGBA(1, 0, 0, 0.5);
                    cr.Rectangle(xo, yo, xt - xo, yt - yo);
                    cr.Stroke();
                }
            }

            cr.SetSourceSurface(Constantes.viewSurface, 0, 0);
            cr.Paint();
        }
Esempio n. 2
0
 public override void calculateVelocity(BoidCollection s, DrawingArea area)
 {
     area.GetPointer(out x, out y);
     y               = (int)Logica.mapeo(y);
     Velocity.X      = x - Location.X;
     Velocity.Y      = y - Location.Y;
     LocationNueva.X = x;
     LocationNueva.Y = y;
 }