/// <summary> /// Gets current FigmaNode children WITHOUT the FigmaInstance /// </summary> /// <param name="figmaNode"></param> /// <param name="func"></param> /// <param name="reverseChildren"></param> /// <returns></returns> public static IEnumerable <FigmaNode> GetChildren(this FigmaNode figmaNode, Func <FigmaNode, bool> func = null, bool reverseChildren = false) { if ((figmaNode.GetWindowContent() ?? figmaNode) is IFigmaNodeContainer container) { var figmaInstance = figmaNode.GetDialogInstanceFromParentContainer(); IEnumerable <FigmaNode> children = container.children; if (reverseChildren) { children = children.Reverse(); } foreach (var item in children) { if (item == figmaInstance) { continue; } if (func == null || (func != null && func.Invoke(item))) { yield return(item); } } } }
protected override IEnumerable <FigmaNode> GetCurrentChildren(FigmaNode currentNode, FigmaNode parentNode, NodeConverter converter, ViewRenderServiceOptions options) { var windowContent = currentNode.GetWindowContent(); if (windowContent != null && windowContent is IFigmaNodeContainer nodeContainer) { return(nodeContainer.children); } return(base.GetCurrentChildren(currentNode, parentNode, converter, options)); }
public override void RenderInWindow(IWindow mainWindow, FigmaNode node, ViewRenderServiceOptions options = null) { if (node is IAbsoluteBoundingBox bounNode) { mainWindow.Size = new Size(bounNode.absoluteBoundingBox.Width, bounNode.absoluteBoundingBox.Height); } if (options == null) { options = new ViewRenderServiceOptions() { GenerateMainView = false }; } SetOptions(options); var content = node.GetWindowContent() ?? node; ProcessFromNode(content, mainWindow.Content, options); var processedNode = FindProcessedNodeById(content.id); RecursivelyConfigureViews(processedNode, options); var windowComponent = node.GetDialogInstanceFromParentContainer(); if (windowComponent != null) { var optionsNode = windowComponent.Options(); if (optionsNode is IFigmaNodeContainer figmaNodeContainer) { mainWindow.IsClosable = figmaNodeContainer.HasChildrenVisible("close"); mainWindow.Resizable = figmaNodeContainer.HasChildrenVisible("resize"); mainWindow.ShowMiniaturizeButton = figmaNodeContainer.HasChildrenVisible("min"); mainWindow.ShowZoomButton = figmaNodeContainer.HasChildrenVisible("max"); } var titleText = optionsNode.FirstChild(s => s.name == "title" && s.visible) as FigmaText; if (titleText != null) { mainWindow.Title = titleText.characters; } } }