CustomControl.cs 905 B

12345678910111213141516171819202122232425262728293031323334
  1. using CustomControls.Pattern;
  2. using DevExpress.XtraPrinting;
  3. using DevExpress.XtraPrinting.Native;
  4. namespace CustomControls
  5. {
  6. /// <summary>
  7. /// 自定义控件
  8. /// </summary>
  9. public class CustomControl
  10. {
  11. /// <summary>
  12. /// 注册解析事件,映射类型
  13. /// </summary>
  14. public static void EnsurePatternBrick() => BrickFactory.BrickResolve += BrickFactory_BrickResolve;
  15. /// <summary>
  16. /// 映射控件类型
  17. /// </summary>
  18. private static void BrickFactory_BrickResolve(object sender, BrickResolveEventArgs args)
  19. {
  20. if (args.Brick != null) return;
  21. /* 根据控件名称选择控件 */
  22. switch (args.Name)
  23. {
  24. case nameof(PatternBrick):
  25. args.Brick = new PatternBrick();
  26. break;
  27. }
  28. }
  29. }
  30. }