示例#1
0
 /// <summary>
 /// Constructs a new DatabaseRenderer that will not draw labels, instead it stores the label
 /// information in the labelStore for drawing by a LabelLayer.
 /// </summary>
 /// <param name="mapDatabase">
 ///            the MapDatabase from which the map data will be read. </param>
 public DatabaseRenderer(MapDataStore mapDatabase, IGraphicFactory graphicFactory, TileBasedLabelStore labelStore)
 {
     this.mapDatabase      = mapDatabase;
     this.graphicFactory   = graphicFactory;
     this.labelStore       = labelStore;
     this.renderLabels     = false;
     this.tileCache        = null;
     this.tileDependencies = null;
 }
 /// <summary>
 /// Constructs a new DatabaseRenderer that will draw labels onto the tiles.
 /// </summary>
 /// <param name="mapFile">
 ///            the MapDatabase from which the map data will be read. </param>
 public DatabaseRenderer(MapDataStore mapFile, IGraphicFactory graphicFactory, TileCache tileCache)
 {
     this.mapDatabase      = mapFile;
     this.graphicFactory   = graphicFactory;
     this.labelStore       = null;
     this.renderLabels     = true;
     this.tileCache        = tileCache;
     this.tileDependencies = new TileDependencies();
 }
示例#3
0
        public static IResourceBitmap CreateBitmap(IGraphicFactory graphicFactory, DisplayModel displayModel, string relativePathPrefix, string src, int width, int height, int percent)
        {
            if (string.ReferenceEquals(src, null) || src.Length == 0)
            {
                // no image source defined
                return(null);
            }

            System.IO.Stream inputStream = graphicFactory.PlatformSpecificSources(relativePathPrefix, src);

            if (inputStream == null)
            {
                inputStream = CreateInputStream(relativePathPrefix, src);
            }

            try
            {
                string absoluteName = GetAbsoluteName(relativePathPrefix, src);
                // we need to hash with the width/height included as the same symbol could be required
                // in a different size and must be cached with a size-specific hash
                int hash = (new StringBuilder()).Append(absoluteName).Append(width).Append(height).Append(percent).ToString().GetHashCode();

                if (src.EndsWith(".svg", StringComparison.Ordinal))
                {
                    try
                    {
                        return(graphicFactory.RenderSvg(inputStream, displayModel.ScaleFactor, width, height, percent, hash));
                    }
                    catch (IOException e)
                    {
                        throw new IOException("SVG render failed " + src, e);
                    }
                }
                try
                {
                    return(graphicFactory.CreateResourceBitmap(inputStream, absoluteName.GetHashCode()));
                }
                catch (IOException e)
                {
                    throw new IOException("Reading bitmap file failed " + src, e);
                }
            }
            finally
            {
                inputStream = null;
            }
        }
示例#4
0
 public ScreenHelper(IGraphicFactory graphicFactory)
 {
     _graphicFactory = graphicFactory;
 }