protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); DispatcherUnhandledException += (_, e) => Record(e.Exception); TaskScheduler.UnobservedTaskException += (_, e) => Record(e.Exception); AppDomain.CurrentDomain.UnhandledException += (_, e) => Record(e.ExceptionObject); var(success, builtinCameraId, usbCameraId) = await Camera.ReadAsync(e.Args); if (!success) { this.Shutdown(); return; } _switcher = new DeviceSwitcher(builtinCameraId, usbCameraId); await _switcher.CheckAsync(); _holder = new NotifyIconHolder( new[] { "pack://application:,,,/HelloSwitcher;component/Resources/Camera_absent.ico", "pack://application:,,,/HelloSwitcher;component/Resources/Camera_present.ico", }, Convert.ToInt32(_switcher.UsbDeviceExists), "Hello Switcher", new[]
protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); Logger.RecordOperation("Start"); if (!Initiate()) { this.Shutdown(); return; } await Settings.LoadAsync(); Logger.RecordOperation($"Settings IsLoaded: {Settings.IsLoaded}"); _switcher = new DeviceSwitcher(Settings, Logger); await _switcher.CheckAsync("Initial Check"); _watcher = new DeviceUsbWindowWatcher(); _watcher.UsbDeviceChanged += async(_, e) => { await _switcher.CheckAsync("Device Changed Check", e.deviceName, e.exists); if (IsInteractive) { _holder?.UpdateIcon(_switcher.RemovableCameraExists); await UpdateWindow(); } }; if (IsInteractive) { _holder = new NotifyIconHolder( new[] { "pack://application:,,,/HelloSwitcher;component/Resources/Disconnected.ico", "pack://application:,,,/HelloSwitcher;component/Resources/Connected.ico", }, "Hello Switcher", new[]