UIFactory.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using CommonLang;
  2. using CommonLang.Log;
  3. using CommonUI.Display;
  4. using CommonUI.Display.Text;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Xml;
  10. namespace CommonUI
  11. {
  12. public abstract class UIFactory
  13. {
  14. static UIFactory()
  15. {
  16. new DefaultUIFactory();
  17. new TextDrawableFactory();
  18. }
  19. public static UIFactory Instance { get; private set; }
  20. protected AttributedStringDecoder mTextDecoder = new AttributedStringDecoder();
  21. public UIFactory()
  22. {
  23. Instance = this;
  24. }
  25. virtual public RichTextLayer CreateRichTextLayer(float width = 100, RichTextAlignment anchor = RichTextAlignment.taLEFT)
  26. {
  27. return new RichTextLayer(width, anchor);
  28. }
  29. virtual public AttributedString DecodeAttributedString(XmlDocument doc, TextAttribute defaultTA = null)
  30. {
  31. return mTextDecoder.CreateFromXML(doc, defaultTA);
  32. }
  33. private class DefaultUIFactory : UIFactory
  34. {
  35. }
  36. }
  37. }