コード例 #1
0
        void buttonSample3_Click(object sender, EventArgs e)
        {
            var scanner = new MobileBarcodeScanner(this);

            var overlay = (LinearLayout)this.LayoutInflater.Inflate(Resource.Layout.ScanOverlayLayout, null, false);

            var buttonCancel = overlay.FindViewById <Button>(Resource.Id.buttonCancelScan);
            var buttonFlash  = overlay.FindViewById <Button>(Resource.Id.buttonToggleFlash);

            buttonCancel.Click += (object sender2, EventArgs e2) =>
            {
                scanner.Cancel();
            };

            buttonFlash.Click += (object sender2, EventArgs e2) =>
            {
                scanner.ToggleTorch();
            };

            scanner.UseCustomOverlay = true;
            scanner.CustomOverlay    = overlay;

            scanner.Scan().ContinueWith((t) => {
                ShowMessage(t.Result != null ? "Scanned: " + t.Result.Text : "No Barcode Scanned");
            });
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner();

            //Setup our button
            buttonDefaultScan       = new UIButton(UIButtonType.RoundedRect);
            buttonDefaultScan.Frame = new RectangleF(20, 80, 280, 40);
            buttonDefaultScan.SetTitle("Scan with Default View", UIControlState.Normal);
            buttonDefaultScan.TouchUpInside += (sender, e) =>
            {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;
                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold camera up to barcode to scan";
                scanner.BottomText = "Barcode will automatically scan";

                //Start scanning
                scanner.Scan().ContinueWith((t) =>
                {
                    //Our scanning finished callback
                    if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                    {
                        HandleScanResult(t.Result);
                    }
                });
            };

            buttonCustomScan       = new UIButton(UIButtonType.RoundedRect);
            buttonCustomScan.Frame = new RectangleF(20, 20, 280, 40);
            buttonCustomScan.SetTitle("Scan with Custom View", UIControlState.Normal);
            buttonCustomScan.TouchUpInside += (sender, e) =>
            {
                //Create an instance of our custom overlay
                customOverlay = new CustomOverlayView();
                //Wireup the buttons from our custom overlay
                customOverlay.ButtonTorch.TouchUpInside += delegate {
                    scanner.ToggleTorch();
                };
                customOverlay.ButtonCancel.TouchUpInside += delegate {
                    scanner.Cancel();
                };

                //Tell our scanner to use our custom overlay
                scanner.UseCustomOverlay = true;
                scanner.CustomOverlay    = customOverlay;

                scanner.Scan().ContinueWith((t) =>
                {
                    //Our scanning finished callback
                    if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                    {
                        HandleScanResult(t.Result);
                    }
                });
            };

            this.View.AddSubview(buttonDefaultScan);
            this.View.AddSubview(buttonCustomScan);
        }
コード例 #3
0
        private void buttonScanCustom_Click(object sender, RoutedEventArgs e)
        {
            //Get our UIElement from the MainPage.xaml (this) file
            // to use as our custom overlay
            if (customOverlayElement == null)
            {
                customOverlayElement = this.customOverlay.Children[0];
                this.customOverlay.Children.RemoveAt(0);
            }

            //Wireup our buttons from the custom overlay
            this.buttonCancel.Click += (s, e2) =>
            {
                scanner.Cancel();
            };
            this.buttonFlash.Click += (s, e2) =>
            {
                scanner.ToggleTorch();
            };

            //Set our custom overlay and enable it
            scanner.CustomOverlay    = customOverlayElement;
            scanner.UseCustomOverlay = true;

            //Start scanning
            scanner.Scan().ContinueWith(t =>
            {
                if (t.Result != null)
                {
                    HandleScanResult(t.Result);
                }
            });
        }
コード例 #4
0
ファイル: PhoneScanner.cs プロジェクト: thanhbv21/scann
        public async void Scan()
        {
            scanner.UseCustomOverlay = true;
            var options = new MobileBarcodeScanningOptions()
            {
                AutoRotate  = false,
                TryInverted = true
            };

            zxingOverlay = LayoutInflater.FromContext(Android.App.Application.Context).Inflate(Resource.Layout.ScanCustom, null);
            //zxingOverlay.scree

            flashButton        = zxingOverlay.FindViewById <Android.Widget.Button>(Resource.Id.buttonFlash);
            flashButton.Click += (sender, e) =>
            {
                if (flashButton.Text == "Tắt Flash")
                {
                    flashButton.Text = "Bật Flash";
                }
                else
                {
                    flashButton.Text = "Tắt Flash";
                }
                scanner.ToggleTorch();
            };
            scanner.CustomOverlay = zxingOverlay;

            //scanner.TopText = "Giữ camera cách mã khoảng 6inch";
            //scanner.BottomText = "Đợi một chút...";

            var result = await scanner.Scan(options);

            System.Diagnostics.Debug.WriteLine("Đợi két quả");
            HandleScanResult(result);
        }
コード例 #5
0
        async void BtnCustomView_TouchUpInsideAsync(object sender, EventArgs e)
        {
            try
            {
                //Create an instance of our custom overlay
                customOverlay = new CustomOverlayView();
                //Wireup the buttons from our custom overlay
                customOverlay.ButtonTorch.TouchUpInside += delegate {
                    scanner.ToggleTorch();
                };
                customOverlay.ButtonCancel.TouchUpInside += delegate {
                    scanner.Cancel();
                };

                //Tell our scanner to use our custom overlay
                scanner.UseCustomOverlay = true;
                scanner.CustomOverlay    = customOverlay;

                var result = await scanner.Scan(new MobileBarcodeScanningOptions { AutoRotate = true });

                HandleScanResult(result);
            }
            catch (Exception ex)
            {
                npcc_services.inf_mobile_exception_managerAsync(ex.Message);
            }
        }
コード例 #6
0
ファイル: BypassActivity.cs プロジェクト: EFinley/Atropos
        protected async void StartScanning()
        {
            scanner = new MobileBarcodeScanner()
            {
                UseCustomOverlay = true
            };

            var customOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.QRoverlay, null);

            customOverlay.FindViewById <ImageButton>(Resource.Id.qr_flashlight_button).Click += (ob, ev) =>
            {
                scanner.ToggleTorch();
            };
            customOverlay.FindViewById <ImageButton>(Resource.Id.qr_cancel_button).Click += (ob, ev) =>
            {
                scanner.Cancel();
            };

            scanner.CustomOverlay = customOverlay;

            var opts = new MobileBarcodeScanningOptions()
            {
                AutoRotate = true, PossibleFormats = new List <BarcodeFormat> {
                    BarcodeFormat.QR_CODE
                }
            };

            var result = await scanner.Scan(opts);

            HandleScanResult(result);
        }
コード例 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.BookListView);
            Scan       = FindViewById <ImageView>(Resource.Id.ListimScan);
            Search     = FindViewById <ImageView>(Resource.Id.ListimSearch);
            SearchEdit = FindViewById <EditText>(Resource.Id.ListEditSearch);
            BookList   = FindViewById <ListView>(Resource.Id.BookList);

            Scan.SetImageResource(Resource.Drawable.IconScan);
            Search.SetImageResource(Resource.Drawable.IconSearch);


            string SearchInfo = Intent.GetStringExtra("SearchInfo");

            BookInfo = new List <BookListViewInfo>();
            if (SearchInfo != "")
            {
                SearchMethod("http://115.159.145.115/SearchByKeyWord.php", SearchInfo);
            }

            MobileBarcodeScanner.Initialize(Application);
            Button flashButton;
            View   zxingOverlay;

            scanner     = new MobileBarcodeScanner();
            Scan.Click += async delegate {
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.Scanning, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            Search.Click += delegate
            {
                if (SearchEdit.Text != "")
                {
                    Intent ActBookList = new Intent(this, typeof(BookListViewAdmin));
                    Bundle bundle      = new Bundle();
                    ActBookList.PutExtra("SearchInfo", SearchEdit.Text);
                    ActBookList.PutExtras(bundle);
                    StartActivity(ActBookList);
                }
            };
        }
コード例 #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.LinkSticker);

            clientName = Android.OS.Build.Manufacturer + " " + Android.OS.Build.Model;

            InitElements();

            FindViewById <RelativeLayout>(Resource.Id.backRL).Click += (s, e) => OnBackPressed();

            _linkStickerBn.Click += async(s, e) =>
            {
                if (Build.VERSION.SdkInt >= Build.VERSION_CODES.M)
                {
                    RequestCameraPermissions();
                }

                MobileBarcodeScanner.Initialize(Application);
                _optionsCustom = new MobileBarcodeScanningOptions();
                _scanner       = new MobileBarcodeScanner();

                _scanner = new MobileBarcodeScanner();
                _scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                _zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                _flashButton       = _zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                _cancelButton      = _zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingCancel);
                _flashButton.Text  = TranslationHelper.GetString("flash", GetCurrentCulture.GetCurrentCultureInfo());
                _cancelButton.Text = TranslationHelper.GetString("cancel", GetCurrentCulture.GetCurrentCultureInfo());
                _flashButton.SetTypeface(_tf, TypefaceStyle.Normal);
                _cancelButton.SetTypeface(_tf, TypefaceStyle.Normal);
                _flashButton.Click  += (sender, e1) => _scanner.ToggleTorch();
                _cancelButton.Click += (sender, e1) => _scanner.Cancel();

                //Set our custom overlay
                _scanner.CustomOverlay = _zxingOverlay;
                try
                {
                    _optionsCustom.CameraResolutionSelector = new CameraResolutionSelectorDelegate(SelectLowestResolutionMatchingDisplayAspectRatio);//new CameraResolution { Height = 1920, Width = 1080 };
                }
                catch (Exception ex)
                {
                }
                _optionsCustom.AutoRotate = false;
                if (Build.VERSION.SdkInt < Build.VERSION_CODES.M)
                {
                    await LaunchScanner();
                }
            };

            _orderBn.Click += OpenOrderLink;
        }
コード例 #9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner(this);

            buttonScanDefaultView        = this.FindViewById <Button>(Resource.Id.buttonScanDefaultView);
            buttonScanDefaultView.Click += delegate {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                //Start scanning
                scanner.Scan().ContinueWith((t) => {
                    if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                    {
                        HandleScanResult(t.Result);
                    }
                });
            };

            Button flashButton;
            View   zxingOverlay;

            buttonScanCustomView        = this.FindViewById <Button>(Resource.Id.buttonScanCustomView);
            buttonScanCustomView.Click += delegate {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                scanner.Scan().ContinueWith((t) => {
                    if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                    {
                        HandleScanResult(t.Result);
                    }
                });
            };
        }
コード例 #10
0
ファイル: RoleActivities.cs プロジェクト: EFinley/Atropos
 protected override void OnPause()
 {
     base.OnPause();
     if (UseQRScanner && scanner != null)
     {
         if (scanner.IsTorchOn)
         {
             scanner.ToggleTorch();
         }
         //scanner.Cancel();
     }
 }
コード例 #11
0
        private void TorchFab_Click(object sender, EventArgs e)
        {
            scanner.ToggleTorch();

            if (scanner.IsTorchOn)
            {
                torchFab.SetImageDrawable(ContextCompat.GetDrawable(Activity, Resource.Drawable.ic_flash_off_white_24dp));
            }
            else
            {
                torchFab.SetImageDrawable(ContextCompat.GetDrawable(Activity, Resource.Drawable.ic_flash_on_white_24dp));
            }
        }
コード例 #12
0
        private void FlashButton_Click(object sender, EventArgs e)
        {
            scanner.ToggleTorch();

            if (scanner.IsTorchOn)
            {
                flashButton.SetBackgroundResource(Resource.Drawable.flash);
            }
            else
            {
                flashButton.SetBackgroundResource(Resource.Drawable.flashoff);
            }
        }
コード例 #13
0
        private async System.Threading.Tasks.Task ScanFunction()
        {
            //Tell our scanner we want to use a custom overlay instead of the default
            scanner.UseCustomOverlay = true;

            //Inflate our custom overlay from a resource layout
            scanOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ScanLayout, null);

            //Find the button from our resource layout and wire up the click event
            buttonFlash        = scanOverlay.FindViewById <Button>(Resource.Id.buttonFlash);
            buttonFlash.Click += (sender, e) =>
            {
                scanner.ToggleTorch();
            };

            buttonCancelScan        = scanOverlay.FindViewById <Button>(Resource.Id.buttonCancel);
            buttonCancelScan.Click += (sender, e) => scanner.Cancel();

            //Set our custom overlay
            scanner.CustomOverlay = scanOverlay;

            //Set scanner possible modes
            var options = new MobileBarcodeScanningOptions();

            options.PossibleFormats = new List <BarcodeFormat>()
            {
                BarcodeFormat.QR_CODE,
                BarcodeFormat.PDF_417,
                BarcodeFormat.CODE_39
            };

            //Start scanning!
            var result = await scanner.Scan(options);


            string msg = "";

            if (result != null && !string.IsNullOrEmpty(result.Text))
            {
                msg = result.Text;
                if (result.BarcodeFormat == BarcodeFormat.QR_CODE)
                {
                    RecipientBurstAddress.Text = msg;
                }
            }
            else
            {
                msg = "Scanning Cancelled!";
                this.RunOnUiThread(() => Toast.MakeText(this, msg, ToastLength.Long).Show());
            }
        }
コード例 #14
0
        public override void ViewDidLoad()
        {
            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner(this.NavigationController);

            //Setup our button
            buttonDefaultScan       = new UIButton(UIButtonType.RoundedRect);
            buttonDefaultScan.Frame = new RectangleF(20, 80, 280, 40);
            buttonDefaultScan.SetTitle("Scan with Default View", UIControlState.Normal);
            buttonDefaultScan.TouchUpInside += async(sender, e) =>
            {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;
                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold camera up to barcode to scan";
                scanner.BottomText = "Barcode will automatically scan";

                //Start scanning
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonCustomScan       = new UIButton(UIButtonType.RoundedRect);
            buttonCustomScan.Frame = new RectangleF(20, 20, 280, 40);
            buttonCustomScan.SetTitle("Scan with Custom View", UIControlState.Normal);
            buttonCustomScan.TouchUpInside += async(sender, e) =>
            {
                //Create an instance of our custom overlay
                customOverlay = new CustomOverlayView();
                //Wireup the buttons from our custom overlay
                customOverlay.ButtonTorch.TouchUpInside += delegate {
                    scanner.ToggleTorch();
                };
                customOverlay.ButtonCancel.TouchUpInside += delegate {
                    scanner.Cancel();
                };

                //Tell our scanner to use our custom overlay
                scanner.UseCustomOverlay = true;
                scanner.CustomOverlay    = customOverlay;

                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            this.View.AddSubview(buttonDefaultScan);
            this.View.AddSubview(buttonCustomScan);
        }
コード例 #15
0
        string Opapp = "OP QR Scanner"; //Title for error-s
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.Gesture);
            scanner = new MobileBarcodeScanner(this);

            //QRScanner Button listener
            Button QRScannerButton = (Button)FindViewById(Resource.Id.QRButton2);

            QRScannerButton.Click += async delegate {
                try
                {
                    scanner.UseCustomOverlay = true;                                                                      //Options TRUE or FALSE
                    zxingOverlay             = LayoutInflater.FromContext(this).Inflate(Resource.Layout.QROverlay, null); //Start QRScanner Overlay


                    flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash); //Instance button for flashlight
                    flashButton.Click += (sender, e) => scanner.ToggleTorch();                             //Event to start flashlight

                    scanner.CustomOverlay = zxingOverlay;                                                  //Display QRScanner View
                    var result = await scanner.Scan();                                                     //Await scaning result from qr scanner

                    HandleScanResult(result);                                                              //forwards QRScanner result to HandleScanResult where we can continue to play with him.
                    //SetContentView (Resource.Layout.Splash);
                    //main=LayoutInflater.FromContext(this).Inflate(Resource.Layout.Splash);
                    //StartActivity(typeof(HopSampleApp.Activities.LoginActivity));
                }
                catch (Exception error)
                {
                    Log.Error(Opapp, String.Format("Error fetching data: {0}", error.Message));                  //Print Error if scanning fail.
                }
            };
            //Skip Button listener
            Button SKIPButton = (Button)FindViewById(Resource.Id.SkipButton1);

            SKIPButton.Click += delegate {
                StartActivity(typeof(HopSampleApp.Activities.ContactsActivity));                //Skip Splash View and go to ContactsActivity
            };
        }
コード例 #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Initialize the scanner first so we can track the current context
            MobileBarcodeScanner.Initialize(Application);

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



            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner();
            Button flashButton;
            View   zxingOverlay;


            button1        = this.FindViewById <Button>(Resource.Id.butto1);
            button1.Click += async delegate {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult(result);
            };
        }
コード例 #17
0
ファイル: PhoneScanner.cs プロジェクト: thanhbv21/scann
        public async void Scan()
        {
            scanner.UseCustomOverlay = true;
            var options = new MobileBarcodeScanningOptions()
            {
                AutoRotate  = false,
                TryInverted = true
            };

            customscanlayout      = new CustomOverlayView();
            scanner.CustomOverlay = customscanlayout;
            //var options = new MobileBarcodeScanningOptions() { };
            customscanlayout.ButtonTorch.TouchUpInside += delegate {
                if (customscanlayout.ButtonTorch.TitleLabel.Text == "Tắt Flash")
                {
                    customscanlayout.ButtonTorch.SetTitle("Bật Flash", UIControlState.Normal);
                }
                else
                {
                    customscanlayout.ButtonTorch.SetTitle("Tắt Flash", UIControlState.Normal);
                }

                scanner.ToggleTorch();
            };
            customscanlayout.ButtonCancel.TouchUpInside += delegate
            {
                scanner.Cancel();
            };
            //scanner.TopText = "Giữ camera cách mã khoảng 6inch";
            //scanner.BottomText = "Đợi một chút...";

            var result = await scanner.Scan();

            System.Diagnostics.Debug.WriteLine("Đợi két quả");
            HandleScanResult(result);
        }
コード例 #18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Xamarin.Essentials.Platform.Init(Application);

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

            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner();

            buttonScanDefaultView        = this.FindViewById <Button>(Resource.Id.buttonScanDefaultView);
            buttonScanDefaultView.Click += async delegate
            {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                //Start scanning
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonContinuousScan        = FindViewById <Button>(Resource.Id.buttonScanContinuous);
            buttonContinuousScan.Click += delegate
            {
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                var opt = new MobileBarcodeScanningOptions();
                opt.DelayBetweenContinuousScans = 3000;

                //Start scanning
                scanner.ScanContinuously(opt, HandleScanResult);
            };

            Button flashButton;
            View   zxingOverlay;

            buttonScanCustomView        = this.FindViewById <Button>(Resource.Id.buttonScanCustomView);
            buttonScanCustomView.Click += async delegate
            {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay    = zxingOverlay;
                scanner.UseCustomOverlay = true;

                //Start scanning!
                var result = await scanner.Scan(new MobileBarcodeScanningOptions { AutoRotate = true });

                HandleScanResult(result);
            };

            buttonScanCustomAreaView        = this.FindViewById <Button>(Resource.Id.buttonScanCustomAreaView);
            buttonScanCustomAreaView.Click += async delegate {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlayCustomScanArea, null);
                scanArea     = zxingOverlay.FindViewById <View>(Resource.Id.scanView);

                //Find all the buttons and wire up their events
                buttonRectangle  = zxingOverlay.FindViewById <Button>(Resource.Id.buttonSquareScanRectangle);
                buttonSquare     = zxingOverlay.FindViewById <Button>(Resource.Id.buttonSquareScanView);
                scanViewPosition = zxingOverlay.FindViewById <ToggleButton>(Resource.Id.toggleButtonScanViewLocation);
                buttonIncrease   = zxingOverlay.FindViewById <ImageButton>(Resource.Id.buttonIncrease);
                buttonDecrease   = zxingOverlay.FindViewById <ImageButton>(Resource.Id.buttonDecrease);
                buttonRandom     = zxingOverlay.FindViewById <Button>(Resource.Id.buttonRandom);

                buttonRectangle.Click  += Rectangle_Click;
                buttonSquare.Click     += Square_Click;
                scanViewPosition.Click += ScanViewPosition_Click;
                buttonIncrease.Click   += ButtonIncrease_Click;
                buttonDecrease.Click   += ButtonDecrease_Click;
                buttonRandom.Click     += ButtonRandom_Click;

                //Set our custom overlay and custom scan area
                scanner.CustomOverlay             = zxingOverlay;
                scanner.UseCustomOverlay          = true;
                scanner.CustomOverlayScanAreaView = scanArea;

                //Start scanning!
                var result = await scanner.Scan(new MobileBarcodeScanningOptions { AutoRotate = true });

                HandleScanResult(result);
            };

            buttonFragmentScanner        = FindViewById <Button>(Resource.Id.buttonFragment);
            buttonFragmentScanner.Click += delegate
            {
                StartActivity(typeof(FragmentActivity));
            };

            buttonFragmentScannerCustomArea        = FindViewById <Button>(Resource.Id.buttonFragmentCustomArea);
            buttonFragmentScannerCustomArea.Click += delegate {
                StartActivityForResult(typeof(FragmentActivityCustomScanArea), FRAGMENT_SCAN_REQUEST);
            };

            buttonGenerate        = FindViewById <Button>(Resource.Id.buttonGenerate);
            buttonGenerate.Click += delegate
            {
                StartActivity(typeof(ImageActivity));
            };
        }
コード例 #19
0
        private async Task launchScaner()
        {
            var    scanner = new MobileBarcodeScanner();
            Button flashButton;
            View   zxingOverlay;

            scanner.UseCustomOverlay = true;

            //Inflate our custom overlay from a resource layout
            zxingOverlay = LayoutInflater.FromContext(this.Activity).Inflate(Resource.Layout.OverlayReadBarCode, null);

            //Find the button from our resource layout and wire up the click event
            flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
            flashButton.Click += (sender, e) => scanner.ToggleTorch();

            //Set our custom overlay
            scanner.CustomOverlay = zxingOverlay;

            //Start scanning!
            var result = await scanner.Scan();



            Toast.MakeText(this.Activity, result.Text, ToastLength.Long);
            //HandleScanResult(result);

            string msg = string.Empty;

            if (!ManagerRepuestos.existeRepuestoEnLista(empleado.No, result.Text))

            {
                if (result != null && !string.IsNullOrEmpty(result.Text))
                {
                    EntregaAlmacen rep = await ManagerRepuestos.addRepuesto(empleado.No, result.Text);

                    if (rep == null)
                    {
                        Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this.Activity);
                        alert.SetTitle("Error en lectura de Código de Barras");
                        alert.SetMessage("Código leido: " + result);
                        alert.SetPositiveButton("Ok", (s, e) =>
                        {
                            rep = null;
                            //msg = "Código leido: " + result;
                            //this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, msg, ToastLength.Short).Show());
                        });
                        alert.Show();
                    }
                    else
                    {
                        //var rep = await ManagerRepuestos.addRepuesto(empleado.No, result.Text);
                        //if (rep != null)
                        //{
                        adaptarSwipe.NotifyDataSetChanged();

                        //var activityDetalleRepuestoActivity = new Intent(this.Activity, typeof(detalleRepuestoActivity));
                        //activityDetalleRepuestoActivity.PutExtra("idEntregaAlmacen", rep.Key);
                        //StartActivity(activityDetalleRepuestoActivity);


                        Android.Support.V4.App.Fragment fragment = new AlmacenRepuestosXamarin.Fragments.DetalleRepuesto();

                        Bundle bundle = new Bundle();
                        bundle.PutString("idEntregaAlmacen", rep.Key);
                        fragment.Arguments = bundle;



                        FragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, fragment)
                        .AddToBackStack("ListaRepuestosEntrega")
                        .Commit();
                        //}
                    }
                }
                else
                {
                    msg = "Scaneo Cancelado";
                }
            }
            else
            {
                msg = "Ya fue escaneado ese producto!!";
            }

            if (!string.IsNullOrEmpty(msg))
            {
                this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, msg, ToastLength.Short).Show());
            }
        }
コード例 #20
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Initialize the scanner first so we can track the current context
            MobileBarcodeScanner.Initialize(Application);

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

            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner();

            buttonScanDefaultView        = this.FindViewById <Button>(Resource.Id.buttonScanDefaultView);
            buttonScanDefaultView.Click += async delegate {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Para evitar erros na leitura.\n Segure o dispositivo a 15 centimetros do código de barras.";
                scanner.BottomText = "Coloque um código de barras no visor da câmera para digitalizá-lo.";

                //Start scanning
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonContinuousScan        = FindViewById <Button>(Resource.Id.buttonScanContinuous);
            buttonContinuousScan.Click += delegate {
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Para evitar erros na leitura.\n Segure o dispositivo a 15 centimetros do código de barras.";
                scanner.BottomText = "Coloque um código de barras no visor da câmera para digitalizá-lo.";

                var opt = new MobileBarcodeScanningOptions
                {
                    DelayBetweenContinuousScans = 2000
                };

                //Start scanning
                scanner.ScanContinuously(opt, HandleScanResult);
            };

            Button flashButton;
            View   zxingOverlay;

            buttonScanCustomView        = this.FindViewById <Button>(Resource.Id.buttonScanCustomView);
            buttonScanCustomView.Click += async delegate {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonFragmentScanner        = FindViewById <Button>(Resource.Id.buttonFragment);
            buttonFragmentScanner.Click += delegate {
                StartActivity(typeof(FragmentActivity));
            };

            buttonGenerate        = FindViewById <Button>(Resource.Id.buttonGenerate);
            buttonGenerate.Click += delegate {
                StartActivity(typeof(ImageActivity));
            };
        }
コード例 #21
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Initialize the scanner first so we can track the current context
            MobileBarcodeScanner.Initialize(Application);

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

            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner();

            buttonScanDefaultView        = this.FindViewById <Button>(Resource.Id.buttonScanDefaultView);
            buttonScanDefaultView.Click += async delegate {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                //Start scanning
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonContinuousScan        = FindViewById <Button> (Resource.Id.buttonScanContinuous);
            buttonContinuousScan.Click += delegate {
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                var opt = new MobileBarcodeScanningOptions();
                opt.DelayBetweenContinuousScans = 3000;

                //Start scanning
                scanner.ScanContinuously(opt, HandleScanResult);
            };

            Button flashButton;
            View   zxingOverlay;

            buttonScanCustomView        = this.FindViewById <Button>(Resource.Id.buttonScanCustomView);
            buttonScanCustomView.Click += async delegate {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonFragmentScanner        = FindViewById <Button> (Resource.Id.buttonFragment);
            buttonFragmentScanner.Click += delegate {
                StartActivity(typeof(FragmentActivity));
            };

            buttonGenerate        = FindViewById <Button> (Resource.Id.buttonGenerate);
            buttonGenerate.Click += delegate {
                StartActivity(typeof(ImageActivity));
            };
        }
コード例 #22
0
ファイル: Admin.cs プロジェクト: LJCHSXWFXYHP/MiniLibrary
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.Admin);
            More       = FindViewById <ImageView>(Resource.Id.AdminMore);
            PhoneNum   = FindViewById <TextView>(Resource.Id.AdminPhoneNum);
            BorrowScan = FindViewById <LinearLayout>(Resource.Id.AdminBorrow);
            ReturnScan = FindViewById <LinearLayout>(Resource.Id.AdminReturn);
            BookList   = FindViewById <LinearLayout>(Resource.Id.AdminSearch);
            Search     = FindViewById <LinearLayout>(Resource.Id.AdminSearch);

            More = FindViewById <ImageView>(Resource.Id.AdminMore);
            More.SetImageResource(Resource.Drawable.IconMore);
            More.Click += delegate
            {
                PopupMenu menu = new PopupMenu(this, More);
                menu.Inflate(Resource.Menu.MoreMenu);
                menu.Show();
                menu.MenuItemClick += Menu_MenuItemClick;
            };

            ISharedPreferences LoginSP = GetSharedPreferences("LoginData", FileCreationMode.Private);

            PhoneNum.Text = LoginSP.GetString("PhoneNum", "");

            MobileBarcodeScanner.Initialize(Application);
            Button   flashButton;
            TextView ScanText;
            View     zxingOverlay;

            scanner           = new MobileBarcodeScanner();
            BorrowScan.Click += async delegate {
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.Scanning, null);

                //Find the button from our resource layout and wire up the click event

                ScanText           = zxingOverlay.FindViewById <TextView>(Resource.Id.ScanText);
                ScanText.Text      = "扫描二维码完成借书操作";
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult_Borrow(result);
            };
            ReturnScan.Click += async delegate {
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.Scanning, null);

                //Find the button from our resource layout and wire up the click event
                ScanText           = zxingOverlay.FindViewById <TextView>(Resource.Id.ScanText);
                ScanText.Text      = "扫描二维码完成还书操作";
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult_Return(result);
            };
            BookList.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListViewAdmin));
                ActList.PutExtra("SearchInfo", "");
                StartActivity(ActList);
            };
        }
コード例 #23
0
        public override void ViewDidLoad()
        {
            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner(this.NavigationController);

            Root = new RootElement("ZXing.Net.Mobile")
            {
                new Section {
                    new StyledStringElement("Scan with Default View", async() => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText    = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Scan Continuously", () => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay    = customOverlay;


                        var opt = new MobileBarcodeScanningOptions();
                        opt.DelayBetweenContinuousScans = 3000;

                        //Start scanning
                        scanner.ScanContinuously(opt, true, HandleScanResult);
                    }),

                    new StyledStringElement("Scan with Custom View", async() => {
                        //Create an instance of our custom overlay
                        customOverlay = new CustomOverlayView();
                        //Wireup the buttons from our custom overlay
                        customOverlay.ButtonTorch.TouchUpInside += delegate {
                            scanner.ToggleTorch();
                        };
                        customOverlay.ButtonCancel.TouchUpInside += delegate {
                            scanner.Cancel();
                        };

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay    = customOverlay;

                        var result = await scanner.Scan();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Scan with AVCapture Engine", async() => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText    = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan(true);

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Generate Barcode", () => {
                        NavigationController.PushViewController(new ImageViewController(), true);
                    })
                }
            };
        }
コード例 #24
0
        protected void CreateMiscTests()
        {
            CategoryNames.Add("Miscellaneous Tests");
            CreateTest("QR scanner", async() =>
            {
                UpdateInfo("Testing...");
                MobileBarcodeScanner.Initialize(Application);
                var scanner = new MobileBarcodeScanner()
                {
                    UseCustomOverlay = true
                };

                var customOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.QRoverlay, null);

                customOverlay.FindViewById <ImageButton>(Resource.Id.qr_flashlight_button).Click += (ob, ev) =>
                {
                    scanner.ToggleTorch();
                };
                customOverlay.FindViewById <ImageButton>(Resource.Id.qr_cancel_button).Click += (ob, ev) =>
                {
                    scanner.Cancel();
                };

                scanner.CustomOverlay = customOverlay;

                var opts = new MobileBarcodeScanningOptions()
                {
                    AutoRotate = true, PossibleFormats = new List <BarcodeFormat> {
                        BarcodeFormat.QR_CODE
                    }
                };

                var result = await scanner.Scan(opts);

                string msg = "";

                if (result != null && !string.IsNullOrEmpty(result.Text))
                {
                    msg = "Found QR code: " + result.Text;
                }
                else
                {
                    msg = "Scanning Canceled!";
                }

                this.RunOnUiThread(() => Toast.MakeText(this, msg, ToastLength.Short).Show());
                UpdateInfo($"Test complete. QR code: {result.Text ?? "(Scanning canceled by user)"}");
            });
            CreateTest("NFC Capability", async() =>
            {
                UpdateInfo("Testing; pass device near an NFC tag.");
                var _nfcAdapter = NfcAdapter.GetDefaultAdapter(this);
                if (_nfcAdapter == null)
                {
                    UpdateInfo("Test failed: this device doesn't seem to have NFC capability.");
                    return;
                }

                signalFlag = new AsyncManualResetEvent();

                // Create an intent filter for when an NFC tag is discovered.
                var tagDetected = new IntentFilter(NfcAdapter.ActionTagDiscovered);
                var filters     = new[] { tagDetected };

                // When an NFC tag is detected, Android will use the PendingIntent to come back to this activity.
                // The OnNewIntent method will be invoked by Android.
                var intent        = new Intent(this, this.GetType()).AddFlags(ActivityFlags.SingleTop);
                var pendingIntent = PendingIntent.GetActivity(this, 0, intent, 0);

                Res.AllowNewActivities = false;
                _nfcAdapter.EnableForegroundDispatch(this, pendingIntent, filters, null);

                var token = SetupStopButtonOneShot("Test ended.");
                await Task.WhenAny(token.AsTask(), signalFlag.WaitAsync());
                if (!token.IsCancellationRequested)
                {
                    var text = resultView.Text;
                    stopButton.CallOnClick();
                    while (cts != null)
                    {
                        await Task.Delay(25);
                    }
                    UpdateInfo(text);
                }
            });
            CreateTest("Vibrate", async() =>
            {
                UpdateInfo("Trying to vibrate...");
                Plugin.Vibrate.CrossVibrate.Current.Vibration(1000);
                await Task.Delay(300);
                UpdateInfo("Test complete.");
            });
        }
コード例 #25
0
ファイル: Index.cs プロジェクト: LJCHSXWFXYHP/MiniLibrary
        private void TabIndex()
        {
            Advp = FindViewById <ViewPager>(Resource.Id.viewpager);

            Scan           = FindViewById <ImageView>(Resource.Id.TabIndeximScan);
            Search         = FindViewById <ImageView>(Resource.Id.TabIndeximSearch);
            Type1          = FindViewById <ImageView>(Resource.Id.type1);
            Type2          = FindViewById <ImageView>(Resource.Id.type2);
            Type3          = FindViewById <ImageView>(Resource.Id.type3);
            Type4          = FindViewById <ImageView>(Resource.Id.type4);
            Type5          = FindViewById <ImageView>(Resource.Id.type5);
            Type6          = FindViewById <ImageView>(Resource.Id.type6);
            Type7          = FindViewById <ImageView>(Resource.Id.type7);
            Type8          = FindViewById <ImageView>(Resource.Id.type8);
            Type9          = FindViewById <ImageView>(Resource.Id.type9);
            TabIndexLayout = FindViewById <LinearLayout>(Resource.Id.TabIndexLayout);
            searchEdit     = FindViewById <EditText>(Resource.Id.TabIndexEditSearch);

            Scan.SetImageResource(Resource.Drawable.IconScan);
            Search.SetImageResource(Resource.Drawable.IconSearch);

            Type1.SetImageResource(Resource.Drawable.IndexIcon_1);
            Type2.SetImageResource(Resource.Drawable.IndexIcon_8);
            Type3.SetImageResource(Resource.Drawable.IndexIcon_7);
            Type4.SetImageResource(Resource.Drawable.IndexIcon_5);
            Type5.SetImageResource(Resource.Drawable.IndexIcon_9);
            Type6.SetImageResource(Resource.Drawable.IndexIcon_2);
            Type7.SetImageResource(Resource.Drawable.IndexIcon_4);
            Type8.SetImageResource(Resource.Drawable.IndexIcon_3);
            Type9.SetImageResource(Resource.Drawable.IndexIcon_6);

            View             v1, v2, v3;
            List <View>      viewList;
            ViewPagerAdapter AdvpAdapter;
            var li = LayoutInflater.From(this);

            v1       = li.Inflate(Resource.Layout.ViewPager_1, null);
            v2       = li.Inflate(Resource.Layout.ViewPager_2, null);
            v3       = li.Inflate(Resource.Layout.ViewPager_3, null);
            viewList = new List <View>();
            viewList.Add(v1);
            viewList.Add(v2);
            viewList.Add(v3);
            ad1 = v1.FindViewById <ImageView>(Resource.Id.Vpimage_1);
            ad2 = v2.FindViewById <ImageView>(Resource.Id.Vpimage_2);
            ad3 = v3.FindViewById <ImageView>(Resource.Id.Vpimage_3);
            Picasso.With(this).Load("http://115.159.145.115/ads/ad1.png").Into(ad1);
            Picasso.With(this).Load("http://115.159.145.115/ads/ad2.png").Into(ad2);
            Picasso.With(this).Load("http://115.159.145.115/ads/ad3.png").Into(ad3);
            AdvpAdapter  = new ViewPagerAdapter(viewList);
            Advp.Adapter = AdvpAdapter;

            MobileBarcodeScanner.Initialize(Application);
            scanner = new MobileBarcodeScanner();

            Button flashButton;
            View   zxingOverlay;

            Scan.Click += async delegate {
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.Scanning, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult(result);
            };
            Search.Click += delegate
            {
                if (searchEdit.Text != "")
                {
                    Intent ActBookList = new Intent(this, typeof(BookListView));
                    Bundle bundle      = new Bundle();
                    ActBookList.PutExtra("SearchInfo", searchEdit.Text);
                    ActBookList.PutExtras(bundle);
                    StartActivity(ActBookList);
                }
            };

            Type1.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "计算机");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type2.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "文学");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type3.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "社会科学");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type4.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "历史");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type5.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "文化");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type6.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "教材");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type7.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "科普");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type8.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "经济");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };
            Type9.Click += delegate
            {
                Intent ActList = new Intent(this, typeof(BookListView_type));
                Bundle bundle  = new Bundle();
                ActList.PutExtra("SearchType", "其他");
                ActList.PutExtra("SearchInfo", "");
                ActList.PutExtras(bundle);
                StartActivity(ActList);
            };

            TabIndexLayout.Click += delegate
            {
                Android.Views.InputMethods.InputMethodManager imm = (Android.Views.InputMethods.InputMethodManager)GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(searchEdit.WindowToken, 0);
            };
        }
コード例 #26
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);



            // Initialize the scanner first so we can track the current context
            MobileBarcodeScanner.Initialize(Application);

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

            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner();

            SetContentView(Resource.Layout.AlterarSituacao);

            var db         = new SQLiteAsyncConnection(dbPath);
            var dadosToken = db.Table <Token>();
            var TokenAtual = await dadosToken.Where(x => x.data_att_token >= DateTime.Now).FirstOrDefaultAsync();


            txtCesv = FindViewById <EditText>(Resource.Id.txtCesv);

            Button flashButton;
            View   zxingOverlay;

            btnOpr        = FindViewById <Button>(Resource.Id.buttonOpr);
            btnOpr.Click += delegate(object sender, EventArgs e)
            {
                if (!string.IsNullOrEmpty(txtCesv.Text))
                {
                    TokenAtual.numeroCesv = HttpUtility.UrlEncode(GeraQrCriptografado(txtCesv.Text));
                    db.InsertOrReplaceAsync(TokenAtual);
                    StartActivity(typeof(AlterarSituacaoOprActivity));
                }
            };

            buttonScanCustomView        = this.FindViewById <Button>(Resource.Id.buttonScanCustomView);
            buttonScanCustomView.Click += async delegate {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            btnOpr.SetTextSize(ComplexUnitType.Sp, 25);
            buttonScanCustomView.SetTextSize(ComplexUnitType.Sp, 25);
        }