Ejemplo n.º 1
0
        private static void DrawDotDensityStyle(PointStyle pointStyle, PlatformGeoCanvas canvas, DrawingRectangleF drawingRectangleF)
        {
            if (pointStyle == null)
            {
                return;
            }

            var    tmpSymbolSize     = pointStyle.SymbolSize;
            var    tmpSymbolPenWidth = pointStyle.SymbolPen.Width;
            var    tmpFontSize       = pointStyle.CharacterFont.Size;
            Bitmap originalBitmap    = null;
            Bitmap newBitmap         = null;

            try
            {
                var customerSymbolStyle = pointStyle as SymbolPointStyle;
                if (customerSymbolStyle != null)
                {
                    originalBitmap            = canvas.ToNativeImage(customerSymbolStyle.Image) as Bitmap;
                    newBitmap                 = new Bitmap(originalBitmap, 9, 9);
                    customerSymbolStyle.Image = canvas.ToGeoImage(newBitmap);
                }
                else
                {
                    pointStyle.SymbolSize      = 3;
                    pointStyle.SymbolPen.Width = 1;
                    pointStyle.CharacterFont   = new GeoFont(pointStyle.CharacterFont.FontName, 6, pointStyle.CharacterFont.Style);
                }

                var     halfWidth  = drawingRectangleF.Width * 0.5f;
                var     halfHeight = drawingRectangleF.Height * 0.5f;
                float[] centersX   = new float[7];
                float[] centersY   = new float[7];
                centersX[0] = halfWidth * 0.5f - 1;
                centersY[0] = halfHeight * 0.5f - 1;
                centersX[1] = centersX[0] + 2;
                centersY[1] = centersY[0] + 2;
                centersX[2] = halfWidth;
                centersY[2] = halfHeight;
                centersX[3] = halfWidth + halfWidth * 0.5f;
                centersY[3] = halfHeight;
                centersX[4] = halfWidth + halfWidth * 0.5f;
                centersY[4] = halfHeight + halfHeight * 0.5f;
                centersX[5] = centersX[4] - 1;
                centersY[5] = centersY[4] - 1;
                centersX[6] = centersX[4] + 1;
                centersY[6] = centersY[4] + 1;
                for (int i = 0; i < 7; i++)
                {
                    float centerX = centersX[i];
                    float centerY = centersY[i];
                    if (pointStyle != null)
                    {
                        pointStyle.DrawSample(canvas, new DrawingRectangleF(centerX, centerY, 11, 11));
                    }
                }

                if (originalBitmap != null)
                {
                    customerSymbolStyle.Image = canvas.ToGeoImage(originalBitmap);
                }
                else
                {
                    pointStyle.SymbolSize      = tmpSymbolSize;
                    pointStyle.SymbolPen.Width = tmpSymbolPenWidth;
                    pointStyle.CharacterFont   = new GeoFont(pointStyle.CharacterFont.FontName, tmpFontSize, pointStyle.CharacterFont.Style);
                }
            }
            finally
            {
                if (originalBitmap != null)
                {
                    originalBitmap.Dispose();
                }
                if (newBitmap != null)
                {
                    newBitmap.Dispose();
                }
            }
        }