/// <summary>
 /// This method is called upon when a claim request is made on instance 2. If a retain request was placed on the device it rejects the new claim.
 /// </summary>
 /// <param name="instance"></param>
 /// <returns></returns>
 async void claimedBarcodeScannerInstance2_ReleaseDeviceRequested(object sender, ClaimedBarcodeScanner e)
 {
     await MainPage.Current.Dispatcher.RunAsync(
         Windows.UI.Core.CoreDispatcherPriority.Normal,
         () =>
     {
         UpdateOutput(String.Format("\nReleaseDeviceRequested ({0})", claimedBarcodeScannerInstance2.DeviceId));
         //check if the instance wants to retain the device
         if (Retain2.IsChecked == true)
         {
             try
             {
                 //Retain the device
                 claimedBarcodeScannerInstance2.RetainDevice();
                 UpdateOutput(String.Format("\t(Scanner Retained)"));
             }
             catch (Exception exception)
             {
                 UpdateOutput(String.Format("\t(retain failed) ({0})", exception.ToString()));
             }
         }
         //Release the device
         else
         {
             claimedBarcodeScannerInstance2.Dispose();
             claimedBarcodeScannerInstance2 = null;
             UpdateOutput("Scanner Released.");
         }
     }
         );
 }
Beispiel #2
0
        /// <summary>
        /// This method is called upon when a claim request is made on instance 2. If a retain request was placed on the device it rejects the new claim.
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        async void claimedBarcodeScannerInstance2_ReleaseDeviceRequested(object sender, ClaimedBarcodeScanner e)
        {
            await MainPage.Current.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                () =>
            {
                //check if the instance wants to retain the device
                if (Retain2.IsChecked == true)
                {
                    try
                    {
                        //Retain the device
                        claimedBarcodeScannerInstance2.RetainDevice();
                    }
                    catch (Exception exception)
                    {
                        rootPage.NotifyUser("Retain instance 1 failed: " + exception.Message, NotifyType.ErrorMessage);
                    }
                }
                //Release the device
                else
                {
                    claimedBarcodeScannerInstance2.Dispose();
                    claimedBarcodeScannerInstance2 = null;

                    if (barcodeScannerInstance2 != null)
                    {
                        barcodeScannerInstance2.Dispose();
                        barcodeScannerInstance2 = null;
                    }
                }
            }
                );
        }
Beispiel #3
0
        async System.Threading.Tasks.Task resetScanner()
        {
            if (_ClaimedBarcodeScanner != null)
            {
                if (_autoScan)
                {
                    await _ClaimedBarcodeScanner.StopSoftwareTriggerAsync();
                }
                _ClaimedBarcodeScanner.DataReceived           -= _ClaimedBarcodeScanner_DataReceived;
                _ClaimedBarcodeScanner.ReleaseDeviceRequested -= _ClaimedBarcodeScanner_ReleaseDeviceRequested;
                _ClaimedBarcodeScanner.Dispose();
                _ClaimedBarcodeScanner = null;
            }
            _BarcodeScanner = null;
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                //UI code here
                textBox_Scan.Background = new SolidColorBrush(Windows.UI.Colors.White);
                textBox_Scan.Text       = "";
                textBox_Time.Text       = "";
                //play sound at end of Release
            });

            App.mySoundEffects.Play(AppSoundEffects.SoundEfxEnum.ComputerError);
        }
Beispiel #4
0
        /// <summary>
        /// Reset the Scenario state
        /// </summary>
        private void ResetTheScenarioState()
        {
            if (claimedScanner != null)
            {
                // Detach the event handlers
                claimedScanner.DataReceived           -= claimedScanner_DataReceived;
                claimedScanner.ReleaseDeviceRequested -= claimedScanner_ReleaseDeviceRequested;
                // Release the Barcode Scanner and set to null
                claimedScanner.Dispose();
                claimedScanner = null;
            }

            if (scanner != null)
            {
                scanner.Dispose();
                scanner = null;
            }

            // Reset the UI if we are still the current page.
            if (Frame.Content == this)
            {
                rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
                this.ScenarioOutputScanData.Text      = "No data";
                this.ScenarioOutputScanDataLabel.Text = "No data";
                this.ScenarioOutputScanDataType.Text  = "No data";

                // reset the button state
                ScenarioEndScanButton.IsEnabled   = false;
                ScenarioStartScanButton.IsEnabled = true;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Close the scanners and stop the preview.
        /// </summary>
        private async Task CloseScannerResourcesAsync()
        {
            claimedScanner?.Dispose();
            claimedScanner = null;

            selectedScanner?.Dispose();
            selectedScanner = null;

            SoftwareTriggerStarted = false;
            RaisePropertyChanged(nameof(SoftwareTriggerStarted));

            if (IsPreviewing)
            {
                if (mediaCapture != null)
                {
                    await mediaCapture.StopPreviewAsync();

                    mediaCapture.Dispose();
                    mediaCapture = null;
                }

                // Allow the display to go to sleep.
                displayRequest.RequestRelease();

                IsPreviewing = false;
                RaisePropertyChanged(nameof(IsPreviewing));
            }
        }
        /// <summary>
        /// Reset the Scenario state
        /// </summary>
        private void ResetTheScenarioState()
        {
            if (claimedScanner != null)
            {
                // Detach the event handlers
                claimedScanner.DataReceived           -= claimedScanner_DataReceived;
                claimedScanner.ReleaseDeviceRequested -= claimedScanner_ReleaseDeviceRequested;
                // Release the Barcode Scanner and set to null
                claimedScanner.Dispose();
                claimedScanner = null;
            }

            if (scanner != null)
            {
                scanner.Dispose();
                scanner = null;
            }

            // Reset the strings in the UI
            rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
            this.ScenarioOutputScanData.Text      = "No data";
            this.ScenarioOutputScanDataLabel.Text = "No data";
            this.ScenarioOutputScanDataType.Text  = "No data";

            // reset the button state
            SetActiveSymbologiesButton.IsEnabled = false;
            ScenarioEndScanButton.IsEnabled      = false;
            ScenarioStartScanButton.IsEnabled    = true;

            // reset symbology list
            listOfSymbologies.Clear();
        }
        /// <summary>
        /// Reset the Scenario state
        /// </summary>
        private async void ResetTheScenarioState()
        {
            if (claimedScanner != null)
            {
                // Detach the event handlers
                claimedScanner.DataReceived           -= claimedScanner_DataReceived;
                claimedScanner.ReleaseDeviceRequested -= claimedScanner_ReleaseDeviceRequested;
                // Release the Barcode Scanner and set to null
                claimedScanner.Dispose();
                claimedScanner = null;
            }

            scanner = null;

            await CleanupCameraAsync();

            // Reset the strings in the UI
            rootPage.NotifyUser("Click the start scanning button to begin.", NotifyType.StatusMessage);
            this.ScenarioOutputScanData.Text      = "No data";
            this.ScenarioOutputScanDataLabel.Text = "No data";
            this.ScenarioOutputScanDataType.Text  = "No data";

            // reset the button state
            ScenarioEndScanButton.IsEnabled        = false;
            ScenarioStartSWTriggerButton.IsEnabled = false;
            ScenarioStopSWTriggerButton.IsEnabled  = false;
            ScenarioStartScanButton.IsEnabled      = true;
        }
Beispiel #8
0
        private async void buttonEnable_Click(object sender, RoutedEventArgs e)
        {
            scanner = await BarcodeScanner.GetDefaultAsync();

            if (claimedScanner != null)
            {
                claimedScanner.Dispose();
            }
            claimedScanner = await scanner.ClaimScannerAsync();

            claimedScanner.DataReceived += ClamedScanner_DataReceived;
            await claimedScanner.EnableAsync();

            claimedScanner.IsDecodeDataEnabled = true;

            await claimedScanner.SetActiveSymbologiesAsync(new uint[] {
                BarcodeSymbologies.Aztec,
                BarcodeSymbologies.AusPost,
                BarcodeSymbologies.CanPost,
                BarcodeSymbologies.Codabar,
                BarcodeSymbologies.Codablock128,
                BarcodeSymbologies.Code11,
                BarcodeSymbologies.Code128,
                BarcodeSymbologies.Code39,
                BarcodeSymbologies.Code39Ex,
                BarcodeSymbologies.DataMatrix,
                BarcodeSymbologies.Ean13,
                BarcodeSymbologies.Ean8,
                BarcodeSymbologies.Gs1128,
                BarcodeSymbologies.Gs1DatabarType1,
                BarcodeSymbologies.Gs1DatabarType2,
                BarcodeSymbologies.Gs1DatabarType3,
                BarcodeSymbologies.Pdf417,
                BarcodeSymbologies.Qr,
                BarcodeSymbologies.OcrB,
                BarcodeSymbologies.UccEan128,
                BarcodeSymbologies.Upca,
                BarcodeSymbologies.Upce,
                BarcodeSymbologies.UsPostNet,
            });

            changeButtonEnable(true);
        }
Beispiel #9
0
        internal void Reset()
        {
            if (claimedScanner != null)
            {
                // Detach the event handlers
                claimedScanner.DataReceived           -= ClaimedScanner_DataReceived;
                claimedScanner.ReleaseDeviceRequested -= claimedScanner_ReleaseDeviceRequested;
                // Release the Barcode Scanner and set to null
                claimedScanner.Dispose();
                claimedScanner = null;
            }

            scanner = null;
        }
Beispiel #10
0
        public async Task <bool> ReleaseScannerAsync(bool exit)
        {
            try
            {
                if (claimedScanner != null)
                {
                    claimedScanner.DataReceived           -= ClaimedScanner_DataReceivedAsync;
                    claimedScanner.ReleaseDeviceRequested -= OnClaimedScannerReleaseDeviceRequested;
                    claimedScanner.IsDecodeDataEnabled     = false;
                    await claimedScanner.DisableAsync();

                    claimedScanner.Dispose();
                }
                scanner = null;
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
Beispiel #11
0
        public bool Deactivate()
        {
            if (claimedScanner != null)
            {
                try
                {
                    // Detach the event handlers
                    claimedScanner.DataReceived           -= claimedScanner_DataReceived;
                    claimedScanner.ReleaseDeviceRequested -= claimedScanner_ReleaseDeviceRequested;

                    // Release the Barcode Scanner and set to null
                    claimedScanner.Dispose();
                    claimedScanner = null;
                }
                catch (Exception)
                {
                }
            }

            scanner = null;

            return(true);
        }
        /// <summary>
        /// Reset the Scenario state
        /// </summary>
        private void ResetTheScenarioState()
        {
            if (claimedScanner != null)
            {
                // Detach the event handlers
                claimedScanner.DataReceived           -= claimedScanner_DataReceived;
                claimedScanner.ReleaseDeviceRequested -= claimedScanner_ReleaseDeviceRequested;
                // Release the Barcode Scanner and set to null
                claimedScanner.Dispose();
                claimedScanner = null;
            }

            scanner = null;

            // Reset the strings in the UI
            UpdateOutput("Click the Start Scanning Button.");
            this.ScenarioOutputScanData.Text      = "No data";
            this.ScenarioOutputScanDataLabel.Text = "No data";
            this.ScenarioOutputScanDataType.Text  = "No data";

            // reset the button state
            ScenarioEndScanButton.IsEnabled   = false;
            ScenarioStartScanButton.IsEnabled = true;
        }