コード例 #1
0
        private void StopCaptureThread()
        {
            bool retry;

            do
            {
                retry = false;
                try
                {
                    if (DefaultScript.UseExternal)
                    {
                        if (DefaultScript.SelectedConfig != null)
                        {
                            ServiceProvider.ExternalDeviceManager.CloseShutter(DefaultScript.SelectedConfig);
                            NikonBase nikonBase = CameraDevice as NikonBase;
                            if (nikonBase != null)
                            {
                                nikonBase.StartEventTimer();
                            }
                        }
                        else
                        {
                            MessageBox.Show(TranslationStrings.LabelNoExternalDeviceSelected);
                        }
                    }
                    else
                    {
                        if (CameraDevice.GetCapability(CapabilityEnum.Bulb))
                        {
                            CameraDevice.EndBulbMode();
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.MsgBulbModeNotSupported;
                        }
                    }
                    //CountDown = 0;
                    StaticHelper.Instance.SystemMessage = "Capture done";
                    Log.Debug("Bulb capture done");
                }
                catch (DeviceException deviceException)
                {
                    if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY)
                    {
                        retry = true;
                    }
                    else
                    {
                        StaticHelper.Instance.SystemMessage = deviceException.Message;
                        Log.Error("Bulb done", deviceException);
                    }
                }
                catch (Exception exception)
                {
                    StaticHelper.Instance.SystemMessage = exception.Message;
                    Log.Error("Bulb done", exception);
                }
            } while (retry);
        }
コード例 #2
0
        private void StartCaptureThread()
        {
            bool retry;

            do
            {
                retry = false;
                try
                {
                    Log.Debug("Bulb capture started");
                    if (UseExternal)
                    {
                        if (SelectedConfig != null)
                        {
                            NikonBase nikonBase = CameraDevice as NikonBase;
                            if (nikonBase != null)
                            {
                                nikonBase.StopEventTimer();
                            }
                            ServiceProvider.ExternalDeviceManager.OpenShutter(SelectedConfig);
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.LabelNoExternalDeviceSelected;
                        }
                    }
                    else
                    {
                        if (CameraDevice.GetCapability(CapabilityEnum.Bulb))
                        {
                            CameraDevice.LockCamera();
                            CameraDevice.StartBulbMode();
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.MsgBulbModeNotSupported;
                        }
                    }
                }
                catch (DeviceException deviceException)
                {
                    if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY)
                    {
                        retry = true;
                    }
                    else
                    {
                        StaticHelper.Instance.SystemMessage = deviceException.Message;
                        Log.Error("Bulb start", deviceException);
                    }
                }
                catch (Exception exception)
                {
                    StaticHelper.Instance.SystemMessage = exception.Message;
                    Log.Error("Bulb start", exception);
                }
            } while (retry);
        }
コード例 #3
0
        public Capabilities(NikonBase obj, NkMAIDCapInfo cap)
        {
            _object = obj;
            _cap    = cap;
            NikonDevice device = _object as NikonDevice;

            if (device != null)
            {
                device.CapabilityValueChanged += new CapabilityChangedDelegate(device_CapabilityValueChanged);
            }
        }
コード例 #4
0
        public ObjectModel(NikonBase obj)
        {
            _caps            = new ObservableCollection <CapModel>();
            _object          = obj;
            _doThumbnail     = false;
            _doPreview       = false;
            _doLowResPreview = false;
            _videoFile       = null;

            _timer          = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(33.0);
            _timer.Tick    += new EventHandler(_timer_Tick);

            NikonDevice device = _object as NikonDevice;

            if (device != null)
            {
                device.CapabilityChanged += new CapabilityChangedDelegate(device_CapabilityChanged);

                device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);
                device.ImageReady      += new ImageReadyDelegate(device_ImageReady);

                // Note: Disable thumbnails and previews by default

                //device.PreviewReady += device_PreviewReady;
                //device.LowResolutionPreviewReady += device_LowResolutionPreviewReady;
                //device.ThumbnailReady += device_ThumbnailReady;
                //_doPreview = true;
                //_doLowResPreview = true;
                //_doThumbnail = true;

                device.VideoFragmentReady        += new VideoFragmentReadyDelegate(device_VideoFragmentReady);
                device.VideoRecordingInterrupted += new VideoRecordingInterruptedDelegate(device_VideoRecordingInterrupted);
            }

            RefreshCaps();
        }
コード例 #5
0
 private void btn_start_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (ServiceProvider.Settings.DefaultSession.WriteComment)
         {
             ServiceProvider.Settings.DefaultSession.Comment  = "c=" + slider_cmera.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "dw=" + slider_drop_wait.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "dw2=" + slider_drop2_wait.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "d1=" + slider_drop1.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "d2=" + slider_drop2.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "d3=" + slider_drop3.Value + "|";
             ServiceProvider.Settings.DefaultSession.Comment += "f=" + slider_flash.Value.ToString() + "|";
         }
         if (chk_external.IsChecked == true)
         {
             NikonBase camera = ServiceProvider.DeviceManager.SelectedCameraDevice as NikonBase;
             if (camera != null)
             {
                 camera.StopEventTimer();
                 _timer.Interval = GetTotalLength() + 100;
                 _timer.Start();
             }
         }
         else
         {
             ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhoto();
         }
         OpenPort();
         sp.WriteLine(" ");
     }
     catch (Exception exception)
     {
         lst_message.Items.Add(exception.Message);
     }
 }
コード例 #6
0
        private void StartCaptureThread()
        {
            bool retry;

            Message = "";
            do
            {
                retry = false;
                try
                {
                    Log.Debug("Bulb capture started");
                    CountDown = CaptureTime;
                    Event     = "Capture";
                    PhotoLeft--;
                    if (DefaultScript.UseExternal)
                    {
                        if (DefaultScript.SelectedConfig != null)
                        {
                            NikonBase nikonBase = CameraDevice as NikonBase;
                            if (nikonBase != null)
                            {
                                nikonBase.StopEventTimer();
                            }
                            ServiceProvider.ExternalDeviceManager.OpenShutter(DefaultScript.SelectedConfig);
                        }
                        else
                        {
                            MessageBox.Show(TranslationStrings.LabelNoExternalDeviceSelected);
                        }
                    }
                    else
                    {
                        if (CameraDevice.GetCapability(CapabilityEnum.Bulb))
                        {
                            expDelay   = CameraDevice.GetExposureDelay();
                            CountDown += expDelay;
                            waitDelay  = CameraDevice.GetPropertyValue(NikonBase.CONST_PROP_NoiseReduction) == "ON" ? CaptureTime : 0;
                            ServiceProvider.DeviceManager.LastCapturedImage[CameraDevice] = "-";
                            CameraDevice.IsBusy = true;
                            CameraDevice.LockCamera();
                            CameraDevice.StartBulbMode();
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.MsgBulbModeNotSupported;
                        }
                    }
                }
                catch (DeviceException deviceException)
                {
                    if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY)
                    {
                        retry = true;
                    }
                    else
                    {
                        StaticHelper.Instance.SystemMessage = deviceException.Message;
                        Log.Error("Bulb start", deviceException);
                        CameraDevice.IsBusy = false;
                    }
                }
                catch (Exception exception)
                {
                    StaticHelper.Instance.SystemMessage = exception.Message;
                    Log.Error("Bulb start", exception);
                    Event               = "Error";
                    CountDown           = 0;
                    CameraDevice.IsBusy = false;
                    return;
                }
            } while (retry);
            _waitSecs    = 0;
            _captureSecs = 0;
            _captureTimer.Start();
        }
コード例 #7
0
        public void ExecuteCommand(string cmd, object param)
        {
            if (param == null)
            {
                param = ServiceProvider.DeviceManager.SelectedCameraDevice;
            }
            lock (_locker)
            {
                switch (cmd)
                {
                case WindowsCmdConsts.LiveViewWnd_Show:
                {
                    if (!_register.ContainsKey(param))
                    {
                        Application.Current.Dispatcher.Invoke(new Action(delegate
                            {
                                LiveViewWnd wnd = new LiveViewWnd();
                                ServiceProvider.Settings.ApplyTheme(wnd);
                                _register.Add(param, wnd);
                                wnd.Owner = ServiceProvider.PluginManager.SelectedWindow as Window;
                            }));
                    }
                    NikonBase nikonBase = param as NikonBase;
                    if (nikonBase != null && ServiceProvider.Settings.EasyLiveViewControl)
                    {
                        CameraPreset preset = new CameraPreset();
                        preset.Get(nikonBase);
                        if (!_presets.ContainsKey(nikonBase))
                        {
                            _presets.Add(nikonBase, preset);
                        }
                        else
                        {
                            _presets[nikonBase] = preset;
                        }
                        if (nikonBase.ShutterSpeed.Value == "Bulb")
                        {
                            nikonBase.ShutterSpeed.Value =
                                nikonBase.ShutterSpeed.Values[nikonBase.ShutterSpeed.Values.Count / 2];
                        }
                        nikonBase.FocusMode.Value = nikonBase.FocusMode.Values[0];
                        nikonBase.FNumber.Value   = nikonBase.FNumber.Values[0];
                    }
                    _register[param].ExecuteCommand(cmd, param);
                }
                break;

                case WindowsCmdConsts.LiveViewWnd_Hide:
                {
                    if (_register.ContainsKey(param))
                    {
                        _register[param].ExecuteCommand(cmd, param);
                    }
                    var nikonBase = param as NikonBase;
                    if (ServiceProvider.Settings.EasyLiveViewControl)
                    {
                        if (nikonBase != null && _presets.ContainsKey(nikonBase))
                        {
                            nikonBase.ShutterSpeed.Value = _presets[nikonBase].GetValue("ShutterSpeed");
                            nikonBase.FNumber.Value      = _presets[nikonBase].GetValue("FNumber");
                            nikonBase.FocusMode.Value    = _presets[nikonBase].GetValue("FocusMode");
                        }
                    }
                }
                break;

                case CmdConsts.All_Minimize:
                case CmdConsts.All_Close:
                    foreach (var liveViewWnd in _register)
                    {
                        liveViewWnd.Value.ExecuteCommand(cmd, param);
                    }
                    break;

                default:
                    if (cmd.StartsWith("LiveView"))
                    {
                        foreach (var liveViewWnd in _register)
                        {
                            liveViewWnd.Value.ExecuteCommand(cmd, param);
                        }
                    }
                    break;
                }
            }
        }
コード例 #8
0
        private void StartCaptureThread()
        {
            bool retry;

            Message = "";
            do
            {
                retry = false;
                try
                {
                    Log.Debug("Bulb capture started");
                    CountDown = CaptureTime;
                    Event     = "Capture";
                    PhotoLeft--;
                    if (DefaultScript.UseExternal)
                    {
                        if (DefaultScript.SelectedConfig != null)
                        {
                            NikonBase nikonBase = CameraDevice as NikonBase;
                            if (nikonBase != null)
                            {
                                nikonBase.StopEventTimer();
                            }
                            ServiceProvider.ExternalDeviceManager.OpenShutter(DefaultScript.SelectedConfig);
                        }
                        else
                        {
                            MessageBox.Show(TranslationStrings.LabelNoExternalDeviceSelected);
                        }
                    }
                    else
                    {
                        if (CameraDevice.GetCapability(CapabilityEnum.Bulb))
                        {
                            AsyncObservableCollection <PropertyValue <long> > coll = CameraDevice.AdvancedProperties;
                            foreach (PropertyValue <long> prop in coll)
                            {
                                if (prop.Code == 0xD06A && !string.IsNullOrEmpty(prop.Value)) //.Name == "Exposure delay mode")
                                {
                                    if (prop.Value != "OFF")
                                    {
                                        expDelay = int.Parse(prop.Value.Substring(0, 1));
                                        //expDelay = (int)prop.NumericValue;
                                        CountDown += expDelay;
                                    }
                                    else
                                    {
                                        expDelay = 0;
                                    }
                                }
                                else if (prop.Code == NikonBase.CONST_PROP_NoiseReduction && prop.Value != null)
                                {
                                    waitDelay = prop.Value == "ON" ? CaptureTime : 0;
                                }
                            }
                            ServiceProvider.DeviceManager.LastCapturedImage[CameraDevice] = "";
                            CameraDevice.IsBusy = true;
                            CameraDevice.LockCamera();
                            CameraDevice.StartBulbMode();
                        }
                        else
                        {
                            StaticHelper.Instance.SystemMessage = TranslationStrings.MsgBulbModeNotSupported;
                        }
                    }
                }
                catch (DeviceException deviceException)
                {
                    if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY)
                    {
                        retry = true;
                    }
                    else
                    {
                        StaticHelper.Instance.SystemMessage = deviceException.Message;
                        Log.Error("Bulb start", deviceException);
                        CameraDevice.IsBusy = false;
                    }
                }
                catch (Exception exception)
                {
                    StaticHelper.Instance.SystemMessage = exception.Message;
                    Log.Error("Bulb start", exception);
                    Event               = "Error";
                    CountDown           = 0;
                    CameraDevice.IsBusy = false;
                    return;
                }
            } while (retry);
            _waitSecs    = 0;
            _captureSecs = 0;
            _captureTimer.Start();
        }