如何在堆叠布局中集成海牛工程条码扫描器?

时间:2017-10-16 11:02:39

标签: c# xamarin manateeworks

我有一个问题,如何将我的堆叠布局中的海牛条码扫描器与特定测量结合起来......这是我的代码图片......

enter image description here

这是我的代码实际代码......请帮帮我......

select  DATEADD(DAY, 
                DATEPART(DAY,(MIN([Actual Date]))) - DATEPART(DAY,(MAX([Payment Date]))),
                    DATEADD(MONTH, 
                        ( 11 - COUNT(*) )
                        , MAX([Payment Date])) )
from @InstalmentTable

1 个答案:

答案 0 :(得分:0)

您需要使用ViewRenderer并在页面中包含该视图。 https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/view/

此应用程序中https://github.com/manateeworks/xamarin-shopping-cart-demo-app扫描程序实现为页面。进行更改并将PageRenderer转换为ViewRenderer。

也可以在本机ViewRenderer中使用scanner.ScanInView而不是scanner.ScanWithCallback。以下是Droid原生ViewRenderer的代码部分



[assembly: ExportRenderer(typeof(ManateeShoppingCart.CameraPreview), typeof(ManateeShoppingCart.Droid.ScanPageRenderer))]
namespace ManateeShoppingCart.Droid
{
    public class ScanPageRenderer : ViewRenderer, IScanSuccessCallback
    {
        Scanner scanner;

        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            scanner = new Scanner(Forms.Context);
            scanner.setInterfaceOrientation("All");
            scanner.closeScannerOnDecode = false;

            customDecoderInit();

            double screenHeight = App.Current.MainPage.Height > App.Current.MainPage.Width ? App.Current.MainPage.Height : App.Current.MainPage.Width;
            double screenWidth = App.Current.MainPage.Height < App.Current.MainPage.Width ? App.Current.MainPage.Height : App.Current.MainPage.Width; ;

            float preivewX = (float)((CameraPreview)Element).CameraPreviewX;
            float preivewY = (float)((CameraPreview)Element).CameraPreviewY;
            float previewWidth = (float)((CameraPreview)Element).CameraPreviewWidth;
            float previewHeight = (float)((CameraPreview)Element).CameraPreviewHeight;

            scanner.ScanInView(this, new RectangleF((float)(preivewX / screenWidth) * 100, (float)(preivewY / screenHeight) * 100, (float)(previewWidth / screenWidth) * 100, (float)(previewHeight / screenHeight) * 100));
        }
&#13;
&#13;
&#13;