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

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;


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

			Report myReport = Report.FromDictionary(new Uri(@"MyReport.xaml", UriKind.Relative), "myReport");

			dataset = new nwindDataSet();
			Tutorial4.nwindDataSetTableAdapters.ProductsTableAdapter adapter =
				new Tutorial4.nwindDataSetTableAdapters.ProductsTableAdapter();
			adapter.Fill(dataset.Products);
			Tutorial4.nwindDataSetTableAdapters.CheapProductsTableAdapter cheapProductsAdapter =
				new Tutorial4.nwindDataSetTableAdapters.CheapProductsTableAdapter();
			cheapProductsAdapter.Fill(dataset.CheapProducts);

			myReport.DataContext = dataset;

			myReport.Run();

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

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

			documentViewer1.Document = renderTarget.Document;
		}


		private nwindDataSet dataset;
	}
}
