示例#1
0
		public override void draw(android.graphics.Canvas canvas)
		{
			int saveCount = canvas.save();
			android.graphics.Rect bounds = mState.mDrawable.getBounds();
			int w = bounds.right - bounds.left;
			int h = bounds.bottom - bounds.top;
			android.graphics.drawable.RotateDrawable.RotateState st = mState;
			float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX;
			float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY;
			canvas.rotate(st.mCurrentDegrees, px + bounds.left, py + bounds.top);
			st.mDrawable.draw(canvas);
			canvas.restoreToCount(saveCount);
		}
示例#2
0
		protected internal override void onDraw(android.graphics.Canvas canvas)
		{
			base.onDraw(canvas);
			bool changed = mChanged;
			if (changed)
			{
				mChanged = false;
			}
			int availableWidth = mRight - mLeft;
			int availableHeight = mBottom - mTop;
			int x = availableWidth / 2;
			int y = availableHeight / 2;
			android.graphics.drawable.Drawable dial = mDial;
			int w = dial.getIntrinsicWidth();
			int h = dial.getIntrinsicHeight();
			bool scaled = false;
			if (availableWidth < w || availableHeight < h)
			{
				scaled = true;
				float scale = System.Math.Min((float)availableWidth / (float)w, (float)availableHeight
					 / (float)h);
				canvas.save();
				canvas.scale(scale, scale, x, y);
			}
			if (changed)
			{
				dial.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2));
			}
			dial.draw(canvas);
			canvas.save();
			canvas.rotate(mHour / 12.0f * 360.0f, x, y);
			android.graphics.drawable.Drawable hourHand = mHourHand;
			if (changed)
			{
				w = hourHand.getIntrinsicWidth();
				h = hourHand.getIntrinsicHeight();
				hourHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2));
			}
			hourHand.draw(canvas);
			canvas.restore();
			canvas.save();
			canvas.rotate(mMinutes / 60.0f * 360.0f, x, y);
			android.graphics.drawable.Drawable minuteHand = mMinuteHand;
			if (changed)
			{
				w = minuteHand.getIntrinsicWidth();
				h = minuteHand.getIntrinsicHeight();
				minuteHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2));
			}
			minuteHand.draw(canvas);
			canvas.restore();
			if (scaled)
			{
				canvas.restore();
			}
		}
示例#3
0
		public override void draw(android.graphics.Canvas canvas)
		{
			base.draw(canvas);
			if (mEdgeGlowLeft != null)
			{
				int scrollX = mScrollX;
				if (!mEdgeGlowLeft.isFinished())
				{
					int restoreCount = canvas.save();
					int height = getHeight() - mPaddingTop - mPaddingBottom;
					canvas.rotate(270);
					canvas.translate(-height + mPaddingTop, System.Math.Min(0, scrollX));
					mEdgeGlowLeft.setSize(height, getWidth());
					if (mEdgeGlowLeft.draw(canvas))
					{
						invalidate();
					}
					canvas.restoreToCount(restoreCount);
				}
				if (!mEdgeGlowRight.isFinished())
				{
					int restoreCount = canvas.save();
					int width = getWidth();
					int height = getHeight() - mPaddingTop - mPaddingBottom;
					canvas.rotate(90);
					canvas.translate(-mPaddingTop, -(System.Math.Max(getScrollRange(), scrollX) + width
						));
					mEdgeGlowRight.setSize(height, width);
					if (mEdgeGlowRight.draw(canvas))
					{
						invalidate();
					}
					canvas.restoreToCount(restoreCount);
				}
			}
		}
示例#4
0
		public override void draw(android.graphics.Canvas canvas)
		{
			base.draw(canvas);
			if (mEdgeGlowTop != null)
			{
				int scrollY = mScrollY;
				if (!mEdgeGlowTop.isFinished())
				{
					int restoreCount = canvas.save();
					int width = getWidth() - mPaddingLeft - mPaddingRight;
					canvas.translate(mPaddingLeft, System.Math.Min(0, scrollY));
					mEdgeGlowTop.setSize(width, getHeight());
					if (mEdgeGlowTop.draw(canvas))
					{
						invalidate();
					}
					canvas.restoreToCount(restoreCount);
				}
				if (!mEdgeGlowBottom.isFinished())
				{
					int restoreCount = canvas.save();
					int width = getWidth() - mPaddingLeft - mPaddingRight;
					int height = getHeight();
					canvas.translate(-width + mPaddingLeft, System.Math.Max(getScrollRange(), scrollY
						) + height);
					canvas.rotate(180, width, 0);
					mEdgeGlowBottom.setSize(width, height);
					if (mEdgeGlowBottom.draw(canvas))
					{
						invalidate();
					}
					canvas.restoreToCount(restoreCount);
				}
			}
		}