code_uiradiobutton.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // UIRadioButton application source code
  2. using System;
  3. using AtomicEngine;
  4. public class code_uiradiobutton : 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], HandleUiradiobuttonEvent );
  11. }
  12. UIWidget demochk = layout.GetWidget ("demoradio");
  13. if ( !demochk.Equals(null))
  14. demochk.SubscribeToEvent<WidgetEvent> ( demochk, HandleUiradiobuttonEvent );
  15. }
  16. private static void HandleUiradiobuttonEvent ( WidgetEvent ev )
  17. {
  18. UIWidget widget = (UIWidget)ev.Target;
  19. if ( widget.Equals(null)) return;
  20. if ( ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) {
  21. if (widget.GetId() == "uiradiobuttoncode" ) {
  22. AtomicMain.AppLog( "UIRadioButton support : " + widget.GetId() + " was pressed " );
  23. AtomicMain.ViewCode ( "Components/code_uiradiobutton.cs", widget.GetParent() );
  24. }
  25. if (widget.GetId() == "uiradiobuttonlayout" ) {
  26. AtomicMain.AppLog( "UIRadioButton support : " + widget.GetId() + " was pressed ");
  27. AtomicMain.ViewCode ( "Scenes/layout_uiradiobutton.ui.txt", widget.GetParent() );
  28. }
  29. if (widget.GetId() == "demoradio" ) {
  30. AtomicMain.AppLog( "UIRadioButton event : " + widget.GetId() + " was pressed, state = " + widget.GetValue().ToString());
  31. }
  32. if (widget.GetId() == "radioset" ) {
  33. UIWidget demochk = widget.FindWidget ("demoradio");
  34. if (!demochk.Equals(null)) {
  35. demochk.SetValue (1);
  36. AtomicMain.AppLog( "UIRadioButton action : " + widget.GetId() + " was pressed, set state to 1" );
  37. }
  38. }
  39. if (widget.GetId() == "radiounset" ) {
  40. UIWidget demochk = widget.FindWidget ("demoradio");
  41. if (!demochk.Equals(null)) {
  42. demochk.SetValue (0);
  43. AtomicMain.AppLog( "UIRadioButton action : " + widget.GetId() + " was pressed, set state to 0" );
  44. }
  45. }
  46. }
  47. }
  48. }