using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace PdfViewerSamples
{
    public sealed partial class Orientation : UserControl
    {
        public Orientation()
        {
            this.InitializeComponent();
            cmbOrientation.SelectedIndex = 0;
            this.Loaded += Orientation_Loaded;
            this.Unloaded += Orientation_Unloaded;
        }

        void Orientation_Unloaded(object sender, RoutedEventArgs e)
        {
            pdfViewer.CloseDocument();
        }

        void Orientation_Loaded(object sender, RoutedEventArgs e)
        {
            //LoadDocument();
        }

        private void cmbOrientation_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbOrientation.SelectedIndex == 0)
            {
                pdfViewer.Orientation = Windows.UI.Xaml.Controls.Orientation.Horizontal;
            }
            else
            {
                pdfViewer.Orientation = Windows.UI.Xaml.Controls.Orientation.Vertical;
            }
            LoadDocument();
        }

        private void LoadDocument()
        {
            Assembly asm = typeof(Orientation).GetTypeInfo().Assembly;
            Stream stream = asm.GetManifestResourceStream("PdfViewerSamples.Files.Presentation.pdf");
            pdfViewer.LoadDocument(stream);
        }
    }
}
