protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
 {
     base.OnElementChanged(e);
     initPaintFlags = Control.PaintFlags;
     SetMaxLines();
     UpdateHasUnderLine();
 }
 public void DrawLine(Pen pen, float x1, float y1, float x2, float y2)
 {
     this.paint.Color = pen.Color.ToAColor();
     this.paint.Flags = this.Flags;
     this.paint.SetStyle(Paint.Style.Stroke);
     this.paint.StrokeWidth = pen.Width;
     this.canvas.DrawLine(x1, y1, x2, y2, paint);
 }
 public void DrawRectangle(Pen pen, float x1, float y1, float w, float h)
 {
     this.paint.Color = pen.Color.ToAColor();
     this.paint.Flags = this.Flags;
     this.paint.SetStyle(Paint.Style.Stroke);
     this.paint.StrokeWidth = pen.Width;
     this.canvas.DrawRect(x1, y1, x1 + w, y1 + h, this.paint);
 }
Exemple #4
0
        static public Paint Create(Color color, Paint.Style style, PaintFlags paint_flags)
        {
            Paint paint = new Paint(paint_flags);

            paint.Color = color;
            paint.SetStyle(style);

            return(paint);
        }
 public void DrawImage(Bitmap bitmap, Rectangle target, Rectangle source, GraphicsUnit gu)
 {
     this.paint.Flags = 0;
     using (Rect sa = source.ToRect())
     using (Rect ta = target.ToRect())
     {
         this.canvas.DrawBitmap(bitmap, sa, ta, this.paint);
     }
 }
Exemple #6
0
 public ExtendedLabelRenderer(Context context) : base(context)
 {
     try
     {
         PaintFlagsOriginal = Control.PaintFlags;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        protected override void OnAttached()
        {
            var pfLabel = Control as TextView;

            if (pfLabel == null)
            {
                return;
            }
            paintFlags         = pfLabel.PaintFlags;
            pfLabel.PaintFlags = Android.Graphics.PaintFlags.UnderlineText;
        }
Exemple #8
0
 private void UpdateUi(ExtendedEntry extendedElement)
 {
     if (extendedElement.IsStrikeThrough)
     {
         PaintFlagsOriginal = Control.PaintFlags;
         Control.PaintFlags = Control.PaintFlags | PaintFlags.StrikeThruText;
     }
     else
     {
         Control.PaintFlags = PaintFlagsOriginal;
     }
 }
Exemple #9
0
        public override bool LoadFont(Font font)
        {
            font.RealSize = font.Size * Scale;
            Paint paint = font.RendererData as Paint;

            if (paint != null)
            {
                paint.Dispose();
            }

            TypefaceStyle fontStyle = TypefaceStyle.Normal;

            if (font.Bold && font.Italic)
            {
                fontStyle = TypefaceStyle.BoldItalic;
            }
            if (font.Italic)
            {
                fontStyle = TypefaceStyle.Italic;
            }
            if (font.Bold)
            {
                fontStyle = TypefaceStyle.Bold;
            }

            PaintFlags paintFlags = PaintFlags.LinearText;

            if (font.Underline)
            {
                paintFlags |= PaintFlags.UnderlineText;
            }
            if (font.Strikeout)
            {
                paintFlags |= PaintFlags.StrikeThruText;
            }

            Typeface typeface = Typeface.Create(font.FaceName, fontStyle);

            paint = new Paint(paintFlags);
            paint.SetTypeface(typeface);
            paint.SetStyle(Paint.Style.Fill);
            paint.TextSize  = font.RealSize;
            paint.TextAlign = Paint.Align.Left;
            paint.Color     = global::Android.Graphics.Color.White;
            paint.AntiAlias = true;

            font.RendererData = paint;

            return(true);
        }
Exemple #10
0
        public async Task TextDecorationsInitializesCorrectly()
        {
            var xplatTextDecorations = TextDecorations.Underline;

            var labelHandler = new LabelStub()
            {
                TextDecorations = xplatTextDecorations
            };

            var values = await GetValueAsync(labelHandler, (handler) =>
            {
                return(new
                {
                    ViewValue = labelHandler.TextDecorations,
                    PlatformViewValue = GetNativeTextDecorations(handler)
                });
            });

            PaintFlags expectedValue = PaintFlags.UnderlineText;

            Assert.Equal(xplatTextDecorations, values.ViewValue);
            values.PlatformViewValue.AssertHasFlag(expectedValue);
        }
Exemple #11
0
 public static void RemovePaintFlag(this TextView textView, PaintFlags flag)
 {
     textView.PaintFlags = textView.PaintFlags & ~flag;
 }
 public void DrawEllipse(Pen pen, float x, float y, float w, float h)
 {
     this.paint.Color = pen.Color.ToAColor();
     this.paint.Flags = this.Flags;
     this.paint.SetStyle(Paint.Style.Stroke);
     this.paint.StrokeWidth = pen.Width;
     using (RectF r = new RectangleF(x, y, w, h).ToRectF())
     {
         this.canvas.DrawOval(r, this.paint);
     }
 }
Exemple #13
0
 public static void AddPaintFlag(this TextView textView, PaintFlags flag)
 {
     textView.PaintFlags = textView.PaintFlags | flag;
 }
 public void FillRectangle(Brush brush, float x1, float y1, float w, float h)
 {
     this.paint.Color = brush.Color.ToAColor();
     this.paint.Flags = this.Flags;
     this.paint.SetStyle(Paint.Style.Fill);
     this.canvas.DrawRect(x1, y1, x1 + w, y1 + h, this.paint);
 }
 private Graphics()
 {
     this.paint = new Paint();
     this.Flags = PaintFlags.AntiAlias;
     this.ownCanvas = false;
 }
 public void DrawImage(Bitmap bitmap, int x, int y)
 {
     this.paint.Flags = 0;
     this.canvas.DrawBitmap(bitmap, x, y, this.paint);
 }
 public void FillEllipse(Brush brush, float x, float y, float w, float h)
 {
     this.paint.Color = brush.Color.ToAColor();
     this.paint.Flags = this.Flags;
     this.paint.SetStyle(Paint.Style.Fill);
     using (RectF r = new RectangleF(x, y, w, h).ToRectF())
     {
         this.canvas.DrawOval(r, this.paint);
     }
 }
        public void DrawString(string text, Font font, Brush brush, float x, float y)
        {
            this.paint.Color = brush.Color.ToAColor();
            this.paint.Flags = PaintFlags.AntiAlias;

            this.paint.TextSize = font.Size;
            this.paint.SetTypeface(font.FontFamily.Typeface);
            this.paint.SetStyle(Paint.Style.Fill);

            using (var fm = this.paint.GetFontMetrics())
            {
                this.canvas.DrawText(text, x, y - (fm.Top + fm.Bottom), this.paint);
            }
        }