Example #1
0
        protected void Initialise(Canvas aCanvas)
        {
            int left       = (int)iStroke.StrokeWidth;
            int right      = aCanvas.Width - (int)iStroke.StrokeWidth;
            int top        = iAnchorOnTop ? iAnchorHeight : (int)iStroke.StrokeWidth;
            int bottom     = iAnchorOnTop ? aCanvas.Height - (int)iStroke.StrokeWidth : aCanvas.Height - iAnchorHeight - (int)iStroke.StrokeWidth;
            int anchorApex = (int)((right - left) * 0.5) - iAnchorOffset;

            if (anchorApex < left + iPadding + iCornerRadius)
            {
                anchorApex = left + iPadding + iCornerRadius;
            }
            else if (anchorApex + iPadding + iCornerRadius > right)
            {
                anchorApex = right - iPadding - iCornerRadius;
            }

            iPath = new Path();
            iPath.MoveTo(left, bottom - iCornerRadius);
            iPath.LineTo(left, top + iCornerRadius);
            RectF rectf = new RectF(left, top, left + iCornerRadius, top + iCornerRadius);

            iPath.ArcTo(rectf, 180, 90);
            rectf.Dispose();

            if (iAnchorOnTop)
            {
                iPath.LineTo((float)(anchorApex - iAnchorWidth * 0.5), top);
                iPath.LineTo(anchorApex, top - iAnchorHeight);
                iPath.LineTo((float)(anchorApex + iAnchorWidth * 0.5), top);
            }

            iPath.LineTo(right - iCornerRadius, top);
            rectf = new RectF(right - iCornerRadius, top, right, top + iCornerRadius);
            iPath.ArcTo(rectf, 270, 90);
            rectf.Dispose();

            iPath.LineTo(right, bottom - iCornerRadius);
            rectf = new RectF(right - iCornerRadius, bottom - iCornerRadius, right, bottom);
            iPath.ArcTo(rectf, 0, 90);
            rectf.Dispose();
            if (!iAnchorOnTop)
            {
                iPath.LineTo((float)(anchorApex + iAnchorWidth * 0.5), bottom);
                iPath.LineTo(anchorApex, bottom + iAnchorHeight);
                iPath.LineTo((float)(anchorApex - iAnchorWidth * 0.5), bottom);
            }
            iPath.LineTo(left + iCornerRadius, bottom);
            rectf = new RectF(left, bottom - iCornerRadius, left + iCornerRadius, bottom);
            iPath.ArcTo(rectf, 90, 90);
            rectf.Dispose();
            rectf = null;
            iPath.Close();
            iInitialised = true;
        }
Example #2
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            textPaint.Dispose();
            bgCirclePaint.Dispose();
            bgBorderPaint.Dispose();
            bgProgressPaint.Dispose();
            progressPaint.Dispose();
            progressPath.Dispose();

            cachedRectF.Dispose();
            cachedTransformMatrix.Dispose();

            textPaint             = bgCirclePaint = bgBorderPaint = bgProgressPaint = progressPaint = null;
            progressPath          = null;
            cachedRectF           = null;
            cachedTransformMatrix = null;
        }