Example #1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            Success.IsVisible = false;
            //var webClient = new WebClient();
            //byte[] imageData = webClient.DownloadData("https://kasikornbank.com/SiteCollectionDocuments/about/img/logo/logo.png");
            ICreateReceipt photoLibrary = DependencyService.Get <ICreateReceipt>();
            string         filename     = DateTime.Now.ToString("yyyyMMdd-hhmmss");
            string         extension    = ".png";
            var            data         = CreateImage();
            bool           result       = await photoLibrary.SavePhotoAsync(data, "Xamarin", filename + extension);

            SKCanvasView sKCanvasView = new SKCanvasView();

            sKCanvasView.HeightRequest     = 300;
            sKCanvasView.HorizontalOptions = LayoutOptions.CenterAndExpand;
            sKCanvasView.WidthRequest      = 50;
            sKCanvasView.PaintSurface     += SKCanvasView_PaintSurface;
            stack.Children.Add(sKCanvasView);
            Success.IsVisible = true;
        }
 bool CreateReceipt()
 {
     try
     {
         ICreateReceipt photoLibrary = DependencyService.Get <ICreateReceipt>();
         string         filename     = DateTime.Now.ToString("yyyyMMdd-hhmmss");
         string         extension    = ".png";
         var            data         = CreateImage();
         bool           result       = photoLibrary.SavePhotoAsync(data, "Xamarin", filename + extension).Result;
         sKCanvasView.PaintSurface += SKCanvasView_PaintSurface;  // += SKCanvasView_PaintSurface;
         if (!result)
         {
             DisplayAlert("Error", "Cannot save new receipt please enable local storage", "Ok");
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Example #3
0
        async Task <bool> CreateReceipt()
        {
            try
            {
                receipt.CreateDate = receipt.CreateDate.ToLocalTime(); //= DateTime.SpecifyKind(receipt.CreateDate, DateTimeKind.Local);
                ICreateReceipt photoLibrary = DependencyService.Get <ICreateReceipt>();
                string         filename     = DateTime.Now.ToString("yyyyMMdd-hhmmss");
                string         extension    = ".png";
                var            data         = CreateImage();
                bool           result       = await photoLibrary.SavePhotoAsync(data, "Xamarin", filename + extension);

                sKCanvasView.HeightRequest = 300;
                sKCanvasView.PaintSurface += SKCanvasView_PaintSurface;  // += SKCanvasView_PaintSurface;
                if (!result)
                {
                    await DisplayAlert("Error", "Cannot save new receipt please enable local storage", "Ok");
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }