コード例 #1
0
ファイル: DailyGraphView.cs プロジェクト: ihatead/XWeather
        void drawLabel(Canvas canvas, float xCoord, float yCoord, Paint.Align alignment, string label, bool centerVertical = false)
        {
            var fontColor = Color.White;

            var textPaint = new TextPaint();

            textPaint.Color = fontColor;

            textPaint.TextSize = fontSize;

            textPaint.TextAlign = alignment;

            textPaint.SetStyle(Paint.Style.Stroke);


            var frame = new Rect();

            textPaint.GetTextBounds(label, 0, label.Length, frame);

            if (centerVertical)
            {
                yCoord -= frame.CenterY();
            }
            else
            {
                yCoord += frame.Height();
            }

            canvas.DrawText(label, xCoord, yCoord, textPaint);
        }
コード例 #2
0
ファイル: IconDrawable.cs プロジェクト: rotorgames/Iconize
        /// <summary>
        /// Create an <see cref="IconDrawable" />.
        /// </summary>
        /// <param name="context">Your activity or application context.</param>
        /// <param name="icon">The icon you want this drawable to display.</param>
        public IconDrawable(Context context, IIcon icon)
        {
            var module = Iconize.FindModuleOf(icon);

            Console.WriteLine("IconDrawable.Icon " + icon);
            if (icon is null)
            {
                throw new Java.Lang.IllegalStateException("El icono no puede estar nulo.");
            }
            if (module is null)
            {
                throw new Java.Lang.IllegalStateException($"Unable to find the module associated with icon {icon.Key}, have you registered the module you are trying to use with Iconize.With(...) in your Application?");
            }

            _context = context;
            _icon    = icon;

            _paint = new TextPaint
            {
                AntiAlias     = true,
                TextAlign     = Paint.Align.Center,
                UnderlineText = false
            };
            _paint.SetStyle(Paint.Style.Fill);
            _paint.SetTypeface(module.ToTypeface(context));
        }
コード例 #3
0
        public CompassViewDrawer(IPoiCategoryBitmapProvider poiCategoryBitmapProvider)
        {
            Typeface normal = Typeface.Create("Arial", TypefaceStyle.Normal);

            this.poiCategoryBitmapProvider = poiCategoryBitmapProvider;

            paintRect = new Paint();
            paintRect.SetARGB(150, 0, 0, 0);
            paintRect.SetStyle(Paint.Style.FillAndStroke);
            paintRect.StrokeWidth = 4;

            paintTapArea = new Paint();
            paintTapArea.SetARGB(100, 0, 0, 0);
            paintTapArea.SetStyle(Paint.Style.Fill);

            paintTapFavourite = new Paint();
            paintTapFavourite.SetARGB(150, 255, 195, 0);
            paintTapFavourite.SetStyle(Paint.Style.Fill);

            paintRectSelectedItem = new Paint();
            paintRectSelectedItem.SetARGB(150, 255, 255, 255);
            paintRectSelectedItem.SetStyle(Paint.Style.FillAndStroke);
            paintRectSelectedItem.StrokeWidth = 4;

            textpaint = new Paint();
            textpaint.SetARGB(255, 200, 255, 0);
            textpaint.TextSize  = 36;
            textpaint.AntiAlias = true;
            textpaint.SetTypeface(normal);

            textpaintSelected = new Paint();
            textpaintSelected.SetARGB(255, 0, 0, 0);
            textpaintSelected.TextSize  = 36;
            textpaintSelected.AntiAlias = true;
            textpaintSelected.SetTypeface(normal);

            textPaintForEllipsize = new TextPaint();
            textPaintForEllipsize.SetARGB(255, 200, 255, 0);
            textPaintForEllipsize.SetStyle(Paint.Style.Fill);
            textPaintForEllipsize.TextSize   = 36;
            textPaintForEllipsize.AntiAlias  = true;
            textPaintForEllipsize.TextAlign  = Paint.Align.Left;
            textPaintForEllipsize.LinearText = true;

            paintWhite = new Paint();
            paintWhite.SetARGB(255, 255, 255, 255);
            paintWhite.SetStyle(Paint.Style.Fill);

            paintGray = new Paint();
            paintGray.SetARGB(255, 186, 186, 186);
            paintGray.SetStyle(Paint.Style.Fill);

            paintBlack = new Paint();
            paintBlack.SetARGB(255, 0, 0, 0);
            paintBlack.SetStyle(Paint.Style.Fill);

            multiplier = 1;
        }
コード例 #4
0
        public void init()
        {
            TextPaint tp1 = borderText.Paint;

            tp1.StrokeWidth = 5;                     // sets the stroke width
            tp1.SetStyle(Style.Stroke);
            borderText.SetTextColor(Color.Black);    // set the stroke color
            borderText.Gravity = Gravity;
        }
コード例 #5
0
        private void Init()
        {
            _paint.SetStyle(Paint.Style.Stroke);
            _paint.StrokeWidth = 2 * Resources.DisplayMetrics.Density;
            _paint.AntiAlias   = true;

            _labelPaint.SetStyle(Paint.Style.Fill);
            _labelPaint.AntiAlias = true;
        }
コード例 #6
0
 private void Init(Context context, Icon icon)
 {
     _context = context;
     _icon    = icon;
     _paint   = new TextPaint();
     _paint.SetTypeface(Iconify.FindTypefaceOf(icon).GetTypeface(context));
     _paint.SetStyle(Paint.Style.Fill);
     _paint.TextAlign     = Paint.Align.Center;
     _paint.UnderlineText = false;
     _paint.Color         = Color.Black;
     _paint.AntiAlias     = true;
 }
コード例 #7
0
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                bool isBg = e.NewElement.ClassId == "BGBLACK";
                if (!Settings.SubtitlesHasOutline && isBg)
                {
                    e.NewElement.Opacity = 0;
                }
                ;

                StrokeTextView2 strokeTextView = new StrokeTextView2(context)
                {
                    Text      = e.NewElement.Text,
                    ShadowStr = (!isBg && Settings.SubtitlesHasDropShadow) ? Settings.SubtitlesShadowStrenght : 1,
                };

                strokeTextView.SetTypeface(Control.Typeface, Settings.SubtitlesHasOutline ? TypefaceStyle.Bold : TypefaceStyle.Normal);
                if (Settings.SubtitlesHasDropShadow && !isBg)
                {
                    float offset = Settings.SubtitlesOutlineIsCentered ? 0 : 5f;
                    strokeTextView.SetShadowLayer(5f, offset, offset, Android.Graphics.Color.Black);
                }
                strokeTextView.SetTextSize(Android.Util.ComplexUnitType.Dip, Settings.SubtitlesSize);
                strokeTextView.TextAlignment = Android.Views.TextAlignment.Center;
                //strokeTextView.BreakStrategy = Android.Text.BreakStrategy.;
                strokeTextView.Gravity = GravityFlags.CenterHorizontal | GravityFlags.Bottom;

                if (isBg)
                {
                    strokeTextView.SetTextColor(Android.Graphics.Color.Black);
                    TextPaint tp1 = strokeTextView.Paint;
                    tp1.StrokeWidth = (Settings.SubtitlesSize / 5.4f);                     //3f;
                    tp1.SetStyle(Paint.Style.Stroke);
                }
                else
                {
                    strokeTextView.SetTextColor(Android.Graphics.Color.White);
                }

                Control.AfterTextChanged += (_o, _e) => {
                    var _txt = e.NewElement.Text;
                    strokeTextView.Text = _txt;
                    //strokeTextView.ChangeText();
                };

                SetNativeControl(strokeTextView);
                //strokeTextView.SetTextColor(Android.Graphics.Color.Purple);
            }
        }
コード例 #8
0
 private void InitPaint()
 {
     mTextPaint           = new TextPaint();
     mTextPaint.AntiAlias = true;
     mTextPaint.TextSize  = TextSize;
     mTextPaint.Color     = mColor;
     mTextPaint.SetStyle(APaint.Style.Fill);
     mTextPaint.SetTypeface(Typeface);
     mTextPaintOutline           = new TextPaint();
     mTextPaintOutline.AntiAlias = true;
     mTextPaintOutline.TextSize  = TextSize;
     mTextPaintOutline.Color     = mBorderColor;
     mTextPaintOutline.SetStyle(APaint.Style.Stroke);
     mTextPaintOutline.SetTypeface(Typeface);
     mTextPaintOutline.StrokeWidth = mBorderSize;
 }
コード例 #9
0
        public FontDrawable(Context context, string text, Color iconColor, int iconSizeDP, string font)
        {
            this.text = text;
            if (font == null || font.Length <= 0)
            {
                font = "fontawesome.ttf";
            }

            paint.SetTypeface(Typeface.CreateFromAsset(context.Assets, font));
            paint.SetStyle(Paint.Style.Fill);
            paint.TextAlign = Paint.Align.Center;
            paint.Color     = iconColor;
            paint.AntiAlias = true;
            size            = GetPX(context, iconSizeDP);
            SetBounds(0, 0, size, size);
        }
コード例 #10
0
        private void InitPaint()
        {
            mTextPaint           = new TextPaint();
            mTextPaint.AntiAlias = true;     // (true);
            mTextPaint.TextSize  = TextSize; // (getTextSize());
            mTextPaint.Color     = mColor;   //  SetColor(mColor);
            mTextPaint.SetStyle(Android.Graphics.Paint.Style.Fill);
            mTextPaint.SetTypeface(Typeface);

            mTextPaintOutline           = new TextPaint();
            mTextPaintOutline.AntiAlias = true;// (true);
            mTextPaintOutline.TextSize  = TextSize;
            mTextPaintOutline.Color     = mBorderColor;
            mTextPaintOutline.SetStyle(Android.Graphics.Paint.Style.Stroke);
            mTextPaintOutline.SetTypeface(Typeface);
            mTextPaintOutline.StrokeWidth = mBorderSize;// SetStrokeWidth(mBorderSize);
        }
コード例 #11
0
        private void Init(Context context, string fontFacePath)
        {
            _context = context;

            _paint = new TextPaint
            {
                AntiAlias     = true,
                Color         = Android.Graphics.Color.Black,
                TextAlign     = Paint.Align.Center,
                UnderlineText = false
            };
            _paint.SetStyle(Paint.Style.Fill);

            if (fontFacePath != null)
            {
                _paint.SetTypeface(Typeface.CreateFromAsset(context.Assets, $"{fontFacePath}.ttf"));
            }
        }
コード例 #12
0
        /// <summary>
        /// Create an <see cref="IconDrawable" />.
        /// </summary>
        /// <param name="context">Your activity or application context.</param>
        /// <param name="iconKey">The icon key you want this drawable to display.</param>
        /// <exception cref="ArgumentException">If the key doesn't match any icon.</exception>
        public IconDrawable(Context context, String iconKey)
        {
            if (FontAwesomeRegular.Items.TryGetValue(iconKey, out char iconChar))
            {
                return;
            }

            _iconChar = iconChar;
            _context  = context;

            _paint = new TextPaint
            {
                AntiAlias     = true,
                TextAlign     = Paint.Align.Center,
                UnderlineText = false
            };
            _paint.SetStyle(Paint.Style.Fill);
            _paint.SetTypeface(GetTypeface(context));
        }
コード例 #13
0
 private void Init(Context context, IIcon icon)
 {
     _context = context;
     _icon = icon;
     _paint = new TextPaint();
     var module = Iconize.FindModuleOf(icon);
     if (module == null)
     {
         throw new Java.Lang.IllegalStateException("Unable to find the module associated " +
                 "with icon " + icon.Key + ", have you registered the module " +
                 "you are trying to use with Iconize.With(...) in your Application?");
     }
     _paint.SetTypeface(module.GetTypeface(context));
     _paint.SetStyle(Paint.Style.Fill);
     _paint.TextAlign = Paint.Align.Center;
     _paint.UnderlineText = false;
     _paint.Color = global::Android.Graphics.Color.Black;
     _paint.AntiAlias = true;
 }
コード例 #14
0
 /// <summary>
 /// Initializes the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="icon">The icon.</param>
 /// <exception cref="Java.Lang.IllegalStateException">Unable to find the module associated  +
 ///                         with icon  + icon.Key + , have you registered the module  +
 ///                         you are trying to use with Iconize.With(...) in your Application?</exception>
 private void Init(Context context, IIcon icon)
 {
     _context = context;
     _icon = icon;
     _paint = new TextPaint();
     var module = Iconize.FindModuleOf(icon);
     if (module == null)
     {
         throw new Java.Lang.IllegalStateException("Unable to find the module associated " +
                 "with icon " + icon.Key + ", have you registered the module " +
                 "you are trying to use with Iconize.With(...) in your Application?");
     }
     _paint.SetTypeface(module.ToTypeface(context));
     _paint.SetStyle(Paint.Style.Fill);
     _paint.TextAlign = Paint.Align.Center;
     _paint.UnderlineText = false;
     _paint.Color = Android.Graphics.Color.Black;
     _paint.AntiAlias = true;
 }
コード例 #15
0
 private void Init(Context context, IIcon icon)
 {
     this.context = context;
     this.icon = icon;
     paint = new TextPaint();
     IconFontDescriptorWrapper descriptor = Iconify.FindTypefaceOf(icon);
     if (descriptor == null)
     {
         throw new IllegalStateException("Unable to find the module associated " +
                 "with icon " + icon.Key + ", have you registered the module " +
                 "you are trying to use with Iconify.with(...) in your Application?");
     }
     paint.SetTypeface(descriptor.GetTypeface(context));
     paint.SetStyle(Paint.Style.Fill);
     paint.TextAlign = Paint.Align.Center;
     paint.UnderlineText = false;
     paint.Color = new Android.Graphics.Color(0, 0, 0);
     //paint.Color = Color.Black;
     paint.AntiAlias = true;
 }
        public override void Draw(Canvas canvas)
        {
            float width  = paddingLeft + segmentWidth + paddingRight;
            float height = paddingTop + segmentHeight * classBreakStyle.ClassBreaks.Count + paddingBottom;

            Paint backgroundPaint = new Paint();

            backgroundPaint.Color = Color.White;
            backgroundPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawRect(new RectF(offsetX, offsetY + (Height - height), offsetX + width, offsetY + Height), backgroundPaint);

            Paint segmentPaint = new Paint();

            segmentPaint.SetStyle(Paint.Style.Fill);

            TextPaint haloTextPaint = new TextPaint();

            haloTextPaint.Color = Color.White;
            haloTextPaint.SetStyle(Paint.Style.Stroke);
            haloTextPaint.StrokeWidth = 2;
            haloTextPaint.AntiAlias   = true;
            haloTextPaint.TextSize    = textPaint.TextSize;

            for (int i = 0; i < classBreakStyle.ClassBreaks.Count; i++)
            {
                int   currentIndex = i;
                float barLeft      = offsetX + paddingLeft;
                float barTop       = offsetY + Height - (paddingBottom + (i + 1) * segmentHeight);
                float barRight     = barLeft + segmentWidth;
                float barBottom    = barTop + segmentHeight;

                segmentPaint.Color = GetColor(classBreakStyle.ClassBreaks[currentIndex]);
                canvas.DrawRect(new RectF(barLeft, barTop, barRight, barBottom), segmentPaint);

                float x = barRight + paddingRight + textMargin;
                float y = barTop + segmentHeight / 2 + textPaint.TextSize / 2;

                canvas.DrawText(classBreakStyle.ClassBreaks[currentIndex].Value.ToString("R0"), x, y, haloTextPaint);
                canvas.DrawText(classBreakStyle.ClassBreaks[currentIndex].Value.ToString("R0"), x, y, textPaint);
            }
        }
コード例 #17
0
        private void Init(Context context, IIcon icon)
        {
            this.context = context;
            this.icon    = icon;
            paint        = new TextPaint();
            IconFontDescriptorWrapper descriptor = Iconify.FindTypefaceOf(icon);

            if (descriptor == null)
            {
                throw new IllegalStateException("Unable to find the module associated " +
                                                "with icon " + icon.Key + ", have you registered the module " +
                                                "you are trying to use with Iconify.with(...) in your Application?");
            }
            paint.SetTypeface(descriptor.GetTypeface(context));
            paint.SetStyle(Paint.Style.Fill);
            paint.TextAlign     = Paint.Align.Center;
            paint.UnderlineText = false;
            paint.Color         = new Android.Graphics.Color(0, 0, 0);
            //paint.Color = Color.Black;
            paint.AntiAlias = true;
        }
コード例 #18
0
        void DrawChart(Canvas canvas)
        {
            if (barRect == null || barRect.Count == 0)
            {
                return;
            }

            try
            {
                var contentWidth  = Width;
                var contentHeight = Height;

                // background color of the canvas
                canvas.DrawColor(Color.White);

                mTextPaint.SetStyle(Paint.Style.Stroke);
                mTextPaint.AntiAlias   = true;
                mTextPaint.TextAlign   = Paint.Align.Left;
                mTextPaint.StrokeWidth = 0;
                mTextPaint.TextSize    = textSize12;

                //get the text width
                string text   = "0120";
                Rect   bounds = new Rect();
                mTextPaint.GetTextBounds(text, 0, text.Length, bounds);
                int textWidth  = bounds.Width();
                int textHeight = bounds.Height();

                float fcontentWidth  = contentWidth - textWidth;
                float fcontentHeight = contentHeight - textHeight * 2;

                rectGraph.Top    = textHeight + (chartData.Radius * 3) + 5;
                rectGraph.Left   = textWidth * 2;
                rectGraph.Right  = (int)fcontentWidth;
                rectGraph.Bottom = (int)fcontentHeight;

                canvas.DrawRect(rectGraph, mBarPaint);

                // vertical data  preparation
                int   noOfBars  = chartData.BarColors.Count;
                float boxHeight = rectGraph.Height() / noOfBars;

                float prevVal = chartData.BaseValue;
                float diffVal = float.Parse(chartData.YValues[noOfBars - 1]) - prevVal;

                float boxHeight1 = 0;

                mTextPaint.TextSize  = textSize12;
                mTextPaint.Color     = Color.White;
                mTextPaint.TextAlign = Paint.Align.Left;

                mLinePaint.Color       = Color.White;
                mLinePaint.StrokeWidth = mHorizontalLineStroke;

                //Draw vertical data
                for (int i = 0; i < noOfBars; i++)
                {
                    //dynamic height

                    float cVal = float.Parse(chartData.YValues[i]) - prevVal;
                    boxHeight = (cVal * 100) / diffVal;
                    boxHeight = (rectGraph.Height() * boxHeight) / 100;
                    prevVal   = float.Parse(chartData.YValues[i]);

                    mBarPaint.Color = Color.ParseColor(chartData.BarColors[i]);

                    barRect[i].Left   = rectGraph.Left;
                    barRect[i].Top    = rectGraph.Bottom - boxHeight1 - boxHeight;
                    barRect[i].Right  = rectGraph.Right;
                    barRect[i].Bottom = rectGraph.Bottom - boxHeight1;

                    canvas.DrawRect(barRect[i], mBarPaint);

                    mTextPaint.TextSize  = textSize12;
                    mTextPaint.Color     = Color.White;
                    mTextPaint.TextAlign = Paint.Align.Left;

                    canvas.DrawText(chartData.BarText[i], barRect[i].Left + 20, barRect[i].Top + barRect[i].Height() / 2 + textHeight / 2, mTextPaint);
                    canvas.DrawLine(barRect[i].Left, barRect[i].Bottom, barRect[i].Right, barRect[i].Bottom, mLinePaint);

                    mTextPaint.TextSize = textSize10;
                    mTextPaint.Color    = Color.Black;

                    //Draw Vertical texts
                    mTextPaint.TextAlign = Paint.Align.Right;
                    canvas.DrawText(chartData.YValues[i], barRect[i].Left - 10, barRect[i].Top + textHeight / 2, mTextPaint);

                    boxHeight1 += boxHeight;
                }

                canvas.DrawText("" + chartData.BaseValue, barRect[0].Left - 10, barRect[0].Bottom, mTextPaint);

                //409bd6 Circle Color
                mBarPaint.Color = Color.ParseColor("#409bd6");

                //Draw x & Y axis borders
                mTextPaint.StrokeWidth = 5;
                canvas.DrawLine(rectGraph.Left, rectGraph.Top, rectGraph.Left, rectGraph.Bottom, mTextPaint);
                canvas.DrawLine(rectGraph.Left, rectGraph.Bottom, rectGraph.Right, rectGraph.Bottom, mTextPaint);

                //Draw horizontal data
                int horizantalpadding = 20;

                mTextPaint.TextSize = textSize10;
                mTextPaint.Color    = Color.Black;

                int pointdistance = (rectGraph.Width() - horizantalpadding * 2) / (chartData.XValues.Count + 1);

                for (int i = 0; i < chartData.XValues.Count; i++)
                {
                    mTextPaint.Color       = Color.Black;
                    mTextPaint.StrokeWidth = 0;

                    float currentValue = float.Parse(chartData.XValues[i]);

                    int quadrant = GetQuadrant(currentValue);

                    float tempvalue  = 0;
                    int   percentage = 0;
                    float difference = 0;

                    if (quadrant > 0)
                    {
                        tempvalue = currentValue - float.Parse(chartData.YValues[quadrant - 1]);

                        difference = float.Parse(chartData.YValues[quadrant]) - float.Parse(chartData.YValues[quadrant - 1]);

                        percentage = (int)((tempvalue * 100) / (difference));
                    }
                    else
                    {
                        tempvalue = currentValue - chartData.BaseValue;

                        difference = float.Parse(chartData.YValues[quadrant]) - chartData.BaseValue;

                        percentage = (int)((tempvalue * 100) / (difference));
                    }

                    //Avoid drawing out of the bounds

                    if (percentage > 100)
                    {
                        percentage = percentage + (chartData.Radius);
                    }



                    //calculate box height
                    float ycenterpoint = 0;
                    if (barRect.Count - 1 >= i)
                    {
                        ycenterpoint = (barRect[i].Height() * percentage) / 100;
                    }
                    else
                    {
                        ycenterpoint = (barRect[i - 1].Height() * percentage) / 100;
                    }



                    mTextPaint.TextAlign = Paint.Align.Center;

                    //draw x legends
                    mTextPaint.TextSize = textSize10;
                    mTextPaint.GetTextBounds(chartData.Legends[i], 0, chartData.Legends[i].Length, bounds);
                    textHeight = bounds.Height();
                    canvas.DrawText(chartData.Legends[i], (pointdistance * (i + 2)), rectGraph.Bottom + textHeight + 10, mTextPaint);


                    // draw vertical Lines
                    mTextPaint.Color       = (Color.DarkGray);
                    mTextPaint.TextAlign   = (Paint.Align.Center);
                    mTextPaint.StrokeWidth = 1;
                    linesRect[i].Left      = (pointdistance * (i + 2));
                    // modify the top value if the last value is beyond last stripe
                    linesRect[i].Top = (int)(barRect[quadrant].Bottom - ycenterpoint);
                    canvas.DrawLine(linesRect[i].Left, linesRect[i].Top, linesRect[i].Left, rectGraph.Bottom, mTextPaint);

                    //draw lines between points
                    mTextPaint.Color       = (Color.Aqua);
                    mTextPaint.StrokeWidth = 2;
                    mTextPaint.SetStyle(Paint.Style.Stroke);

                    if (i == 0)
                    {
                        mLinePath.MoveTo((pointdistance * (i + 2)), linesRect[i].Top);
                    }
                    else
                    {
                        mLinePath.LineTo((pointdistance * (i + 2)), linesRect[i].Top);
                    }
                }

                canvas.DrawPath(mLinePath, mLinePathPaint);


                // plot X  values and draw Circle for them
                for (int i = 0; i < linesRect.Count; i++)
                {
                    // draw Inner circle
                    canvas.DrawCircle(linesRect[i].Left, linesRect[i].Top, chartData.Radius, mBarPaint);

                    // draw outer circle
                    mTextPaint.Color = (Color.Black);
                    canvas.DrawCircle(linesRect[i].Left, linesRect[i].Top, chartData.Radius, mTextPaint);

                    // draw x values
                    mTextPaint.Color    = (Color.White);
                    mTextPaint.TextSize = textSize8;
                    canvas.DrawText(chartData.XValues[i], linesRect[i].Left, linesRect[i].Top + textHeight / 2, mTextPaint);
                }
            }
            catch (System.Exception e)
            {
                throw new System.Exception("Withdrawal failed", e);
            }
        }
コード例 #19
0
ファイル: IconDrawable.cs プロジェクト: PragmaticIT/xiconify
 private void Init(Context context, Icon icon)
 {
     _context = context;
     _icon = icon;
     _paint = new TextPaint();
     _paint.SetTypeface(Iconify.FindTypefaceOf(icon).GetTypeface(context));
     _paint.SetStyle(Paint.Style.Fill);
     _paint.TextAlign = Paint.Align.Center;
     _paint.UnderlineText = false;
     _paint.Color = Color.Black;
     _paint.AntiAlias = true;
 }
コード例 #20
0
		void drawLabel (Canvas canvas, float xCoord, float yCoord, Paint.Align alignment, string label, bool centerVertical = false)
		{
			var fontColor = Color.White;

			var textPaint = new TextPaint ();

			textPaint.Color = fontColor;

			textPaint.TextSize = fontSize;

			textPaint.TextAlign = alignment;

			textPaint.SetStyle (Paint.Style.Stroke);


			var frame = new Rect ();

			textPaint.GetTextBounds (label, 0, label.Length, frame);

			if (centerVertical) {

				yCoord -= frame.CenterY ();

			} else {

				yCoord += frame.Height ();
			}

			canvas.DrawText (label, xCoord, yCoord, textPaint);
		}
コード例 #21
0
 /// <summary>
 /// Sets paint style.
 /// </summary>
 /// <param name="style">The style to be applied.</param>
 public void SetStyle(Paint.Style style)
 {
     _paint.SetStyle(style);
 }
コード例 #22
0
ファイル: CompassView.cs プロジェクト: 42Spikes/F2S
        public CompassView(Context context, Android.Util.IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            _paint = new Paint();
            _paint.SetStyle(Paint.Style.Fill);
            _paint.AntiAlias = true;
            _paint.TextSize = (float)DIRECTION_TEXT_HEIGHT;
            _paint.SetTypeface(Typeface.Create("sans-serif-thin", TypefaceStyle.Normal));

            _tickPaint = new Paint();
            _tickPaint.SetStyle(Paint.Style.Stroke);
            _tickPaint.StrokeWidth = (float)TICK_WIDTH;
            _tickPaint.AntiAlias = true;
            _tickPaint.Color = Color.White;

            _placePaint = new TextPaint();
            _placePaint.SetStyle(Paint.Style.Fill);
            _placePaint.AntiAlias = true;
            _placePaint.Color = Color.White;
            _placePaint.TextSize = (float)PLACE_TEXT_HEIGHT;
            _placePaint.SetTypeface(Typeface.Create("sans-serif-light", TypefaceStyle.Normal));

            _path = new Path();
            _textBounds = new Rect();
            _allBounds = new List<Rect>();

            _distanceFormat = NumberFormat.GetNumberInstance(Locale.Default);
            _distanceFormat.MinimumFractionDigits = 0;
            _distanceFormat.MaximumFractionDigits = 1;

            _placeBitmap = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.place_mark);
            _animatedHeading = Double.NaN;

            _directions = context.Resources.GetStringArray(Resource.Array.direction_abbreviations);

            _animator = new ValueAnimator();
            setupAnimator();
        }