Esempio n. 1
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();
            }
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: @Override public void onDraw(final android.graphics.Canvas canv)
        public override void onDraw(Canvas canv)
        {
            if (null == mOfficeLayout || null == mRenderUtil)
            {
                Log.w(TAG, "Tried to render empty office");
                return;
            }

            foreach (OfficeThing thing in mOfficeLayout.ThingsBottomUp)
            {
                Bitmap thingBitmap = mRenderUtil.getBitmap(thing);

                //TODO: reimplement glow rendering
                //            // If it's the selected thing, make it GLOW!
                //            if (thing.getKey().equals(mSelectedThingKey)) {
                //                thingBitmap = mRenderUtil.getGlowingBitmap(thing);
                //            }

                // Draw furniture
                canv.drawBitmap(thingBitmap, modelToScreen(thing.Left), modelToScreen(thing.Top), DEFAULT_PAINT);

                // Draw desk label
                if (thing.Type.Equals("desk") && thing.Name != null)
                {
                    // TODO: these offset numbers were empirically determined. Calculate them instead
                    float centerX = modelToScreen(thing.Left) + 102;
                    float centerY = modelToScreen(thing.Top) + 70;

                    canv.save();
                    // TODO: OMG this is so hacky. Fix it. These numbers were empirically determined
                    if (thing.Rotation == 180)
                    {
                        canv.rotate(-thing.Rotation, centerX, centerY - 10);
                    }
                    else if (thing.Rotation == 90)
                    {
                        canv.rotate(-thing.Rotation, centerX, centerY + 45);
                    }
                    else if (thing.Rotation == 270)
                    {
                        canv.rotate(-thing.Rotation, centerX - 40, centerY);
                    }

                    canv.drawText(thing.Name, centerX, centerY, DESK_LABEL_PAINT);
                    canv.restore();
                }
            }
        }
Esempio n. 3
0
        public override void draw(android.graphics.Canvas canvas)
        {
            int saveCount = canvas.save();

            android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState st = mState;
            android.graphics.drawable.Drawable drawable = st.mDrawable;
            android.graphics.Rect bounds = drawable.getBounds();
            int   w  = bounds.right - bounds.left;
            int   h  = bounds.bottom - bounds.top;
            float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX;
            float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY;

            canvas.rotate(mCurrentDegrees, px + bounds.left, py + bounds.top);
            drawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
Esempio n. 4
0
        public override void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
        {
            applyCustomTypeFace(paint, type);
            paint.getTextBounds(icon, 0, 1, TEXT_BOUNDS);
            canvas.save();
            if (rotate)
            {
                float rotation = (DateTimeHelperClass.CurrentUnixTimeMillis() - rotationStartTime) / (float)ROTATION_DURATION * 360f;
                float centerX  = x + TEXT_BOUNDS.width() / 2f;
                float centerY  = y - TEXT_BOUNDS.height() / 2f + TEXT_BOUNDS.height() * BASELINE_RATIO;
                canvas.rotate(rotation, centerX, centerY);
            }

            canvas.drawText(icon, x - TEXT_BOUNDS.left, y - TEXT_BOUNDS.bottom + TEXT_BOUNDS.height() * BASELINE_RATIO, paint);
            canvas.restore();
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: @Override public void onDraw(final android.graphics.Canvas canv)
		public override void onDraw(Canvas canv)
		{
			if (null == mOfficeLayout || null == mRenderUtil)
			{
				Log.w(TAG, "Tried to render empty office");
				return;
			}

			foreach (OfficeThing thing in mOfficeLayout.ThingsBottomUp)
			{
				Bitmap thingBitmap = mRenderUtil.getBitmap(thing);

				//TODO: reimplement glow rendering
	//            // If it's the selected thing, make it GLOW!
	//            if (thing.getKey().equals(mSelectedThingKey)) {
	//                thingBitmap = mRenderUtil.getGlowingBitmap(thing);
	//            }

				// Draw furniture
				canv.drawBitmap(thingBitmap, modelToScreen(thing.Left), modelToScreen(thing.Top), DEFAULT_PAINT);

				// Draw desk label
				if (thing.Type.Equals("desk") && thing.Name != null)
				{
					// TODO: these offset numbers were empirically determined. Calculate them instead
					float centerX = modelToScreen(thing.Left) + 102;
					float centerY = modelToScreen(thing.Top) + 70;

					canv.save();
					// TODO: OMG this is so hacky. Fix it. These numbers were empirically determined
					if (thing.Rotation == 180)
					{
						canv.rotate(-thing.Rotation, centerX, centerY - 10);
					}
					else if (thing.Rotation == 90)
					{
						canv.rotate(-thing.Rotation, centerX, centerY + 45);
					}
					else if (thing.Rotation == 270)
					{
						canv.rotate(-thing.Rotation, centerX - 40, centerY);
					}

					canv.drawText(thing.Name, centerX, centerY, DESK_LABEL_PAINT);
					canv.restore();
				}
			}
		}