using Valg.EVA.Skanning.UserInterfaceElements.LightBox;

namespace Valg.EVA.Skanning.UserInterfaceElements.Spinner
{
    public class SpinnerViewModel : ViewModelBase, ISpinnerViewModel
    {
        private string spinnerToolTip;
        private bool spinnerVisible;
        private string message;

        protected override void SubscribeToViewModelSpecificEvents()
        {
            SubscribeToEvent<SpinnerEvent, SpinnerEventArgs>(SpinnerEventHandler);
        }

        private void SpinnerEventHandler(SpinnerEventArgs e)
        {
            SpinnerVisible = e.ShowSpinner;
            Message = e.Message;
            SpinnerToolTip = e.SpinnerToolTip;
            ShowLightBox(e.ShowSpinner, e.Blocking);
        }

        private void ShowLightBox(bool show, bool blocking)
        {
            var eventArgs = new LightBoxEventArgs(show, blocking);
            PublishEvent<ShowLightBoxEvent, LightBoxEventArgs>(eventArgs);
        }


        public string SpinnerToolTip
        {
            get { return spinnerToolTip; }
            set
            {
                spinnerToolTip = value;
                OnPropertyChanged();
            }
        }

        public string Message
        {
            get { return message; }
            set
            {
                message = value;
                OnPropertyChanged();
            }
        }

        public bool SpinnerVisible
        {
            get { return spinnerVisible; }
            set
            {
                spinnerVisible = value;
                OnPropertyChanged();
            }
        }

        
    }
}
