AddRect() public method

public AddRect ( CGAffineTransform transform, RectangleF rect ) : void
transform CGAffineTransform
rect System.Drawing.RectangleF
return void
コード例 #1
0
		static CTFrame CreateFrame (LayoutInfo li)
		{
			if (string.IsNullOrEmpty (li.Text))
				return null;

			using (CTFramesetter framesetter = new CTFramesetter (CreateAttributedString (li))) {
				CGPath path = new CGPath ();
				bool ellipsize = li.Width.HasValue && li.TextTrimming == TextTrimming.WordElipsis;
				path.AddRect (new RectangleF (0, 0, li.Width.HasValue && !ellipsize ? li.Width.Value : float.MaxValue, li.Height ?? float.MaxValue));

				return framesetter.GetFrame (new NSRange (0, li.Text.Length), path, null);
			}
		}
コード例 #2
0
        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            this.SetAlias (true);
            var convertedRect = rect.ConvertAliased ();

            if (fill.IsVisible ()) {
                this.SetFill (fill);
                using (var path = new CGPath ()) {
                    path.AddRect (convertedRect);
                    this.gctx.AddPath (path);
                }

                this.gctx.DrawPath (CGPathDrawingMode.Fill);
            }

            if (stroke.IsVisible () && thickness > 0) {
                this.SetStroke (stroke, thickness);

                using (var path = new CGPath ()) {
                    path.AddRect (convertedRect);
                    this.gctx.AddPath (path);
                }

                this.gctx.DrawPath (CGPathDrawingMode.Stroke);
            }
        }
コード例 #3
0
        internal static void Draw(CGContext ctx, object layout, double x, double y)
        {
            LayoutInfo li = (LayoutInfo)layout;
            if (li.Framesetter == null)
                return;

            CGPath path = new CGPath ();
            path.AddRect (new RectangleF (0, 0, li.Width ?? float.MaxValue, li.Height ?? float.MaxValue));
            CTFrame frame = li.Framesetter.GetFrame (new NSRange (0, li.Text.Length), path, null);

            CTLine ellipsis = null;
            bool ellipsize = li.Width.HasValue && li.TextTrimming == TextTrimming.WordElipsis;
            if (ellipsize)
                ellipsis = new CTLine (CreateAttributedString (li, "..."));

            float lineHeight = layoutManager.DefaultLineHeightForFont (li.Font);

            ctx.SaveState ();
            ctx.TextMatrix = CGAffineTransform.MakeScale (1f, -1f);
            ctx.TranslateCTM ((float)x, (float)y + li.Font.Ascender);
            foreach (var line in frame.GetLines ()) {
                ctx.TextPosition = PointF.Empty;
                if (ellipsize) // we need to create a new CTLine here because the framesetter already truncated the text for the line
                    new CTLine (CreateAttributedString (li, li.Text.Substring (line.StringRange.Location)))
                        .GetTruncatedLine (li.Width.Value, CTLineTruncation.End, ellipsis).Draw (ctx);
                else
                    line.Draw (ctx);
                ctx.TranslateCTM (0, lineHeight);
            }
            ctx.RestoreState ();
        }
コード例 #4
0
        static CTFrame CreateFrame(LayoutInfo li)
        {
            if (string.IsNullOrEmpty (li.Text))
                return null;

            using (CTFramesetter framesetter = new CTFramesetter (CreateAttributedString (li))) {
                CGPath path = new CGPath ();
                path.AddRect (new RectangleF (0, 0, li.Width ?? float.MaxValue, li.Height ?? float.MaxValue));

                return framesetter.GetFrame (new NSRange (0, li.Text.Length), path, null);
            }
        }