Ejemplo n.º 1
0
        public void DrawingExtensions()
        {
            TestRuntime.AssertXcodeVersion(5, 0);

            using (var s = new NSString("foo")) {
                NSStringDrawingOptions options = NSStringDrawingOptions.OneShot;
                var attrib = new UIStringAttributes();
                using (var dict = new NSDictionary()) {
                    Assert.DoesNotThrow(() => s.GetBoundingRect(new SizeF(5, 5), options, attrib, null), "GetBoundingRect 1");
                    Assert.DoesNotThrow(() => s.WeakGetBoundingRect(new SizeF(5, 5), options, dict, null), "WeakGetBoundingRect 1");
                    Assert.DoesNotThrow(() => s.DrawString(new RectangleF(0, 0, 10, 10), options, attrib, null), "DrawString 1");
                    Assert.DoesNotThrow(() => s.WeakDrawString(new RectangleF(0, 0, 10, 10), options, dict, null), "WeakDrawString 1");
#if !MONOMAC //WeakDrawString on mac doesn't have versions with these parameters
                    Assert.DoesNotThrow(() => s.WeakDrawString(new RectangleF(0, 0, 10, 10), dict), "WeakDrawString 2");
                    Assert.DoesNotThrow(() => s.WeakDrawString(new PointF(0, 0), dict), "WeakDrawString 3");
#endif
                }
            }
        }
Ejemplo n.º 2
0
        public void DrawingExtensions()
        {
            TestRuntime.AssertXcodeVersion(5, 0);
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 11, throwIfOtherPlatform: false);

            using (var s = new NSString("foo")) {
                NSStringDrawingOptions options = NSStringDrawingOptions.OneShot;
                var attrib = new UIStringAttributes();
                using (var dict = new NSDictionary()) {
                    Assert.DoesNotThrow(() => s.GetBoundingRect(new CGSize(5, 5), options, attrib, null), "GetBoundingRect 1");
                    Assert.DoesNotThrow(() => s.WeakGetBoundingRect(new CGSize(5, 5), options, dict, null), "WeakGetBoundingRect 1");
                    Assert.DoesNotThrow(() => s.DrawString(new CGRect(0, 0, 10, 10), options, attrib, null), "DrawString 1");
                    Assert.DoesNotThrow(() => s.WeakDrawString(new CGRect(0, 0, 10, 10), options, dict, null), "WeakDrawString 1");
#if !MONOMAC //WeakDrawString on mac doesn't have versions with these parameters
                    Assert.DoesNotThrow(() => s.WeakDrawString(new CGRect(0, 0, 10, 10), dict), "WeakDrawString 2");
                    Assert.DoesNotThrow(() => s.WeakDrawString(new CGPoint(0, 0), dict), "WeakDrawString 3");
#endif
                }
            }
        }
Ejemplo n.º 3
0
 public static CGSize StringSize(this string This, NSStringAttributes attributes)
 {
     return(This.StringSize(attributes == null ? null : attributes.Dictionary));
 }
Ejemplo n.º 4
0
 public static void DrawInRect(this string This, CGRect rect, NSStringAttributes attributes)
 {
     This.DrawInRect(rect, attributes == null ? null : attributes.Dictionary);
 }
Ejemplo n.º 5
0
 public static void DrawAtPoint(this string This, CGPoint point, NSStringAttributes attributes)
 {
     This.DrawAtPoint(point, attributes == null ? null : attributes.Dictionary);
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public NSStringFontMetrics(NativeStringAttributes nsattrs)
 {
     this.nsattrs = nsattrs;
 }