Beispiel #1
0
        public ActionResult Edit(EditorInputViewModel editor)
        {
            // cleaning directory just for demonstrations
            foreach (var f in Directory.GetFiles(StorageCrop)) System.IO.File.Delete(f);

            var image = new WebImage(StorageRoot + editor.Imagem);

            int _height = (int)editor.Height;
            int _width = (int)editor.Width;

            if (_width > 0 && _height > 0)
            {
                image.Resize(_width, _height, false, false);

                int _top = (int)(editor.Top);
                int _bottom = (int)editor.Bottom;
                int _left = (int)editor.Left;
                int _right = (int)editor.Right;

                _height = (int)image.Height;
                _width = (int)image.Width;

                image.Crop(_top, _left, (_height - _bottom), (_width - _right));
            }

            var originalFile = editor.Imagem;

            var name = "profile-c" + Path.GetExtension(image.FileName);

            editor.Imagem = Url.Content(StorageCrop + name);
            image.Save(editor.Imagem);

            System.IO.File.Delete(Url.Content(StorageRoot + originalFile));

            return RedirectToAction("Index", "Home");
        }
Beispiel #2
0
        public ActionResult Index(string rotulo = "Alter photo")
        {
            EditorInputViewModel editor = new EditorInputViewModel
            {
                Rotulo = rotulo
            };

            return PartialView(editor);
        }