Ejemplo n.º 1
0
        public void Update(Observable from, CameraEvent e)
        {
            CameraEvent.Type eventType = e.GetEventType();

            switch (eventType)
            {
            case CameraEvent.Type.SHUT_DOWN:

                MessageBox.Show("Camera is disconnected");

                if (_remoteCapture != null && !_remoteCapture.IsDisposed)
                {
                    _remoteCapture.Close();
                    _remoteCapture.Dispose();
                }

                this.Close();

                break;

            case CameraEvent.Type.PROPERTY_CHANGED:
                if (null != _remoteCapture)
                {
                    uint propertyID = (uint)e.GetArg();
                    if (propertyID == EDSDKLib.EDSDK.PropID_Evf_AFMode)
                    {
                        (_remoteCapture as RemoteCapture).controlFocusButton((int)EDSDKLib.EDSDK.EdsEvfAFMode.Evf_AFMode_LiveFace != _controller.GetModel().EvfAFMode);
                    }
                    if (propertyID == EDSDKLib.EDSDK.PropID_FixedMovie)
                    {
                        (_remoteCapture as RemoteCapture).updateFixedMovie(_controller.GetModel().FixedMovie);
                    }
                    if (propertyID == EDSDKLib.EDSDK.PropID_MirrorLockUpState)
                    {
                        (_remoteCapture as RemoteCapture).updateMirrorLockUpState(_controller.GetModel().MirrorLockUpState);
                    }
                }
                break;

            case CameraEvent.Type.ANGLEINFO:
                if (null != _remoteCapture)
                {
                    IntPtr cameraPosPtr = e.GetArg();
                    if (cameraPosPtr != IntPtr.Zero)
                    {
                        EDSDKLib.EDSDK.EdsCameraPos cameraPos = (EDSDKLib.EDSDK.EdsCameraPos)Marshal.PtrToStructure(cameraPosPtr, typeof(EDSDKLib.EDSDK.EdsCameraPos));
                        double pos = cameraPos.position;
                        // Convert to floating point
                        double roll = cameraPos.rolling * 0.01;
                        double pitc = cameraPos.pitching * 0.01;
                        (_remoteCapture as RemoteCapture).updateAngleInfoLabel(pos.ToString(), roll.ToString(), pitc.ToString());
                    }
                    else
                    {
                        uint err = EDSDKLib.EDSDK.EdsSendCommand(_controller.GetModel().Camera, EDSDKLib.EDSDK.CameraCommand_RequestRollPitchLevel, 1);
                        (_remoteCapture as RemoteCapture).updateAngleInfoLabel("-", "-", "-");
                    }
                }
                break;

            case CameraEvent.Type.MOUSE_CURSOR:
                if (null != _remoteCapture)
                {
                    IntPtr onOffPtr = e.GetArg();
                    if (onOffPtr != IntPtr.Zero)
                    {
                        (_remoteCapture as RemoteCapture).changeMouseCursor(true);
                    }
                    else
                    {
                        (_remoteCapture as RemoteCapture).changeMouseCursor(false);
                        _actionSource.FireEvent(ActionEvent.Command.CLICK_MOUSE, IntPtr.Zero);
                    }
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        public override void ActionPerformed(ActionEvent e)
        {
            ActionEvent.Command command = e.GetActionCommand();

            uint inPropertyID;
            uint data;

            EDSDKLib.EDSDK.EdsPoint point;
            switch (command)
            {
            case ActionEvent.Command.GET_PROPERTY:
                inPropertyID = (uint)e.GetArg();
                _processor.PostCommand(new GetPropertyCommand(ref _model, inPropertyID));
                break;

            case ActionEvent.Command.GET_PROPERTYDESC:
                inPropertyID = (uint)e.GetArg();
                _processor.PostCommand(new GetPropertyDescCommand(ref _model, inPropertyID));
                break;

            case ActionEvent.Command.TAKE_PICTURE:
                _processor.PostCommand(new TakePictureCommand(ref _model));
                break;

            case ActionEvent.Command.PRESS_COMPLETELY:
                _processor.PostCommand(new PressShutterCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsShutterButton.CameraCommand_ShutterButton_Completely));
                break;

            case ActionEvent.Command.PRESS_HALFWAY:
                _processor.PostCommand(new PressShutterCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsShutterButton.CameraCommand_ShutterButton_Halfway));
                break;

            case ActionEvent.Command.PRESS_OFF:
                _processor.PostCommand(new PressShutterCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsShutterButton.CameraCommand_ShutterButton_OFF));
                break;

            case ActionEvent.Command.START_EVF:
                _model.isEvfEnable = true;
                _processor.PostCommand(new StartEvfCommand(ref _model));
                break;

            case ActionEvent.Command.END_EVF:
                _model.isEvfEnable = false;
                // When exit LiveView, cancel EVF AF ON
                _processor.PostCommand(new DoEvfAFCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF));
                _processor.PostCommand(new EndEvfCommand(ref _model));
                break;

            case ActionEvent.Command.DOWNLOAD_EVF:
                _processor.PostCommand(new DownloadEvfCommand(ref _model));
                break;

            case ActionEvent.Command.SET_AF_MODE:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_AFMode, data));
                break;

            case ActionEvent.Command.SET_AE_MODE:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_AEModeSelect, data));
                break;

            case ActionEvent.Command.SET_AV:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_Av, data));
                break;

            case ActionEvent.Command.SET_TV:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_Tv, data));
                break;

            case ActionEvent.Command.SET_ISO_SPEED:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_ISOSpeed, data));
                break;

            case ActionEvent.Command.SET_METERING_MODE:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_MeteringMode, data));
                break;

            case ActionEvent.Command.SET_DRIVE_MODE:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_DriveMode, data));
                break;

            case ActionEvent.Command.SET_WHITE_BALANCE:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_WhiteBalance, data));
                break;

            case ActionEvent.Command.SET_EXPOSURE_COMPENSATION:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_ExposureCompensation, data));
                break;

            case ActionEvent.Command.SET_IMAGEQUALITY:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_ImageQuality, data));
                break;

            case ActionEvent.Command.SET_EVF_AFMODE:
                // When switching a EVF AF MODE, cancel EVF AF ON
                _processor.PostCommand(new DoEvfAFCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF));
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_Evf_AFMode, data));
                break;

            case ActionEvent.Command.SET_ZOOM:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_DC_Zoom, data));
                break;

            case ActionEvent.Command.SET_FLASH_MODE:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_DC_Strobe, data));
                break;

            case ActionEvent.Command.SET_MOVIEQUALITY:
                data = (uint)e.GetArg();
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_MovieParam, data));
                break;

            case ActionEvent.Command.CLICK_WB:
                _processor.PostCommand(new ClickWBCommand(ref _model, 1));
                break;

            case ActionEvent.Command.CLICK_MOUSE:
                _processor.PostCommand(new ClickWBCommand(ref _model, 2));
                break;

            case ActionEvent.Command.FOCUS_NEAR1:
                _processor.PostCommand(new DriveLensCommand(ref _model, EDSDKLib.EDSDK.EvfDriveLens_Near1));
                break;

            case ActionEvent.Command.FOCUS_NEAR2:
                _processor.PostCommand(new DriveLensCommand(ref _model, EDSDKLib.EDSDK.EvfDriveLens_Near2));
                break;

            case ActionEvent.Command.FOCUS_NEAR3:
                _processor.PostCommand(new DriveLensCommand(ref _model, EDSDKLib.EDSDK.EvfDriveLens_Near3));
                break;

            case ActionEvent.Command.FOCUS_FAR1:
                _processor.PostCommand(new DriveLensCommand(ref _model, EDSDKLib.EDSDK.EvfDriveLens_Far1));
                break;

            case ActionEvent.Command.FOCUS_FAR2:
                _processor.PostCommand(new DriveLensCommand(ref _model, EDSDKLib.EDSDK.EvfDriveLens_Far2));
                break;

            case ActionEvent.Command.FOCUS_FAR3:
                _processor.PostCommand(new DriveLensCommand(ref _model, EDSDKLib.EDSDK.EvfDriveLens_Far3));
                break;

            case ActionEvent.Command.DOWNLOAD:
                IntPtr inRef = (IntPtr)e.GetArg();
                _processor.PostCommand(new DownloadCommand(ref _model, ref inRef));
                break;

            case ActionEvent.Command.CLOSING:
                _processor.PostCommand(new CloseSessionCommand(ref _model));
                _processor.Stop();
                break;

            case ActionEvent.Command.SHUT_DOWN:
                _processor.Stop();

                CameraEvent shotDownEvent = new CameraEvent(CameraEvent.Type.SHUT_DOWN, IntPtr.Zero);
                _model.NotifyObservers(shotDownEvent);
                break;

            case ActionEvent.Command.EVF_AF_ON:
                if (_model.isEvfEnable)
                {
                    _processor.PostCommand(new DoEvfAFCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsEvfAf.CameraCommand_EvfAf_ON));
                }
                break;

            case ActionEvent.Command.EVF_AF_OFF:
                _processor.PostCommand(new DoEvfAFCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF));
                break;

            case ActionEvent.Command.ZOOM_FIT:
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_Evf_Zoom, EDSDKLib.EDSDK.EvfZoom_Fit));
                break;

            case ActionEvent.Command.ZOOM_ZOOM:
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_Evf_Zoom, EDSDKLib.EDSDK.EvfZoom_x5));
                break;

            case ActionEvent.Command.POSITION_UP:
            case ActionEvent.Command.POSITION_DOWN:
                const int stepY = 128;
                point = _model.GetZoomPosition();
                if (command == ActionEvent.Command.POSITION_UP)
                {
                    point.y -= stepY;
                    if (point.y < 0)
                    {
                        point.y = 0;
                    }
                }
                if (command == ActionEvent.Command.POSITION_DOWN)
                {
                    point.y += stepY;
                }
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_Evf_ZoomPosition, point));
                break;

            case ActionEvent.Command.POSITION_LEFT:
            case ActionEvent.Command.POSITION_RIGHT:
                const int stepX = 128;
                point = _model.GetZoomPosition();
                if (command == ActionEvent.Command.POSITION_LEFT)
                {
                    point.x -= stepX;
                    if (point.x < 0)
                    {
                        point.x = 0;
                    }
                }
                if (command == ActionEvent.Command.POSITION_RIGHT)
                {
                    point.x += stepX;
                }
                _processor.PostCommand(new SetPropertyCommand(ref _model, EDSDKLib.EDSDK.PropID_Evf_ZoomPosition, point));
                break;

            case ActionEvent.Command.REMOTESHOOTING_START:
                _processor.PostCommand(new SetRemoteShootingCommand(ref _model, (uint)EDSDKLib.EDSDK.DcRemoteShootingMode.DcRemoteShootingModeStart));
                break;

            case ActionEvent.Command.REMOTESHOOTING_STOP:
                _processor.PostCommand(new SetRemoteShootingCommand(ref _model, (uint)EDSDKLib.EDSDK.DcRemoteShootingMode.DcRemoteShootingModeStop));
                break;

            case ActionEvent.Command.PRESS_STILL:
                _processor.PostCommand(new SwitchStillMovieCommand(ref _model, (uint)EDSDKLib.EDSDK.CameraCommand_MovieSelectSwOFF));
                break;

            case ActionEvent.Command.PRESS_MOVIE:
                _processor.PostCommand(new SwitchStillMovieCommand(ref _model, (uint)EDSDKLib.EDSDK.CameraCommand_MovieSelectSwON));
                break;

            case ActionEvent.Command.REC_START:
                _processor.PostCommand(new SetRecCommand(ref _model, (uint)4));
                break;

            case ActionEvent.Command.REC_END:
                _processor.PostCommand(new SetRecCommand(ref _model, (uint)0));
                _processor.PostCommand(new SwitchStillMovieCommand(ref _model, (uint)EDSDKLib.EDSDK.CameraCommand_MovieSelectSwOFF));
                break;

            case ActionEvent.Command.MIRRORUP_ON:
                _processor.PostCommand(new SwitchMirrorUpCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsMirrorUpSetting.On));
                break;

            case ActionEvent.Command.MIRRORUP_OFF:
                _processor.PostCommand(new SwitchMirrorUpCommand(ref _model, (uint)EDSDKLib.EDSDK.EdsMirrorUpSetting.Off));
                break;

            case ActionEvent.Command.ROLLPITCH:
                if (_model.isEvfEnable)
                {
                    if (_model.RollPitch == 0)
                    {
                        _model.RollPitch = 1;
                    }
                    else
                    {
                        _model.RollPitch = 0;
                    }
                }
                _processor.PostCommand(new SetRollPitchCommand(ref _model, (uint)EDSDKLib.EDSDK.CameraCommand_RequestRollPitchLevel));
                break;

            case ActionEvent.Command.END_ROLLPITCH:
                _model.RollPitch = 1;
                _processor.PostCommand(new SetRollPitchCommand(ref _model, (uint)EDSDKLib.EDSDK.CameraCommand_RequestRollPitchLevel));
                break;
            }
        }
Ejemplo n.º 3
0
        private uint DownloadImageByDirectory(IntPtr camera)
        {
            IntPtr fileitem;

            EDSDKLib.EDSDK.EdsDirectoryItemInfo dirItemInfo;
            dirItemInfo.szFileName = "";
            dirItemInfo.Size       = 0;

            int index = 0;

            for (index = 0; index < _imageItems.Count; ++index)
            {
                fileitem = _imageItems[_currentFileNum];
                uint err = EDSDKLib.EDSDK.EdsGetDirectoryItemInfo(fileitem, out dirItemInfo);
                if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
                {
                    return(err);
                }

                // Create file stream for transfer destination
                IntPtr stream;
                var    szDstFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

                szDstFileName += "\\" + dirItemInfo.szFileName;

                err = EDSDKLib.EDSDK.EdsCreateFileStream(szDstFileName,
                                                         EDSDKLib.EDSDK.EdsFileCreateDisposition.CreateAlways,
                                                         EDSDKLib.EDSDK.EdsAccess.ReadWrite, out stream);
                if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
                {
                    return(err);
                }

                //Set Progress
                //err = EdsSetProgressCallback(stream, ProgressFunc, EDSDKLib.EDSDK.kEdsProgressOption_Periodically, this);
                // Download image
                err = EDSDKLib.EDSDK.EdsDownload(fileitem, dirItemInfo.Size, stream);
                if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
                {
                    return(err);
                }

                // Issue notification that download is complete
                err = EDSDKLib.EDSDK.EdsDownloadComplete(fileitem);
                if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
                {
                    return(err);
                }

                //Release Item
                if (fileitem != null)
                {
                    err      = EDSDKLib.EDSDK.EdsRelease(fileitem);
                    fileitem = IntPtr.Zero;
                }

                //Release stream
                if (stream != null)
                {
                    err    = EDSDKLib.EDSDK.EdsRelease(stream);
                    stream = IntPtr.Zero;
                }

                _currentFileNum += 1;
                // Continue next 1 file download.
                if (_model._ExecuteStatus == CameraModel.Status.CANCELING)
                {
                    _event = new CameraEvent(CameraEvent.Type.DOWNLOAD_COMPLETE, (IntPtr)index);
                    _model.NotifyObservers(_event);
                    _currentFileNum = 0;
                    _imageItems.Clear();
                }
                else
                {
                    _event = new CameraEvent(CameraEvent.Type.PROGRESS_REPORT, (IntPtr)_currentFileNum);
                    _model.NotifyObservers(_event);
                }
            }
            // Finish download files.
            _event = new CameraEvent(CameraEvent.Type.DOWNLOAD_COMPLETE, camera);
            _model.NotifyObservers(_event);
            _currentFileNum = 0;
            _imageItems.Clear();
            return(EDSDKLib.EDSDK.EDS_ERR_OK);
        }