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


C# Paint.SetTypeface方法代码示例

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


在下文中一共展示了Paint.SetTypeface方法的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: CreateBitmapData

		void CreateBitmapData (string str, out byte[] bitmapData, out int width, out int height)
		{
			Paint paint = new Paint ();
			paint.TextSize = 128;
			paint.TextAlign = Paint.Align.Left;
			paint.SetTypeface (Typeface.Default);
			width = height = 256;
			float textWidth = paint.MeasureText (str);

			using (Bitmap bitmap = Bitmap.CreateBitmap (width, height, Bitmap.Config.Argb8888)) {
				Canvas canvas = new Canvas (bitmap);
				paint.Color = str != " " ? Color.White : Color.LightGray;
				canvas.DrawRect (new Rect (0, 0, width, height), paint);
				paint.Color = Color.Black;
				canvas.DrawText (str, (256 - textWidth) / 2f, (256 - paint.Descent () - paint.Ascent ()) / 2f, paint);
				bitmapData = new byte [width * height * 4];
				Java.Nio.ByteBuffer buffer = Java.Nio.ByteBuffer.Allocate (bitmapData.Length);
				bitmap.CopyPixelsToBuffer (buffer);
				buffer.Rewind ();
				buffer.Get (bitmapData, 0, bitmapData.Length);
			}
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:22,代码来源:GLKeysView.cs

示例3: Initialize

		void Initialize ()
		{
			_basePaint = new Paint ();
			_basePaint.Color = Color.Black;
			_basePaint.AntiAlias = true;
			_basePaint.SetStyle (Paint.Style.Fill);

			_gridPaint = new Paint ();
			_gridPaint.SetStyle (Paint.Style.Stroke);
			_gridPaint.Color = Color.ParseColor (RSColors.RS_LIGHT_GRAY);

			_circlesPaint = new Paint ();
			_circlesPaint.Color = Color.ParseColor (RSColors.PURPLE_4);
			_circlesPaint.SetStyle (Paint.Style.Fill);
			_circlesPaint.AntiAlias = true;

			_dataLabelPaint = new Paint ();
			_dataLabelPaint.Color = Color.ParseColor (RSColors.GREEN_4);
			_dataLabelPaint.TextSize = PixelUtil.GetPixelFromDP (dataLabelSize, _context.Resources);
			_dataLabelPaint.SetStyle (Paint.Style.Stroke);
			_dataLabelPaint.AntiAlias = true;
			_dataLabelPaint.SetTypeface (Typeface.DefaultBold);
			_dataLabelPaint.TextAlign = Paint.Align.Center;

			_dataLabelBgPaint = new Paint ();
			_dataLabelBgPaint.Color = Color.White;
			_dataLabelBgPaint.SetStyle (Paint.Style.Fill);

			_xLabelPaint = new Paint ();
			_xLabelPaint.Color = Color.Black;
			_xLabelPaint.SetStyle (Paint.Style.Stroke);
			_xLabelPaint.AntiAlias = true;
			_xLabelPaint.TextAlign = Paint.Align.Center;
			_xLabelPaint.TextSize = PixelUtil.GetPixelFromDP (xLabelSize, _context.Resources);
		}
开发者ID:KiranKumarAlugonda,项目名称:TXTSHD,代码行数:35,代码来源:LineChartView.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: DrawingImageView

	public DrawingImageView(Context context, Fragment fragment): base(context) {
		mPaint = new Paint();
		mPaint.AntiAlias = true;
		mPaint.Dither = true;
		mPaint.Color = Color.Yellow;
		mPaint.SetStyle (Paint.Style.Stroke);
		mPaint.StrokeJoin = Paint.Join.Round;
		mPaint.StrokeCap = Paint.Cap.Round;
		mPaint.StrokeWidth = 10;

		cPaint = new Paint ();
		cPaint.Color = Color.Yellow;
		cPaint.StrokeJoin = Paint.Join.Round;
		cPaint.StrokeCap = Paint.Cap.Round;
		cPaint.SetTypeface(Typeface.Default);
		cPaint.TextSize = 40;

		mPath = new Android.Graphics.Path();
		mBitmapPaint = new Paint();
		mBitmapPaint.Color = Color.Yellow;

		DrawingStatus = DrawingType.None;

		_fragment = fragment;
	}
开发者ID:ehill8624,项目名称:ValkreRender,代码行数:25,代码来源:DrawingImageView.cs

示例6: ApplyCustomTypeFace

        private static void ApplyCustomTypeFace(Paint paint, Typeface tf, Android.Graphics.Color color)
        {
            int oldStyle;
            Typeface old = paint.Typeface;
            if (old == null)
            {
                oldStyle = 0;
            }
            else
            {
                oldStyle = (int)old.Style;
            }

            int fake = oldStyle & ~(int)tf.Style;
            if ((fake & (int)TypefaceStyle.Bold) != 0)
            {
                paint.FakeBoldText = true;
            }

            if ((fake & (int)TypefaceStyle.Italic) != 0)
            {
                paint.TextSkewX = -0.25f;
            }



            paint.SetARGB(color.A, color.R, color.G, color.B);

            paint.SetTypeface(tf);
        }
开发者ID:renatojunior2009,项目名称:Xamarin-Forms-Labs,代码行数:30,代码来源:CustomTypeFaceSpan.cs

示例7: InitStepCountPaint

			void InitStepCountPaint()
			{
				stepcountPaint = new Paint();
				//stepcountPaint.Color = Color.White;
				stepcountPaint.SetARGB(255, 50, 151, 218);
				stepcountPaint.SetTypeface(Typeface.Create(Typeface.SansSerif, TypefaceStyle.Normal));
				stepcountPaint.AntiAlias = true;
				stepcountPaint.TextSize = owner.Resources.GetDimension(Resource.Dimension.StepCountTextSize);
			}
开发者ID:chrisriesgo,项目名称:mini-hacks,代码行数:9,代码来源:XFitWatchfaceServiceStepCount.cs

示例8: ApplyCustomTypeface

        private static void ApplyCustomTypeface(Paint paint, Typeface tf, TypefaceStyle style, int size)
        {
            if (style == TypefaceStyle.Italic)
                paint.TextSkewX = -0.25f;

            if(size > 0)
                paint.TextSize = size;

            paint.SetTypeface (tf);
        }
开发者ID:FrederickEskens,项目名称:Totem,代码行数:10,代码来源:CustomTypefaceSpan.cs

示例9: ApplyCustomTypeFace

 private void ApplyCustomTypeFace(Paint paint, Typeface tf)
 {
     paint.FakeBoldText = false;
     paint.TextSkewX = 0f;
     paint.SetTypeface(tf);
     if (_rotate)
         paint.ClearShadowLayer();
     if (_iconSizeRatio > 0)
         paint.TextSize = (paint.TextSize * _iconSizeRatio);
     else if (_iconSizePx > 0)
         paint.TextSize = _iconSizePx;
     if (_iconColor < Int32.MaxValue)
         paint.Color = new Color(_iconColor);
     paint.Flags = paint.Flags | PaintFlags.SubpixelText;
 }
开发者ID:MuffPotter,项目名称:Xamarin.Plugins,代码行数:15,代码来源:CustomTypefaceSpan.cs

示例10: Draw

        /// <Docs>The Canvas to which the View is rendered.</Docs>
        /// <summary>
        /// Draw the specified canvas.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        public override void Draw(Android.Graphics.Canvas canvas)
        {  
            base.Draw(canvas);

            var paintForAngle = new Paint { Color = (Android.Graphics.Color.White), TextSize = 37f };
            paintForAngle.SetStyle(Paint.Style.Stroke);
            paintForAngle.SetTypeface(Typeface.CreateFromAsset(Forms.Context.Assets, "Fonts/fontawesome.ttf"));

            canvas.DrawText('\uf078'.ToString(), (float)(canvas.ClipBounds.CenterX() * 1.65), (float)(canvas.ClipBounds.CenterY() * 1.15), paintForAngle);


            #region Disposing 
            paintForAngle.Dispose();
            canvas.Dispose();
            #endregion
        }
开发者ID:kosomgua,项目名称:CustomPicker,代码行数:21,代码来源:CustomPickerRenderer.cs

示例11: apply

        private static void apply(Paint paint, Typeface tf) {
            TypefaceStyle oldStyle;
            var old = paint.Typeface;
            if (old == null) {
                oldStyle = 0;
            } else {
                oldStyle = old.Style;
            }

            var fake = oldStyle & ~tf.Style;
            if ((fake & TypefaceStyle.Bold) == TypefaceStyle.Bold) {
                paint.FakeBoldText = true;
            }

            if ((fake & TypefaceStyle.Italic) == TypefaceStyle.Italic) {
                paint.TextSkewX = -0.25f;
            }

            paint.SetTypeface(tf);
            paint.Flags = paint.Flags | PaintFlags.SubpixelText;
        }
开发者ID:zhangcj,项目名称:Xamarin.Forms.Lagou,代码行数:21,代码来源:CustomTypefaceSpan.cs

示例12: AdjustTextToSize

        public static float AdjustTextToSize(string text, SizeF box, float edgeInset, Context context)
        {
            SizeF constrainSize = new SizeF (box.Width - edgeInset, 9999);
            float toReturn = 0f;

            Paint paint = new Paint (PaintFlags.AntiAlias);
            paint.TextSize = 16f;
            paint.SetTypeface (Typeface.Default);
            float height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context);

            if (height > box.Height - edgeInset) {

                do {
                    height -= 0.5f;
                    paint.TextSize = height;
                    height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context);
                } while (height > box.Height - edgeInset);

                toReturn = paint.TextSize;

            } else if (height < box.Height - edgeInset) {

                do {
                    height += 0.5f;
                    paint.TextSize = height;
                    height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context);

                } while (height < box.Height - edgeInset);

                toReturn = paint.TextSize;

            } else {

                toReturn = paint.TextSize;

            }//end if else

            return toReturn;
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:39,代码来源:AnimationUtils.cs

示例13: CreateTextPaint

 private Paint CreateTextPaint(Color defaultInteractiveColor, Typeface typeface)
 {
     Paint paint = new Paint ();
     paint.Color = defaultInteractiveColor;
     paint.SetTypeface (typeface);
     paint.AntiAlias = true;
     return paint;
 }
开发者ID:gandersson,项目名称:android-wear-xamarin-watchface,代码行数:8,代码来源:DigitalWatchFaceService.cs

示例14: GetTextParamsForCallout

        /// <summary>
        /// Creates and returns the text parameters for the given callout text area.
        /// </summary>
        /// <returns>
        /// A Pair<UIFont, SizeF> containing the font and text size.
        /// </returns>
        /// <param name='textRect'>
        /// The current text area of the callout.
        /// </param>
        /// <param name='text'>
        /// The text for which to calculate and create the parameters.
        /// </param>
        public static float GetTextParamsForCallout(RectangleF textRect, string text, Context context)
        {
            SizeF constrainSize = new SizeF (textRect.Width, 9999);
            Paint paint = new Paint (PaintFlags.AntiAlias);
            paint.TextSize = 18f;
            paint.SetTypeface (Typeface.Default);
            float height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context);

            float minHeight = textRect.Height - 2f;

            if (height > minHeight) {

                do {
                    height -= 1f;
                    paint.TextSize = height;
                    height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context);
                } while (height > textRect.Height);

            } else if (height < minHeight) {

                do {
                    height += 1f;
                    paint.TextSize = height;
                    height = ImageHelper.convertDpToPixel (paint.MeasureText (text), context);
                } while (height < minHeight);

            }//end if else

            return paint.TextSize;
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:42,代码来源:AnimationUtils.cs

示例15: ApplyFontToPaint

        static void ApplyFontToPaint(Font f, Paint p)
        {
            var fi = GetFontInfo (f);

            p.SetTypeface (fi.Typeface);
            p.TextSize = f.Size;

            if (fi.FontMetrics == null) {
                fi.FontMetrics = new AndroidFontMetrics (p);
            }
        }
开发者ID:nissan,项目名称:CrossGraphics,代码行数:11,代码来源:AndroidGraphics.cs


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