I'm using MS Chart in my WindowsForms app and I want to have a lot of different markers visible on chart. In principle it's done by specifying a MarkerImage
for Series
or DataPoint
. The problem is that the MarkerImage
property is of string type with no documentation for it's usage. According to the MS Chart samples, it is the path to the image file.
I managed to make it work by putting the images into project/images folder, specifying 'Copy to Output Directory' for them, and then using series.MarkerImage = "images/image.bmp";
in the code. It works in principle but in runtime when it comes to first displaying the marker image on chart, the application freezes for some time. I assume it's because of a disk access time for loading a new file. And it happens every time a new image should first appear on screen, making the application really unresponsive until all the images are cached.
What I'm looking for is some solution to improve this. At best I'd prefer to have all the images stored as embedded resources, which is much better than having to ship additional folder of images with the app. According to documentation for the LegendCell.Image
(which have a similar meaning) the string is actually an URL. I found that it's possible to get URL for the embedded resource in a ASP.NET applications using Page.ClientScript.GetWebResourceUrl
, but my application if just plain WindowsForms. Is it possible to get some kind of URL for the embedded resource in windows forms?
I am already thinking of implementing my own Series or DataPoint descendants to handle resource references, but does not seem to be a right way, as I see nothing related to actual rendering of the Series that I can override...
Another solution I think of is just pre-loading all the image files myself at the application start, but this seem to be a hack. And what if I want to provide the markers together with a separate assembly (.dll)?
Update. I tried:
- Preloading images with File.ReadAllBytes. Does not speedup anything.
- Using Data URI. Fails with exception with text "The given path's format is not supported."