public override void Write(FigmaClassBase figmaClassBase, StringBuilder sb) { figmaClassBase.AddTabLevel(); figmaClassBase.GenerateMethod(sb, Name, CodeObjectModifierType.Protected, arguments: new List <(string, string)>() { (enumTypeName, argumentName) }); figmaClassBase.AppendLine(sb, $"{contentViewName}?.{nameof(AppKit.NSView.RemoveFromSuperview)}();"); figmaClassBase.AppendLine(sb, $"{selectedContentName} = {argumentName};"); var frameName = "frame"; figmaClassBase.AppendLine(sb, $"var {frameName} = {typeof (CoreGraphics.CGRect).FullName}.{nameof (CoreGraphics.CGRect.Empty)};"); for (int i = 0; i < figmaFrameEntities.Count; i++) { string ifcase = "if"; if (i > 0) { ifcase = "else " + ifcase; } var className = figmaFrameEntities[i].GetClassName(); figmaClassBase.AppendLine(sb, $"{ifcase} ({argumentName} == {enumTypeName}.{className}) {{"); figmaClassBase.AddTabLevel(); figmaClassBase.AppendLine(sb, $"{contentViewName} = new {className}();"); figmaClassBase.AppendLine(sb, $"{nameof(AppKit.NSWindow.ContentView)}.{nameof(AppKit.NSView.AddSubview)}({contentViewName});"); //var leftConstraintStringValue = CodeGenerationHelpers.GetLeftConstraintEqualToAnchor( // contentViewName, figmaFrameEntities[i].Item2.Left, nameof(AppKit.NSWindow.ContentView)); //figmaClassBase.AppendLine(sb, $"{figmaFrameEntities[i].Item2}.{nameof (AppKit.NSLayoutConstraint.Active)} = {true.ToDesignerString ()};"); //var topConstraintStringValue = CodeGenerationHelpers.GetLeftConstraintEqualToAnchor( // contentViewName, figmaFrameEntities[i].Item2.Left, nameof(AppKit.NSWindow.ContentView)); //figmaClassBase.AppendLine(sb, $"{figmaFrameEntities[i].Item2}.{nameof(AppKit.NSLayoutConstraint.Active)} = {true.ToDesignerString()};"); var parentNode = new CodeNode(figmaFrameEntities[i], nameof(AppKit.NSWindow.ContentView)); var nodeContent = figmaFrameEntities[i].children.FirstOrDefault(s => s.IsNodeWindowContent()); //hack: var oldboundingBox = figmaFrameEntities[i].absoluteBoundingBox; figmaFrameEntities[i].absoluteBoundingBox = new Rectangle(oldboundingBox.X, oldboundingBox.Y + DefaultWindowBarHeight, oldboundingBox.Width, oldboundingBox.Height - DefaultWindowBarHeight); var codeNode = new CodeNode(nodeContent, contentViewName, parent: parentNode); var converter = rendererService.GetNodeConverter(codeNode); var frameCode = rendererService.codePropertyConverter.ConvertToCode(PropertyNames.Frame, codeNode, parentNode, converter, rendererService); foreach (var line in frameCode.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) { figmaClassBase.AppendLine(sb, line); } var contraintsCode = rendererService.codePropertyConverter.ConvertToCode(PropertyNames.Constraints, codeNode, parentNode, converter, rendererService); foreach (var line in contraintsCode.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) { figmaClassBase.AppendLine(sb, line); } figmaFrameEntities[i].absoluteBoundingBox = oldboundingBox; figmaClassBase.RemoveTabLevel(); figmaClassBase.CloseBracket(sb, removeTabIndex: false); } figmaClassBase.RemoveTabLevel(); figmaClassBase.CloseBracket(sb); }