public override bool Execute() { uint err = EDSDKLib.EDSDK.EDS_ERR_OK; IntPtr camera = _model.Camera; IntPtr directoryItem = IntPtr.Zero; FileCounterCommand fileCounter = new FileCounterCommand(ref _model, ref _volume); // Prepare Download if (_currentFileNum == 0) { int directoryCount; err = fileCounter.CountDirectory(camera, ref directoryItem, out directoryCount); _fileNumber = new FileCounterCommand.FileNumber(directoryCount); _fileNumber.DcimItem = directoryItem; err = fileCounter.CountImages(camera, ref directoryItem, ref directoryCount, ref _fileCount, ref _fileNumber, ref _imageItems); if (err != EDSDKLib.EDSDK.EDS_ERR_OK) { return(false); } // Show progress. _event = new CameraEvent(CameraEvent.Type.DOWNLOAD_START, (IntPtr)_fileCount); _model.NotifyObservers(_event); } // Download file. err = DownloadImageByDirectory(camera); if (err != EDSDKLib.EDSDK.EDS_ERR_OK) { return(false); } return(true); }
public override bool Execute() { uint err = EDSDKLib.EDSDK.EDS_ERR_OK; IntPtr camera = _model.Camera; IntPtr directoryItem = IntPtr.Zero; FileCounterCommand fileCounter = new FileCounterCommand(ref _model); _imageItems = new List <IntPtr>(); // Prepare delete if (_currentFileNum == 0) { int directoryCount = 0; int fileCount = 0; // Show progress. Display Message. _event = new CameraEvent(CameraEvent.Type.DELETE_START, (IntPtr)fileCount); _model.NotifyObservers(_event); err = fileCounter.CountDirectory(camera, ref directoryItem, out directoryCount); _fileNumber = new FileCounterCommand.FileNumber(directoryCount); _fileNumber.DcimItem = directoryItem; err = fileCounter.CountImages(camera, ref directoryItem, ref directoryCount, ref fileCount, ref _fileNumber, ref _imageItems); if (err != EDSDKLib.EDSDK.EDS_ERR_OK) { return(false); } // Show progress. _event = new CameraEvent(CameraEvent.Type.DELETE_START, (IntPtr)fileCount); _model.NotifyObservers(_event); if (fileCount == 0) { _event = new CameraEvent(CameraEvent.Type.DELETE_COMPLETE, (IntPtr)fileCount); _model.NotifyObservers(_event); } } // Delete file. err = DeleteFileByDirectory(camera); if (err != EDSDKLib.EDSDK.EDS_ERR_OK) { return(false); } return(true); }