source: libcaca/trunk/csharp/test.cs @ 2045

Last change on this file since 2045 was 2045, checked in by Sam Hocevar, 13 years ago
  • Some mass-renaming in the C# bindings: + Renamed the dlls so that the C# versions do not have the same name

as the C DLLs on Win32. It's now "cucul-sharp.dll", mimicking GTK#.

+ Renamed namespaces: "using Cucul" instead of "using libCucul".
+ Renamed the Cucul class into CuculCanvas? to avoid namespace/class

name collisions.

+ Renamed old-fashioned "kk"/"qq" names into "dp"/"cv".

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1/*
2 *  Test      .NET bindings test program
3 *  Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
4 *                All Rights Reserved
5 *
6 *  $Id: test.cs 2045 2007-11-24 13:26:33Z sam $
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15
16using System;
17
18using Cucul;
19using Caca;
20
21class Test {
22
23
24
25        public static void Main() {
26        int barCount = 6;
27        Console.WriteLine("libcaca .NET test");
28                Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>");
29       
30        /* Instanciate a cucul canvas */
31        CuculCanvas cv = new CuculCanvas();
32
33 
34        /* Random number. This is a static method,
35           not to be used with previous instance */
36        Console.WriteLine("A random number : {0}", Libcucul.Rand(0, 1337));
37
38
39
40        /* We have a proper canvas, let's display it using Caca */
41        Display dp = new Display(cv);
42        dp.setDisplayTime(20000); // Refresh every 20 ms
43
44        dp.setDisplayTitle("libcaca .NET Bindings test suite");
45
46        double v;
47        Int32 y = 0;
48        Event e = new Event();
49        Int32 i;
50       
51        DateTime startTime = DateTime.Now;
52        while(dp.getEvent(Event.type.KEY_RELEASE, e, 10) == 0)
53          {
54            TimeSpan curTime = DateTime.Now - startTime;
55            double t = curTime.TotalMilliseconds;
56            cv.setColor(Libcucul.WHITE, Libcucul.BLACK);
57            for(i=0; i<barCount;i++)
58             {
59                v = ((Math.Sin((t/500.0)+(i/((double)barCount)))+1)/2)*cv.getHeight();
60                y = (Int32) v;
61
62 
63
64                cv.setColor(i+9, Libcucul.BLACK);
65                /* drawLine is already clipped, we don't care about overflows */
66                cv.drawLine(0, y-2, cv.getWidth(), y-2, '-');
67                cv.drawLine(0, y-1, cv.getWidth(), y-1, '*');
68                cv.drawLine(0, y, cv.getWidth(), y, '#');
69                cv.drawLine(0, y+1, cv.getWidth(), y+1, '*');
70                cv.drawLine(0, y+2, cv.getWidth(), y+2, '-');
71             }
72
73             cv.setColor(Libcucul.WHITE, Libcucul.BLUE);   
74             cv.putStr(cv.getWidth() - 30,cv.getHeight() - 2," -=[ Powered by libcaca ]=- ");
75             cv.setColor(Libcucul.WHITE, Libcucul.BLACK);   
76 
77
78            dp.Refresh();
79            cv.Clear();
80           
81          }
82
83        /* Force deletion of our instances for fun */
84        dp.Dispose();
85        cv.Dispose();
86        }
87
88}
Note: See TracBrowser for help on using the repository browser.