Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Test .NET bindings test program
  3. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  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. using System;
  15. using libCucul;
  16. using libCaca;
  17. class Test {
  18. public static void Main() {
  19. int barCount = 6;
  20. Console.WriteLine("libcaca .NET test");
  21. Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>");
  22. /* Instanciate a cucul canvas */
  23. Cucul qq = new Cucul();
  24. /* Random number. This is a static method,
  25. not to be used with previous instance */
  26. Console.WriteLine("A random number : {0}", Cucul.Rand(0, 1337));
  27. /* We have a proper canvas, let's display it using Caca */
  28. Caca kk = new Caca(qq);
  29. kk.setDisplayTime(20000); // Refresh every 20 ms
  30. kk.setDisplayTitle("libcaca .NET Bindings test suite");
  31. double v;
  32. Int32 y = 0;
  33. Event e = new Event();
  34. Int32 i;
  35. DateTime startTime = DateTime.Now;
  36. while(kk.getEvent(Event.type.KEY_RELEASE, e, 10) == 0)
  37. {
  38. TimeSpan curTime = DateTime.Now - startTime;
  39. double t = curTime.TotalMilliseconds;
  40. qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLACK);
  41. for(i=0; i<barCount;i++)
  42. {
  43. v = ((Math.Sin((t/500.0)+(i/((double)barCount)))+1)/2)*qq.getHeight();
  44. y = (Int32) v;
  45. qq.setColor(i+9, Cucul.CUCUL_BLACK);
  46. /* drawLine is already clipped, we don't care about overflows */
  47. qq.drawLine(0, y-2, qq.getWidth(), y-2, '-');
  48. qq.drawLine(0, y-1, qq.getWidth(), y-1, '*');
  49. qq.drawLine(0, y, qq.getWidth(), y, '#');
  50. qq.drawLine(0, y+1, qq.getWidth(), y+1, '*');
  51. qq.drawLine(0, y+2, qq.getWidth(), y+2, '-');
  52. }
  53. qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLUE);
  54. qq.putStr(qq.getWidth() - 30,qq.getHeight() - 2," -=[ Powered by libcaca ]=- ");
  55. qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLACK);
  56. kk.Refresh();
  57. qq.Clear();
  58. }
  59. /* Force deletion of our instances for fun */
  60. qq.Dispose();
  61. kk.Dispose();
  62. }
  63. }