Ignore:
Timestamp:
Nov 25, 2007, 12:12:25 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Adapt the C# bindings to the event API change.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/csharp/test.cs

    r2047 r2052  
    5959class DemoDisplay : CacaDisplay
    6060{
    61     private Event e;
    6261    private DemoCanvas cv;
    6362
    6463    public DemoDisplay(DemoCanvas _cv) : base(_cv)
    6564    {
    66         setDisplayTime(20000); // Refresh every 20 ms
    67         setDisplayTitle("libcaca .NET Bindings test suite");
     65        displayTime = 20000; // Refresh every 20 ms
     66        title = "libcaca .NET Bindings test suite";
    6867        cv = _cv;
    69         e = new Event();
    7068    }
    7169
    7270    public void EventLoop()
    7371    {
    74         while(getEvent(Event.type.KEY_RELEASE, e, 10) == 0)
     72        CacaEvent ev;
     73
     74        while((ev = getEvent(CacaEventType.KEY_RELEASE, 10)).type == 0)
    7575        {
    7676            cv.Draw();
     
    7878            Refresh();
    7979        }
     80
     81        if(ev.keyCh > 0x20 && ev.keyCh < 0x7f)
     82            Console.WriteLine("Key pressed: {0}", ev.keyUtf8);
     83        else
     84            Console.WriteLine("Key pressed: 0x{0:x}", ev.keyCh);
    8085    }
    8186}
     
    96101        /* Random number. This is a static method,
    97102           not to be used with previous instance */
    98         Console.WriteLine("A random number : {0}", Libcucul.Rand(0, 1337));
     103        Console.WriteLine("A random number: {0}", Libcucul.Rand(0, 1337));
    99104
    100105        dp.EventLoop();
Note: See TracChangeset for help on using the changeset viewer.