Beispiel #1
0
            protected override void onDraw(android.graphics.Canvas canvas)
            {
                {
                    var paint = new android.graphics.Paint();

                    paint.setStyle(android.graphics.Paint.Style.STROKE);
                    //paint.setStyle(android.graphics.Paint.Style.FILL_AND_STROKE);
                    //paint.setColor(android.graphics.Color.RED);
                    //paint.setColor(android.graphics.Color.YELLOW);
                    paint.setColor(color);
                    paint.setTextSize(textSize);
                    paint.setAlpha(alpha);

                    var a = this.text().Split('\n');

                    a.WithEachIndex(
                        (text, i) =>
                    {
                        canvas.drawText(text, x, y + i * 24, paint);
                        canvas.drawText(text, x + 2560 / 2, y + i * 24, paint);
                    }
                        );
                }

                if (AtDraw != null)
                {
                    AtDraw(canvas);
                }


                base.onDraw(canvas);
            }
            protected override void onDraw(android.graphics.Canvas canvas)
            {
                var paint = new android.graphics.Paint();

                paint.setStyle(android.graphics.Paint.Style.STROKE);
                //paint.setStyle(android.graphics.Paint.Style.FILL_AND_STROKE);
                paint.setColor(android.graphics.Color.RED);
                paint.setTextSize(textSize);

                var text = this.text();

                canvas.drawText(text, x, y, paint);
                canvas.drawText(text, x + 2560 / 2, y, paint);

                base.onDraw(canvas);
            }
Beispiel #3
0
        void drawCenter(string text, float yMultiply)
        {
            var r = new android.graphics.Rect();

            frameCanvas.getClipBounds(r);
            paint.setTextAlign(android.graphics.Paint.Align.LEFT);
            paint.getTextBounds(text, 0, text.Length, r);
            float x = frameWidth / 2f - r.width() / 2f - r.left;
            float y = frameHeight / 2f + (r.height() * yMultiply) / 2f - r.bottom;

            frameCanvas.drawText(text, x, y, paint);
        }
Beispiel #4
0
 public override void draw(android.graphics.Canvas c, android.graphics.Path highlight
                           , android.graphics.Paint highlightpaint, int cursorOffset)
 {
     if (mDirect != null && highlight == null)
     {
         c.drawText(mDirect, 0, mBottom - mDesc, mPaint);
     }
     else
     {
         base.draw(c, highlight, highlightpaint, cursorOffset);
     }
 }
        public override void draw(Canvas canvas)
        {
            Rect  r     = Bounds;
            Paint paint = mPaint;

            // only draw shape if it may affect output
            if (paint.Alpha != 0 || paint.Xfermode != null)
            {
                //            canvas.drawRect(r, paint);
                Rect textBounds = TextBounds;
                canvas.drawText(mText, r.left + r.width() / 2, r.top + r.height() / 2 + textBounds.height() / 2, paint);
            }

            // restore
        }
		public override void draw(Canvas canvas)
		{
			Rect r = Bounds;
			Paint paint = mPaint;

			// only draw shape if it may affect output
			if (paint.Alpha != 0 || paint.Xfermode != null)
			{
	//            canvas.drawRect(r, paint);
				Rect textBounds = TextBounds;
				canvas.drawText(mText, r.left + r.width() / 2, r.top + r.height() / 2 + textBounds.height() / 2, paint);
			}

			// 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();
                }
            }
        }
Beispiel #8
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();
        }
Beispiel #9
0
        protected internal override void onDraw(Canvas canvas)
        {
            if (mFaces != null && mZoomRect != null)
            {
                // Prepare matrix
                mMatrix.reset();
                mAspectRatio.reset();
                mActualRect.set(0, 0, mPreviewSize.Width, mPreviewSize.Height);

                // First apply zoom (crop) rect.
                // Unlike the documentation, many device does not report final crop region.
                // So, here we calculate final crop region which takes account aspect ratio between crop region and preview size.
                {
                    mRevisionZoomRect.set(mZoomRect);
                    float left = mRevisionZoomRect.left;
                    float top  = mRevisionZoomRect.top;

                    mRevisionZoomRect.offsetTo(0, 0);

                    mAspectRatio.setRectToRect(mActualRect, mRevisionZoomRect, Matrix.ScaleToFit.CENTER);

                    mAspectRatio.mapRect(mActualRect);
                    mActualRect.offset(left, top);
                }

                mMatrix.postTranslate(-mActualRect.centerX(), -mActualRect.centerY());

                // compensate mirror
                mMatrix.postScale(mFacing == SCameraCharacteristics.LENS_FACING_FRONT ? -1 : 1, 1);

                // Then rotate and scale to UI size
                mMatrix.postRotate(mRotation);
                if (mOrientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                    mMatrix.postScale((float)Width / mActualRect.width(), (float)Height / mActualRect.height());
                }
                else
                {
                    mMatrix.postScale((float)Height / mActualRect.width(), (float)Width / mActualRect.height());
                }
                mMatrix.postTranslate((float)Width / 2, (float)Height / 2);

                foreach (Face face in mFaces)
                {
                    mBoundRect.set(face.Bounds);
                    mMatrix.mapRect(mBoundRect);

                    mPaint.Color       = Color.BLUE;
                    mPaint.StrokeWidth = 3;
                    canvas.drawRect(mBoundRect, mPaint);

                    {                     // Additional features may not supported.
                        float[] point = new float[2];
                        mPaint.Color       = Color.RED;
                        mPaint.StrokeWidth = 10;

                        if (face.LeftEyePosition != null)
                        {
                            mMatrix.mapPoints(point, new float[] { face.LeftEyePosition.x, face.LeftEyePosition.y });
                            canvas.drawPoint(point[0], point[1], mPaint);
                        }

                        if (face.RightEyePosition != null)
                        {
                            mMatrix.mapPoints(point, new float[] { face.RightEyePosition.x, face.RightEyePosition.y });
                            canvas.drawPoint(point[0], point[1], mPaint);
                        }

                        if (face.MouthPosition != null)
                        {
                            mMatrix.mapPoints(point, new float[] { face.MouthPosition.x, face.MouthPosition.y });
                            canvas.drawPoint(point[0], point[1], mPaint);
                        }

                        mPaint.Color       = Color.YELLOW;
                        mPaint.StrokeWidth = 3;
                        mPaint.TextSize    = 30;
                        if (face.Id != Face.ID_UNSUPPORTED)
                        {
                            canvas.drawText(string.Format("ID:{0:D}, Score:{1:D}", face.Id, face.Score), mBoundRect.left, mBoundRect.top, mPaint);
                        }
                        else
                        {
                            canvas.drawText(string.Format("Score:{0:D}", face.Score), mBoundRect.left, mBoundRect.top, mPaint);
                        }
                    }
                }
            }
        }
//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();
				}
			}
		}
		protected internal override void onDraw(Canvas canvas)
		{

			if (mFaces != null && mZoomRect != null)
			{
				// Prepare matrix
				mMatrix.reset();
				mAspectRatio.reset();
				mActualRect.set(0, 0, mPreviewSize.Width, mPreviewSize.Height);

				// First apply zoom (crop) rect.
				// Unlike the documentation, many device does not report final crop region.
				// So, here we calculate final crop region which takes account aspect ratio between crop region and preview size.
				{
					mRevisionZoomRect.set(mZoomRect);
					float left = mRevisionZoomRect.left;
					float top = mRevisionZoomRect.top;

					mRevisionZoomRect.offsetTo(0, 0);

					mAspectRatio.setRectToRect(mActualRect, mRevisionZoomRect, Matrix.ScaleToFit.CENTER);

					mAspectRatio.mapRect(mActualRect);
					mActualRect.offset(left, top);
				}

				mMatrix.postTranslate(-mActualRect.centerX(), -mActualRect.centerY());

				// compensate mirror
				mMatrix.postScale(mFacing == SCameraCharacteristics.LENS_FACING_FRONT ? - 1 : 1, 1);

				// Then rotate and scale to UI size
				mMatrix.postRotate(mRotation);
				if (mOrientation == Configuration.ORIENTATION_LANDSCAPE)
				{
					mMatrix.postScale((float) Width / mActualRect.width(), (float) Height / mActualRect.height());
				}
				else
				{
					mMatrix.postScale((float) Height / mActualRect.width(), (float) Width / mActualRect.height());
				}
				mMatrix.postTranslate((float)Width / 2, (float)Height / 2);

				foreach (Face face in mFaces)
				{

					mBoundRect.set(face.Bounds);
					mMatrix.mapRect(mBoundRect);

					mPaint.Color = Color.BLUE;
					mPaint.StrokeWidth = 3;
					canvas.drawRect(mBoundRect, mPaint);

					{ // Additional features may not supported.
						float[] point = new float[2];
						mPaint.Color = Color.RED;
						mPaint.StrokeWidth = 10;

						if (face.LeftEyePosition != null)
						{
							mMatrix.mapPoints(point, new float[]{face.LeftEyePosition.x, face.LeftEyePosition.y});
							canvas.drawPoint(point[0], point[1], mPaint);
						}

						if (face.RightEyePosition != null)
						{
							mMatrix.mapPoints(point, new float[]{face.RightEyePosition.x, face.RightEyePosition.y});
							canvas.drawPoint(point[0], point[1], mPaint);
						}

						if (face.MouthPosition != null)
						{
							mMatrix.mapPoints(point, new float[]{face.MouthPosition.x, face.MouthPosition.y});
							canvas.drawPoint(point[0], point[1], mPaint);
						}

						mPaint.Color = Color.YELLOW;
						mPaint.StrokeWidth = 3;
						mPaint.TextSize = 30;
						if (face.Id != Face.ID_UNSUPPORTED)
						{
							canvas.drawText(string.Format("ID:{0:D}, Score:{1:D}", face.Id, face.Score), mBoundRect.left, mBoundRect.top, mPaint);
						}
						else
						{
							canvas.drawText(string.Format("Score:{0:D}", face.Score), mBoundRect.left, mBoundRect.top, mPaint);
						}
					}
				}
			}
		}
Beispiel #12
0
        public virtual void draw(android.graphics.Canvas canvas)
        {
            if (mState == STATE_NONE)
            {
                // No need to draw anything
                return;
            }
            int y         = mThumbY;
            int viewWidth = mList.getWidth();

            android.widget.FastScroller.ScrollFade scrollFade = mScrollFade;
            int alpha = -1;

            if (mState == STATE_EXIT)
            {
                alpha = scrollFade.getAlpha();
                if (alpha < android.widget.FastScroller.ScrollFade.ALPHA_MAX / 2)
                {
                    mThumbDrawable.setAlpha(alpha * 2);
                }
                int left = 0;
                switch (mPosition)
                {
                case android.view.View.SCROLLBAR_POSITION_DEFAULT:
                case android.view.View.SCROLLBAR_POSITION_RIGHT:
                {
                    left = viewWidth - (mThumbW * alpha) / android.widget.FastScroller.ScrollFade.ALPHA_MAX;
                    break;
                }

                case android.view.View.SCROLLBAR_POSITION_LEFT:
                {
                    left = -mThumbW + (mThumbW * alpha) / android.widget.FastScroller.ScrollFade.ALPHA_MAX;
                    break;
                }
                }
                mThumbDrawable.setBounds(left, 0, left + mThumbW, mThumbH);
                mChangedBounds = true;
            }
            if (mTrackDrawable != null)
            {
                android.graphics.Rect thumbBounds = mThumbDrawable.getBounds();
                int left            = thumbBounds.left;
                int halfThumbHeight = (thumbBounds.bottom - thumbBounds.top) / 2;
                int trackWidth      = mTrackDrawable.getIntrinsicWidth();
                int trackLeft       = (left + mThumbW / 2) - trackWidth / 2;
                mTrackDrawable.setBounds(trackLeft, halfThumbHeight, trackLeft + trackWidth, mList
                                         .getHeight() - halfThumbHeight);
                mTrackDrawable.draw(canvas);
            }
            canvas.translate(0, y);
            mThumbDrawable.draw(canvas);
            canvas.translate(0, -y);
            // If user is dragging the scroll bar, draw the alphabet overlay
            if (mState == STATE_DRAGGING && mDrawOverlay)
            {
                if (mOverlayPosition == OVERLAY_AT_THUMB)
                {
                    int left = 0;
                    switch (mPosition)
                    {
                    case android.view.View.SCROLLBAR_POSITION_DEFAULT:
                    case android.view.View.SCROLLBAR_POSITION_RIGHT:
                    default:
                    {
                        left = System.Math.Max(0, mThumbDrawable.getBounds().left - mThumbW - mOverlaySize
                                               );
                        break;
                    }

                    case android.view.View.SCROLLBAR_POSITION_LEFT:
                    {
                        left = System.Math.Min(mThumbDrawable.getBounds().right + mThumbW, mList.getWidth
                                                   () - mOverlaySize);
                        break;
                    }
                    }
                    int top = System.Math.Max(0, System.Math.Min(y + (mThumbH - mOverlaySize) / 2, mList
                                                                 .getHeight() - mOverlaySize));
                    android.graphics.RectF pos = mOverlayPos;
                    pos.left   = left;
                    pos.right  = pos.left + mOverlaySize;
                    pos.top    = top;
                    pos.bottom = pos.top + mOverlaySize;
                    if (mOverlayDrawable != null)
                    {
                        mOverlayDrawable.setBounds((int)pos.left, (int)pos.top, (int)pos.right, (int)pos.
                                                   bottom);
                    }
                }
                mOverlayDrawable.draw(canvas);
                android.graphics.Paint paint = mPaint;
                float descent = paint.descent();
                android.graphics.RectF rectF   = mOverlayPos;
                android.graphics.Rect  tmpRect = mTmpRect;
                mOverlayDrawable.getPadding(tmpRect);
                int hOff = (tmpRect.right - tmpRect.left) / 2;
                int vOff = (tmpRect.bottom - tmpRect.top) / 2;
                canvas.drawText(mSectionText, (int)(rectF.left + rectF.right) / 2 - hOff, (int)(rectF
                                                                                                .bottom + rectF.top) / 2 + mOverlaySize / 4 - descent - vOff, paint);
            }
            else
            {
                if (mState == STATE_EXIT)
                {
                    if (alpha == 0)
                    {
                        // Done with exit
                        setState(STATE_NONE);
                    }
                    else
                    {
                        if (mTrackDrawable != null)
                        {
                            mList.invalidate(viewWidth - mThumbW, 0, viewWidth, mList.getHeight());
                        }
                        else
                        {
                            mList.invalidate(viewWidth - mThumbW, y, viewWidth, y + mThumbH);
                        }
                    }
                }
            }
        }