//
// Copyright (c) 2015, MindFusion LLC - Bulgaria.
//

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Xml.Linq;


namespace MindFusion.Reporting.Wpf.Samples.CS.LinqBinding
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();

			var document = XDocument.Load(@"Data\nwind.xml");

			var linqData = document.Element("dataroot");

			Report report = Report.FromDictionary(new Uri("LinqBoundReport.xaml", UriKind.Relative), "linqBoundReport");
			report.DataContext = linqData;
			report.Run();

			ReportLayout layout = report.Layout(new Size(8.5 * 96, 11 * 96),
				new Thickness(0.5 * 96), PageOrientation.Portrait);

			FixedDocumentRenderTarget renderTarget = new FixedDocumentRenderTarget();
			layout.RenderAllPages(renderTarget);

			viewer.Document = renderTarget.Document;
		}
	}
}
