Esempio n. 1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView;

            if (view == null)
            {
                view = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.UserRow, parent, false);
                var Image = view.FindViewById <ImageView>(Resource.Id.row_photoImageView);
                var Name  = view.FindViewById <TextView>(Resource.Id.row_nameTextView);
                var Email = view.FindViewById <TextView>(Resource.Id.row_emailTextView);

                view.Tag = new ViewHolder {
                    Photo = Image, Name = Name, Email = Email
                };

                var holder = (ViewHolder)view.Tag;

                if (string.IsNullOrWhiteSpace(users[position].ImageSource))
                {
                    holder.Photo.SetImageResource(Resource.Drawable.facebook);
                }
                else
                {
                    using (var bitmap = BitmapHelpers.LoadAndResizeBitmap(users[position].ImageSource))
                    {
                        holder.Photo.SetImageBitmap(bitmap);
                    }
                }
                holder.Name.Text  = users[position].FirstName;
                holder.Email.Text = users[position].Email;
            }


            return(view);
        }
Esempio n. 2
0
        void StoreLogoEkle(PdfPTable table, int imgg, string urll)
        {
            var logo = BitmapHelpers.LoadAndResizeBitmap(imgg, 500, 500, this);
            var ms1  = new MemoryStream();

            logo.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 100, ms1);
            var logobyte = ms1.ToArray();

            iTextSharp.text.Image LogoIcon = iTextSharp.text.Image.GetInstance(logobyte);
            LogoIcon.ScaleToFit(220, 220);
            Chunk cImage = new Chunk(LogoIcon, 0, 0, false);

            Anchor anchor = new Anchor(cImage);

            anchor.Reference = urll;

            PdfPCell logocell = new PdfPCell(anchor);

            logocell.Colspan = 1;
            //logocell.FixedHeight = 100f;
            logocell.Border              = 0;
            logocell.BorderWidthLeft     = 0;       //İCON
            logocell.BorderWidthBottom   = 0;
            logocell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(logocell);
        }
Esempio n. 3
0
        private void LoadImageFromGallery(int requestCode, Result resultCode, Intent data)
        {
            if ((resultCode == Result.Ok) && (data != null))
            {
                Stream stream = ContentResolver.OpenInputStream(data.Data);
                Bitmap image  = BitmapFactory.DecodeStream(stream);

                int height = Resources.DisplayMetrics.HeightPixels;
                int width  = _imageView.Height;
                imagePath = GetRealPathFromURI(data.Data);
                Bitmap test = BitmapHelpers.LoadAndResizeBitmap(imagePath, width, height);
                _imageView.SetImageBitmap(test);
            }
        }
Esempio n. 4
0
        private void SetImage()
        {
            int width  = Resources.DisplayMetrics.WidthPixels;
            int height = Resources.DisplayMetrics.HeightPixels;

            Photo newPhoto = new Photo()
            {
                Path = CameraHelper.file.Path,
                DateOfPublication = DateTime.Now.ToLongDateString(),
                Author            = UserService.GetCurrentUserName()
            };

            _imageView.SetImageBitmap(BitmapHelpers.LoadAndResizeBitmap(CameraHelper.file.Path, width, height));

            PhotoService.AddPhoto(newPhoto);

            GC.Collect();
        }
Esempio n. 5
0
            PdfPCell TestBangLogoEkle()
            {
                var logo = BitmapHelpers.LoadAndResizeBitmap(Resource.Mipmap.testbang_logo_img1, 500, 500, context1);
                var ms1  = new MemoryStream();

                logo.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 100, ms1);
                var logobyte = ms1.ToArray();

                iTextSharp.text.Image LogoIcon = iTextSharp.text.Image.GetInstance(logobyte);
                LogoIcon.ScaleToFit(100, 100);
                PdfPCell logocell = new PdfPCell(LogoIcon);

                logocell.Colspan = 1;
                //logocell.FixedHeight = 100f;
                logocell.Border              = 0;
                logocell.BorderWidthLeft     = 0;       //İCON
                logocell.BorderWidthBottom   = 0;
                logocell.HorizontalAlignment = Element.ALIGN_RIGHT;
                logocell.VerticalAlignment   = Element.ALIGN_TOP;
                return(logocell);
            }
Esempio n. 6
0
        //handle input of photos, either from gallery or camera
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            string    path = "";
            Bitmap    pic;
            ImageView iv = null;

            if (imageViewRow != null)
            {
                iv = (ImageView)imageViewRow.FindViewWithTag("image");
            }

            //user cancelled
            if (resultCode == Result.Canceled && requestCode != REQUEST_DRAWING)
            {
                File.Delete(photoFile.Path);
                return;
            }
            //camera
            if (requestCode == REQUEST_IMAGE_CAPTURE)
            {
                //

                GalleryAddPic();


                if (this is DrawingActivity)
                {
                    SetPic(DrawingActivity.BackgroundImage, photoUri);
                }
                else
                {
                    SetPic(iv, photoUri);
                }

                path = mCurrentPhotoPath;
            }

            //gallery
            else if (requestCode == REQUEST_GALLERY_IMAGE)
            {
                pic = MediaStore.Images.Media.GetBitmap(ContentResolver, data.Data);
                using (var os = new FileStream(mCurrentPhotoPath, FileMode.Create))
                {
                    pic.Compress(Bitmap.CompressFormat.Jpeg, 100, os);
                }

                path = mCurrentPhotoPath;

                if (this is DrawingActivity)
                {
                    SetPic(DrawingActivity.BackgroundImage, data.Data);
                }
                else
                {
                    SetPic(iv, data.Data);
                }


                //iv.SetImageBitmap(imageBitmap);
            }
            //this only has a value when coming directly from the camera/gallery
            if (bindingForImage != null)
            {
                XForm.SetValue(bindingForImage.nodeset, path);
            }

            //coming back from a canvas
            if (requestCode == REQUEST_DRAWING && data != null)
            {
                iv = (ImageView)WidgetHelper.viewToPass.FindViewWithTag("image");
                iv.SetImageBitmap(BitmapHelpers.LoadAndResizeBitmap(data.Data.Path, 100, 100, this));
                //iv.SetImageBitmap(Bitmap.CreateScaledBitmap(BitmapFactory.DecodeFile(data.Data.Path), 100, 100, true));
            }

            if (this is ScrollFormActivity)
            {
                try
                {
                    _formActivity.FireFormChangeEvent(imageViewRow);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                if (showDialogAfterImageSelect)
                {
                    iv.PerformClick();
                }
            }
        }