using System.Windows;

namespace VMwareLauncher
{
    /// <summary>
    /// Interaction logic for Startup.xaml
    /// </summary>
    public partial class Startup : Window
    {
        static internal TrayIcon trayIcon = new TrayIcon();
        static internal ServiceControl serviceControl = new ServiceControl();
        internal StatusWindow statusWindow = new StatusWindow();
        internal CheckDependencies checkDependencies = new CheckDependencies();
        
        public Startup()
        {
            InitializeComponent();

            ProcessControl vmWStationControl = new ProcessControl();
            vmWStationControl.ProcessName = ProcessControl.DefaultVmwarePath;

            ProcessControl vmLauncherControl = new ProcessControl();
            vmLauncherControl.ProcessName = ProcessControl.DefaultVmLauncherPath;

            checkDependencies.PerformCheck();

            // Modify service status to manual.
            serviceControl.ForceServicesManual();

            if (!vmLauncherControl.IsProcessRunning())
            {
                statusWindow.Show();
                trayIcon.Create();
            }
            else
            {
                vmWStationControl.StartProcess();
                ApplicationControl.Shutdown(0);
            }
        }
    }
}
