Esempio n. 1
0
        private int MeasureHeight(int measureSpec)
        {
            float result;
            var   specMode = MeasureSpec.GetMode(measureSpec);
            var   specSize = MeasureSpec.GetSize(measureSpec);

            if (specMode == MeasureSpecMode.Exactly || null == _viewPager)
            {
                result = specSize;
            }
            else
            {
                result = _paintSelected.StrokeWidth + PaddingTop + PaddingBottom;
                if (specMode == MeasureSpecMode.AtMost)
                {
                    result = Math.Min(result, specSize);
                }
            }
            return((int)FloatMath.Ceil(result));
        }
Esempio n. 2
0
        // ===========================================================
        // Constructors
        // ===========================================================

        public Font(Texture pTexture, Typeface pTypeface, float pSize, bool pAntiAlias, int pColor)
        {
            this.mTexture       = pTexture;
            this.mTextureWidth  = pTexture.GetWidth();
            this.mTextureHeight = pTexture.GetHeight();

            this.mPaint = new Paint();
            this.mPaint.SetTypeface(pTypeface);
            this.mPaint.Color     = pColor;
            this.mPaint.TextSize  = pSize;
            this.mPaint.AntiAlias = pAntiAlias;

            this.mBackgroundPaint       = new Paint();
            this.mBackgroundPaint.Color = Color.Transparent;
            this.mBackgroundPaint.SetStyle(Style.Fill);

            this.mFontMetrics = this.mPaint.GetFontMetrics();
            this.mLineHeight  = (int)FloatMath.Ceil(Math.Abs(this.mFontMetrics.Ascent) + Math.Abs(this.mFontMetrics.Descent));
            this.mLineGap     = (int)(FloatMath.Ceil(this.mFontMetrics.Leading));
        }
Esempio n. 3
0
        private int MeasureWidth(int measureSpec)
        {
            float result;
            var   specMode = MeasureSpec.GetMode(measureSpec);
            var   specSize = MeasureSpec.GetSize(measureSpec);

            if (specMode == MeasureSpecMode.Exactly || null == _viewPager)
            {
                result = specSize;
            }
            else
            {
                //Calculate the width according to the views count
                var count = _viewPager.Adapter.Count;
                result = (PaddingLeft + PaddingRight + (count * _lineWidth) + (count - 1) * _gapWidth);
                if (specMode == MeasureSpecMode.AtMost)
                {
                    result = Math.Min(result, specSize);
                }
            }
            return((int)FloatMath.Ceil(result));
        }
        /// <summary>
        /// Determines the height of this view
        /// </summary>
        /// <returns>The height.</returns>
        /// <param name="measureSpec">Measure spec.</param>
        private int MeasureHeight(int measureSpec)
        {
            float result;
            var   specMode = MeasureSpec.GetMode(measureSpec);
            var   specSize = MeasureSpec.GetSize(measureSpec);

            if (specMode == MeasureSpecMode.Exactly)
            {
                //We were told how big to be
                result = specSize;
            }
            else
            {
                //Measure the height
                result = paintSelected.StrokeWidth + PaddingTop + PaddingBottom;
                //Respect AT_MOST value if that was what is called for by measureSpec
                if (specMode == MeasureSpecMode.AtMost)
                {
                    result = Java.Lang.Math.Min(result, specSize);
                }
            }
            return((int)FloatMath.Ceil(result));
        }
        /// <summary>
        /// Determines the width of this view
        /// </summary>
        /// <returns>The width.</returns>
        /// <param name="measureSpec">Measure spec.</param>
        private int MeasureWidth(int measureSpec)
        {
            float result;
            var   specMode = MeasureSpec.GetMode(measureSpec);
            var   specSize = MeasureSpec.GetSize(measureSpec);

            if ((specMode == MeasureSpecMode.Exactly) || (viewPager == null))
            {
                //We were told how big to be
                result = specSize;
            }
            else
            {
                //Calculate the width according the views count
                int count = viewPager.Adapter.Count;
                result = PaddingLeft + PaddingRight + (count * lineWidth) + ((count - 1) * gapWidth);
                //Respect AT_MOST value if that was what is called for by measureSpec
                if (specMode == MeasureSpecMode.AtMost)
                {
                    result = Java.Lang.Math.Min(result, specSize);
                }
            }
            return((int)FloatMath.Ceil(result));
        }
Esempio n. 6
0
 private int GetLetterAdvance(char pCharacter)
 {
     this.mPaint.GetTextWidths(pCharacter.ToString(), this.mTemporaryTextWidthFetchers);
     return((int)(FloatMath.Ceil(this.mTemporaryTextWidthFetchers[0])));
 }