public static void Swallow(this VisualTreeAsset vta, VisualElementAsset parent, VisualTreeAsset other) { var otherIdToChildren = VisualTreeAssetUtilities.GenerateIdToChildren(other); if (parent == null) { parent = vta.GetRootUXMLElement(); } var nextOrderInDocument = (vta.visualElementAssets.Count + vta.templateAssets.Count) * BuilderConstants.VisualTreeAssetOrderIncrement; var assetsList = new List <VisualElementAsset>(); assetsList.AddRange(other.visualElementAssets); assetsList.AddRange(other.templateAssets); assetsList = assetsList.OrderBy(x => x.orderInDocument).ToList(); foreach (var asset in assetsList) { if (other.IsRootUXMLElement(asset)) { continue; } ReinitElementWithNewParentAsset( vta, parent, other, otherIdToChildren, asset, ref nextOrderInDocument); } foreach (var vea in other.visualElementAssets) { if (other.IsRootUXMLElement(vea)) { continue; } vta.visualElementAssets.Add(vea); } foreach (var vea in other.templateAssets) { if (!vta.TemplateExists(vea.templateAlias)) { vta.RegisterTemplate(vea.templateAlias, other.ResolveTemplate(vea.templateAlias)); } vta.templateAssets.Add(vea); } VisualTreeAssetUtilities.ReOrderDocument(vta); }
internal static List<StyleSheet> GetAllReferencedStyleSheets(this VisualTreeAsset vta) { var sheets = new HashSet<StyleSheet>(); foreach (var vea in vta.visualElementAssets) if (vta.IsRootElement(vea) || vta.IsRootUXMLElement(vea)) GetAllReferencedStyleSheets(vea, sheets); foreach (var vea in vta.templateAssets) if (vta.IsRootElement(vea)) GetAllReferencedStyleSheets(vea, sheets); return sheets.ToList(); }
public static void Swallow(this VisualTreeAsset vta, VisualElementAsset parent, VisualTreeAsset other) { var otherIdToChildren = VisualTreeAssetUtilities.GenerateIdToChildren(other); if (parent == null) { parent = vta.GetRootUXMLElement(); } var nextOrderInDocument = (vta.visualElementAssets.Count + vta.templateAssets.Count) * BuilderConstants.VisualTreeAssetOrderIncrement; foreach (var vea in other.visualElementAssets) { if (other.IsRootUXMLElement(vea)) { continue; } ReinitElementWithNewParentAsset( vta, parent, other, otherIdToChildren, vea, ref nextOrderInDocument); vta.visualElementAssets.Add(vea); } foreach (var vea in other.templateAssets) { ReinitElementWithNewParentAsset( vta, parent, other, otherIdToChildren, vea, ref nextOrderInDocument); if (!vta.TemplateExists(vea.templateAlias)) { var path = other.GetPathFromTemplateName(vea.templateAlias); vta.RegisterTemplate(vea.templateAlias, path); } vta.templateAssets.Add(vea); } VisualTreeAssetUtilities.ReOrderDocument(vta); }