Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ScannerCode.Log("OnCreate...");
            ScannerCode.ScanCount = 0;
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);



            selectScanner               = FindViewById <Spinner>(Resource.Id.openReaderSpinner);
            openScanner                 = FindViewById <Android.Widget.Switch>(Resource.Id.openScannerSwitch);
            scanData                    = FindViewById <TextView>(Resource.Id.scanDataView);
            scanButton                  = FindViewById <Button>(Resource.Id.scanButton);
            symConfig                   = FindViewById <Button>(Resource.Id.config_symbologies);
            symConfig.Click            += SymConfig_Click;
            scanButton.Click           += ScanButton_Click;
            selectScanner.ItemSelected += SelectScanner_ItemSelected;
            openScanner.CheckedChange  += OpenScanner_CheckedChange;
            //pass the context of this activity to the ScannCode class
            ScannerCode.AppContext = this.context;

            // Register ScanCode events from static instance
            ScannerCode.Log("Attach Scan_Result_Event...");


            getReaderList();
        }
Example #2
0
 /// <summary>
 /// Allows you to pass the scanned data form the ScannerCode.cs to the TextView on this Activity
 /// </summary>
 /// <param name="Result"></param>
 public void On_Result_Event(string Result)//Changed Scan Result event from static instance
 {
     ScannerCode.Log("Called On_Result_Event..., ScanCount=" + ScannerCode.ScanCount.ToString());
     this.RunOnUiThread(() => {//Changed Invoke UI Thread
         scanData.SetText(Result, TextView.BufferType.Normal);
     });
 }
Example #3
0
 /// <summary>
 /// When the ScanPage is about to go to the background, release the
 /// scanner.
 /// </summary>
 protected override void OnPause()
 {
     ScannerCode.Log("OnPause()...");
     base.OnPause();
     ScannerCode.CloseBarcodeScanner();
     ScannerCode.Update_Event      -= On_Update_Event;
     ScannerCode.Scan_Result_Event -= On_Result_Event;
 }
Example #4
0
        /// <summary>
        /// When the ScanPage is about to go to the foreground, claim the
        /// scanner.
        /// </summary>
        protected override void OnResume()
        {
            ScannerCode.Log("OnResume()...");
            base.OnResume();
            ScannerCode.OpenBarcodeReader();
            ScannerCode.Scan_Result_Event += new ScannerCode.ScanResult(On_Result_Event);
            ScannerCode.Update_Event      += new ScannerCode.UpdateControls(On_Update_Event);

            //lock the orientationt to Portrait
            this.RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
        }
Example #5
0
 /// <summary>
 /// Allows Updates to the UI controls from the ScanCode class
 /// </summary>
 /// <param name="bscanButton"></param>
 /// <param name="bscanSpinner"></param>
 /// <param name="strViewText"></param>
 public void On_Update_Event(bool bscanButton, bool bscanSpinner, bool syConfig, bool bOpenbtn, string strViewText)
 {
     ScannerCode.Log("On_Update_Event...");
     this.RunOnUiThread(() =>
     {
         scanButton.Enabled    = bscanButton;
         selectScanner.Enabled = bscanSpinner;
         symConfig.Enabled     = syConfig;
         openScanner.Checked   = bOpenbtn;
     });
 }
Example #6
0
 /// <summary>
 /// Toggles the reader object
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OpenScanner_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e)
 {
     ScannerCode.mOpenReader = e.IsChecked;
     if (ScannerCode.mOpenReader)
     {
         ScannerCode.OpenBarcodeReader();
     }
     else
     {
         ScannerCode.CloseBarcodeScanner();
     }
 }
Example #7
0
        private static BarcodeReader GetBarcodeReader(string readerName)
        {
            ScannerCode.Log("GetBarcodeReader...");
            BarcodeReader reader = null;

            if (readerName == DEFAULT_READER_KEY)
            {
                // This name was added to the Open Reader picker list if the
                // query for connected barcode readers failed. It is not a
                // valid reader name. Set the readerName to null to default
                // to internal scanner.
                readerName = null;
            }

            if (null == readerName)
            {
                if (mBarcodeReaders.ContainsKey(DEFAULT_READER_KEY))
                {
                    reader = mBarcodeReaders[DEFAULT_READER_KEY];
                }
            }
            else
            {
                if (mBarcodeReaders.ContainsKey(readerName))
                {
                    reader = mBarcodeReaders[readerName];
                }
            }

            if (null == reader)
            {
                // Create an instance of BarcodeReader.
                reader = new BarcodeReader(readerName, AppContext);
                // Add an event handler to receive barcode data.
                // Even though we may have multiple reader sessions, we only
                // have one event handler. In this app, no matter which reader
                // the data come frome it will update the same UI controls.


                // Add the BarcodeReader object to mBarcodeReaders collection.
                if (null == readerName)
                {
                    mBarcodeReaders.Add(DEFAULT_READER_KEY, reader);
                }
                else
                {
                    mBarcodeReaders.Add(readerName, reader);
                }
            }
            return(reader);
        }
Example #8
0
        /// <summary>
        /// gets all the scanner devices in the device list and populates the picker
        /// </summary>
        private async void getReaderList()
        {
            //PopulateReaderPicker with the available scanners
            scanList = await ScannerCode.PopulateReaderPicker();

            if (scanList.Count > 0)
            {
                adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, (List <string>)scanList);
                adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                selectScanner.Adapter = adapter;
                selectScanner.SetSelection(0);
                ScannerCode.selectedScanneName = selectScanner.SelectedItem.ToString();
            }
        }
Example #9
0
        /// <summary>
        /// Updates the settings dictionary with the changes made to switch positions and EditText field content,
        /// then enabels the new settings.
        /// </summary>
        private void UpdateSymbologyDictionary()
        {
            foreach (KeyValuePair <string, object> sym in symbologyButtons)
            {
                if (sym.Value.ToString().Contains("Switch"))
                {
                    Switch sw = (Switch)sym.Value;
                    ScannerCode.settings[sym.Key] = sw.Checked;
                }
                else
                {
                    EditText et = (EditText)sym.Value;
                    ScannerCode.settings[sym.Key] = et.Text;
                }
            }

            // Update the settings for the selected scanner
            ScannerCode.EnableSymbologies();
        }
Example #10
0
 /// <summary>
 /// initiates a software trigger scan
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ScanButton_Click(object sender, EventArgs e)
 {
     ScannerCode.onScanButtonCLicked(scanData);
 }