using System;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Navigation;

using ATK;

using Windows.UI.Xaml.Media.Imaging;

using Windows.UI.Core;

using Windows.ApplicationModel.Background;

using Windows.Devices.Bluetooth;



// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556



namespace Zebra_RFID_Mobile

{

    /// <summary>

    /// An empty page that can be used on its own or navigated to within a Frame.

    /// </summary>

    public sealed partial class PageSettings : Page

    {

        public PageSettings()

        {

            this.InitializeComponent();            

            DPOImage.DataContext = ReaderConfig.DPOImage;

            PopUpSettings.DataContext = ReaderConfig.SettingsStaus;

            textSettingsStatusLabel.DataContext = ReaderConfig.SettingsStaus;

            //DPOImage.Source = new Uri("ms-appx:///Assets/title_dpo_disabled.png", UriKind.Absolute);              

        }



        /// <summary>

        /// Invoked when this page is about to be displayed in a Frame.

        /// </summary>

        /// <param name="e">Event data that describes how this page was reached.

        /// This parameter is typically used to configure the page.</param>

        protected override void OnNavigatedTo(NavigationEventArgs e)

        {

            //Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

        }



        protected override void OnNavigatedFrom(NavigationEventArgs e)

        {

            base.OnNavigatedFrom(e);

            //Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;

            SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested;

        }



        private void AppBarButton_Click(object sender, RoutedEventArgs e)

        {

            this.Frame.Navigate(typeof(MainPage));

        }



        private void AppBarButton_Click_1(object sender, RoutedEventArgs e)

        {

            this.Frame.Navigate(typeof(PageInventory));

        }



        private void AppBarButton_Click_2(object sender, RoutedEventArgs e)

        {

            this.Frame.Navigate(typeof(PageRapidRead));

        }



        private void AppBarButton_Click_3(object sender, RoutedEventArgs e)

        {

            this.Frame.Navigate(typeof(PageSettings));

        }



        private void AppBarButton_Click_4(object sender, RoutedEventArgs e)

        {

            this.Frame.Navigate(typeof(PageLocateTag));

        }



        void App_BackRequested(object sender, BackRequestedEventArgs e)

        {

            Frame.Navigate(typeof(MainPage));

        

        }



        private void list1_SelectionChanged(object sender, SelectionChangedEventArgs e)

        {

            if (list1.SelectedIndex == 0)

                this.Frame.Navigate(typeof(PageReaderList));

            else if (list1.SelectedIndex == 1)

                this.Frame.Navigate(typeof(PageConnection));

            else if (list1.SelectedIndex == 2)

                this.Frame.Navigate(typeof(PageAntennaConfig));

            else if (list1.SelectedIndex == 3)

                this.Frame.Navigate(typeof(PageSingulation));

            else if (list1.SelectedIndex == 4)

                this.Frame.Navigate(typeof(PageStartStop));

            else if (list1.SelectedIndex == 5)

                this.Frame.Navigate(typeof(PageTagReport));

            else if (list1.SelectedIndex == 6)

                this.Frame.Navigate(typeof(PageRegulatory));

            else if (list1.SelectedIndex == 7)

                this.Frame.Navigate(typeof(PageBattery));

            else if (list1.SelectedIndex == 8)

                this.Frame.Navigate(typeof(PagePowerOptimization));

            else if (list1.SelectedIndex == 9)

                this.Frame.Navigate(typeof(PageBeeper));

            else if (list1.SelectedIndex == 10)

                this.Frame.Navigate(typeof(PageSave));



            list1.SelectedIndex = -1; // make it -1 because it is a selection_changed event



        }



        private void ProgressRing_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)

        {

            if ((bool)e.NewValue == true)

                Flyout.ShowAttachedFlyout((FrameworkElement)sender);

            else

            {

                SettingsStatusFlyout.Hide();

            }

        }



    }

}

