using System.ComponentModel;
using System.Windows.Interop;

namespace Valg.EVA.Skanning.Verify.Startup.VerifyWindow
{
    public partial class VerifyWindow : IVerifyWindow
    {
        private readonly IVerifyWindowViewModel viewModel;
        private bool isElectionConfigInstalled;

        public VerifyWindow(IVerifyWindowViewModel viewModel)
        {
            InitializeComponent();
            this.viewModel = viewModel;

            DataContext = viewModel;
        }

        public void Initialize(bool isEmlInstalled)
        {
            isElectionConfigInstalled = isEmlInstalled;
        }

        public void ShowWindow(bool isKioskMode)
        {
            Show();
            if (isElectionConfigInstalled)
            {
                viewModel.Login();
            }
            else
            {
                viewModel.ShowElectionConfigMissingWindow();
            }
            if (isKioskMode)
            {
                HideMinimizeButton();
            }
        }
        private void HideMinimizeButton()
        {
            var hwnd = new WindowInteropHelper(this).Handle;
            Valg.EVA.Skanning.Tools.WindowExtensions.HideMinimizeButton(hwnd);

        }
        protected override void OnClosing(CancelEventArgs e)
        {
            viewModel.CloseApplication();
            base.OnClosing(e);
        }
    }
}
