Beispiel #1
0
        public ActionResult Display(string file, bool sized, string name, bool savedFile, int legoSize = 0, string savedFilePath = null, int w = 0, int h = 0)
        {
            PhotoPack Ppack = new PhotoPack {
                newFileName = Guid.NewGuid().ToString() + "_" + name + ".jpg", PhotoName = name, ShareThisPhoto = false
            };

            string filepath = HttpRuntime.AppDomainAppPath;
            Bitmap newImage;
            Bitmap bmpPostedImage;

            if (savedFilePath == null)
            {
                savedFilePath = uploadedPath;
            }

            WebImage photo = new WebImage(filepath + savedFilePath + file);

            int currentH = photo.Height;
            int currentW = photo.Width;

            if (sized == false)
            {
                FitLegoSize(photo, file, currentH, currentW, legoSize);
            }
            else
            {
                photo.Resize(width: w, height: h, preserveAspectRatio: true,
                             preventEnlarge: false);

                FitLegoSize(photo, file, h, w, legoSize);
            }


            bmpPostedImage = new Bitmap(filepath + displayPath + file);
            newImage       = Pixelate(bmpPostedImage, new Rectangle(0, 0, bmpPostedImage.Width, bmpPostedImage.Height), legoSize);
            bmpPostedImage.Dispose();
            newImage.Save(filepath + pixelPath + Ppack.newFileName, ImageFormat.Jpeg);

            newImage.Dispose();
            ViewBag.filepath = displayPath + Ppack.newFileName;
            LegoWaterMark(Ppack, legoSize);

            SearchPhotoPack Spack = new SearchPhotoPack
            {
                Id             = Ppack.Id,
                newFileName    = Ppack.newFileName,
                oldFileName    = file,
                Original       = Ppack.Original,
                PhotoName      = Ppack.PhotoName,
                savedPath      = Ppack.savedPath,
                savedFile      = savedFile,
                SelectedSize   = Ppack.SelectedSize,
                ShareThisPhoto = Ppack.ShareThisPhoto
            };

            return(View(Spack));
        }
        public ActionResult Rename(SearchPhotoPack Spack, FormCollection collection)
        {
            PhotoPack Ppack = _db.PhotoPacks.Find(Spack.Id);

            Ppack.PhotoName = Spack.PhotoName;

            _db.Entry(Ppack).State = EntityState.Modified;
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int deletedid, string returnUrl)
        {
            PhotoPack Ppack = _db.PhotoPacks.Find(deletedid);

            SearchPhotoPack Spack = new SearchPhotoPack
            {
                Id             = Ppack.Id,
                newFileName    = Ppack.newFileName,
                Original       = Ppack.Original,
                PhotoName      = Ppack.PhotoName,
                savedPath      = Ppack.savedPath,
                SelectedSize   = Ppack.SelectedSize,
                ShareThisPhoto = Ppack.ShareThisPhoto
            };

            ViewBag.fileName  = Ppack.savedPath + Ppack.newFileName;
            ViewBag.returnUrl = returnUrl;
            return(View(Spack));
        }