当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.DrawText方法代码示例

本文整理汇总了C#中Android.Graphics.Canvas.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.DrawText方法的具体用法?C# Canvas.DrawText怎么用?C# Canvas.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Graphics.Canvas的用法示例。


在下文中一共展示了Canvas.DrawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBackground

			public override ImageReference GetBackground (int row, int col)
			{
				var pt = new Point (row, col);
				ImageReference imgRef = null;
				if(mBackgrounds.ContainsKey(pt))
					imgRef = mBackgrounds [pt];
				if (imgRef == null) {
					var bm = Bitmap.CreateBitmap (200, 200, Bitmap.Config.Argb8888);
					var c = new Canvas (bm);
					var p = new Paint ();
					c.DrawRect (0, 0, 200, 200, p);
					p.AntiAlias = true;
					p.SetTypeface (Typeface.Default);
					p.TextSize = 64;
					p.Color = Color.LightGray;
					c.DrawText (col + "-" + row, 20, 100, p);
					imgRef = ImageReference.ForBitmap (bm);
					mBackgrounds.Add (pt, imgRef);
				}
				return imgRef;
			}
开发者ID:WalterVale,项目名称:monodroid-samples,代码行数:21,代码来源:GridExampleActivity.cs

示例2: OnDraw

            protected override void OnDraw(Canvas canvas)
            {
                canvas.DrawColor (Color.White);

                mPaint.SetTypeface (null);
                canvas.DrawText ("Default", 10, 100, mPaint);
                mPaint.SetTypeface (mFace);
                canvas.DrawText ("Custom", 10, 200, mPaint);
            }
开发者ID:rudini,项目名称:monodroid-samples,代码行数:9,代码来源:Typefaces.cs

示例3: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            Paint p = new Paint();
            Paint n = new Paint();
            n.Color = (Color.Black);
            n.TextAlign = (Paint.Align.Center);
            p.Color = (Color.Blue);
            p.Alpha = (50);
            canvas.DrawRect(picker, p);
            int[,] field = GameController.getInstance().getNumbers();
            float widthStep = (float)MeasuredWidth/9;
            float heightStep = (float)MeasuredHeight/9;
            n.TextSize = (heightStep);
            int[,] initial = GameController.getInstance().getInitialNumber();
            for (int i = 0; i < 9; i++){
                for (int q = 0; q < 9; q++){
                    if (initial[i,q] != 0){
                        canvas.DrawText(initial[i,q] + "", widthStep*q + (widthStep / 2),
                            heightStep*i + heightStep - (heightStep*0.1f), n);
                    }
                }
            }
            n.Alpha = (150);
            for (int i = 0; i < 9; i++){
                for (int q = 0; q < 9; q++){
                    if (field[i,q] != 0){
                        canvas.DrawText(field[i,q] + "", widthStep*i + (widthStep / 2),
                            heightStep*q + heightStep - (heightStep*0.1f), n);
                    }
                }
            }

            base.OnDraw(canvas);
        }
开发者ID:JustLex,项目名称:CourseTask,代码行数:34,代码来源:SudokuFieldView.cs

示例4: GetBackgroundForPage

			public override Android.Graphics.Drawables.Drawable GetBackgroundForPage (int row, int column)
			{
				Point pt = new Point (column, row);
				Drawable drawable;
				if (!mBackgrounds.ContainsKey(pt))
				{
					// the key wasn't found in Dictionary
					var bm = Bitmap.CreateBitmap(200, 200, Bitmap.Config.Argb8888);
					var c = new Canvas(bm);
					var p = new Paint();
					// Clear previous image.
					c.DrawRect(0, 0, 200, 200, p);
					p.AntiAlias = true;
					p.SetTypeface(Typeface.Default);
					p.TextSize = 64;
					p.Color = Color.LightGray;
					p.TextAlign = Paint.Align.Center;
					c.DrawText(column + "-" + row, 100, 100, p);
					drawable = new BitmapDrawable(owner.Resources, bm);
					mBackgrounds.Add(pt, drawable);
				}
				else
				{
					// the key was found
					drawable = mBackgrounds[pt];
				}
				return drawable;
			}
开发者ID:xamarin,项目名称:monodroid-samples,代码行数:28,代码来源:GridExampleActivity.cs

示例5: Draw

        public override void Draw(Canvas canvas)
        {
            LoadResources ();

            var blackPaint = new Paint () { Color = black.Value };
            var whitePaint = new Paint () { Color = white.Value };

            XamGame.RenderBoard ((RectangleF rect, Square.ColourNames color) =>
            {
                var paint = color == Square.ColourNames.White ? whitePaint : blackPaint;
                canvas.DrawRect (rect.X, rect.Y, rect.Right, rect.Bottom, paint);

            }, (RectangleF rect, object image) =>
            {
                if (image != null)
                    canvas.DrawBitmap ((Bitmap) image, rect.Left, rect.Top, null);
            });

            // New Game button
            whitePaint.Color = white.Value;
            whitePaint.SetStyle (Paint.Style.Fill);
            whitePaint.TextSize = 30;
            whitePaint.AntiAlias = true;
            Rect bounds = new Rect ();
            whitePaint.GetTextBounds ("New Game", 0, 8, bounds);
            canvas.DrawText ("New Game", (this.Width - bounds.Width ()) / 2, this.Bottom - (XamGame.BoardUpperLeftCorner.Y - bounds.Height ()) / 2, whitePaint);

            whitePaint.Dispose ();
            blackPaint.Dispose ();

            base.Draw (canvas);
        }
开发者ID:rolfbjarne,项目名称:XamChess,代码行数:32,代码来源:GameView.cs

示例6: GetBitmapMarker

        public Bitmap GetBitmapMarker(Context mContext, int resourceId, string text)
        {
            Resources resources = mContext.Resources;
            float scale = resources.DisplayMetrics.Density;
            Bitmap bitmap = BitmapFactory.DecodeResource(resources, resourceId);

            Bitmap.Config bitmapConfig = bitmap.GetConfig();

            // set default bitmap config if none
            if (bitmapConfig == null)
                bitmapConfig = Bitmap.Config.Argb8888;

            bitmap = bitmap.Copy(bitmapConfig, true);

            Canvas canvas = new Canvas(bitmap);
            Paint paint = new Paint(PaintFlags.AntiAlias);
            paint.Color = global::Android.Graphics.Color.Black;
            paint.TextSize = ((int)(14 * scale));
            paint.SetShadowLayer(1f, 0f, 1f, global::Android.Graphics.Color.White);

            // draw text to the Canvas center
            Rect bounds = new Rect();
            paint.GetTextBounds(text, 0, text.Length, bounds);
            int x = (bitmap.Width - bounds.Width()) / 2;
            int y = (bitmap.Height + bounds.Height()) / 2 - 20;

            canvas.DrawText(text, x, y, paint);

            return bitmap;
        }
开发者ID:sgraphics,项目名称:BindableMapTest,代码行数:30,代码来源:ExtendedMapRenderer.cs

示例7: Draw

 public override void Draw(Canvas canvas) {
     base.Draw(canvas);
     var paint = new Paint {
         Color = Color.White,
         TextSize = 40,
         AntiAlias = true
     };
     canvas.DrawText("Developers.IO", 100, 60, paint);
 }
开发者ID:furuya02,项目名称:Xamarin.Android.Samples,代码行数:9,代码来源:MyView.cs

示例8: DrawScaledText

		private void DrawScaledText(Canvas canvas, int lineStart, String line, float lineWidth) {
			float x = 0;
			if (IsFirstLineOfParagraph(lineStart, line)) {
				String blanks = "  ";
				canvas.DrawText(blanks, x, mLineY, Paint);
				float bw = StaticLayout.GetDesiredWidth(blanks, Paint);
				x += bw;

				line = line.Substring(3);
			}

			float d = (mViewWidth - lineWidth) / line.Length - 1;
			for (int i = 0; i < line.Length; i++) {
				String c = line[i].ToString();
				float cw = StaticLayout.GetDesiredWidth(c, Paint);
				canvas.DrawText(c, x, mLineY, Paint);
				x += cw + d;
			}
		}
开发者ID:aocsa,项目名称:CInca,代码行数:19,代码来源:JustifiedTextView.cs

示例9: DrawDebugInfo

        private static void DrawDebugInfo(Canvas canvas, IEnumerable<ILayer> layers)
        {
            using (var paint = new Paint {TextSize = 40})
            {
                var lineCounter = 1;
                const float tabWidth = 40f;
                const float lineHeight = 40f;

                foreach (var layer in layers)
                {
                    canvas.DrawText(layer.ToString(), tabWidth, lineHeight*(lineCounter++), paint);

                    if (layer is ITileLayer)
                    {
                        var text = "Tiles in memory: " + (layer as ITileLayer).MemoryCache.TileCount.ToString(CultureInfo.InvariantCulture);
                        canvas.DrawText(text, tabWidth, lineHeight*(lineCounter++), paint);
                    }
                }
            }
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:20,代码来源:MapRenderer.cs

示例10: Draw

		// Found at http://stackoverflow.com/questions/13884603/dynamic-button-text-size

		public override void Draw(Canvas canvas)
		{
			// let the ImageButton paint background as normal
			base.Draw(canvas);

			// draw the text
			// position is centered on width
			// and the baseline is calculated to be positioned from the
			// view bottom
			canvas.DrawText(((Button)Element).Text, _viewWidth/2, _viewHeight - _textBaseline, _textPaint);
		}
开发者ID:Surfoo,项目名称:WF.Player,代码行数:13,代码来源:ExtendedButtonRenderer.cs

示例11: Draw

 public override void Draw(Canvas canvas)
 {
     Rect bounds = Bounds;
     int height = bounds.Height();
     paint.TextSize = height;
     Rect textBounds = new Rect();
     string textValue = icon.Character.ToString();
     paint.GetTextBounds(textValue, 0, 1, textBounds);
     int textHeight = textBounds.Height();
     float textBottom = bounds.Top + (height - textHeight) / 2f + textHeight - textBounds.Bottom;
     canvas.DrawText(textValue, bounds.ExactCenterX(), textBottom, paint);
 }
开发者ID:Mitch528,项目名称:IconifyXamarin,代码行数:12,代码来源:IconDrawable.cs

示例12: Draw

        public override void Draw (Canvas canvas)
        {
            base.Draw (canvas);

            var circleX = canvas.Width /2 - CircleShape.MinimumWidth /4;
            var circleY = canvas.Height /2 - CircleShape.MinimumHeight;
            CircleShape.SetBounds (circleX, circleY, circleX + CircleShape.MinimumWidth, circleY + CircleShape.MinimumHeight);
            CircleShape.Draw (canvas);

            LabelPaint.GetTextBounds (BubbleText, 0, BubbleText.Length, textBoundsRect);
            canvas.DrawText (BubbleText,
                             circleX + CircleShape.MinimumWidth /2 - textBoundsRect.Width () /2,
                             (canvas.Height - textBoundsRect.Height ())/2, LabelPaint);
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:14,代码来源:NotificationImageView.cs

示例13: drawString

		private void drawString(Canvas gfx, TextPaint paint, float x, float y)
		{
			if (_maxWidth == int.MaxValue)
			{
				gfx.DrawText(_text, x, y, paint);
			}
			else
			{
				paint.TextAlign = alignWrap();
				StaticLayout layout = new StaticLayout (_text, paint, _maxWidth, Layout.Alignment.AlignNormal, 1f, 0f, false);
				gfx.Translate(x, y);
				layout.Draw(gfx);
				gfx.Translate(-x, -y);
			}
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:15,代码来源:AndroidBitmapTextDraw.cs

示例14: Draw

        public override void Draw(Canvas canvas, ICharSequence text, Int32 start, Int32 end, Single x, Int32 top, Int32 y, Int32 bottom, Paint paint)
        {
            ApplyCustomTypeFace(paint, _type);
            paint.GetTextBounds(_icon, 0, 1, TEXT_BOUNDS);
            canvas.Save();
            var baselineRatio = _baselineAligned ? 0f : BASELINE_RATIO;
            if (_rotate)
            {
                var rotation = (SystemClock.CurrentThreadTimeMillis() - _rotationStartTime) / (Single)ROTATION_DURATION * 360f;
                var centerX = x + TEXT_BOUNDS.Width() / 2f;
                var centerY = y - TEXT_BOUNDS.Height() / 2f + TEXT_BOUNDS.Height() * baselineRatio;
                canvas.Rotate(rotation, centerX, centerY);
            }

            canvas.DrawText(_icon, x - TEXT_BOUNDS.Left, y - TEXT_BOUNDS.Bottom + TEXT_BOUNDS.Height() * baselineRatio, paint);
            canvas.Restore();
        }
开发者ID:MuffPotter,项目名称:Xamarin.Plugins,代码行数:17,代码来源:CustomTypefaceSpan.cs

示例15: Draw

		public override void Draw (Canvas canvas)
		{
			child.Draw (canvas);
			if (count <= 0)
				return;
			badgePaint.Alpha = textPaint.Alpha = alpha;
			badgeBounds.Set (0, 0, Bounds.Width () / 2, Bounds.Height () / 2);
			canvas.DrawRoundRect (badgeBounds, 8, 8, badgePaint);
			textPaint.TextSize = (8 * badgeBounds.Height ()) / 10;
			var text = count.ToString ();
			textPaint.GetTextBounds (text, 0, text.Length, txtBounds);
			canvas.DrawText (
				text,
				badgeBounds.CenterX (),
				badgeBounds.Bottom - (badgeBounds.Height () - txtBounds.Height ()) / 2 - 1,
				textPaint
			);
		}
开发者ID:rmarinho,项目名称:xamarin-store-app,代码行数:18,代码来源:BadgeDrawable.cs


注:本文中的Android.Graphics.Canvas.DrawText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。