Пример #1
0
        protected override void OnSizeChanged(int width, int height, int oldw, int oldh)
        {
            base.OnSizeChanged(width, height, oldw, oldh);

            Random        random       = new Random();
            IInterpolator interpolator = new LinearInterpolator();

            coords = new int[snow_flake_count][];
            drawables.Clear();
            for (int i = 0; i < snow_flake_count; i++)
            {
                //Console.WriteLine ("Add animation for number " + i);
                Animation animation = new TranslateAnimation(0, height / 10 - random.Next(height / 5), 0, height + 50);
                animation.Duration    = (10 * height + random.Next(10 * height)) + 3000;
                animation.RepeatCount = -1;
                animation.Initialize(10, 10, 10, 10);
                animation.Interpolator = interpolator;

                coords[i] = new int[] { random.Next(width - 30), -40 };
                //Console.WriteLine ("Coords = " + coords[i][0] + " and " + coords[i][1]);
                var snow = GetSnowFlake();
                snow.SetAlpha(random.Next(180, 255));
                drawables.Add(new AnimateDrawable(snow, animation));
                animation.StartOffset = random.Next(20 * height);
                animation.StartNow();
            }
        }
Пример #2
0
        async void AutoScan()
        {
            scanner.UseCustomOverlay = true;
            zxingOverlay             = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

            ImageView ivScanning    = zxingOverlay.FindViewById <ImageView>(Resource.Id.ivScanning);
            Button    btnCancelScan = zxingOverlay.FindViewById <Button>(Resource.Id.btnCancelScan);

            btnCancelScan.Click += (s, e) =>
            {
                if (scanner != null)
                {
                    scanner.Cancel();
                }
            };

            zxingOverlay.Measure(MeasureSpecMode.Unspecified.GetHashCode(), MeasureSpecMode.Unspecified.GetHashCode());
            int width  = zxingOverlay.MeasuredWidth;
            int height = zxingOverlay.MeasuredHeight;

            // 从上到下的平移动画
            Animation verticalAnimation = new TranslateAnimation(0, 0, 0, height);

            verticalAnimation.Duration    = 3000;               // 动画持续时间
            verticalAnimation.RepeatCount = Animation.Infinite; // 无限循环

            // 播放动画
            ivScanning.Animation = verticalAnimation;
            verticalAnimation.StartNow();

            scanner.CustomOverlay = zxingOverlay;
            var mbs = MobileBarcodeScanningOptions.Default;

            mbs.AssumeGS1                 = true;
            mbs.AutoRotate                = true;
            mbs.DisableAutofocus          = false;
            mbs.PureBarcode               = false;
            mbs.TryInverted               = true;
            mbs.TryHarder                 = true;
            mbs.UseCode39ExtendedMode     = true;
            mbs.UseFrontCameraIfAvailable = false;
            mbs.UseNativeScanning         = true;

            var result = await scanner.Scan(this, mbs);

            HandleScanResult(result);
        }