Esempio n. 1
0
        public Camera(IntPtr aPointer, ICameraNotifications aCameraNotifications)
        {
            _onCameraEvent           = DownloadImage;
            _onCameraStateChanged    = CameraStateChanged;
            _onCameraPropertyChanged = CameraPropertyChanged;
            _pointer             = aPointer;
            _cameraNotifications = aCameraNotifications;
            _eventHandlers       = new List <CameraEvent>();

            SDKHelper.CheckError(EDSDK.EdsOpenSession(_pointer));
            SDKHelper.CheckError(EDSDK.EdsSetObjectEventHandler(_pointer, EDSDK.ObjectEvent_All, _onCameraEvent, IntPtr.Zero));
            SDKHelper.CheckError(EDSDK.EdsSetCameraStateEventHandler(_pointer, EDSDK.StateEvent_All, _onCameraStateChanged, IntPtr.Zero));
            SDKHelper.CheckError(EDSDK.EdsSetPropertyEventHandler(_pointer, EDSDK.PropertyEvent_All, _onCameraPropertyChanged, IntPtr.Zero));
        }
Esempio n. 2
0
 public uint[] GetAvailableValues(uint aPropertyType)
 {
     CameraAlreadyDisposedException.ThrowIf(_disposed);
     EDSDK.EdsPropertyDesc propertyDesc;
     try
     {
         SDKHelper.CheckError(EDSDK.EdsGetPropertyDesc(_pointer, aPropertyType, out propertyDesc));
         int[] result = new int[propertyDesc.NumElements];
         Array.Copy(propertyDesc.PropDesc, result, result.Length);
         return(Array.ConvertAll(result, new Converter <int, uint>(int32 => Convert.ToUInt32(int32))));
     }
     catch (SDKInvalidParameterExeption)
     {
         return(new uint[0]);
     }
 }
Esempio n. 3
0
        private ImageFile GetImageFile(IntPtr inRef, Folder aFolder)
        {
            EDSDK.EdsDirectoryItemInfo directoryItemInfo = GetDirectoryItemInfo(inRef);
            string filename = aFolder.ComposeFilename(directoryItemInfo.szFileName);
            IntPtr stream   = GetFileStream(filename);

            try
            {
                SDKHelper.CheckError(EDSDK.EdsDownload(inRef, directoryItemInfo.Size, stream));
                SDKHelper.CheckError(EDSDK.EdsDownloadComplete(inRef));
            }
            catch
            {
                SDKHelper.CheckError(EDSDK.EdsDownloadCancel(inRef));
                throw;
            }
            finally
            {
                SDKHelper.CheckError(EDSDK.EdsRelease(stream));
            }
            return(new ImageFile(File.ReadAllBytes(filename), directoryItemInfo.szFileName));
        }
Esempio n. 4
0
        private uint CameraPropertyChanged(uint inEvent, uint inPropertyID, uint inParam, IntPtr inContext)
        {
            _cameraNotifications.Log(string.Format("Camera property changed: {0}, {1}, {2}", SDKHelper.DecodeEvent(inEvent), SDKHelper.DecodeProperty(inPropertyID), inParam));

            lock (_eventHandlersSync)
            {
                foreach (CameraEvent cameraEvent in _eventHandlers)
                {
                    cameraEvent.Process(inPropertyID, inParam);
                }
                _eventHandlers.RemoveAll(cameraEvent => cameraEvent.RunOnce);
            }

            return(EDSDK.EDS_ERR_OK);
        }
Esempio n. 5
0
 public void MoveFocus(uint value)
 {
     SDKHelper.CheckError(EDSDK.EdsSendCommand(_pointer, EDSDK.CameraCommand_DriveLensEvf, (int)value));
 }
Esempio n. 6
0
 public void KeepALive()
 {
     CameraAlreadyDisposedException.ThrowIf(_disposed);
     SDKHelper.CheckError(EDSDK.EdsSendCommand(_pointer, EDSDK.CameraCommand_ExtendShutDownTimer, 0));
 }
Esempio n. 7
0
 private static EDSDK.EdsDirectoryItemInfo GetDirectoryItemInfo(IntPtr inRef)
 {
     EDSDK.EdsDirectoryItemInfo directoryItemInfo;
     SDKHelper.CheckError(EDSDK.EdsGetDirectoryItemInfo(inRef, out directoryItemInfo));
     return(directoryItemInfo);
 }
Esempio n. 8
0
 public void LockUI()
 {
     CameraAlreadyDisposedException.ThrowIf(_disposed);
     SDKHelper.CheckError(EDSDK.EdsSendStatusCommand(_pointer, EDSDK.CameraState_UILock, 0));
 }
Esempio n. 9
0
 public void SetProperty <T>(uint propertyId, T value)
 {
     CameraAlreadyDisposedException.ThrowIf(_disposed);
     SDKHelper.CheckError(EDSDK.EdsSetPropertyData(_pointer, propertyId, 0, sizeof(int), value));
 }
Esempio n. 10
0
 private void UnInitialize()
 {
     Array.ForEach(_processors.Values.ToArray(), cameraProcessor => cameraProcessor.Dispose());
     SDKHelper.CheckError(EDSDK.EdsRelease(_cameraListPointer));
     SDKHelper.CheckError(EDSDK.EdsTerminateSDK());
 }