using C1.Xaml.Document;
using C1.Xaml.SsrsViewer;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.DataTransfer;
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;

namespace SsrsViewerSamples.Samples
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class AppBarDemo : Page
    {
        public AppBarDemo()
        {
            this.InitializeComponent();
            ssrsViewer.Credential = new System.Net.NetworkCredential("ssrs_demo", "bjqveS5gh89BH1Q");
            searchBar.Viewer = ssrsViewer;
            navigationTool.Viewer = ssrsViewer;
            optionTool.Viewer = ssrsViewer;
        }

        private void CommandBar_Opened(object sender, object e)
        {
            searchBar.FocusSearchBox();
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            HideBars();
            searchBar.ResetSearch();
        }

        private void btnCopy_Click(object sender, RoutedEventArgs e)
        {
            string s = ssrsViewer.GetSelectedText();
            if (!string.IsNullOrEmpty(s))
            {
                DataPackage dp = new DataPackage();
                dp.RequestedOperation = DataPackageOperation.Copy;
                dp.SetText(s);
                Clipboard.SetContent(dp);
                HideBars();
            }
        }

        private void btnThumbs_Click(object sender, RoutedEventArgs e)
        {
            HideBars();
        }

        void HideBars()
        {
            TopAppBar.IsOpen = false;
            BottomAppBar.IsOpen = false;
        }
    }
}
