TestStyles.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Avalonia.Controls;
  2. using Avalonia.Styling;
  3. namespace Avalonia.Benchmarks
  4. {
  5. public class TestStyles : Styles
  6. {
  7. public TestStyles(int childStylesCount, int childInnerStyleCount, int childResourceCount, int childThemeResourcesCount)
  8. {
  9. for (int i = 0; i < childStylesCount; i++)
  10. {
  11. var childStyles = new Styles();
  12. for (int j = 0; j < childInnerStyleCount; j++)
  13. {
  14. var childStyle = new Style();
  15. for (int k = 0; k < childResourceCount; k++)
  16. {
  17. childStyle.Resources.Add($"resource.{i}.{j}.{k}", null);
  18. }
  19. if (childThemeResourcesCount > 0)
  20. {
  21. ResourceDictionary darkTheme, lightTheme;
  22. childStyle.Resources.ThemeDictionaries[ThemeVariant.Dark] = darkTheme = new ResourceDictionary();
  23. childStyle.Resources.ThemeDictionaries[ThemeVariant.Light] = lightTheme = new ResourceDictionary();
  24. for (int k = 0; k < childThemeResourcesCount; k++)
  25. {
  26. darkTheme.Add($"resource.theme.{i}.{j}.{k}", null);
  27. lightTheme.Add($"resource.theme.{i}.{j}.{k}", null);
  28. }
  29. }
  30. childStyles.Add(childStyle);
  31. }
  32. Add(childStyles);
  33. }
  34. }
  35. }
  36. }