コード例 #1
0
        public OrderQRCodePageViewModel(OrderResp orderResp)
        {
            OrderID = orderResp.data.id;
            BitMatrix bmqr = new QRCodeWriter().encode(orderResp.guid, ZXing.BarcodeFormat.QR_CODE, 750, 750);

            skbmp = new SKBitmap(bmqr.Width, bmqr.Height);
            for (int i = 0; i < bmqr.Width; i++)
            {
                for (int j = 0; j < bmqr.Height; j++)
                {
                    if (bmqr[i, j])
                    {
                        skbmp.SetPixel(i, j, new SKColor(0, 0, 0));
                    }
                    else
                    {
                        skbmp.SetPixel(i, j, new SKColor(255, 255, 255));
                    }
                }
            }

            ScreenshotCommand = new Command(async() =>
            {
                using (UserDialogs.Instance.Loading("Taking screenshot", null, null, true, MaskType.Black))
                {
                    try
                    {
                        string path = await CrossScreenshot.Current.CaptureAndSaveAsync();
                        await Application.Current.MainPage.DisplayAlert("Result", "Screenshot saved", "Close");
                    }
                    catch (Exception ex)
                    {
                        await Application.Current.MainPage.DisplayAlert("Result", ex.Message, "Close");
                    }
                }
            });
        }
コード例 #2
0
 public OrderQRCodePage(OrderResp orderResp)
 {
     InitializeComponent();
     BindingContext = this.viewModel = new OrderQRCodePageViewModel(orderResp);
 }