[]
        
(Showing Draft Content)

GrapeCity.ActiveReports.SectionReport.ResourceLocator

ResourceLocator Property

ResourceLocator

Gets or sets a value representing the implementation of the resource locator.

Declaration
[Browsable(false)]
public ResourceLocator ResourceLocator { get; set; }
Property Value
Type Description
ResourceLocator

A ResourceLocator object.

Remarks

The default value is an instance of a DefaultResourceLocator.

Examples

Resource locator implementation

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);
	}
}

Resource locator assigning

var sectionReport = new GrapeCity.ActiveReports.SectionReport();
sectionReport.ResourceLocator = new MyPicturesLocator();
var xtr = new System.Xml.XmlTextReader(filePath);
sectionReport.LoadLayout(xtr);
sectionReport.Document.Printer.PrinterName = String.Empty;
sectionReport.Run();