Exemplo n.º 1
0
        public NMapCalloutCustomOldOverlay(NMapOverlay itemOverlay, NMapOverlayItem item, Rect itemBounds,
                                           IResourceProvider resourceProvider) : base(itemOverlay, item, itemBounds)
        {
            mTextPaint.AntiAlias = true;
            // set font style
            mTextPaint.Color = Color.ParseColor(CALLOUT_TEXT_COLOR);
            // set font size
            mTextPaint.TextSize = CALLOUT_TEXT_SIZE * NMapResourceProvider.ScaleFactor;
            // set font type
            if (CALLOUT_TEXT_TYPEFACE != null)
            {
                mTextPaint.SetTypeface(CALLOUT_TEXT_TYPEFACE);
            }

            mMarginX          = NMapResourceProvider.ToPixelFromDIP(CALLOUT_MARGIN_X);
            mPaddingX         = NMapResourceProvider.ToPixelFromDIP(CALLOUT_PADDING_X);
            mPaddingOffset    = NMapResourceProvider.ToPixelFromDIP(CALLOUT_PADDING_OFFSET);
            mPaddingY         = NMapResourceProvider.ToPixelFromDIP(CALLOUT_PADDING_Y);
            mMinimumWidth     = NMapResourceProvider.ToPixelFromDIP(CALLOUT_MIMIMUM_WIDTH);
            mTotalHeight      = NMapResourceProvider.ToPixelFromDIP(CALLOUT_TOTAL_HEIGHT);
            mBackgroundHeight = NMapResourceProvider.ToPixelFromDIP(CALLOUT_BACKGROUND_HEIGHT);
            mItemGapY         = NMapResourceProvider.ToPixelFromDIP(CALLOUT_ITEM_GAP_Y);

            mTailGapX = NMapResourceProvider.ToPixelFromDIP(CALLOUT_TAIL_GAP_X);
            mTailText = item.TailText;

            mTitleOffsetY = NMapResourceProvider.ToPixelFromDIP(CALLOUT_TITLE_OFFSET_Y);

            if (resourceProvider == null)
            {
                throw new IllegalArgumentException(
                          "NMapCalloutCustomOverlay.ResourceProvider should be provided on creation of NMapCalloutCustomOverlay.");
            }

            mBackgroundDrawable = resourceProvider.GetCalloutBackground(item);

            bool hasRightAccessory = false;

            mDrawableRightButton = resourceProvider.GetCalloutRightAccessory(item);
            if (mDrawableRightButton != null && mDrawableRightButton.Length > 0)
            {
                hasRightAccessory = true;

                mRightButtonText = null;
            }
            else
            {
                mDrawableRightButton = resourceProvider.GetCalloutRightButton(item);
                mRightButtonText     = resourceProvider.GetCalloutRightButtonText(item);
            }

            if (mDrawableRightButton != null)
            {
                if (hasRightAccessory)
                {
                    mCalloutRightButtonWidth  = mDrawableRightButton[0].IntrinsicWidth;
                    mCalloutRightButtonHeight = mDrawableRightButton[0].IntrinsicHeight;
                }
                else
                {
                    mCalloutRightButtonWidth  = NMapResourceProvider.ToPixelFromDIP(CALLOUT_RIGHT_BUTTON_WIDTH);
                    mCalloutRightButtonHeight = NMapResourceProvider.ToPixelFromDIP(CALLOUT_RIGHT_BUTTON_HEIGHT);
                }

                mRightButtonRect = new Rect();

                base.ItemCount = mCalloutButtonCount;
            }
            else
            {
                mCalloutRightButtonWidth  = 0;
                mCalloutRightButtonHeight = 0;
                mRightButtonRect          = null;
            }

            mTitleTruncated      = null;
            mWidthTitleTruncated = 0;
        }