當前位置: 首頁>>代碼示例>>C#>>正文


C# Mobile.MobileBarcodeScanningOptions類代碼示例

本文整理匯總了C#中ZXing.Mobile.MobileBarcodeScanningOptions的典型用法代碼示例。如果您正苦於以下問題:C# MobileBarcodeScanningOptions類的具體用法?C# MobileBarcodeScanningOptions怎麽用?C# MobileBarcodeScanningOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MobileBarcodeScanningOptions類屬於ZXing.Mobile命名空間,在下文中一共展示了MobileBarcodeScanningOptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ZXingScannerPage

        public ZXingScannerPage (MobileBarcodeScanningOptions options = null, View customOverlay = null) : base ()
        {
            zxing = new ZXingScannerView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Options = options,
                AutomationId = "zxingScannerView"
            };

            zxing.SetBinding( ZXingScannerView.IsTorchOnProperty, new Binding( nameof( IsTorchOn ) ) );
            zxing.SetBinding( ZXingScannerView.IsAnalyzingProperty, new Binding( nameof( IsAnalyzing ) ) );
            zxing.SetBinding( ZXingScannerView.IsScanningProperty, new Binding( nameof( IsScanning ) ) );
            zxing.SetBinding( ZXingScannerView.HasTorchProperty, new Binding( nameof( HasTorch ) ) );
            zxing.SetBinding( ZXingScannerView.ResultProperty, new Binding( nameof( Result ) ) );

            zxing.OnScanResult += (result) => {
                this.OnScanResult?.Invoke( result );
                //Device.BeginInvokeOnMainThread (() => eh (result));
            };

            if (customOverlay == null) {
                defaultOverlay = new ZXingDefaultOverlay () { AutomationId = "zxingDefaultOverlay" };

                defaultOverlay.SetBinding( ZXingDefaultOverlay.TopTextProperty, new Binding( nameof( DefaultOverlayTopText ) ) );
                defaultOverlay.SetBinding( ZXingDefaultOverlay.BottomTextProperty, new Binding( nameof( DefaultOverlayBottomText ) ) );
                defaultOverlay.SetBinding( ZXingDefaultOverlay.ShowFlashButtonProperty, new Binding( nameof( DefaultOverlayShowFlashButton ) ) );

                DefaultOverlayTopText = "Hold your phone up to the barcode";
                DefaultOverlayBottomText = "Scanning will happen automatically";
                DefaultOverlayShowFlashButton = HasTorch;

                defaultOverlay.FlashButtonClicked += (sender, e) => {
                    zxing.IsTorchOn = !zxing.IsTorchOn;
                };

                Overlay = defaultOverlay;
            } else {
                Overlay = customOverlay;
            }

            var grid = new Grid
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            grid.Children.Add(zxing);
            grid.Children.Add(Overlay);

            // The root page of your application
            Content = grid;
        }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:52,代碼來源:ZXingScannerPage.cs

示例2: Scan

        public void Scan()
        {
            var options = new ZXing.Mobile.MobileBarcodeScanningOptions();
            options.PossibleFormats = new List<ZXing.BarcodeFormat>() {
                ZXing.BarcodeFormat.PDF_417
            };
            options.TryHarder = true;
            options.AutoRotate = true;
            options.TryInverted = true;

            
            var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);
            //Tell our scanner to use the default overlay
            scanner.UseCustomOverlay = false;
            scanner.CameraUnsupportedMessage = "This Device's Camera is not supported.";
            
            //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!";
            scanner.Scan(options).ContinueWith(t => {   
                if (t.Result != null)
                {
                    System.Console.WriteLine("Scanned Barcode: " + t.Result.Text);
                    Toast.MakeText(this, t.Result.Text, ToastLength.Short);
                }
            });
        }
開發者ID:sfurlani,項目名稱:ZXing.Net.Mobile,代碼行數:27,代碼來源:MainActivity.cs

示例3: scan

        void scan ()
        {
            var opts = new MobileBarcodeScanningOptions {
                PossibleFormats = new List<ZXing.BarcodeFormat> {
                    ZXing.BarcodeFormat.QR_CODE
                },
                CameraResolutionSelector = availableResolutions => {

                    foreach (var ar in availableResolutions) {
                        Console.WriteLine ("Resolution: " + ar.Width + "x" + ar.Height);
                    }
                    return null;
                }
            };

            scanFragment.StartScanning (opts, result => {

                // Null result means scanning was cancelled
                if (result == null || string.IsNullOrEmpty (result.Text)) {
                    Toast.MakeText (this, "Scanning Cancelled", ToastLength.Long).Show ();
                    return;
                }

                // Otherwise, proceed with result
                RunOnUiThread (() => Toast.MakeText (this, "Scanned: " + result.Text, ToastLength.Short).Show ());
            });
        }
開發者ID:xmendoza,項目名稱:BeerDrinkin,代碼行數:27,代碼來源:FragmentActivity.cs

示例4: ScanCode

        public async Task ScanCode()
        {
            MobileBarcodeScanner scanner;
            scanner = new MobileBarcodeScanner();
            

            

  
                       
            //scannerO.TryHarder = true;
            
            //Tell our scanner to use the default overlay
            scanner.UseCustomOverlay = false;
            //We can customize the top and bottom text of our default overlay
            scanner.TopText = "Hold camera up to barcode";
            scanner.BottomText = "Camera will automatically scan barcode\r\n\r\nPress the 'Back' button to Cancel";
           

            var options = new MobileBarcodeScanningOptions();
            //options.CameraResolutionSelector = ;
            //options.PossibleFormats = new List<ZXing.BarcodeFormat>() {ZXing.BarcodeFormat.Ean8, ZXing.BarcodeFormat.Ean13};



            //options.PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.PDF_417 };
            //options.TryHarder = false;
           
            //options.UseNativeScanning = true;

 
            var result = await scanner.Scan(options);
            HandleScanResult(result);
        }
開發者ID:TinusGreen,項目名稱:GendacProjects,代碼行數:34,代碼來源:CodeScannerViewModel.cs

示例5: Scan

        public override async Task<Result> Scan(MobileBarcodeScanningOptions options)
        {
            var rootFrame = RootFrame ?? Window.Current.Content as Frame ?? ((FrameworkElement) Window.Current.Content).GetFirstChildOfType<Frame>();
            var dispatcher = Dispatcher ?? Window.Current.Dispatcher;

            var tcsScanResult = new TaskCompletionSource<Result>();

            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                rootFrame.Navigate(typeof(ScanPage), new ScanPageNavigationParameters
                {
                    Options = options,
                    ResultHandler = r =>
                    {
                        tcsScanResult.SetResult(r);
                    },
                    Scanner = this,
                    ContinuousScanning = false
                });
            });
            
            var result = await tcsScanResult.Task;

            await dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                if (rootFrame.CanGoBack)
                    rootFrame.GoBack();
            });

            return result;
        }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:31,代碼來源:MobileBarcodeScanner.cs

示例6: Scan

        public override Task<Result> Scan(MobileBarcodeScanningOptions options)
        {
            var rootFrame = RootFrame ?? Window.Current.Content as Frame ?? ((FrameworkElement) Window.Current.Content).GetFirstChildOfType<Frame>();
            var dispatcher = Dispatcher ?? Window.Current.Dispatcher;

            return Task.Factory.StartNew(new Func<Result>(() =>
            {
                var scanResultResetEvent = new System.Threading.ManualResetEvent(false);

                Result result = null;

                ScanPage.ScanningOptions = options;
                ScanPage.ResultFoundAction = (r) => 
                {
                    result = r;
                    scanResultResetEvent.Set();
                };

                ScanPage.UseCustomOverlay = this.UseCustomOverlay;
                ScanPage.CustomOverlay = this.CustomOverlay;
                ScanPage.TopText = TopText;
                ScanPage.BottomText = BottomText;

                dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    rootFrame.Navigate(typeof(ScanPage));
                });
                
                scanResultResetEvent.WaitOne();

                return result;
            }));            
        }
開發者ID:M3psipax,項目名稱:ZXing.Net.Mobile,代碼行數:33,代碼來源:MobileBarcodeScanner.cs

示例7: Scan

        public override Task<Result> Scan(MobileBarcodeScanningOptions options)
        {
            return Task.Factory.StartNew(new Func<Result>(() =>
            {
                var scanResultResetEvent = new System.Threading.ManualResetEvent(false);

                Result result = null;

                //Navigate: /ZxingSharp.WindowsPhone;component/Scan.xaml

                ScanPage.ScanningOptions = options;
                ScanPage.ResultFoundAction = (r) => 
                {
                    result = r;
                    scanResultResetEvent.Set();
                };

                ScanPage.UseCustomOverlay = this.UseCustomOverlay;
                ScanPage.CustomOverlay = this.CustomOverlay;
                ScanPage.TopText = TopText;
                ScanPage.BottomText = BottomText;

                Dispatcher.BeginInvoke(() =>
				{
					((Microsoft.Phone.Controls.PhoneApplicationFrame)Application.Current.RootVisual).Navigate(
						new Uri("/ZXingNetMobile;component/ScanPage.xaml", UriKind.Relative));
				});

                scanResultResetEvent.WaitOne();

                return result;
            }));            
        }
開發者ID:Binjaaa,項目名稱:ZXing.Net.Mobile,代碼行數:33,代碼來源:MobileBarcodeScanner.cs

示例8: ZxingCameraViewController

        public ZxingCameraViewController(MobileBarcodeScanningOptions options, MobileBarcodeScanner scanner)
            : base()
        {
			this.ScanningOptions = options;
			this.Scanner = scanner;
            Initialize();
        }
開發者ID:GSerjo,項目名稱:Seminars,代碼行數:7,代碼來源:ZxingCameraViewController.cs

示例9: ScanContinuously

        public override void ScanContinuously (MobileBarcodeScanningOptions options, Action<Result> scanHandler)
        {                
            var scanIntent = new Intent(lifecycleListener.Context, typeof(ZxingActivity));

            scanIntent.AddFlags(ActivityFlags.NewTask);

            ZxingActivity.UseCustomOverlayView = this.UseCustomOverlay;
            ZxingActivity.CustomOverlayView = this.CustomOverlay;
            ZxingActivity.ScanningOptions = options;
            ZxingActivity.ScanContinuously = true;
            ZxingActivity.TopText = TopText;
            ZxingActivity.BottomText = BottomText;

            ZxingActivity.OnCanceled += () => 
            {
                ZxingActivity.RequestCancel ();
            };

            ZxingActivity.OnScanCompleted += (Result result) => 
            {
                if (scanHandler != null)
                    scanHandler (result);
            };

            lifecycleListener.Context.StartActivity(scanIntent);
        }
開發者ID:rpmendes2017,項目名稱:ZXing.Net.Mobile,代碼行數:26,代碼來源:MobileBarcodeScanner.cs

示例10: ZXingSurfaceView

        public ZXingSurfaceView (Activity activity, MobileBarcodeScanningOptions options)
            : base (activity)
        {
            this.activity = activity;
            this.scanningOptions = options;

            Init ();
        }
開發者ID:tony98789,項目名稱:ZXing.Net.Mobile,代碼行數:8,代碼來源:ZXingSurfaceView.cs

示例11: ZxingViewController

		public ZxingViewController(MobileBarcodeScanningOptions options, bool showButtons, bool showOverlay) : base()
		{
			this.Options = options;
			this.ShowButtons = showButtons;
			this.ShowOverlay = showOverlay;

			this.resxMgr = new ResourceManager("Resources", System.Reflection.Assembly.GetExecutingAssembly());
		}
開發者ID:AMersch,項目名稱:ZXing.Net.Mobile,代碼行數:8,代碼來源:ZxingViewController.cs

示例12: ScanController

 public ScanController()
 {
     ScanningOptions = new MobileBarcodeScanningOptions();
     ScanningOptions.AutoRotate = false;
     ScanningOptions.PossibleFormats = new List<BarcodeFormat>()
     {
         BarcodeFormat.QR_CODE
     };
 }
開發者ID:rzaitov,項目名稱:LoftGuide,代碼行數:9,代碼來源:ScanController.cs

示例13: Scannit

		async public void Scannit()
        {
			var scanner = new MobileBarcodeScanner ();
            var opt = new MobileBarcodeScanningOptions();
            opt.PossibleFormats.Clear();
            opt.PossibleFormats.Add(ZXing.BarcodeFormat.QR_CODE);
            var result = await scanner.Scan(opt);
            HandleResult(result);
        }
開發者ID:KuroiAme,項目名稱:Indexer,代碼行數:9,代碼來源:Scanner.cs

示例14: AVCaptureScannerViewController

		public AVCaptureScannerViewController(MobileBarcodeScanningOptions options, MobileBarcodeScanner scanner)
		{
			this.ScanningOptions = options;
			this.Scanner = scanner;

			var appFrame = UIScreen.MainScreen.ApplicationFrame;

			View.Frame = new CGRect(0, 0, appFrame.Width, appFrame.Height);
			View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
		}
開發者ID:rpmendes2017,項目名稱:ZXing.Net.Mobile,代碼行數:10,代碼來源:AVCaptureScannerViewController.cs

示例15: ScanContinuously

        public void ScanContinuously (MobileBarcodeScanningOptions options, bool useAVCaptureEngine, Action<Result> scanHandler)
        {
            try
            {             
                Version sv = new Version (0, 0, 0);
                Version.TryParse (UIDevice.CurrentDevice.SystemVersion, out sv);

                var is7orgreater = sv.Major >= 7;
                var allRequestedFormatsSupported = true;

                if (useAVCaptureEngine)
                    allRequestedFormatsSupported = AVCaptureScannerView.SupportsAllRequestedBarcodeFormats(options.PossibleFormats);

                this.appController.InvokeOnMainThread(() => {


                    if (useAVCaptureEngine && is7orgreater && allRequestedFormatsSupported)
                    {
                        viewController = new AVCaptureScannerViewController(options, this);
                        viewController.ContinuousScanning = true;
                    }
                    else
                    {           
                        if (useAVCaptureEngine && !is7orgreater)
                            Console.WriteLine("Not iOS 7 or greater, cannot use AVCapture for barcode decoding, using ZXing instead");
                        else if (useAVCaptureEngine && !allRequestedFormatsSupported)
                            Console.WriteLine("Not all requested barcode formats were supported by AVCapture, using ZXing instead");

                        viewController = new ZXing.Mobile.ZXingScannerViewController(options, this);
                        viewController.ContinuousScanning = true;
                    }

                    viewController.OnScannedResult += barcodeResult => {

                        // If null, stop scanning was called
                        if (barcodeResult == null) {
                            ((UIViewController)viewController).InvokeOnMainThread(() => {
                                ((UIViewController)viewController).DismissViewController(true, null);
                            });
                        }

                        scanHandler (barcodeResult);
                    };

                    appController.PresentViewController((UIViewController)viewController, true, null);
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
開發者ID:Binjaaa,項目名稱:ZXing.Net.Mobile,代碼行數:52,代碼來源:MobileBarcodeScanner.cs


注:本文中的ZXing.Mobile.MobileBarcodeScanningOptions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。