using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Valg.EVA.Skanning.Sample.Startup.Box
{
    
    
    
    public partial class BoxControl : UserControl
    {
        private BoxControlViewModel _model;

        public BoxControl()
        {
            InitializeComponent();
        }

        private void BoxControl_OnLoaded(object sender, RoutedEventArgs e)
        {
            _model = (BoxControlViewModel) DataContext;
            var window = Window.GetWindow(this);
            if (window != null)
            {
                window.KeyDown += HandleKeyPress;
            }
        }

        private void HandleKeyPress(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.PageDown)
            {
                _model.NavigateBallotsViewModel.BallotControlViewModel.BallotPaperImageViewModel.FlipImage.Execute(0);
                e.Handled = true;
            }
            else if (e.Key == Key.PageUp)
            {
                _model.NavigateBallotsViewModel.BallotControlViewModel.BallotPaperImageViewModel.FlipImage.Execute(0);
                e.Handled = true;
            }
        }
    }
}

