demo.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Terminal;
  2. class Demo {
  3. static void ShowTextAlignments (View container)
  4. {
  5. container.Add (
  6. new Label (new Rect (0, 0, 40, 3), "1-Hello world, how are you doing today") { TextAlignment = TextAlignment.Left },
  7. new Label (new Rect (0, 4, 40, 3), "2-Hello world, how are you doing today") { TextAlignment = TextAlignment.Right },
  8. new Label (new Rect (0, 8, 40, 3), "3-Hello world, how are you doing today") { TextAlignment = TextAlignment.Centered },
  9. new Label (new Rect (0, 12, 40, 3), "4-Hello world, how are you doing today") { TextAlignment = TextAlignment.Justified });
  10. }
  11. static void ShowEntries (View container)
  12. {
  13. container.Add (
  14. new Label (3, 2, "Login: "),
  15. new TextField (14, 2, 40, ""),
  16. new Label (3, 4, "Password: "),
  17. new TextField (14, 4, 40, "") { Secret = true },
  18. new CheckBox (3, 6, "Remember me"),
  19. new RadioGroup (3, 8, new [] { "_Personal", "_Company" }),
  20. new Button (3, 14, "Ok"),
  21. new Button (10, 14, "Cancel"),
  22. new Label (3, 18, "Press ESC and 9 to activate the menubar")
  23. );
  24. }
  25. static void NewFile ()
  26. {
  27. var d = new Dialog ("New File", 50, 20, new Button ("Ok"), new Button ("Cancel"));
  28. Application.Run (d);
  29. }
  30. static void Main ()
  31. {
  32. Application.Init ();
  33. var top = Application.Top;
  34. var tframe = top.Frame;
  35. var win = new Window (new Rect (0, 1, tframe.Width, tframe.Height-1), "Hello");
  36. var menu = new MenuBar (new MenuBarItem [] {
  37. new MenuBarItem ("_File", new MenuItem [] {
  38. new MenuItem ("_New", "Creates new file", NewFile),
  39. new MenuItem ("_Open", "", null),
  40. new MenuItem ("_Close", "", null),
  41. new MenuItem ("_Quit", "", null)
  42. }),
  43. new MenuBarItem ("_Edit", new MenuItem [] {
  44. new MenuItem ("_Copy", "", null),
  45. new MenuItem ("C_ut", "", null),
  46. new MenuItem ("_Paste", "", null)
  47. })
  48. });
  49. ShowEntries (win);
  50. // ShowTextAlignments (win);
  51. top.Add (win);
  52. top.Add (menu);
  53. Application.Run ();
  54. }
  55. }