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

namespace Valg.Eva.Skanning.Scan.Presentation.ScanInProgress
{
    public class BatchInUseForJobViewModel : ViewModelBase, INotificationDuringScanningViewModel
    {
        private readonly ICommand deleteAllAndCancelCommand;
        private bool errorIsResolved;
        private bool isDeleteAllAndCancelButtonFocused;

        public BatchInUseForJobViewModel()
        {
            deleteAllAndCancelCommand = new DelegateCommand(DeleteAndCancel);
        }

        private void DeleteAndCancel()
        {
            ErrorIsResolved = true;
            PublishEvent<DeleteAllInBoxAndScanAgainEvent, DeleteAllInBoxAndScanAgainEventArgs>(new DeleteAllInBoxAndScanAgainEventArgs(false));
        }

        public string ProblemWithJobUsingBatch
        {
            get { return Valg.EVA.Skanning.Resources.Language.ScanLanguageString.ProblemWithJobUsingBatch; }
        }

        public string ProblemWithJobUsingBatchSolution
        {
            get { return Valg.EVA.Skanning.Resources.Language.ScanLanguageString.ProblemWithJobUsingBatchSolution; }
        }
        
        public string DeleteAllBallotsIsBoxAndCancel
        {
            get { return Valg.EVA.Skanning.Resources.Language.LanguageString.Button_Cancel; }
        }
        
        public ICommand DeleteAllAndCancelCommand
        {
            get { return deleteAllAndCancelCommand; }
        }
        public bool ErrorIsResolved
        {
            get { return errorIsResolved; }
            private set
            {
                errorIsResolved = value;
                OnPropertyChanged();
            }
        }

        public bool IsDeleteAllAndCancelButtonFocused
        {
            get { return isDeleteAllAndCancelButtonFocused; }
            set
            {
                isDeleteAllAndCancelButtonFocused = value;
                OnPropertyChanged();
            }
        }

        public void SetDefaultFocus()
        {
            DelayedFocusSetter.SetFocus(() => IsDeleteAllAndCancelButtonFocused = true);            
        }
    }
}
