Exemplo n.º 1
0
        public static void Configure(this TransparentLabel label, FigmaText text)
        {
            Configure(label, (FigmaNode)text);

            //label.TextAlign = text.style.textAlignHorizontal == "CENTER" ? System.Drawing.ContentAlignment.TopCenter : text.style.textAlignHorizontal == "LEFT" ? System.Drawing.ContentAlignment.TopLeft : System.Drawing.ContentAlignment.TopRight;
            //label.AlphaValue = text.opacity;
            //label.LineBreakMode = NSLineBreakMode.ByWordWrapping;
            //label.SetContentCompressionResistancePriority(250, NSLayoutConstraintOrientation.Horizontal);

            var fills = text.fills.FirstOrDefault();

            if (fills != null)
            {
                label.ForeColor = FigmaExtensions.ToColor(fills.color);
            }

            //if (text.characterStyleOverrides != null && text.characterStyleOverrides.Length > 0)
            //{
            //    var attributedText = new NSMutableAttributedString(label.AttributedStringValue);
            //    for (int i = 0; i < text.characterStyleOverrides.Length; i++)
            //    {
            //        var key = text.characterStyleOverrides[i].ToString();
            //        if (!text.styleOverrideTable.ContainsKey(key))
            //        {
            //            continue;
            //        }
            //        var element = text.styleOverrideTable[key];
            //        if (element.fontFamily == null)
            //        {
            //            continue;
            //        }
            //        var localFont = FigmaExtensions.ToNSFont(element);
            //        var range = new NSRange(i, 1);
            //        attributedText.AddAttribute(NSStringAttributeKey.Font, localFont, range);
            //        attributedText.AddAttribute(NSStringAttributeKey.ForegroundColor, label.TextColor, range);
            //    }

            //    label.AttributedStringValue = attributedText;
            //}
        }
Exemplo n.º 2
0
 public static void Configure(this TransparentControl view, FigmaFrameEntity child)
 {
     Configure(view, (FigmaNode)child);
     view.Opacity   = child.opacity;
     view.BackColor = FigmaExtensions.ToColor(child.backgroundColor);
 }