コード例 #1
0
        private void StartLiveView()
        {
            //if (!IsActive)
            //    return;

            string resp = SelectedCameraDevice.GetProhibitionCondition(OperationEnum.LiveView);

            if (string.IsNullOrEmpty(resp))
            {
                Thread thread = new Thread(StartLiveViewThread);
                thread.Start();
                thread.Join();
            }
            else
            {
                Log.Error("Error starting live view " + resp);
                // in nikon case no show error message
                // if the images not transferd yet from SDRam
                if (resp != "LabelImageInRAM" && resp != "LabelCommandProcesingError")
                {
                    ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.LiveViewWnd_Message,
                                                                  TranslationStrings.LabelLiveViewError + "\n" +
                                                                  TranslationManager.GetTranslation(resp));
                }
            }
        }
コード例 #2
0
        private void GetLiveImage()
        {
            if (_operInProgress)
            {
                return;
            }

            try
            {
                LiveViewData = SelectedCameraDevice.GetLiveViewImage();
            }
            catch (Exception ex)
            {
                Log.Error("Error geting lv", ex);
                _operInProgress = false;
                return;
            }

            if (LiveViewData == null)
            {
                _operInProgress = false;
                return;
            }

            try
            {
                if (LiveViewData != null && LiveViewData.ImageData != null)
                {
                    MemoryStream stream = new MemoryStream(LiveViewData.ImageData,
                                                           LiveViewData.
                                                           ImageDataPosition,
                                                           LiveViewData.ImageData.
                                                           Length -
                                                           LiveViewData.
                                                           ImageDataPosition);
                    BitmapImage bi = new BitmapImage();
                    bi.BeginInit();
                    bi.CacheOption  = BitmapCacheOption.OnLoad;
                    bi.StreamSource = stream;
                    bi.EndInit();
                    bi.Freeze();
                    WriteableBitmap bitmap = BitmapFactory.ConvertToPbgra32Format(bi);
                    DrawGrid(bitmap);
                    bitmap.Freeze();
                    Bitmap          = bitmap;
                    _operInProgress = false;
                    return;
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error geting lv", ex);
                _operInProgress = false;
                return;
            }
        }
コード例 #3
0
        public LiveViewViewModel()
        {
            StartLiveViewCommand = new RelayCommand(StartLiveView);
            StopLiveViewCommand  = new RelayCommand(StopLiveView);
            SetAreaCommand       = new RelayCommand(() => SettingArea = true);
            DoneSetAreaCommand   = new RelayCommand(() => SettingArea = false);

            _timer.AutoReset = true;
            _timer.Elapsed  += _timer_Elapsed;
            if (!IsInDesignMode)
            {
                SelectedCameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                CameraProperty       = SelectedCameraDevice.LoadProperties();
            }
        }
コード例 #4
0
 private void StartLiveViewThread()
 {
     try
     {
         bool retry    = false;
         int  retryNum = 0;
         Log.Debug("LiveView: Liveview started");
         do
         {
             try
             {
                 SelectedCameraDevice.StartLiveView();
             }
             catch (DeviceException deviceException)
             {
                 if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY ||
                     deviceException.ErrorCode == ErrorCodes.MTP_Device_Busy)
                 {
                     Thread.Sleep(100);
                     Log.Debug("Retry live view :" + deviceException.ErrorCode.ToString("X"));
                     retry = true;
                     retryNum++;
                 }
                 else
                 {
                     throw;
                 }
             }
         } while (retry && retryNum < 35);
         _timer.Start();
         _operInProgress = false;
         Log.Debug("LiveView: Liveview start done");
     }
     catch (Exception exception)
     {
         Log.Error("Unable to start liveview !", exception);
         StaticHelper.Instance.SystemMessage = "Unable to start liveview ! " + exception.Message;
     }
 }