[]
Gets or sets the object responsible for resolving report resources.
public ResourceLocator ResourceLocator { get; set; }
Type | Description |
---|---|
ResourceLocator | A ResourceLocator object. |
The default value is an instance of a DefaultResourceLocator.
internal sealed class MyPicturesLocator : GrapeCity.ActiveReports.ResourceLocator
{
private const string UriSchemeMyImages = "MyPictures:";
public override Resource GetResource(ResourceInfo resourceInfo)
{
Resource resource;
Uri uri = new Uri(resourceInfo.Name);
string picturePath = GetPath(resourceInfo.Name);
MemoryStream stream = new MemoryStream();
using (FileStream source = File.Open(picturePath, FileMode.Open))
{
source.CopyTo(stream);
}
stream.Position = 0;
return new Resource(stream, uri);
}
private string GetPath(string resourceName)
{
string name = resourceName.Substring(UriSchemeMyImages.Length);
string myPicturesPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
return Path.Combine(myPicturesPath, name);
}
}
PageReport pageReport = new PageReport(reportFileInfo);
pageReport.ResourceLocator = new MyPicturesLocator();
PageDocument pageDocument = new PageDocument(pageReport);
pageDocument.Parameters["PictureName"].CurrentValue = _imageName;
pageDocument.Parameters["MimeType"].CurrentValue = "image/jpg";
reportViewer.LoadDocument(pageDocument);