Exemplo n.º 1
0
        private void SetTextStyle(TextView view)
        {
            if (view.Handle == IntPtr.Zero)
            {
                return;
            }
            if (Font.Size > 0)
            {
                view.SetTextSize(ComplexUnitType.Sp, (float)Font.Size);
            }

            if (!string.IsNullOrEmpty(Font.Name))
            {
                var format = (Android.Graphics.TypefaceStyle)Font.Formatting;
                view.SetTypeface(Android.Graphics.Typeface.Create(Font.Name, format), format);
            }

            if (!ForegroundColor.IsDefaultColor)
            {
                view.SetTextColor(ForegroundColor.ToColor());
            }

            if (!BackgroundColor.IsDefaultColor)
            {
                view.SetBackgroundColor(BackgroundColor.ToColor());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// renders the text based on the properties set
        /// </summary>
        public IImageAdapter Render()
        {
            IImageAdapter retVal = null;

            SizeF fsize = Measure();

            using (Bitmap bmp = new Bitmap((int)(fsize.Width + .5), (int)(fsize.Height + .5)))
            {
                using (Graphics gpr = Graphics.FromImage(bmp))
                {
                    gpr.TextRenderingHint = TextRenderingHint;
                    gpr.Clear(BackgroundColor.ToColor());
                    using (Brush brush = new SolidBrush(ForegroundColor.ToColor()))
                    {
                        gpr.DrawString(Text, getFont(), brush, 0, 0);
                    }
                }
                retVal = new ImageAdapter(bmp);
            }
            return(retVal);
        }
Exemplo n.º 3
0
 public void Paint(Graphics g)
 {
     g.DrawLine(new Pen(ForegroundColor.IsDefaultColor ? System.Drawing.Color.Black : ForegroundColor.ToColor()),
                (int)Location.X, (int)Location.Y,
                (int)Location.X, (int)(Location.Y + Size.Height));
 }