code_uimessagewindow.cs 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // UIMessageWindow application source code
  2. using System;
  3. using AtomicEngine;
  4. public class code_uimessagewindow : 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], HandleUimessagewindowEvent );
  11. }
  12. }
  13. private static void HandleUimessagewindowEvent ( WidgetEvent ev )
  14. {
  15. UIWidget widget = (UIWidget)ev.Target;
  16. string refid = (string)ev.RefID;
  17. if ( widget.Equals(null)) return;
  18. UIWidget mylayout = (UIWidget)widget.FindWidget("pageuimessagewindow");
  19. if ( ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) {
  20. if (widget.GetId() == "uimessagewindowcode" ) {
  21. AtomicMain.AppLog( "UIMessageWindow support : " + widget.GetId() + " was pressed " );
  22. AtomicMain.ViewCode ( "Components/code_uimessagewindow.cs", widget.GetParent() );
  23. }
  24. if (widget.GetId() == "uimessagewindowlayout" ) {
  25. AtomicMain.AppLog( "UIMessageWindow support : " + widget.GetId() + " was pressed ");
  26. AtomicMain.ViewCode ( "Scenes/layout_uimessagewindow.ui.txt", widget.GetParent() );
  27. }
  28. if (widget.GetId() == "msgnone" ) {
  29. AtomicMain.AppLog( "UIMessageWindow support : " + widget.GetId() + " was pressed ");
  30. UIMessageWindow mess1 = new UIMessageWindow( mylayout, "mymess1");
  31. mess1.Show("MessageWindow - NONE", "this is a MessageWindow - None button", (UI_MESSAGEWINDOW_SETTINGS)0, false, 0, 0);
  32. }
  33. if (widget.GetId() == "msgok" ) {
  34. AtomicMain.AppLog( "UIMessageWindow support : " + widget.GetId() + " was pressed ");
  35. UIMessageWindow mess2 = new UIMessageWindow( mylayout, "mymess2");
  36. mess2.SubscribeToEvent<WidgetEvent> (mess2, HandleUimessagewindowEvent );
  37. mess2.Show("MessageWindow - OK", "this is a MessageWindow - OK button", UI_MESSAGEWINDOW_SETTINGS.UI_MESSAGEWINDOW_SETTINGS_OK, false, 0, 0);
  38. }
  39. if (widget.GetId() == "msgkcancel" ) {
  40. AtomicMain.AppLog( "UIMessageWindow support : " + widget.GetId() + " was pressed ");
  41. UIMessageWindow mess3 = new UIMessageWindow( mylayout, "mymess3");
  42. mess3.SubscribeToEvent<WidgetEvent> (mess3, HandleUimessagewindowEvent );
  43. mess3.Show("MessageWindow - OK CANCEL", "this is a MessageWindow - OK CANCEL buttons", UI_MESSAGEWINDOW_SETTINGS.UI_MESSAGEWINDOW_SETTINGS_OK_CANCEL, false, 0, 0);
  44. }
  45. if (widget.GetId() == "msgyesno" ) {
  46. AtomicMain.AppLog( "UIMessageWindow support : " + widget.GetId() + " was pressed ");
  47. UIMessageWindow mess4 = new UIMessageWindow( mylayout, "mymess4");
  48. mess4.SubscribeToEvent<WidgetEvent> (mess4, HandleUimessagewindowEvent );
  49. mess4.Show( "MessageWindow - YES NO", "this is a MessageWindow - YES NO buttons", UI_MESSAGEWINDOW_SETTINGS.UI_MESSAGEWINDOW_SETTINGS_YES_NO, false, 0, 0);
  50. }
  51. if (refid == "TBMessageWindow.ok" ) {
  52. AtomicMain.AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  53. }
  54. if (refid == "TBMessageWindow.cancel" ) {
  55. AtomicMain.AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  56. }
  57. if (refid == "TBMessageWindow.yes" ) {
  58. AtomicMain.AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  59. }
  60. if (refid == "TBMessageWindow.no" ) {
  61. AtomicMain.AppLog( "UIMessageWindow event : " + refid + " closed the UIMessageWindow");
  62. }
  63. } else {
  64. AtomicMain.AppLog( "UIMessageWindow event : " + widget.GetId() + " event type = " + AtomicMain.EventReport((int)ev.Type));
  65. }
  66. }
  67. }