using System.Threading.Tasks;
using MvvmCross.Core.ViewModels;
using MvvmCross.Platform.UI;

namespace KoloryMvvmCross.Core.ViewModels
{
    public class MainViewModel : MvxViewModel
    {
        private Models.KolorModel model = new Models.KolorModel(0, 0, 0);

        public MainViewModel()
        {
        }
        
        public override Task Initialize()
        {
            //TODO: Add starting logic here
		    
            return base.Initialize();
        }
        
        /*
        public IMvxCommand ResetTextCommand => new MvxCommand(ResetText);
        private void ResetText()
        {
            Text = "Hello MvvmCross";
        }

        private string _text = "Hello MvvmCross";
        public string Text
        {
            get { return _text; }
            set { SetProperty(ref _text, value); }
        }
        */

        public byte R
        {
            get
            {
                return model.R;
            }
            set
            {
                model.R = value;
                RaisePropertyChanged(nameof(R));
                RaisePropertyChanged(nameof(Kolor));
            }
        }

        public byte G
        {
            get
            {
                return model.G;
            }
            set
            {
                model.G = value;
                RaisePropertyChanged(nameof(G));
                RaisePropertyChanged(nameof(Kolor));
            }
        }

        public byte B
        {
            get
            {
                return model.B;
            }
            set
            {
                model.B = value;
                RaisePropertyChanged(nameof(B));
                RaisePropertyChanged(nameof(Kolor));
            }
        }

        public MvxColor Kolor
        {
            get
            {
                return new MvxColor(R, G, B);
            }
        }

        public void Resetuj()
        {
            model.Resetuj();
            RaisePropertyChanged(nameof(R));
            RaisePropertyChanged(nameof(G));
            RaisePropertyChanged(nameof(B));
            RaisePropertyChanged(nameof(Kolor));
        }

        /*
        public IMvxCommand ResetujCommand
        {
            get
            {
                return new MvxCommand(Resetuj);
            }
        }
        */
        public IMvxCommand ResetujCommand => new MvxCommand(Resetuj);
    }
}