using System;
using System.Threading;
using System.Windows.Forms;

namespace AutoIngest.App
{
    static class Program
    {
        static Mutex _mutex = null!;

        [STAThread]
        static void Main()
        {
            bool owned;
            _mutex = new Mutex(true, "AutoIngest_SingleInstance", out owned);
            if (!owned)
            {
                MessageBox.Show(
                    "AutoIngest is already running.",
                    "Already Running",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.SetHighDpiMode(HighDpiMode.SystemAware);

            // MainForm starts hidden — it lives in the tray and only pops up as a toast
            // when an SD card / USB import is in progress.
            Application.Run(new MainForm());
        }
    }
}
