code_uiimagewidget.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // UIImageWidget application source code
  2. using System;
  3. using AtomicEngine;
  4. public class code_uiimagewidget : 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], HandleUiimagewidgetEvent );
  11. }
  12. }
  13. private static void HandleUiimagewidgetEvent ( 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() == "uiimagewidgetcode" ) {
  19. AtomicMain.AppLog( "UIImageWidget support : " + widget.GetId() + " was pressed " );
  20. AtomicMain.ViewCode ( "Components/code_uiimagewidget.cs", widget.GetParent() );
  21. }
  22. if (widget.GetId() == "uiimagewidgetlayout" ) {
  23. AtomicMain.AppLog( "UIImageWidget support : " + widget.GetId() + " was pressed ");
  24. AtomicMain.ViewCode ( "Scenes/layout_uiimagewidget.ui.txt", widget.GetParent() );
  25. }
  26. if (widget.GetId() == "imagecolor" ) {
  27. AtomicMain.AppLog( "UIImageWidget action : " + widget.GetId() + " was pressed ");
  28. UIImageWidget img1 = (UIImageWidget)widget.FindWidget("imagewidgetdemo");
  29. img1.SetImage("Textures/HSV21.png");
  30. }
  31. if (widget.GetId() == "imagenewbuild" ) {
  32. AtomicMain.AppLog( "UIImageWidget action : " + widget.GetId() + " was pressed ");
  33. UIImageWidget img1 = (UIImageWidget)widget.FindWidget("imagewidgetdemo");
  34. img1.SetImage("Textures/newbuilddetected_header.jpg");
  35. }
  36. }
  37. }
  38. }