Beispiel #1
0
        protected internal override void Redraw(ICanvas canvas)
        {
            canvas.FillColor(Color.TRANSPARENT);

            float scale = this.displayModel.ScaleFactor;
            ScaleBarLengthAndValue lengthAndValue = this.CalculateScaleBarLengthAndValue();
            ScaleBarLengthAndValue lengthAndValue2;

            if (this.scaleBarMode == ScaleBarMode.BOTH)
            {
                lengthAndValue2 = this.CalculateScaleBarLengthAndValue(this.secondaryDistanceUnitAdapter);
            }
            else
            {
                lengthAndValue2 = new ScaleBarLengthAndValue(0, 0);
            }

            DrawScaleBar(canvas, lengthAndValue.scaleBarLength, lengthAndValue2.scaleBarLength, this.paintScaleBarStroke, scale);
            DrawScaleBar(canvas, lengthAndValue.scaleBarLength, lengthAndValue2.scaleBarLength, this.paintScaleBar, scale);

            string scaleText1 = this.distanceUnitAdapter.GetScaleText(lengthAndValue.scaleBarValue);
            string scaleText2 = this.scaleBarMode == ScaleBarMode.BOTH ? this.secondaryDistanceUnitAdapter.GetScaleText(lengthAndValue2.scaleBarValue) : "";

            DrawScaleText(canvas, scaleText1, scaleText2, this.paintScaleTextStroke, scale);
            DrawScaleText(canvas, scaleText1, scaleText2, this.paintScaleText, scale);
        }
Beispiel #2
0
        public override void Draw(BoundingBox boundingBox, sbyte zoomLevel, ICanvas canvas, Point topLeftPoint)
        {
            IList <TilePosition> tilePositions = LayerUtil.GetTilePositions(boundingBox, zoomLevel, topLeftPoint, this.displayModel.TileSize);

            // In a rotation situation it is possible that drawParentTileBitmap sets the
            // clipping bounds to portrait, while the device is just being rotated into
            // landscape: the result is a partially painted screen that only goes away
            // after zooming (which has the effect of resetting the clip bounds if drawParentTileBitmap
            // is called again).
            // Always resetting the clip bounds here seems to avoid the problem,
            // I assume that this is a pretty cheap operation, otherwise it would be better
            // to hook this into the onConfigurationChanged call chain.
            canvas.ResetClip();

            if (!isTransparent)
            {
                canvas.FillColor(this.displayModel.BackgroundColor);
            }

            ISet <Job> jobs = new HashSet <Job>();

            foreach (TilePosition tilePosition in tilePositions)
            {
                jobs.Add(CreateJob(tilePosition.Tile));
            }
            this.tileCache.WorkingSet = jobs;

            for (int i = tilePositions.Count - 1; i >= 0; --i)
            {
                TilePosition tilePosition = tilePositions[i];
                Point        point        = tilePosition.Point;
                Tile         tile         = tilePosition.Tile;
                T            job          = CreateJob(tile);
                ITileBitmap  bitmap       = this.tileCache.GetImmediately(job);

                if (bitmap == null)
                {
                    if (this.hasJobQueue && !this.tileCache.ContainsKey(job))
                    {
                        this.jobQueue.Add(job);
                    }
                    DrawParentTileBitmap(canvas, point, tile);
                }
                else
                {
                    if (IsTileStale(tile, bitmap) && this.hasJobQueue && !this.tileCache.ContainsKey(job))
                    {
                        this.jobQueue.Add(job);
                    }
                    RetrieveLabelsOnly(job);
                    canvas.DrawBitmap(bitmap, (int)Math.Round(point.X), (int)Math.Round(point.Y));
                    bitmap.DecrementRefCount();
                }
            }
            if (this.hasJobQueue)
            {
                this.jobQueue.NotifyWorkers();
            }
        }