using Gtk;
using System;
class Test_GGusano
{
static Gdk.Pixmap pixmap;
static Gtk.DrawingArea darea;
static GGusano gg1;
static Gdk.GC pen_rojo;
static Gdk.GC pen_azul;
public static void Main (string[] args)
{
new Test_GGusano (args);
}
public Test_GGusano (string[] args)
{
Application.Init();
Window window = new Window ("Test-GGusano");
window.DeleteEvent += new DeleteEventHandler (OnWindowDeleteEvent);
darea = new DrawingArea();
window.Add(darea);
window.SetDefaultSize (400, 200);
window.ShowAll();
darea.ConfigureEvent+=new ConfigureEventHandler (on_configure_event);
darea.ExposeEvent+=new ExposeEventHandler (on_expose_event);
darea.SetSizeRequest (200, 200);
configurar_colores();
gg1 = new GGusano(darea, new Gusano(8));
gg1.Origen=new Vector(100,100);
gg1.Origen_panel=new Vector(10,40);
gg1.Radio = 4;
gg1.Gusano.Lseg = 15.0;
gg1.Ejex_visible=true;
gg1.Narts_visibles=true;
gg1.Panel_visible=true;
gg1.Art_Color = pen_rojo;
gg1.Seg_Color = pen_azul;
Application.Run();
}
static void configurar_colores()
{
Gdk.Color rojo = new Gdk.Color(0xff,0,0);
Gdk.Color azul = new Gdk.Color(0,0,0xff);
Gdk.Colormap colormap = Gdk.Colormap.System;
colormap.AllocColor (ref rojo, true, true);
colormap.AllocColor (ref azul,true,true);
pen_rojo = new Gdk.GC(darea.GdkWindow);
pen_azul = new Gdk.GC(darea.GdkWindow);
pen_rojo.Foreground = rojo;
pen_azul.Foreground = azul;
pen_azul.SetLineAttributes (2, Gdk.LineStyle.Solid,
Gdk.CapStyle.Butt,
Gdk.JoinStyle.Round);
}
void OnWindowDeleteEvent (object o, DeleteEventArgs args)
{
Application.Quit ();
args.RetVal = true;
}
public void on_configure_event(object o,
ConfigureEventArgs args)
{
Gdk.EventConfigure ev = args.Event;
Gdk.Window window = ev.Window;
Gdk.Rectangle allocation = darea.Allocation;
pixmap = new Gdk.Pixmap (window, allocation.Width, allocation.Height, -1);
pixmap.DrawRectangle (darea.Style.WhiteGC, true, 0, 0,
allocation.Width, allocation.Height);
gg1.Render(pixmap);
darea.QueueDraw();
args.RetVal = true;
}
public void on_expose_event(object o, ExposeEventArgs args)
{
Gdk.Rectangle area = args.Event.Area;
args.Event.Window.DrawDrawable (
darea.Style.BlackGC,
pixmap,
area.X, area.Y,
area.X, area.Y,
area.Width, area.Height);
args.RetVal = false;
}
}