Exemplo n.º 1
0
 public NSAttributedString(string str,
                           NSFont font                         = null,
                           NSColor foregroundColor             = null,
                           NSColor backgroundColor             = null,
                           NSColor strokeColor                 = null,
                           NSColor underlineColor              = null,
                           NSColor strikethroughColor          = null,
                           NSUnderlineStyle underlineStyle     = NSUnderlineStyle.None,
                           NSUnderlineStyle strikethroughStyle = NSUnderlineStyle.None,
                           NSParagraphStyle paragraphStyle     = null,
                           float strokeWidth                   = 0,
                           NSShadow shadow                     = null,
                           NSUrl link                  = null,
                           bool superscript            = false,
                           NSTextAttachment attachment = null,
                           NSLigatureType ligature     = NSLigatureType.Default,
                           float baselineOffset        = 0,
                           float kerningAdjustment     = 0,
                           float obliqueness           = 0,
                           float expansion             = 0,
                           NSCursor cursor             = null,
                           string toolTip              = null,
                           int characterShape          = 0,
                           NSGlyphInfo glyphInfo       = null,
                           NSArray writingDirection    = null,
                           bool markedClauseSegment    = false,
                           NSTextLayoutOrientation verticalGlyphForm = NSTextLayoutOrientation.Horizontal,
                           NSTextAlternatives textAlternatives       = null,
                           NSSpellingState spellingState             = NSSpellingState.None) : this(str, NSStringAttributes.ToDictionary(
                                                                                                        font : font,
                                                                                                        foregroundColor : foregroundColor,
                                                                                                        backgroundColor : backgroundColor,
                                                                                                        strokeColor : strokeColor,
                                                                                                        underlineColor : underlineColor,
                                                                                                        strikethroughColor : strikethroughColor,
                                                                                                        underlineStyle : underlineStyle,
                                                                                                        strikethroughStyle : strikethroughStyle,
                                                                                                        paragraphStyle : paragraphStyle,
                                                                                                        strokeWidth : strokeWidth,
                                                                                                        shadow : shadow,
                                                                                                        link : link,
                                                                                                        superscript : superscript,
                                                                                                        attachment : attachment,
                                                                                                        ligature : ligature,
                                                                                                        baselineOffset : baselineOffset,
                                                                                                        kerningAdjustment : kerningAdjustment,
                                                                                                        obliqueness : obliqueness,
                                                                                                        expansion : expansion,
                                                                                                        cursor : cursor,
                                                                                                        toolTip : toolTip,
                                                                                                        characterShape : characterShape,
                                                                                                        glyphInfo : glyphInfo,
                                                                                                        writingDirection : writingDirection,
                                                                                                        markedClauseSegment : markedClauseSegment,
                                                                                                        verticalGlyphForm : verticalGlyphForm,
                                                                                                        textAlternatives : textAlternatives,
                                                                                                        spellingState : spellingState
                                                                                                        ))
 {
 }
		static internal NSDictionary ToDictionary (
						  UIFont font,
						  UIColor foregroundColor,
						  UIColor backgroundColor,
						  UIColor strokeColor,
						  NSParagraphStyle paragraphStyle,
						  NSLigatureType ligature,
						  float kerning,
						  NSUnderlineStyle underlineStyle,
						  NSShadow shadow,
						  float strokeWidth,
						  NSUnderlineStyle strikethroughStyle)
		{
			var attr = new UIStringAttributes ();
			if (font != null){
				attr.Font = font;
			}
			if (foregroundColor != null){
				attr.ForegroundColor = foregroundColor;
			}
			if (backgroundColor != null){
				attr.BackgroundColor = backgroundColor;
			}
			if (strokeColor != null){
				attr.StrokeColor = strokeColor;
			}
			if (paragraphStyle != null){
				attr.ParagraphStyle = paragraphStyle;
			}
			if (ligature != NSLigatureType.Default){
				attr.Ligature = ligature;
			}
			if (kerning != 0){
				attr.KerningAdjustment = kerning;
			}
			if (underlineStyle != NSUnderlineStyle.None){
				attr.UnderlineStyle = underlineStyle;
			}
			if (shadow != null){
				attr.Shadow = shadow;
			}
			if (strokeWidth != 0){
				attr.StrokeWidth = strokeWidth;
			}
			if (strikethroughStyle != NSUnderlineStyle.None){
				attr.StrikethroughStyle = strikethroughStyle;
			}
			var dict = attr.Dictionary;
			return dict.Count == 0 ? null : dict;
		}				
Exemplo n.º 3
0
 public NSMutableAttributedString(string str,
                                  UIFont font                         = null,
                                  UIColor foregroundColor             = null,
                                  UIColor backgroundColor             = null,
                                  UIColor strokeColor                 = null,
                                  NSParagraphStyle paragraphStyle     = null,
                                  NSLigatureType ligatures            = NSLigatureType.Default,
                                  float kerning                       = 0,
                                  NSUnderlineStyle underlineStyle     = NSUnderlineStyle.None,
                                  NSShadow shadow                     = null,
                                  float strokeWidth                   = 0,
                                  NSUnderlineStyle strikethroughStyle = NSUnderlineStyle.None)
     : this(str, ToDictionary(font, foregroundColor, backgroundColor, strokeColor, paragraphStyle, ligatures, kerning, underlineStyle, shadow, strokeWidth, strikethroughStyle))
 {
 }
		public NSMutableAttributedString (string str,
						  UIFont font = null,
						  UIColor foregroundColor = null,
						  UIColor backgroundColor = null,
						  UIColor strokeColor = null,
						  NSParagraphStyle paragraphStyle = null,
						  NSLigatureType ligatures = NSLigatureType.Default,
						  float kerning = 0,
						  NSUnderlineStyle underlineStyle = NSUnderlineStyle.None,
						  NSShadow shadow = null,
						  float strokeWidth = 0,
						  NSUnderlineStyle strikethroughStyle = NSUnderlineStyle.None)
		: this (str, ToDictionary (font, foregroundColor, backgroundColor, strokeColor, paragraphStyle, ligatures, kerning, underlineStyle, shadow, strokeWidth, strikethroughStyle))
		{
		}
        static internal NSDictionary ToDictionary(
            NSFont font,
            NSColor foregroundColor,
            NSColor backgroundColor,
            NSColor strokeColor,
            NSColor underlineColor,
            NSColor strikethroughColor,
            NSUnderlineStyle underlineStyle,
            NSUnderlineStyle strikethroughStyle,
            NSParagraphStyle paragraphStyle,
            float strokeWidth,
            NSShadow shadow,
            NSUrl link,
            bool superscript,
            NSTextAttachment attachment,
            NSLigatureType ligature,
            float baselineOffset,
            float kerningAdjustment,
            float obliqueness,
            float expansion,
            NSCursor cursor,
            string toolTip,
            int characterShape,
            NSGlyphInfo glyphInfo,
            NSArray writingDirection,
            bool markedClauseSegment,
            NSTextLayoutOrientation verticalGlyphForm,
            NSTextAlternatives textAlternatives,
            NSSpellingState spellingState)
        {
            var attr = new NSStringAttributes();

            if (font != null)
            {
                attr.Font = font;
            }

            if (paragraphStyle != null)
            {
                attr.ParagraphStyle = paragraphStyle;
            }

            if (foregroundColor != null)
            {
                attr.ForegroundColor = foregroundColor;
            }

            if (underlineStyle != NSUnderlineStyle.None)
            {
                attr.UnderlineStyle = (int?)underlineStyle;
            }

            if (superscript)
            {
                attr.Superscript = true;
            }

            if (backgroundColor != null)
            {
                attr.BackgroundColor = backgroundColor;
            }

            if (attachment != null)
            {
                attr.Attachment = attachment;
            }

            if (ligature != NSLigatureType.Default)
            {
                attr.Ligature = ligature;
            }

            if (baselineOffset != 0)
            {
                attr.BaselineOffset = baselineOffset;
            }

            if (kerningAdjustment != 0)
            {
                attr.KerningAdjustment = kerningAdjustment;
            }

            if (link != null)
            {
                attr.Link = link;
            }

            if (strokeWidth != 0)
            {
                attr.StrokeWidth = strokeWidth;
            }

            if (strokeColor != null)
            {
                attr.StrokeColor = strokeColor;
            }

            if (underlineColor != null)
            {
                attr.UnderlineColor = underlineColor;
            }

            if (strikethroughStyle != NSUnderlineStyle.None)
            {
                attr.StrikethroughStyle = (int?)strikethroughStyle;
            }

            if (strikethroughColor != null)
            {
                attr.StrikethroughColor = strikethroughColor;
            }

            if (shadow != null)
            {
                attr.Shadow = shadow;
            }

            if (obliqueness != 0)
            {
                attr.Obliqueness = obliqueness;
            }

            if (expansion != 0)
            {
                attr.Expansion = expansion;
            }

            if (cursor != null)
            {
                attr.Cursor = cursor;
            }

            if (toolTip != null)
            {
                attr.ToolTip = toolTip;
            }

            if (characterShape != 0)
            {
                attr.CharacterShape = 0;
            }

            if (glyphInfo != null)
            {
                attr.GlyphInfo = glyphInfo;
            }

            if (writingDirection != null)
            {
                attr.WritingDirection = writingDirection;
            }

            if (markedClauseSegment)
            {
                attr.MarkedClauseSegment = true;
            }

            if (verticalGlyphForm != NSTextLayoutOrientation.Horizontal)
            {
                attr.VerticalGlyphForm = verticalGlyphForm;
            }

            if (textAlternatives != null)
            {
                attr.TextAlternatives = textAlternatives;
            }

            if (spellingState != NSSpellingState.None)
            {
                attr.SpellingState = spellingState;
            }

            var dict = attr.Dictionary;

            return(dict.Count == 0 ? null : dict);
        }
Exemplo n.º 6
0
        static internal NSDictionary ToDictionary(
            UIFont font,
            UIColor foregroundColor,
            UIColor backgroundColor,
            UIColor strokeColor,
            NSParagraphStyle paragraphStyle,
            NSLigatureType ligature,
            float kerning,
            NSUnderlineStyle underlineStyle,
#if !WATCH
            NSShadow shadow,
#endif
            float strokeWidth,
            NSUnderlineStyle strikethroughStyle)
        {
            var attr = new UIStringAttributes();

            if (font != null)
            {
                attr.Font = font;
            }
            if (foregroundColor != null)
            {
                attr.ForegroundColor = foregroundColor;
            }
            if (backgroundColor != null)
            {
                attr.BackgroundColor = backgroundColor;
            }
            if (strokeColor != null)
            {
                attr.StrokeColor = strokeColor;
            }
            if (paragraphStyle != null)
            {
                attr.ParagraphStyle = paragraphStyle;
            }
            if (ligature != NSLigatureType.Default)
            {
                attr.Ligature = ligature;
            }
            if (kerning != 0)
            {
                attr.KerningAdjustment = kerning;
            }
            if (underlineStyle != NSUnderlineStyle.None)
            {
                attr.UnderlineStyle = underlineStyle;
            }
#if !WATCH
            if (shadow != null)
            {
                attr.Shadow = shadow;
            }
#endif
            if (strokeWidth != 0)
            {
                attr.StrokeWidth = strokeWidth;
            }
            if (strikethroughStyle != NSUnderlineStyle.None)
            {
                attr.StrikethroughStyle = strikethroughStyle;
            }
            var dict = attr.Dictionary;
            return(dict.Count == 0 ? null : dict);
        }
Exemplo n.º 7
0
        public NSAttributedString(string str,
            NSFont font = null,
            NSColor foregroundColor = null,
            NSColor backgroundColor = null,
            NSColor strokeColor = null,
            NSColor underlineColor = null,
            NSColor strikethroughColor = null,
            NSUnderlineStyle underlineStyle = NSUnderlineStyle.None,
            NSUnderlineStyle strikethroughStyle = NSUnderlineStyle.None,
            NSParagraphStyle paragraphStyle = null,
            float strokeWidth = 0,
            NSShadow shadow = null,
            NSUrl link = null,
            bool superscript = false,
            NSTextAttachment attachment = null,
            NSLigatureType ligature = NSLigatureType.Default,
            float baselineOffset = 0,
            float kerningAdjustment = 0,
            float obliqueness = 0,
            float expansion = 0,
            NSCursor cursor = null,
            string toolTip = null,
            int characterShape = 0,
            NSGlyphInfo glyphInfo = null,
            NSArray writingDirection = null,
            bool markedClauseSegment = false,
            NSTextLayoutOrientation verticalGlyphForm = NSTextLayoutOrientation.Horizontal,
            NSTextAlternatives textAlternatives = null,
            NSSpellingState spellingState = NSSpellingState.None)
            : this(str, NSStringAttributes.ToDictionary (
				font: font,
				foregroundColor: foregroundColor,
				backgroundColor: backgroundColor,
				strokeColor: strokeColor,
				underlineColor: underlineColor,
				strikethroughColor: strikethroughColor,
				underlineStyle: underlineStyle,
				strikethroughStyle: strikethroughStyle,
				paragraphStyle: paragraphStyle,
				strokeWidth: strokeWidth,
				shadow: shadow,
				link: link,
				superscript: superscript,
				attachment: attachment,
				ligature: ligature,
				baselineOffset: baselineOffset,
				kerningAdjustment: kerningAdjustment,
				obliqueness: obliqueness,
				expansion: expansion,
				cursor: cursor,
				toolTip: toolTip,
				characterShape: characterShape,
				glyphInfo: glyphInfo,
				writingDirection: writingDirection,
				markedClauseSegment: markedClauseSegment,
				verticalGlyphForm: verticalGlyphForm,
				textAlternatives: textAlternatives,
				spellingState: spellingState
			))
        {
        }