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


C# android.drawRect方法代码示例

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


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

示例1: draw

		public override void draw(android.graphics.Canvas canvas)
		{
			if (((int)(((uint)mState.mUseColor) >> 24)) != 0)
			{
				mPaint.setColor(mState.mUseColor);
				canvas.drawRect(getBounds(), mPaint);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:8,代码来源:ColorDrawable.cs

示例2: draw

		public override void draw(android.graphics.Canvas canvas)
		{
			android.graphics.Bitmap bitmap = mBitmap;
			if (bitmap != null)
			{
				android.graphics.drawable.BitmapDrawable.BitmapState state = mBitmapState;
				if (state.mRebuildShader)
				{
					android.graphics.Shader.TileMode? tmx = state.mTileModeX;
					android.graphics.Shader.TileMode? tmy = state.mTileModeY;
					if (tmx == null && tmy == null)
					{
						state.mPaint.setShader(null);
					}
					else
					{
						state.mPaint.setShader(new android.graphics.BitmapShader(bitmap, tmx == null ? android.graphics.Shader.TileMode
							.CLAMP : tmx, tmy == null ? android.graphics.Shader.TileMode.CLAMP : tmy));
					}
					state.mRebuildShader = false;
					copyBounds(mDstRect);
				}
				android.graphics.Shader shader = state.mPaint.getShader();
				if (shader == null)
				{
					if (mApplyGravity)
					{
						int layoutDirection = getResolvedLayoutDirectionSelf();
						android.view.Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight, getBounds
							(), mDstRect, layoutDirection);
						mApplyGravity = false;
					}
					canvas.drawBitmap(bitmap, null, mDstRect, state.mPaint);
				}
				else
				{
					if (mApplyGravity)
					{
						copyBounds(mDstRect);
						mApplyGravity = false;
					}
					canvas.drawRect(mDstRect, state.mPaint);
				}
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:45,代码来源:BitmapDrawable.cs

示例3: draw

		public override void draw(android.graphics.Canvas canvas)
		{
			if (!ensureValidRect())
			{
				// nothing to draw
				return;
			}
			// remember the alpha values, in case we temporarily overwrite them
			// when we modulate them with mAlpha
			int prevFillAlpha = mFillPaint.getAlpha();
			int prevStrokeAlpha = mStrokePaint != null ? mStrokePaint.getAlpha() : 0;
			// compute the modulate alpha values
			int currFillAlpha = modulateAlpha(prevFillAlpha);
			int currStrokeAlpha = modulateAlpha(prevStrokeAlpha);
			bool haveStroke = currStrokeAlpha > 0 && mStrokePaint.getStrokeWidth() > 0;
			bool haveFill = currFillAlpha > 0;
			android.graphics.drawable.GradientDrawable.GradientState st = mGradientState;
			bool useLayer = haveStroke && haveFill && st.mShape != LINE && currStrokeAlpha < 
				255 && (mAlpha < 255 || mColorFilter != null);
			if (useLayer)
			{
				if (mLayerPaint == null)
				{
					mLayerPaint = new android.graphics.Paint();
				}
				mLayerPaint.setDither(mDither);
				mLayerPaint.setAlpha(mAlpha);
				mLayerPaint.setColorFilter(mColorFilter);
				float rad = mStrokePaint.getStrokeWidth();
				canvas.saveLayer(mRect.left - rad, mRect.top - rad, mRect.right + rad, mRect.bottom
					 + rad, mLayerPaint, android.graphics.Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
				// don't perform the filter in our individual paints
				// since the layer will do it for us
				mFillPaint.setColorFilter(null);
				mStrokePaint.setColorFilter(null);
			}
			else
			{
				mFillPaint.setAlpha(currFillAlpha);
				mFillPaint.setDither(mDither);
				mFillPaint.setColorFilter(mColorFilter);
				if (haveStroke)
				{
					mStrokePaint.setAlpha(currStrokeAlpha);
					mStrokePaint.setDither(mDither);
					mStrokePaint.setColorFilter(mColorFilter);
				}
			}
			switch (st.mShape)
			{
				case RECTANGLE:
				{
					if (st.mRadiusArray != null)
					{
						if (mPathIsDirty || mRectIsDirty)
						{
							mPath.reset();
							mPath.addRoundRect(mRect, st.mRadiusArray, android.graphics.Path.Direction.CW);
							mPathIsDirty = mRectIsDirty = false;
						}
						canvas.drawPath(mPath, mFillPaint);
						if (haveStroke)
						{
							canvas.drawPath(mPath, mStrokePaint);
						}
					}
					else
					{
						if (st.mRadius > 0.0f)
						{
							// since the caller is only giving us 1 value, we will force
							// it to be square if the rect is too small in one dimension
							// to show it. If we did nothing, Skia would clamp the rad
							// independently along each axis, giving us a thin ellipse
							// if the rect were very wide but not very tall
							float rad = st.mRadius;
							float r = System.Math.Min(mRect.width(), mRect.height()) * 0.5f;
							if (rad > r)
							{
								rad = r;
							}
							canvas.drawRoundRect(mRect, rad, rad, mFillPaint);
							if (haveStroke)
							{
								canvas.drawRoundRect(mRect, rad, rad, mStrokePaint);
							}
						}
						else
						{
							canvas.drawRect(mRect, mFillPaint);
							if (haveStroke)
							{
								canvas.drawRect(mRect, mStrokePaint);
							}
						}
					}
					break;
				}

				case OVAL:
//.........这里部分代码省略.........
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:101,代码来源:GradientDrawable.cs

示例4: draw

		public override void draw(android.graphics.Canvas canvas)
		{
			android.graphics.Rect r = getBounds();
			android.graphics.Paint paint = mShapeState.mPaint;
			int prevAlpha = paint.getAlpha();
			paint.setAlpha(modulateAlpha(prevAlpha, mShapeState.mAlpha));
			if (mShapeState.mShape != null)
			{
				// need the save both for the translate, and for the (unknown) Shape
				int count = canvas.save();
				canvas.translate(r.left, r.top);
				onDraw(mShapeState.mShape, canvas, paint);
				canvas.restoreToCount(count);
			}
			else
			{
				canvas.drawRect(r, paint);
			}
			// restore
			paint.setAlpha(prevAlpha);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:21,代码来源:ShapeDrawable.cs

示例5: draw

		public override void draw(android.graphics.Canvas canvas, android.graphics.Paint 
			paint)
		{
			canvas.drawRect(mRect, paint);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:5,代码来源:RectShape.cs


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