using Valg.EVA.Skanning.UserInterfaceElements.LightBox;
using Valg.EVA.Skanning.UserInterfaceElements.UserSettings;
using Valg.EVA.Skanning.UserInterfaceElements;

namespace Valg.EVA.Skanning.Verify.Startup.NavigationTip
{
    public class NavigationTipViewModel : ViewModelBase, INavigationTipViewModel
    {
        private readonly IUserSettingsProvider SettingManager;
        private bool dontShowTipOnStartup;

        public NavigationTipViewModel(IUserSettingsProvider settingManager)
        {
            SettingManager = settingManager;
            SetPropertyValues();
        }

        
        
        
        
        
        
        
        public bool DontShowTipOnStartup
        {
            get { return dontShowTipOnStartup; }
            set
            {
                dontShowTipOnStartup = value;
                OnPropertyChanged();
            }
        }

        
        
        
        public void ShowTipIfNotHiddenByUser()
        {
            if (!DontShowTipOnStartup)
            {
                var eventArgs = new LightBoxEventArgs(typeof(NavigationTipWindow), this);
                PublishEvent<ShowLightBoxEvent, LightBoxEventArgs>(eventArgs);
            }
        }
        
        public void SaveSettings()
        {
            UserSettings settings = SettingManager.GetUserSettings();
            settings.ShowVerifyNavigationTip = !DontShowTipOnStartup;
            SettingManager.SaveUserSettings(settings);
        }

        private void SetPropertyValues()
        {
            UserSettings settings = SettingManager.GetUserSettings();
            DontShowTipOnStartup = !settings.ShowVerifyNavigationTip;
        }
    }
}
