code_uipromptwindow.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // UIPromptWindow application source code
  2. using System;
  3. using AtomicEngine;
  4. public class code_uipromptwindow : 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], HandleUipromptwindowEvent );
  11. }
  12. }
  13. private static void HandlePromptCompleteEvent ( UIPromptCompleteEvent ev )
  14. {
  15. AtomicMain.AppLog( "UIPromptWindow event : the window " + ev.Title
  16. + " file was " + ev.Selected + ", the button pressed was " + ev.Reason);
  17. }
  18. private static void HandleUipromptwindowEvent ( WidgetEvent ev )
  19. {
  20. UIWidget widget = (UIWidget)ev.Target;
  21. if ( widget.Equals(null)) return;
  22. if ( ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) {
  23. if (widget.GetId() == "uipromptwindowcode" ) {
  24. AtomicMain.AppLog( "UIPromptWindow support : " + widget.GetId() + " was pressed " );
  25. AtomicMain.ViewCode ( "Components/code_uipromptwindow.cs", widget.GetParent() );
  26. }
  27. if (widget.GetId() == "uipromptwindowlayout" ) {
  28. AtomicMain.AppLog( "UIPromptWindow support : " + widget.GetId() + " was pressed ");
  29. AtomicMain.ViewCode ( "Scenes/layout_uipromptwindow.ui.txt", widget.GetParent() );
  30. }
  31. if (widget.GetId() == "stringfinder" ) {
  32. AtomicMain.AppLog( "UIPromptWindow action : " + widget.GetId() + " was pressed ");
  33. UIWidget someview = (UIWidget )widget.GetView();
  34. UIPromptWindow windowp = new UIPromptWindow( someview, widget.GetId());
  35. windowp.SubscribeToEvent<UIPromptCompleteEvent> (windowp, HandlePromptCompleteEvent );
  36. windowp.Show( "WindowTitle", "Message in window", "preset value", 0, 0, 0);
  37. }
  38. }
  39. }
  40. }