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


C# Paint.SetStyle方法代码示例

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


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

示例1: OnDraw

 protected override void OnDraw(Android.Graphics.Canvas canvas)
 {
     Paint paint = new Paint () { Color = Color.ForestGreen, StrokeWidth = 5 };
     for (int i = 0; i < maxLevel; i++) {
         if (i < Level)
             paint.SetStyle (Paint.Style.Fill);
         else
             paint.SetStyle (Paint.Style.Stroke);
         canvas.DrawCircle (canvas.Height / 2 + canvas.Height*i , canvas.Height / 2, canvas.Height / 2 - 5, paint);
     }
 }
开发者ID:orzech85,项目名称:Cards,代码行数:11,代码来源:LevelView.cs

示例2: 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 (Canvas canvas)
		{			
			try
			{
				var element = Element as RoundCornerView;
				var cornerRadius = (float)element.CornerRadius*Resources.DisplayMetrics.Density;

				// Paint rounded rect itself
				canvas.Save();
				var paint = new Paint();
				paint.AntiAlias = true;
				var strokeWidth = (((float)element.BorderWidth)*Resources.DisplayMetrics.Density);
				paint.StrokeWidth = strokeWidth;

				if(element.BackgroundColor != Xamarin.Forms.Color.Transparent)
				{
					paint.SetStyle(Paint.Style.Fill);
					paint.Color = element.BackgroundColor.ToAndroid();
					canvas.DrawRoundRect(new RectF(0, 0, Width, Height), cornerRadius, cornerRadius, paint);
				}

				if(element.BorderColor != Xamarin.Forms.Color.Transparent)
				{
					paint.SetStyle(Paint.Style.Stroke);
					paint.Color = element.BorderColor.ToAndroid();
					canvas.DrawRoundRect(new RectF(0, 0, Width, Height), cornerRadius, cornerRadius, paint);
				}

				//Properly dispose
				paint.Dispose();
				canvas.Restore();

				// Create clip path
				var path = new Path();
				path.AddRoundRect(new RectF(0.0f + (strokeWidth/2), 0.0f + (strokeWidth/2), 
					Width - (strokeWidth/2), Height - (strokeWidth/2)), cornerRadius, cornerRadius, Path.Direction.Cw);
				
				canvas.Save();
				canvas.ClipPath(path);

				// Do base drawing
				for(var i=0; i<ChildCount; i++)
					GetChildAt(i).Draw(canvas);

				canvas.Restore();
				path.Dispose();
			}
			catch (Exception)
			{				
			}				
		}
开发者ID:patridge,项目名称:NControl.Controls,代码行数:56,代码来源:RoundCornerViewRenderer.cs

示例3: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            var rect = new RectF(0, 0, 300, 300);
            switch (Shape)
            {
                case Shape.Circle:
                    canvas.DrawOval(rect, new Paint() { Color = Color.CornflowerBlue });
                    break;
                case Shape.Square:
                    canvas.DrawRect(rect, new Paint() { Color = Color.Crimson });
                    break;
                case Shape.Triangle:

                    var path = new Path();
                    path.MoveTo(rect.CenterX(), rect.Top);
                    path.LineTo(rect.Left, rect.Bottom);
                    path.LineTo(rect.Right, rect.Bottom);
                    path.Close();
                    var paint = new Paint() {Color = Color.Crimson};
                    paint.Color = Color.Gold;
                    paint.SetStyle(Paint.Style.Fill);
                    canvas.DrawPath(path, paint);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:Coolerhino,项目名称:MvvmCross-Tutorials,代码行数:27,代码来源:ShapeView.cs

示例4: 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

示例5: 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

示例6: Initialize

        private void Initialize()
        {
            var scaledDensity = Context.Resources.DisplayMetrics.ScaledDensity;

            SetLayerType(LayerType.Software, null);

            _paintBorder = new Paint(PaintFlags.AntiAlias) { Color = Color.DarkGray };

            _paintGrid = new Paint(PaintFlags.AntiAlias) { Color = Color.LightGray };
            _paintGrid.SetStyle(Paint.Style.Stroke);
            _paintGrid.SetPathEffect(new DashPathEffect(new float[] { 5, 5 }, 0));
            _paintGrid.StrokeWidth = 5;

            _paintSubGrid = new Paint(PaintFlags.AntiAlias) { Color = Color.LightGray };
            _paintSubGrid.SetStyle(Paint.Style.Stroke);
            _paintSubGrid.SetPathEffect(new DashPathEffect(new float[] { 5, 5 }, 0));
            _paintSubGrid.StrokeWidth = 2;

            _paintPos = new Paint(PaintFlags.AntiAlias) { Color = Color.CornflowerBlue };

            _paintGridText = new Paint(PaintFlags.AntiAlias)
            {
                Color = Color.LightGray,
                TextSize = 20*scaledDensity
            };
        }
开发者ID:milindur,项目名称:MdkControlApp,代码行数:26,代码来源:JoystickView.cs

示例7: Draw

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

            var rect = new RectF(0,0,300,300);
            switch (TheShape)
            {
                case Shape.Circle:
                    canvas.DrawOval(rect, new Paint() { Color = Color.Aqua });
                    break;
                case Shape.Square:
                    canvas.DrawRect(rect, new Paint() { Color = Color.Red });
                    break;
                case Shape.Triangle:
                    var path = new Path();
                    path.MoveTo(rect.CenterX(), 0);
                    path.LineTo(0, rect.Height());
                    path.LineTo(rect.Width(), rect.Height());
                    path.Close();

                    var paint = new Paint() {Color = Color.Magenta};
                    paint.SetStyle(Paint.Style.Fill);
                    canvas.DrawPath(path, paint);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:29,代码来源:CustomDrawShapeView.cs

示例8: DrawChild

 protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
 {
     try
     {
         var radius = Math.Min(Width, Height) / 2;
         var strokeWidth = 10;
         radius -= strokeWidth / 2;
         //Create path to clip
         var path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         canvas.Save();
         canvas.ClipPath(path);
         var result = base.DrawChild(canvas, child, drawingTime);
         canvas.Restore();
         // Create path for circle border
         path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         var paint = new Paint();
         paint.AntiAlias = true;
         paint.StrokeWidth = 5;
         paint.SetStyle(Paint.Style.Stroke);
         paint.Color = global::Android.Graphics.Color.White;
         canvas.DrawPath(path, paint);
         //Properly dispose
         paint.Dispose();
         path.Dispose();
         return result;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to create circle image: " + ex);
     }
     return base.DrawChild(canvas, child, drawingTime);
 }
开发者ID:colbylwilliams,项目名称:BasicBeer-Forms,代码行数:34,代码来源:CircleImage.cs

示例9: Initialize

		void Initialize ()
		{
			mPaint = new Paint ();
			mPaint.Color = Color.Black;
			mPaint.AntiAlias = true;
			mPaint.SetStyle (Paint.Style.Fill);
		}
开发者ID:KiranKumarAlugonda,项目名称:TXTSHD,代码行数:7,代码来源:CircleView.cs

示例10: CirclePageIndicator

		public CirclePageIndicator(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
		{
			//Load defaults from resources
			var res = Resources;
			int defaultPageColor = res.GetColor(Resource.Color.default_circle_indicator_page_color);
			int defaultFillColor = res.GetColor(Resource.Color.default_circle_indicator_fill_color);
			int defaultOrientation = res.GetInteger(Resource.Integer.default_circle_indicator_orientation);
			int defaultStrokeColor = res.GetColor(Resource.Color.default_circle_indicator_stroke_color);
			float defaultStrokeWidth = res.GetDimension(Resource.Dimension.default_circle_indicator_stroke_width);
			float defaultRadius = res.GetDimension(Resource.Dimension.default_circle_indicator_radius);
			bool defaultCentered = res.GetBoolean(Resource.Boolean.default_circle_indicator_centered);
			bool defaultSnap = res.GetBoolean(Resource.Boolean.default_circle_indicator_snap);

			//Retrieve styles attributes
			var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.CirclePageIndicator, defStyle, Resource.Style.Widget_CirclePageIndicator);

			mCentered = a.GetBoolean(Resource.Styleable.CirclePageIndicator_vpiCentered, defaultCentered);
			mOrientation = a.GetInt(Resource.Styleable.CirclePageIndicator_vpiOrientation, defaultOrientation);
			mPaintPageFill = new Paint(PaintFlags.AntiAlias);
			mPaintPageFill.SetStyle(Paint.Style.Fill);
			mPaintPageFill.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_vpiPageColor, defaultPageColor);
			mPaintStroke = new Paint(PaintFlags.AntiAlias);
			mPaintStroke.SetStyle(Paint.Style.Stroke);
			mPaintFill = new Paint(PaintFlags.AntiAlias);
			mPaintFill.SetStyle(Paint.Style.Fill);
			mSnap = a.GetBoolean(Resource.Styleable.CirclePageIndicator_vpiSnap, defaultSnap);

			mRadius = a.GetDimension(Resource.Styleable.CirclePageIndicator_vpiRadius, defaultRadius);
			mPaintFill.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_vpiFillColor, defaultFillColor);
			mPaintStroke.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_vpiStrokeColor, defaultStrokeColor);
			mPaintStroke.StrokeWidth = a.GetDimension(Resource.Styleable.CirclePageIndicator_vpiStrokeWidth, defaultStrokeWidth);

			a.Recycle();

		}
开发者ID:alexrainman,项目名称:CarouselView,代码行数:35,代码来源:CirclePageIndicator.cs

示例11: OnElementSizeChanged

        void OnElementSizeChanged(object sender, EventArgs e)
        {
            var elem = sender as View;
            if (elem == null)
                return;

            var density = Resources.System.DisplayMetrics.Density;

            using (var imageBitmap = Bitmap.CreateBitmap((int)((elem.Width + 2) * density), (int)((elem.Height + 1) * density), Bitmap.Config.Argb8888))
            using (var canvas = new Canvas(imageBitmap))
            using (var paint = new Paint() { Dither = false, Color = Xamarin.Forms.Color.White.ToAndroid(), AntiAlias = true })
            {
                paint.Hinting = PaintHinting.On;
                paint.Flags = PaintFlags.AntiAlias;
                paint.SetStyle(Paint.Style.Stroke);
                paint.StrokeWidth = 2 * density;

                var height = (float)elem.Height;

                canvas.DrawRoundRect(new RectF(density, density, (float)(elem.Width) * density, (float)(height) * density), height * density / 2, height * density / 2, paint);
                canvas.Density = (int)density;

                Container.Background = new BitmapDrawable(imageBitmap);
            }
        }
开发者ID:antixaker,项目名称:ProgressBar,代码行数:25,代码来源:BorderEffect.cs

示例12: 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

示例13: Draw

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

            Paint mBgPaints = new Paint ();
            mBgPaints.AntiAlias = true;
            mBgPaints.SetStyle (Paint.Style.Fill);
            mBgPaints.Color = Color.Blue;
            mBgPaints.StrokeWidth = 0.5f;

            Paint tPaint = new Paint ();
            tPaint.Alpha = 0;
            canvas.DrawColor (tPaint.Color);

            RectF mOvals = new RectF (40, 40, layout.MeasuredWidth - 40, layout.MeasuredHeight - 40);

            decimal total = 0;
            foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
                total += value.amount;
            }

            if (total == 0) {
                return;
            }

            decimal degressPerAmount = 360 / total;
            decimal currentAngle = 0;
            foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
                canvas.DrawArc (mOvals, (float)currentAngle, (float)(degressPerAmount * value.amount), true, mBgPaints);
                currentAngle += (degressPerAmount * value.amount);
                mBgPaints.SetARGB (255, new Random ().Next (256), new Random ().Next (256), new Random ().Next (256));
            }
        }
开发者ID:sadiq81,项目名称:Pengeplan_Xamarin,代码行数:33,代码来源:PieView.cs

示例14: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);

            var r = new Rect ();
            this.GetLocalVisibleRect (r);

            var half = r.Width() / 2;
            var height = r.Height();

            var percentage = (this.Limit - Math.Abs(this.CurrentValue)) / this.Limit;


            var paint = new Paint()
            {
                Color = this.CurrentValue < 0 ? this.negativeColor : this.positiveColor,
                StrokeWidth = 5
            };

            paint.SetStyle(Paint.Style.Fill);

            if (this.CurrentValue < 0)
            {
                var start = (float)percentage * half;
                var size = half - start;
                canvas.DrawRect (new Rect ((int)start, 0, (int)(start + size), height), paint);
            }
            else
            {
                canvas.DrawRect (new Rect((int)half, 0, (int)(half + percentage * half), height), paint);
            }
        }
开发者ID:GGHG72,项目名称:Xamarin-Forms-Labs,代码行数:32,代码来源:SensorBarDroidView.cs

示例15: Init

 private void Init()
 {
     mPaint = new Paint();
     mPaint.Color = Resources.GetColor(Resource.Color.triangle);
     mPaint.AntiAlias = true;
     mPaint.SetStyle(Paint.Style.FillAndStroke);
     SetBackgroundColor(Resources.GetColor(Resource.Color.view_bg));
 }
开发者ID:huguodong,项目名称:XamandroidSupportDesign22.2.0.0,代码行数:8,代码来源:ShapeLoadingView.cs


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