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

namespace Valg.EVA.Skanning.Sample.Startup
{
    
    
    
    public partial class MainWindow : IMainWindow 
    {
        private bool _isElectionConfigInstalled;
        private readonly IMainWindowViewModel _viewModel;
        public MainWindow(IMainWindowViewModel viewModel)
        {
            InitializeComponent();
            _viewModel = viewModel;

            DataContext = viewModel;
        }

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

        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);
        }
    }
}

