// not bound public static CGRect BoundingRect(this NSAttributedString str, CGSize size, NSStringDrawingOptions options) { CGRect rect; Messaging.RectangleF_objc_msgSend_stret_SizeF_int(out rect, str.Handle, selBoundingRectWithSize, size, (int)options); return(rect); }
public override Xamarin.Forms.Size Measure(string text, double fontSize, string fontName) { UIFont font = this.getFont(fontName, fontSize); UIStringAttributes attributes = new UIStringAttributes(); attributes.Font = font; SizeF boundSize = new SizeF(float.PositiveInfinity, float.PositiveInfinity); NSStringDrawingOptions options = NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin; NSString nsText = new NSString(text); CGSize resultSize = nsText.GetBoundingRect( boundSize, options, attributes, null).Size; nsText.Dispose(); return(new Xamarin.Forms.Size( Math.Ceiling((double)resultSize.Width), Math.Ceiling((double)resultSize.Height))); }
public static CGRect GetBoundingRect (this NSString This, CGSize size, NSStringDrawingOptions options, UIStringAttributes attributes, NSStringDrawingContext context) { // Define attributes var attr = new NSMutableDictionary (); attr.Add (NSFont.NameAttribute, attributes.Font.NSFont); var rect = This.BoundingRectWithSize (size, options, attr); // HACK: Cheating on the height return new CGRect(rect.Left, rect.Top , rect.Width, rect.Height * 1.5f); }
public static CGRect GetBoundingRect(this NSString This, CGSize size, NSStringDrawingOptions options, UIStringAttributes attributes, NSStringDrawingContext context) { // Define attributes var attr = new NSMutableDictionary(); attr.Add(NSFont.NameAttribute, attributes.Font.NSFont); var rect = This.BoundingRectWithSize(size, options, attr); // HACK: Cheating on the height return(new CGRect(rect.Left, rect.Top, rect.Width, rect.Height * 1.5f)); }
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"); Assert.DoesNotThrow(() => s.WeakDrawString(new RectangleF(0, 0, 10, 10), dict), "WeakDrawString 2"); Assert.DoesNotThrow(() => s.WeakDrawString(new PointF(0, 0), dict), "WeakDrawString 3"); } } }
public void DrawingExtensions() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Inconclusive("requires iOS7+"); } 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"); Assert.DoesNotThrow(() => s.WeakDrawString(new RectangleF(0, 0, 10, 10), dict), "WeakDrawString 2"); Assert.DoesNotThrow(() => s.WeakDrawString(new PointF(0, 0), dict), "WeakDrawString 3"); } } }
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 } } }
public virtual void DrawWithRect(CGRect rect, NSStringDrawingOptions options, Dictionary <NSObject, AnyObject> attributes, [Unwrapped] NSStringDrawingContext context) { }
public virtual CGRect BoundingRectWithSize(CGSize size, NSStringDrawingOptions options, Dictionary <NSObject, AnyObject> attributes, [Unwrapped] NSStringDrawingContext context) { return(default(CGRect)); }
// not bound public static CGRect BoundingRect(this NSAttributedString str, CGSize size, NSStringDrawingOptions options) { CGRect rect; Messaging.RectangleF_objc_msgSend_stret_SizeF_int(out rect, str.Handle, selBoundingRectWithSize, size, (int)options); return rect; }
public static CGRect BoundingRectWithSize(this NSAttributedString attrString, CGSize size, NSStringDrawingOptions options) => attrString.GetBoundingRect(size, options, null);
// not bound public static RectangleF BoundingRect(this NSAttributedString str, SizeF size, NSStringDrawingOptions options) { RectangleF rect; RectangleF_objc_msgSend_stret_SizeF_int(out rect, str.Handle, selBoundingRectWithSize, size, (int)options); return rect; }
public static CGRect BoundingRectWithSize (this NSAttributedString attrString, CGSize size, NSStringDrawingOptions options) => attrString.GetBoundingRect (size, options, null);
// not bound public static RectangleF BoundingRect(this NSAttributedString str, SizeF size, NSStringDrawingOptions options) { RectangleF rect; RectangleF_objc_msgSend_stret_SizeF_int(out rect, str.Handle, selBoundingRectWithSize, size, (int)options); return(rect); }
public virtual CGRect BoundingRectWithSize(CGSize size, NSStringDrawingOptions options, [Optional] NSStringDrawingContext context) { return(default(CGRect)); }
public virtual void DrawWithRect(CGRect rect, NSStringDrawingOptions options, [Optional] NSStringDrawingContext context) { }