using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
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;

using Windows.UI.Popups;
using BxlWinUniversalSDK;

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

namespace BxlUniversalTestAPP.Content
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class PageMode : Page
    {
        BxlUniversalSDK _BxlUniversalSDK;

        public PageMode()
        {
            this.InitializeComponent();

            if (true == MainPage._ConnectedPrinter)
            {
                _BxlUniversalSDK = MainPage._BxlUniversalSDK;
            }
            else
            {
                var Dialog = new MessageDialog("First connect to the printer.");
                Dialog.ShowAsync();
            }
        }

        private void PageMode_Click(object sender, RoutedEventArgs e)
        {
            _BxlUniversalSDK.SelectPageMode(true);
        }

        private void PageSample_Click(object sender, RoutedEventArgs e)
        {
            _BxlUniversalSDK.InitializePrinter();
            _BxlUniversalSDK.SelectPageMode(true);
            _BxlUniversalSDK.SetPrintAreaInPM(0, 0, 416, 416);
            _BxlUniversalSDK.SetPrintDirectionInPM(MainPage.BXL_PD_TOP_TO_BOTTOM);

            string barCode = "1234567890123";

            _BxlUniversalSDK.SetVerticalPositionInPM(70);
            _BxlUniversalSDK.SetHorizontalPositionInPM(5);

            _BxlUniversalSDK.PrintBarcode(barCode, MainPage.BXL_BCS_CODE93, 50, 2, MainPage.BXL_ALIGNMENT_LEFT, MainPage.BXL_BC_TEXT_NONE);

            _BxlUniversalSDK.SetVerticalPositionInPM(155);
            _BxlUniversalSDK.SetHorizontalPositionInPM(80);
            _BxlUniversalSDK.PrintText(barCode, MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_FT_DEFAULT,
                                MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);

            _BxlUniversalSDK.SetVerticalPositionInPM(200);
            _BxlUniversalSDK.SetHorizontalPositionInPM(0);
            _BxlUniversalSDK.PrintText("Name :", MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_ExFT_CHINA_FONTB,
                                MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);
            _BxlUniversalSDK.SetVerticalPositionInPM(200);
            _BxlUniversalSDK.SetHorizontalPositionInPM(90);

            _BxlUniversalSDK.PrintText(" Frank  ", MainPage.BXL_ALIGNMENT_LEFT, MainPage.BXL_ExFT_CHINA_FONTA |
                                MainPage.BXL_FT_UNDERTHICK | MainPage.BXL_FT_BOLD, MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);
            _BxlUniversalSDK.SetVerticalPositionInPM(200);
            _BxlUniversalSDK.SetHorizontalPositionInPM(180);
            _BxlUniversalSDK.PrintText("Sex  :", MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_ExFT_CHINA_FONTA |
                                MainPage.BXL_TS_0WIDTH, MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);
            _BxlUniversalSDK.SetVerticalPositionInPM(200);
            _BxlUniversalSDK.SetHorizontalPositionInPM(260);
            _BxlUniversalSDK.PrintText("  male   ", MainPage.BXL_ALIGNMENT_LEFT, MainPage.BXL_ExFT_CHINA_FONTA |
                                MainPage.BXL_FT_UNDERTHICK | MainPage.BXL_FT_BOLD, MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);

            _BxlUniversalSDK.SetVerticalPositionInPM(250);
            _BxlUniversalSDK.SetHorizontalPositionInPM(0);
            _BxlUniversalSDK.PrintText("Age  :", MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_ExFT_CHINA_FONTA,
                                MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);
            _BxlUniversalSDK.SetVerticalPositionInPM(250);
            _BxlUniversalSDK.SetHorizontalPositionInPM(90);
            _BxlUniversalSDK.PrintText("  30  ", MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_ExFT_CHINA_FONTA |
                                MainPage.BXL_FT_UNDERTHICK | MainPage.BXL_FT_BOLD, MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);
            _BxlUniversalSDK.SetVerticalPositionInPM(250);
            _BxlUniversalSDK.SetHorizontalPositionInPM(180);
            _BxlUniversalSDK.PrintText("City :", MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_ExFT_CHINA_FONTA |
                                MainPage.BXL_TS_0WIDTH, MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);
            _BxlUniversalSDK.SetVerticalPositionInPM(250);
            _BxlUniversalSDK.SetHorizontalPositionInPM(260);
            _BxlUniversalSDK.PrintText("  Seoul  ", MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_ExFT_CHINA_FONTA |
                                MainPage.BXL_FT_UNDERTHICK | MainPage.BXL_FT_BOLD, MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);


            _BxlUniversalSDK.SetVerticalPositionInPM(360);
            _BxlUniversalSDK.SetHorizontalPositionInPM(60);
            _BxlUniversalSDK.PrintText("abcdefgHIJK-123", MainPage.BXL_ALIGNMENT_CENTER, MainPage.BXL_FT_DEFAULT,
                                MainPage.BXL_TS_0WIDTH | MainPage.BXL_TS_0HEIGHT);

            _BxlUniversalSDK.PrintDataInPM();

            _BxlUniversalSDK.LineFeed(2);
        }

        private void LabelMode_Click(object sender, RoutedEventArgs e)
        {
            _BxlUniversalSDK.SelectLabelMode(true);
        }

        private void Calibration_Click(object sender, RoutedEventArgs e)
        {
            _BxlUniversalSDK.AutoCalibration();
        }
    }
}
