Example #1
0
 public virtual void Measure(Size avilableSize);
        public void DrawText(Point p, string text, Color fill, string fontFamily = null, double fontSize = 10, double fontWeight = 500, double rotate = 0, HorizontalAlignment halign = HorizontalAlignment.Left, VerticalAlignment valign = VerticalAlignment.Top, Size? maxSize = new Size?())
        {
            using (var paint = new Paint())
            {
                paint.AntiAlias = true;
                paint.TextSize = (float)fontSize;
                paint.Color = fill;
                var bounds = new Rect();
                paint.GetTextBounds(text, 0, text.Length, bounds);

                float dx = 0;
                if (halign == HorizontalAlignment.Center)
                {
                    dx = -bounds.Width() / 2;
                }

                if (halign == HorizontalAlignment.Right)
                {
                    dx = -bounds.Width();
                }

                float dy = 0;
                if (valign == VerticalAlignment.Center)
                {
                    dy = +bounds.Height() / 2;
                }

                if (valign == VerticalAlignment.Top)
                {
                    dy = bounds.Height();
                }

                canvas.Save();
                canvas.Translate(dx, dy);
                canvas.Rotate((float)rotate);
                canvas.Translate((float)p.X, (float)p.Y);
                canvas.DrawText(text, 0, 0, paint);
                canvas.Restore();
            }
        }
Example #3
0
 public virtual void Arrange(Size finalSize);