using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace KoloryWPF.ModelWidoku
{
    class PolecenieResetowania : ICommand
    {        
        Model.Kolor model;
        Action<string[]> onPropertyChanged;

        public PolecenieResetowania(Model.Kolor model, Action<string[]> onPropertyChanged)
        {
            this.model = model;
            this.onPropertyChanged = onPropertyChanged;            
        }

        public event EventHandler CanExecuteChanged
        {
            add
            {
                CommandManager.RequerySuggested += value;
            }
            remove
            {
                CommandManager.RequerySuggested -= value;
            }
        }

        public bool CanExecute(object parameter)
        {
            return model.R != 0 || model.G != 0 || model.B != 0;
        }

        public void Execute(object parameter)
        {
            model.R = 0;
            model.G = 0;
            model.B = 0;
            onPropertyChanged(new string[] { "R", "G", "B" });
        }
    }
}
