code_uiwindow.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // UIWindow application source code
  2. using System;
  3. using AtomicEngine;
  4. public class code_uiwindow : CSComponent {
  5. public void Setup( UIWidget layout )
  6. {
  7. var dest = new AtomicEngine.Vector<AtomicEngine.UIWidget>();
  8. layout.SearchWidgetClass( "TBButton", dest );
  9. for (var ii = 0; ii < dest.Size; ii++) {
  10. dest[ii].SubscribeToEvent<WidgetEvent> (dest [ii], HandleUiwindowEvent );
  11. }
  12. }
  13. private static void HandleUiwindowEvent ( WidgetEvent ev )
  14. {
  15. UIWidget widget = (UIWidget)ev.Target;
  16. if ( widget.Equals(null)) return;
  17. if ( ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) {
  18. if (widget.GetId() == "uiwindowcode" ) {
  19. AtomicMain.AppLog( "UIWindow support : " + widget.GetId() + " was pressed " );
  20. AtomicMain.ViewCode ( "Components/code_uiwindow.cs", widget.GetParent() );
  21. }
  22. if (widget.GetId() == "uiwindowlayout" ) {
  23. AtomicMain.AppLog( "UIWindow support : " + widget.GetId() + " was pressed ");
  24. AtomicMain.ViewCode ( "Scenes/layout_uiwindow.ui.txt", widget.GetParent() );
  25. }
  26. if (widget.GetId() == "windowdemo" ) {
  27. AtomicMain.AppLog( "UIWindow action : " + widget.GetId() + " was pressed " );
  28. UIView someview = widget.GetView();
  29. UIWindow window = new UIWindow();
  30. window.SetSettings (UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT );
  31. window.SetText("UIWindow demo (a login dialog)");
  32. window.Load("Scenes/login_dialog.ui.txt");
  33. window.ResizeToFitContent();
  34. someview.AddChild(window);
  35. window.Center();
  36. UIWidget login = window.GetWidget("login");
  37. login.SubscribeToEvent<WidgetEvent> (login, HandleUiwindowEvent );
  38. UIWidget cancel = window.GetWidget("cancel");
  39. cancel.SubscribeToEvent<WidgetEvent> (cancel, HandleUiwindowEvent );
  40. }
  41. if (widget.GetId() == "login" ) {
  42. AtomicMain.AppLog( "UIWindow action : " + widget.GetId() + " was pressed " );
  43. UIWindow mywindow = (UIWindow)AtomicMain.FindTheWindowParent(widget);
  44. if (!mywindow.Equals(null))
  45. mywindow.Close();
  46. }
  47. if (widget.GetId() == "cancel" ) {
  48. AtomicMain.AppLog( "UIWindow action : " + widget.GetId() + " was pressed " );
  49. UIWindow mywindow = (UIWindow)AtomicMain.FindTheWindowParent(widget);
  50. if (!mywindow.Equals(null))
  51. mywindow.Close();
  52. }
  53. if (widget.GetId() == "windowdemo1" ) {
  54. AtomicMain.AppLog( "UIWindow action : " + widget.GetId() + " was pressed " );
  55. UIView someview = widget.GetView();
  56. UIWindow window = new UIWindow();
  57. window.SetSettings ( UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT );
  58. window.SetText("UIWindow demo (a table)" );
  59. window.Load("Scenes/sheet.ui.txt");
  60. window.ResizeToFitContent();
  61. someview.AddChild(window);
  62. window.Center();
  63. }
  64. }
  65. }
  66. }