Ejemplo n.º 1
0
 public void TurnCameraOn()
 {
     this._cam              = new PhotoCamera();
     this._cam.Initialized += new EventHandler <CameraOperationCompletedEventArgs>(this._cam_Initialized);
     if (this._cameraRectangle != null && this._cameraVideoBrush != null)
     {
         CameraVideoBrushExtensions.SetSource(this._cameraVideoBrush, this._cam);
     }
     this._YFramesThread = null;
     this._pumpYFrames   = true;
     this._YFramesThread = new Thread(new ThreadStart(this.PumpYFrames));
     this._YFramesThread.Start();
 }
Ejemplo n.º 2
0
 private void BarcodeScanner_LayoutUpdated(object sender, EventArgs e)
 {
     this._cam              = new PhotoCamera();
     this._cam.Initialized += new EventHandler <CameraOperationCompletedEventArgs>(this._cam_Initialized);
     if (this._cameraRectangle != null && this._cameraVideoBrush != null)
     {
         CameraVideoBrushExtensions.SetSource(this._cameraVideoBrush, this._cam);
     }
     if (this._YFramesThread == null || !this._YFramesThread.IsAlive)
     {
         this._pumpYFrames   = true;
         this._YFramesThread = new Thread(new ThreadStart(this.PumpYFrames));
         this._YFramesThread.Start();
     }
 }
Ejemplo n.º 3
0
 private void BarcodeScanner_Loaded(object sender, RoutedEventArgs e)
 {
     this.IsCameraInitialized = false;
     if (this._cam == null)
     {
         this._cam              = new PhotoCamera();
         this._cam.Initialized += new EventHandler <CameraOperationCompletedEventArgs>(this._cam_Initialized);
         if (this._cameraRectangle != null && this._cam != null && this._cameraVideoBrush != null)
         {
             CameraVideoBrushExtensions.SetSource(this._cameraVideoBrush, this._cam);
         }
     }
     if (this._YFramesThread == null || !this._YFramesThread.IsAlive)
     {
         this._pumpYFrames   = true;
         this._YFramesThread = new Thread(new ThreadStart(this.PumpYFrames));
         this._YFramesThread.Start();
     }
     CompositionTarget.Rendering += new EventHandler(this.CompositionTarget_Rendering);
 }
Ejemplo n.º 4
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this._cam              = new PhotoCamera();
     this._cam.Initialized += new EventHandler <CameraOperationCompletedEventArgs>(this._cam_Initialized);
     this._cameraRectangle  = (base.GetTemplateChild("PART_CamRect") as Rectangle);
     if (this._cameraRectangle != null && this._cam != null)
     {
         this._cameraVideoBrush = (base.GetTemplateChild("PART_VideoBrush") as VideoBrush);
         this._cameraTransform  = (base.GetTemplateChild("PART_VideoTransform") as CompositeTransform);
         if (this._cameraVideoBrush != null)
         {
             CameraVideoBrushExtensions.SetSource(this._cameraVideoBrush, this._cam);
         }
     }
     this._hintDictionary = new Dictionary <object, object>();
     this._currentReader  = this.GetReader(this.ScanType);
     this._scanType       = this.ScanType;
     if (this.ScanType == CodeType.QRCode)
     {
         VisualStateManager.GoToState(this, "QRCode", true);
     }
     else
     {
         if (this.ScanType == CodeType.TwoDCodes || this.ScanType == CodeType.DataMatrix)
         {
             VisualStateManager.GoToState(this, "TwoDCode", true);
         }
         else
         {
             VisualStateManager.GoToState(this, "OneDCode", true);
         }
     }
     if (this.IsScanning)
     {
         VisualStateManager.GoToState(this, "Scanning", true);
     }
     else
     {
         VisualStateManager.GoToState(this, "NotScanning", true);
     }
     if (this.CameraOrientation == PageOrientation.Portrait || this.CameraOrientation == PageOrientation.PortraitDown || this.CameraOrientation == PageOrientation.PortraitUp)
     {
         this._cameraTransform.Rotation = 90.0;
     }
     else
     {
         if (this.CameraOrientation == PageOrientation.LandscapeLeft)
         {
             this._cameraTransform.Rotation = 0.0;
         }
         else
         {
             this._cameraTransform.Rotation = 180.0;
         }
     }
     if (this.IsScanning)
     {
         this._isScanning = true;
     }
     else
     {
         this._isScanning = false;
     }
     CompositionTarget.Rendering += new EventHandler(this.CompositionTarget_Rendering);
 }