code_uifontdescription.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // UIFontdescription application source code
  2. using System;
  3. using AtomicEngine;
  4. public class code_uifontdescription : 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], HandleUifontdescriptionEvent );
  11. }
  12. UIWidget demo = layout.GetWidget ("fontstep");
  13. if ( !demo.Equals(null))
  14. demo.SubscribeToEvent<WidgetEvent> ( demo, HandleUifontdescriptionEvent );
  15. }
  16. private static void HandleUifontdescriptionEvent ( 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() == "uifontdescriptioncode" ) {
  22. AtomicMain.AppLog( "UIFontdescription support : " + widget.GetId() + " was pressed " );
  23. AtomicMain.ViewCode ( "Components/code_uifontdescription.cs", widget.GetParent() );
  24. }
  25. if (widget.GetId() == "uifontdescriptionlayout" ) {
  26. AtomicMain.AppLog( "UIFontdescription support : " + widget.GetId() + " was pressed ");
  27. AtomicMain.ViewCode ( "Scenes/layout_uifontdescription.ui.txt", widget.GetParent() );
  28. }
  29. } else if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED ) {
  30. if ( widget.GetId() == "fontstep" ) {
  31. UISlider uis = (UISlider)widget;
  32. if ( !uis.Equals(null)) {
  33. UITextField mytext = (UITextField)widget.FindWidget("changetext");
  34. UIFontDescription myfont = new UIFontDescription();
  35. int mysize = (int)uis.GetValue();
  36. myfont.SetSize( mysize );
  37. myfont.SetId("Vera");
  38. mytext.SetFontDescription (myfont);
  39. mytext.SetText ( "Size " + mysize);
  40. AtomicMain.AppLog( "UIFontdescription action : " + widget.GetId() + " step size changed to " + mysize );
  41. }
  42. }
  43. }
  44. }
  45. }