using C1.BarCode;
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.Storage;
using Windows.Storage.Pickers;
using Windows.Storage.Streams;
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.Media.Imaging;
using Windows.UI.Xaml.Navigation;

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

namespace BarCodeSamples
{
    public sealed partial class Generator : UserControl
    {
        public Generator()
        {
            this.InitializeComponent();
            editor.Loaded += Editor_Loaded;
        }

        private void Editor_Loaded(object sender, RoutedEventArgs e)
        {
            RefreshBarCode();
        }

        private void RefreshBarCode()
        {
            var entity = editor.DataContext as Entity;
            if (entity != null)
            {
                barCode.Text = entity.EncodingText;
            }
        }

        private void GenerateBarCode(object sender, RoutedEventArgs e)
        {
            RefreshBarCode();
        }
    }
}
