public void statusChanged(bool disabled, bool available)
 {
     if (this.previousState && !available && !disabled)
     {
         this.previousState = false;
         YubikeyScreenLocker.LockWorkStation();
         Console.Out.WriteLine("Screen lock");
     }
     else if (disabled)
     {
         this.previousState = false;
     }
     else
     {
         this.previousState = available;
     }
 }
Beispiel #2
0
        static void Main()
        {
            using (Mutex mutex = new Mutex(false, @"Global\" + appGuid))
            {
                if (!mutex.WaitOne(0, false))
                {
                    MessageBox.Show("Instance already running");
                    return;
                }

                GC.Collect();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                ApplicationContext context = new ApplicationContext();

                YubikeyUsbMonitor   monitor = new YubikeyUsbMonitor();
                YubikeyLockSystray  systray = new YubikeyLockSystray(monitor);
                YubikeyScreenLocker locker  = new YubikeyScreenLocker(monitor);
                monitor.addObserver(systray);
                monitor.addObserver(locker);
                monitor.startMonitoring();
                Application.Run(context);
            }
        }