using OnAir;

namespace CamWatch
{
#pragma warning disable CA1416 // Plattformkompatibilität überprüfen
    internal class Program
    {
        static void Main(string[] args)
        {
            var apps = WebCamWatcher.GetAppsUsingCam();
            if (apps.Count() == 0)
            {
                Console.WriteLine("Webcam ist unbenutzt.");
            }
            else
            {
                foreach (var app in WebCamWatcher.GetAppsUsingCam())
                {
                    Console.WriteLine(app);
                }
            }

            var watcher = new WebCamWatcher();
            watcher.Watch(CamUsageChanged);
            Console.WriteLine("Enter to continue ... ");
            Console.ReadLine();
            watcher.EndWatch();
        }

        static void CamUsageChanged()
        {
            var apps = WebCamWatcher.GetAppsUsingCam();
            if (apps.Count() == 0)
            {
                Console.WriteLine("Webcam ist unbenutzt.");
            }
            else
            {
                foreach (var app in WebCamWatcher.GetAppsUsingCam())
                {
                    Console.WriteLine(app);
                }
            }
        }

    }
#pragma warning restore CA1416 // Plattformkompatibilität überprüfen
}
