public YubikeyLockSystray(YubikeyUsbMonitor monitor) { System.ComponentModel.Container comp = new System.ComponentModel.Container(); notifyIcon = new NotifyIcon(comp); notifyIcon.Visible = true; menu = new ContextMenu(); notifyIcon.ContextMenu = menu; this.monitor = monitor; this.disabled = new MenuItem("Disabled", disabledClick); menu.MenuItems.Add(disabled); menu.MenuItems.Add(new MenuItem("Exit", exitClick)); this.statusChanged(!monitor.WatcherActivated, monitor.YubikeyPresent); }
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); } }
public YubikeyScreenLocker(YubikeyUsbMonitor monitor) { this.previousState = monitor.YubikeyPresent; }