using System.Windows.Input;
using System.Windows.Media.Imaging;
using Prism.Commands;
using Valg.EVA.Skanning.UserInterfaceElements;
using Valg.EVA.Skanning.UserInterfaceElements.BallotPaperImage;

namespace Valg.EVA.Skanning.Scan.Presentation.ScannerQuality
{
    public class ScannerQualityBallotPaperImageViewModel : ViewModelBase, IBallotPaperImageViewModel
    {
        private int currentBallotPaperImageIndex;

        private BitmapSource selected;

        public ScannerQualityBallotPaperImageViewModel(BitmapSource front, BitmapSource back)
        {
            Front = front;
            Back = back;
            ShowZoomPanelMiniMap = true;
            CurrentBallotPaperImageIndex = 0;
            Selected = CurrentBallotPaperImageIndex == 0 ? Front : Back;
            WindowIcon = "/Valg.EVA.Skanning.Assets;component/Images/Icons/EvaScan.ico";
        }

        public BitmapSource Front { get; set; }

        public BitmapSource Back { get; set; }

        public BitmapSource Selected
        {
            get
            {
                return selected;
            }
            set
            {
                selected = value;
                OnPropertyChanged();
            }
        }

        public bool ShowZoomPanelMiniMap { get; set; }

        public int CurrentBallotPaperImageIndex
        {
            get { return currentBallotPaperImageIndex; }
            set
            {
                currentBallotPaperImageIndex = value;
                Selected = currentBallotPaperImageIndex == 0 ? Front : Back;
                OnPropertyChanged();
            }
        }

        public int BallotPaperId { get; set; }

        public int BoxCountingId { get; set; }

        public ICommand FlipImage
        {
            get
            {
                return new DelegateCommand(
                    () =>
                    {
                        CurrentBallotPaperImageIndex = CurrentBallotPaperImageIndex == 0 ? 1 : 0;
                    });
            }
        }
        public string WindowIcon { get; }
    }
}

