Example #1
0
        public void Update(Observable from, CameraEvent e)
        {
            CameraModel model = (CameraModel)from;

            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED || eventType == CameraEvent.Type.PROPERTY_DESC_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                // DS does not need zoom step value
                if (propertyID == EDSDKLib.EDSDK.PropID_DC_Zoom && !model.isTypeDS)
                {
                    uint property = model.Zoom;

                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        this.UpdateProperty(property);
                        break;

                    case CameraEvent.Type.PROPERTY_DESC_CHANGED:
                        _desc = model.ZoomDesc;
                        this.UpdatePropertyDesc(ref _desc);
                        this.UpdateProperty(property);
                        break;
                    }
                }
            }
        }
        public void Update(Observable from, CameraEvent e)
        {
            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                if (propertyID == EDSDKLib.EDSDK.PropID_TempStatus)
                {
                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        CameraModel model    = (CameraModel)from;
                        var         infoText = new string[] { "Normal", "Warning", "Frameratedown", "Disableliveview", "Disablerelease", "Stillqualitywarning", "unknown" };
                        if (infoText.Length > model.TempStatus)
                        {
                            this.UpdateProperty(infoText[model.TempStatus]);
                        }
                        else
                        {
                            this.UpdateProperty(infoText[infoText.Length - 1]);
                        }
                        break;
                    }
                }
            }
        }
        public void Update(Observable from, CameraEvent e)
        {
            CameraModel model = (CameraModel)from;

            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED || eventType == CameraEvent.Type.PROPERTY_DESC_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                if (propertyID == EDSDKLib.EDSDK.PropID_MeteringMode)
                {
                    uint property = model.MeteringMode;
                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        this.UpdateProperty(property);
                        break;

                    case CameraEvent.Type.PROPERTY_DESC_CHANGED:
                        _desc = model.MeteringModeDesc;
                        this.UpdatePropertyDesc(ref _desc);
                        this.UpdateProperty(property);
                        break;
                    }
                }
            }
        }
        public void Update(Observable from, CameraEvent e)
        {
            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                if (propertyID == EDSDKLib.EDSDK.PropID_BatteryLevel)
                {
                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:

                        CameraModel model    = (CameraModel)from;
                        string      infoText = "AC power";
                        if (0xffffffff != model.BatteryLebel)
                        {
                            infoText = model.BatteryLebel.ToString() + "%";
                        }
                        this.UpdateProperty(infoText);
                        break;
                    }
                }
            }
        }
Example #5
0
        public void Update(Observable from, CameraEvent e)
        {
            CameraModel model = (CameraModel)from;

            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED || eventType == CameraEvent.Type.PROPERTY_DESC_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                if (propertyID == EDSDKLib.EDSDK.PropID_MovieParam)
                {
                    uint property = model.MovieQuality;

                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        this.UpdateProperty(property);
                        break;

                    case CameraEvent.Type.PROPERTY_DESC_CHANGED:
                        _desc = model.MovieQualityDesc;
                        // Ignore PropertyDesc when shooting still images.
                        if (model.FixedMovie == 0)
                        {
                            _desc.NumElements = 0;
                        }
                        this.UpdatePropertyDesc(ref _desc);
                        this.UpdateProperty(property);
                        break;
                    }
                }
            }
        }
Example #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            CameraModel cameramodel = _controller.GetModel();

            cameramodel._ExecuteStatus = CameraModel.Status.CANCELING;
            frmProgress.label2.Text    = "Canceling ...";
            frmProgress.Invalidate();
        }
Example #7
0
        public void Update(Observable from, CameraEvent e)
        {
            CameraModel model = (CameraModel)from;

            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROGRESS)
            {
                uint percentage = (uint)e.GetArg();
                this.UpdateProperty(percentage);
            }
            if ((eventType = e.GetEventType()) == CameraEvent.Type.DOWNLOAD_COMPLETE)
            {
                System.Threading.Thread.Sleep(1000);
                uint percentage = (uint)0;
                this.UpdateProperty(percentage);
            }
        }
        public void Update(Observable from, CameraEvent e)
        {
            CameraModel model = (CameraModel)from;

            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED || eventType == CameraEvent.Type.PROPERTY_DESC_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                if (propertyID == EDSDKLib.EDSDK.PropID_Evf_AFMode)
                {
                    uint property = model.EvfAFMode;

                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        // At the time of application start, if the camera setting is 'Catch AF', make 'Evf_AFMode_LiveFace' forcibly.
                        if (0x09 == property)
                        {
                            EDSDKLib.EDSDK.EdsSetPropertyData(model.Camera, EDSDKLib.EDSDK.PropID_Evf_AFMode, 0, sizeof(uint), 0x02);
                        }
                        else
                        {
                            this.UpdateProperty(property);
                        }
                        break;

                    case CameraEvent.Type.PROPERTY_DESC_CHANGED:
                        // If property is 'Catch AF', do not call UpdateProperty().
                        _desc = model.EvfAFModeDesc;
                        this.UpdatePropertyDesc(ref _desc);
                        if (0x09 != property)
                        {
                            this.UpdateProperty(property);
                        }
                        break;
                    }
                }
            }
        }
Example #9
0
        private void Update(CameraEvent e)
        {
            if (this.InvokeRequired)
            {
                //The update processing can be executed from another thread.
                this.Invoke(new _Update(Update), new object[] { e });
                return;
            }

            CameraEvent.Type eventType = e.GetEventType();

            switch (eventType)
            {
            case CameraEvent.Type.SHUT_DOWN:
                CameraModel cameramodel = _controller.GetModel();
                cameramodel._ExecuteStatus = CameraModel.Status.CANCELING;
                break;

            default:
                break;
            }
        }
        public void Update(Observable from, CameraEvent e)
        {
            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                if (propertyID == EDSDKLib.EDSDK.PropID_AvailableShots)
                {
                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        CameraModel model    = (CameraModel)from;
                        string      infoText = "";
                        infoText = model.AvailableShot.ToString();
                        this.UpdateProperty(infoText);
                        break;
                    }
                }
            }
        }
 public SwitchStillMovieCommand(ref CameraModel model, uint status) : base(ref model)
 {
     _status = status;
 }
Example #12
0
 public SetPropertyCommand(ref CameraModel model, uint propertyID, object data) : base(ref model)
 {
     _propertyID = propertyID;
     _data       = data;
 }
 public GetPropertyDescCommand(ref CameraModel model, uint propertyID)
     : base(ref model)
 {
     _propertyID = propertyID;
 }
 public FileCounterCommand(ref CameraModel model) : base(ref model)
 {
 }
 public SwitchMirrorUpCommand(ref CameraModel model, uint status) : base(ref model)
 {
     _status = status;
 }
Example #16
0
 public OpenSessionCommand(ref CameraModel model) : base(ref model)
 {
 }
Example #17
0
 public DoEvfAFCommand(ref CameraModel model, uint status) : base(ref model)
 {
     _status = status;
 }
Example #18
0
 public DownloadEvfCommand(ref CameraModel model) : base(ref model)
 {
 }
Example #19
0
        private void FormRotationDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            CameraModel cameramodel = _controller.GetModel();

            cameramodel._ExecuteStatus = CameraModel.Status.CANCELING;
        }
Example #20
0
 public TakePictureCommand(ref CameraModel model) : base(ref model)
 {
 }
 public DownloadAllFilesCommand(ref CameraModel model, ref IntPtr volume) : base(ref model)
 {
     _volume = volume;
 }
 public CameraController(ref CameraModel model)
 {
     _model = model;
 }
        public void Update(Observable from, CameraEvent e)
        {
            CameraModel model = (CameraModel)from;

            CameraEvent.Type eventType = CameraEvent.Type.NONE;

            if ((eventType = e.GetEventType()) == CameraEvent.Type.PROPERTY_CHANGED || eventType == CameraEvent.Type.PROPERTY_DESC_CHANGED)
            {
                uint propertyID = (uint)e.GetArg();

                if (propertyID == EDSDKLib.EDSDK.PropID_WhiteBalance)
                {
                    uint property = (uint)model.WhiteBalance;

                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        this.UpdateProperty(property);
                        break;

                    case CameraEvent.Type.PROPERTY_DESC_CHANGED:
                        _desc = model.WhiteBalanceDesc;
                        this.UpdatePropertyDesc(ref _desc);
                        this.UpdateProperty(property);
                        break;
                    }
                }
                else if (propertyID == EDSDKLib.EDSDK.PropID_Evf_ClickWBCoeffs)
                {
                    //Update property
                    switch (eventType)
                    {
                    case CameraEvent.Type.PROPERTY_CHANGED:
                        int size;
                        EDSDKLib.EDSDK.EdsDataType datatype;
                        uint err = EDSDKLib.EDSDK.EdsGetPropertySize(model.Camera, EDSDKLib.EDSDK.PropID_Evf_ClickWBCoeffs, 0, out datatype, out size);
                        if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
                        {
                            return;
                        }

                        //Get the WB coefficient
                        EDSDKLib.EDSDK.EdsManualWBData wbCoefs = new EDSDKLib.EDSDK.EdsManualWBData();
                        IntPtr ptr = Marshal.AllocHGlobal(size);
                        err = EDSDKLib.EDSDK.EdsGetPropertyData(model.Camera, EDSDKLib.EDSDK.PropID_Evf_ClickWBCoeffs, 0, size, ptr);
                        if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
                        {
                            Marshal.FreeHGlobal(ptr);
                            return;
                        }

                        //Set the WB coefficient converted to the manual white balance data structure to manual white balance.
                        wbCoefs = EDSDKLib.EDSDK.MarshalPtrToManualWBData(ptr);
                        byte[] mwb = EDSDKLib.EDSDK.ConvertMWB(wbCoefs);
                        err = EDSDKLib.EDSDK.EdsSetPropertyData(model.Camera, EDSDKLib.EDSDK.PropID_ManualWhiteBalanceData, 0, mwb.Length, mwb);
                        if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
                        {
                            Marshal.FreeHGlobal(ptr);
                            return;
                        }

                        //Change the camera's white balance setting to manual white balance.
                        err = EDSDKLib.EDSDK.EdsSetPropertyData(model.Camera, EDSDKLib.EDSDK.PropID_WhiteBalance, 0, sizeof(uint), 6);

                        Marshal.FreeHGlobal(ptr);
                        break;
                    }
                }
            }
        }
 public SetRollPitchCommand(ref CameraModel model, uint status) : base(ref model)
 {
     _status = status;
 }
 public DeleteAllFilesCommand(ref CameraModel model) : base(ref model)
 {
 }
 public DriveLensCommand(ref CameraModel model, uint parameter) : base(ref model)
 {
     _parameter = parameter;
 }
 public SetRemoteShootingCommand(ref CameraModel model, uint parameter) : base(ref model)
 {
     _parameter = parameter;
 }
Example #28
0
 public DownloadCommand(ref CameraModel model, ref IntPtr inRef) : base(ref model)
 {
     _directoryItem = inRef;
 }
Example #29
0
 public EndEvfCommand(ref CameraModel model) : base(ref model)
 {
 }
Example #30
0
        static void Main()
        {
            // Initialization of SDK
            uint err = EDSDKLib.EDSDK.EdsInitializeSDK();

            bool isSDKLoaded = false;

            if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                isSDKLoaded = true;
            }

            //Acquisition of camera list
            IntPtr cameraList = IntPtr.Zero;

            if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                err = EDSDKLib.EDSDK.EdsGetCameraList(out cameraList);
            }

            //Acquisition of number of Cameras
            if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                int count = 0;
                err = EDSDKLib.EDSDK.EdsGetChildCount(cameraList, out count);
                if (count == 0)
                {
                    err = EDSDKLib.EDSDK.EDS_ERR_DEVICE_NOT_FOUND;
                }
            }


            //Acquisition of camera at the head of the list
            IntPtr camera = IntPtr.Zero;

            if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                err = EDSDKLib.EDSDK.EdsGetChildAtIndex(cameraList, 0, out camera);
            }

            //Acquisition of camera information
            EDSDKLib.EDSDK.EdsDeviceInfo deviceInfo;
            if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                err = EDSDKLib.EDSDK.EdsGetDeviceInfo(camera, out deviceInfo);
                if (err == EDSDKLib.EDSDK.EDS_ERR_OK && camera == IntPtr.Zero)
                {
                    err = EDSDKLib.EDSDK.EDS_ERR_DEVICE_NOT_FOUND;
                }
            }


            //Release camera list
            if (cameraList != IntPtr.Zero)
            {
                EDSDKLib.EDSDK.EdsRelease(cameraList);
            }

            //Create Camera model
            CameraModel model = null;

            if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                model = new CameraModel(camera);
            }

            if (err != EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                MessageBox.Show("Cannot detect camera");
            }

            EDSDKLib.EDSDK.EdsPropertyEventHandler handlePropertyEvent = new EDSDKLib.EDSDK.EdsPropertyEventHandler(CameraEventListener.HandlePropertyEvent);
            EDSDKLib.EDSDK.EdsObjectEventHandler   handleObjectEvent   = new EDSDKLib.EDSDK.EdsObjectEventHandler(CameraEventListener.HandleObjectEvent);
            EDSDKLib.EDSDK.EdsStateEventHandler    handleStateEvent    = new EDSDKLib.EDSDK.EdsStateEventHandler(CameraEventListener.HandleStateEvent);

            CameraController controller;

            if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
            {
                //Create CameraController
                controller = new CameraController(ref model);
                GCHandle handle = GCHandle.Alloc(controller);
                IntPtr   ptr    = GCHandle.ToIntPtr(handle);

                //Set Property Event Handler
                if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
                {
                    err = EDSDKLib.EDSDK.EdsSetPropertyEventHandler(camera, EDSDKLib.EDSDK.PropertyEvent_All, handlePropertyEvent, ptr);
                }

                //Set Object Event Handler
                if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
                {
                    err = EDSDKLib.EDSDK.EdsSetObjectEventHandler(camera, EDSDKLib.EDSDK.ObjectEvent_All, handleObjectEvent, ptr);
                }

                //Set State Event Handler
                if (err == EDSDKLib.EDSDK.EDS_ERR_OK)
                {
                    err = EDSDKLib.EDSDK.EdsSetCameraStateEventHandler(camera, EDSDKLib.EDSDK.StateEvent_All, handleStateEvent, ptr);
                }

                controller.Run();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                IObserver form = new MainWindow(ref controller);
                model.Add(ref form);
                Application.Run((MainWindow)form);

                handle.Free();
            }

            GC.KeepAlive(handlePropertyEvent);
            GC.KeepAlive(handleObjectEvent);
            GC.KeepAlive(handleStateEvent);

            //Release Camera
            if (camera != IntPtr.Zero)
            {
                EDSDKLib.EDSDK.EdsRelease(camera);
            }

            //Termination of SDK
            if (isSDKLoaded)
            {
                EDSDKLib.EDSDK.EdsTerminateSDK();
            }
        }