protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            PhotoEditing.Activity = this;
            PhotoEditing photoEditing = new PhotoEditing();

            SetContentView(photoEditing.Window);

            photoEditing.Run();
        }
Exemple #2
0
        public JsonResult UploadPhotoAdd(FormDataUpload form)
        {
            if (Response.IsClientConnected)
            {
                if (form.Photos == null || form.StringId == null)
                {
                    return(Json(new { success = false }));
                }
                var dir = HostingEnvironment.MapPath("~/Photos/" + form.StringId.Substring(2, 4) + "/" + form.StringId.Substring(0, 4));
                Directory.CreateDirectory(dir);
                List <UploadPhoto> phos = new List <UploadPhoto>();
                int _curr = form.CurrentPhotoCount;
                int _max  = form.MaxPhotoCount;
                for (int i = 0; i < form.Photos.Count && form.CurrentPhotoCount <= form.MaxPhotoCount && i < _max - _curr; i++, form.CurrentPhotoCount++)
                {
                    HttpPostedFileBase photo = form.Photos.ElementAt(i);
                    if (AllowedFileTypes.AllowedFileTypesValidation(photo, "CreateAd"))
                    {
                        var p = new UploadPhoto()
                        {
                            Original_FileName = photo.FileName
                        };
                        // Compress image for ad list thumbnail
                        PhotoEditing.CompressUploadPhoto(dir, true, false, photo, ref p);
                        // Compress image for ad details thumbnail
                        PhotoEditing.CompressUploadPhoto(dir, false, true, photo, ref p);
                        // Compress imgae
                        PhotoEditing.DefaultCompressionJpegUpload(dir, photo, ref p);
                        // Set display src
                        p.Src = "/Images/" + form.StringId.Substring(2, 4) + "/" + form.StringId.Substring(0, 4) + "/" + p.AdList_FileName;
                        phos.Add(p);
                    }
                }

                return(Json(new { success = true, photocount = new { current = form.CurrentPhotoCount }, photos = JsonConvert.SerializeObject(phos) }));
            }
            return(Json(new { success = false }));
        }