예제 #1
0
        internal void UpdateNotInitializedFirstEgsDeviceOnSomeDeviceConnected()
        {
            // TODO: MUSTDO: Test with connecting and re-connecting USB connector, because various problems can occur here.
            try
            {
                // At first it checks HID connection.
                MessageReceivingForm.SetupDi.Update();
                foreach (var device in DeviceList)
                {
                    device.UpdateHidDeviceConnectionStatus();
                }

                // And then it checks camera connection.
                var cameras = GetCameraInterfaceInformationList();
                Debug.WriteLine("cameras.Count: " + cameras.Count);
                foreach (var camera in cameras)
                {
                    var matchedDeviceExists = DeviceList.Any(e => e.CameraViewImageSourceBitmapCapture.VideoCaptureDeviceIndex == camera.Index);
                    if (matchedDeviceExists)
                    {
                        continue;
                    }
                    var notInitializedFirstEgsDevice = DeviceList.FirstOrDefault(e => (e.CameraViewImageSourceBitmapCapture.VideoCaptureDeviceIndex.HasValue == false));
                    if (notInitializedFirstEgsDevice == null)
                    {
                        return;
                    }

                    Trace.Assert(notInitializedFirstEgsDevice.Settings != null);

                    // TODO: MUSTDO: get root device's serial number;
                    notInitializedFirstEgsDevice.CameraViewImageSourceBitmapCapture.VideoCaptureDeviceIndex      = camera.Index;
                    notInitializedFirstEgsDevice.CameraViewImageSourceBitmapCapture.VideoCaptureDeviceName       = camera.Description;
                    notInitializedFirstEgsDevice.CameraViewImageSourceBitmapCapture.VideoCaptureDeviceDevicePath = camera.DevicePath;
                    notInitializedFirstEgsDevice.TrySetIsCameraDeviceConnectedToTrue();
                    Debug.WriteLine("notInitializedFirstEgsDevice.IsConnected: " + notInitializedFirstEgsDevice.IsConnected);
                }
            }
            catch (EgsHostApplicationIsClosingException)
            {
                // NOTE: The exception occurs from inside of Timer, so the application thread cannot catch it.  EgsDevicesManager.Dispose() is called and then the application exit in the event handler of EgsDevicesManager.Disposing.
                System.Windows.Forms.MessageBox.Show(Resources.CommonStrings_ApplicationWillExit, ApplicationCommonSettings.HostApplicationName, System.Windows.Forms.MessageBoxButtons.OK);
                // NOTE! EgsHostAppBaseComponents should save Settings before disposing this object!
                this.Dispose();
            }
            catch (Exception ex)
            {
                if (ApplicationCommonSettings.IsDebugging)
                {
                    Debugger.Break();
                }
                Debug.WriteLine(ex.Message);
            }
        }
예제 #2
0
        private string GetNoteName()
        {
            string noteName = DefaultNoteName;

            if (DeviceList.Any(x => x.Name == noteName))
            {
                return(GetNoteName());
            }

            return(noteName);
        }
예제 #3
0
 private static void ServiceWorkerThread(object state)
 {
     while (!isStopping)
     {
         IDeviceList list = new DeviceList();
         list.Scan();
         if (list.Any())
         {
             var device = list.First();
             if (device != null && IsAudioPlaying(audioDevice))
             {
                 device.SetColor(LedTarget.All, yellow);
             }
             else
             {
                 device?.SetColor(LedTarget.All, defaultColor);
             }
         }
         Thread.Sleep(500);
     }
 }