Exemplo n.º 1
0
        private void KeyDownThread(KeyboardHookEventArgs e)
        {
            _eventIsBusy = true;
            try
            {
                Key inputKey = KeyInterop.KeyFromVirtualKey((int)e.Key);
                foreach (var item in ServiceProvider.Settings.Actions)
                {
                    if (!item.Global)
                    {
                        continue;
                    }
                    if (item.Alt == e.isAltPressed && item.Ctrl == e.isCtrlPressed && item.KeyEnum == inputKey)
                    {
                        ServiceProvider.WindowsManager.ExecuteCommand(item.Name);
                    }
                }
                ICameraDevice lastDevice = null;
                foreach (ICameraDevice device in ServiceProvider.DeviceManager.ConnectedDevices)
                {
                    if (lastDevice != null)
                    {
                        lastDevice.WaitForCamera(1500);
                    }

                    // wait for camera to finish last transfer with timeot of 1.5 sec
                    device.WaitForCamera(1500);
                    // skip camera is camera is still busy
                    if (device.IsBusy)
                    {
                        continue;
                    }
                    CameraProperty property = device.LoadProperties();
                    if (property.KeyTrigger.KeyEnum != Key.None && property.KeyTrigger.Alt == e.isAltPressed &&
                        property.KeyTrigger.Ctrl == e.isCtrlPressed &&
                        property.KeyTrigger.KeyEnum == inputKey)
                    {
                        CameraHelper.Capture(device);
                        lastDevice = device;
                    }
                    if (property.KeyTriggerNoAF.KeyEnum != Key.None && property.KeyTriggerNoAF.Alt == e.isAltPressed &&
                        property.KeyTriggerNoAF.Ctrl == e.isCtrlPressed &&
                        property.KeyTriggerNoAF.KeyEnum == inputKey)
                    {
                        CameraHelper.CaptureNoAf(device);
                        lastDevice = device;
                    }
                }
            }
            catch (Exception exception)
            {
                StaticHelper.Instance.SystemMessage = exception.Message;
                Log.Error("Key trigger ", exception);
            }
            _eventIsBusy = false;
        }
Exemplo n.º 2
0
 private void Capture()
 {
     try
     {
         WaitForReady(ServiceProvider.DeviceManager.SelectedCameraDevice);
         if (NoAutofocus && ServiceProvider.DeviceManager.SelectedCameraDevice.GetCapability(CapabilityEnum.CaptureNoAf))
         {
             CameraHelper.CaptureNoAf(ServiceProvider.DeviceManager.SelectedCameraDevice);
         }
         else
         {
             CameraHelper.Capture(ServiceProvider.DeviceManager.SelectedCameraDevice);
         }
         //_timer.Enabled = true;
     }
     catch (Exception exception)
     {
         Log.Error(exception);
         StaticHelper.Instance.SystemMessage = exception.Message;
     }
 }