Example #1
0
        public BarcodeGraphic(GraphicOverlay overlay) : base(overlay)
        {
            mCurrentColorIndex = (mCurrentColorIndex + 1) % COLOR_CHOICES.Length;
            var selectedColor = COLOR_CHOICES[mCurrentColorIndex];

            //mPositionPaint = new Paint();
            //mPositionPaint.Color = selectedColor;

            mIdPaint          = new Paint();
            mIdPaint.Color    = selectedColor;
            mIdPaint.TextSize = ID_TEXT_SIZE;

            mBoxPaint       = new Paint();
            mBoxPaint.Color = selectedColor;
            mBoxPaint.SetStyle(Paint.Style.Stroke);
            mBoxPaint.StrokeWidth = BOX_STROKE_WIDTH;
        }
 public void Start(CameraSource cameraSource, GraphicOverlay overlay)
 {
     mOverlay = overlay;
     Start(cameraSource);
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.BarcodeTracker);

            //this.ActionBar.SetDisplayHomeAsUpEnabled(true);

            buttonFlash        = FindViewById <TextView>(Resource.Id.btnFlash2);
            buttonFlash.Click += ButtonFlash_Click;

            var buttonExit = FindViewById <ImageButton>(Resource.Id.btnExit);

            buttonExit.Click += ButtonExit_Click;

            Intent intent = new Intent(this.Intent);

            rowPosition = 0;
            IsContinue  = intent.GetBooleanExtra("IsContinue", false);
            IsFixed     = intent.GetBooleanExtra("IsFixed", false);

            AllScanBarcode       = intent.GetStringArrayListExtra("AllScanBarcode");
            ScanCompletedBarcode = intent.GetStringArrayListExtra("ScanCompletedBarcode");
            SaveCompletedBarcode = intent.GetStringArrayListExtra("SaveCompletedBarcode");

            mPreview        = FindViewById <CameraSourcePreview>(Resource.Id.preview);
            mGraphicOverlay = FindViewById <GraphicOverlay>(Resource.Id.barcodeOverlay);

            //mView = FindViewById<TouchView>(Resource.Id.left_top_view);
            //mView.setRec(rec);

            //BarcodeFormat supportBarcodeFormat = new BarcodeFormat();
            //supportBarcodeFormat |= BarcodeFormat.Code128;
            //supportBarcodeFormat |= BarcodeFormat.Ean13;

            string jsonList = Xamarin.Forms.Application.Current.Properties["SupportBarcodeFormat"].ToString();
            List <Helpers.BarcodeFormat> tmpList = JsonConvert.DeserializeObject <List <Helpers.BarcodeFormat> >(jsonList);

            Detector detector = null;

            //Xamarin.Android에서 AztecCode를 사용하기 위해서는 바코드 지원타입을 비워놔야 한다.
            //AztecCode 지원코드는 4096인데 Xamarin.Android에선 코드 타입이 없고 전체로 하면 스캔 가능한다.
            if (tmpList.Contains(Helpers.BarcodeFormat.AztecCode))
            {
                detector = new BarcodeDetector.Builder(Application.Context)
                           .Build();
            }
            else
            {
                var barcodeFormat = ConvertToAndroid(JsonConvert.DeserializeObject <List <Helpers.BarcodeFormat> >(jsonList));
                detector = new BarcodeDetector.Builder(Application.Context)
                           .SetBarcodeFormats(barcodeFormat)
                           .Build();
            }

            detector.SetProcessor(new MultiProcessor.Builder(new GraphicBarcodeTrackerFactory(mGraphicOverlay, this)).Build());

            //FocusingProcessor를 사용해도 되기는 하나 한번 포커스 지정되고 나서 연속 스캔할때 벗어나도 계속 스캐되는 버그가 있음.
            //detector.SetProcessor(new CentralBarcodeFocusingProcessor(detector, new GraphicBarcodeTracker(mGraphicOverlay, this)));

            if (!detector.IsOperational)
            {
                Android.Util.Log.Warn(TAG, "Barcode detector dependencies are not yet available.");
            }

            mCameraSource = new CameraSource.Builder(Application.Context, detector)
                            .SetRequestedPreviewSize((int)DeviceDisplay.MainDisplayInfo.Height, (int)DeviceDisplay.MainDisplayInfo.Width) //Max Size :  1920 x 1080 (아이폰과 동일함)
                                                                                                                                          //.SetRequestedPreviewSize(1600, 1200)
                            .SetFacing(CameraFacing.Back)
                            .SetRequestedFps(30.0f)                                                                                       //안드로이 공식샘플은 15.0f 로 되어 있으나 기본값은 30.0f
                            .SetAutoFocusEnabled(true)
                            .Build();

            _playerBeep    = MediaPlayer.Create(this, Resource.Raw.beep07); //Beep음 (Scandit과 동일함)
            _playerCaution = MediaPlayer.Create(this, Resource.Raw.beep06); //경고음.
        }
 public GraphicBarcodeTracker(GraphicOverlay overlay, Activity activity)
 {
     mOverlay        = overlay;
     _activity       = activity;
     mBarcodeGraphic = new BarcodeGraphic(overlay);
 }
 public GraphicBarcodeTrackerFactory(GraphicOverlay overlay, Activity activity) : base()
 {
     Overlay   = overlay;
     _activity = activity;
 }
Example #6
0
 public Graphic(GraphicOverlay overlay)
 {
     mOverlay = overlay;
 }