using Microsoft.Win32;
using System.ComponentModel;
using System.IO;

namespace VMwareLauncher
{
    public class CheckDependencies
    {
        private readonly BackgroundWorker performInitialChecks = new BackgroundWorker();

        public void PerformCheck()
        {
            // Check Vmware Workstation has been installed.
            if (!File.Exists(ProcessControl.DefaultVmwarePath))
            {
                MessageHandler.Show(MessageHandler.MessageCode.VmwareNotInstalled);
                ApplicationControl.Shutdown(-1);
            }
            else
            {
                // Determine if VML has ever run before.
                string vmlPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\VmwareLauncher";
                string vmlKey = "HasBeenSetup";

                if (Registry.GetValue(vmlPath, vmlKey, null) == null)
                {
                    Registry.SetValue(vmlPath, vmlKey, 1);
                    MessageHandler.Show(MessageHandler.MessageCode.WelcomeMessage);
                }
            }
        }
    }
}