Exemple #1
0
        public static NSAttributedString ToAttributed(this Span span, Font defaultFont, Color defaultForegroundColor)
        {
            if (span == null)
            {
                return((NSAttributedString)null);
            }
            Color color = span.ForegroundColor;

            if (color.IsDefault)
            {
                color = defaultForegroundColor;
            }
            if (color.IsDefault)
            {
                color = Color.Black;
            }

            Font self = span.Font != Font.Default ? span.Font : defaultFont;
            var  font = self == Font.Default ? (NSFont)null : FontExtensions.ToUIFont(self);

            return(new NSAttributedString(
                       span.Text,
                       font,
                       ColorExtensions.ToUIColor(color),
                       ColorExtensions.ToUIColor(span.BackgroundColor),
                       null,                  // NSColor strokeColor = null,
                       null,                  // NSColor underlineColor = null,
                       null,                  // NSColor strikethroughColor = null,
                       NSUnderlineStyle.None, // UnderlineStyle
                       NSUnderlineStyle.None, // Strikethrough Style
                       null,                  // NSParagraphStyle paragraphStyle = null,
                       0,                     // float strokeWidth = 0,
                       null,                  // NSShadow shadow = null,
                       null,                  // NSUrl link = null,
                       false,                 // bool superscript = false,
                       null,                  // NSTextAttachment attachment = null,
                       NSLigatureType.Default,
                       0,                     // float baselineOffset = 0,
                       0,                     // float kerningAdjustment = 0,
                       0,                     // float obliqueness = 0,
                       0,                     // float expansion = 0,
                       null,                  // NSCursor cursor = null,
                       null,                  // string toolTip = null,
                       0,                     // int characterShape = 0,
                       null,                  // NSGlyphInfo glyphInfo = null,
                       null,                  // NSArray writingDirection = null,
                       false,                 // bool markedClauseSegment = false,
                       NSTextLayoutOrientation.Horizontal,
                       null,                  // NSTextAlternatives textAlternatives = null,
                       NSSpellingState.None));
        }
Exemple #2
0
        private void UpdateText()
        {
            this.perfectSizeValid = false;

            object[] values = this.Element.GetValues(Label.FormattedTextProperty, Label.TextProperty, Label.TextColorProperty);

            FormattedString formattedString = (FormattedString)values [0];

            if (formattedString != null)
            {
                this.Control.AttributedStringValue = FormattedStringExtensions.ToAttributed(formattedString, (Element)this.Element, (Color)values [2]);
            }
            else
            {
                this.Control.StringValue = (string)values [1];
                this.Control.Font        = FontExtensions.ToUIFont(this.Element);
                this.Control.TextColor   = ColorExtensions.ToUIColor((Color)values [2], ColorExtensions.Black);
            }
            this.Layout();
        }
Exemple #3
0
 private void UpdateFont()
 {
     this.Control.Font = FontExtensions.ToUIFont((IFontElement)this.Element);
 }
Exemple #4
0
 internal static NSFont ToUIFont(this IFontElement element)
 {
     return(FontExtensions.ToUIFont(element.FontFamily, (float)element.FontSize, element.FontAttributes));
 }
Exemple #5
0
 internal static NSFont ToUIFont(this Label label)
 {
     object[] values = label.GetValues(Label.FontFamilyProperty, Label.FontSizeProperty, Label.FontAttributesProperty);
     return(FontExtensions.ToUIFont((string)values [0], (float)(double)values [1], (FontAttributes)values [2]) ??
            NSFont.SystemFontOfSize(NSFont.LabelFontSize));
 }