当前位置: 首页>>代码示例>>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;未经允许,请勿转载。