public ActionResult Create(ImageEditorViewModel model, int Id) { try { if (ModelState.IsValid) { DefaultContext db = new DefaultContext(); var fileModel = WebFileViewModel.getEntityModel(model.FileImage, Server.MapPath("~/Uploads/")); fileModel.IsDefault = false; fileModel.GalleryId = Id; db.WebFiles.Add(fileModel); db.SaveChanges(); return(Json(new { success = true, Caption = model.Caption })); } return(Json(new { success = false, ValidationMessage = "Please check validation messages" })); } catch (Exception ex) { return(Json(new { success = false, ExceptionMessage = "Some error here" })); } }
public PhotoPickerPhotosViewModel(int maxAllowedToSelect, bool ownPhotoPick) { this._albumId = "Camera Roll"; this._maxAllowedToSelect = maxAllowedToSelect; this._ownPhotoPick = ownPhotoPick; this._imageEditor = new ImageEditorViewModel(); }
public ImageEditorPage() { _vm = new ImageEditorViewModel(); BindingContext = _vm; _vm.RotateTheImage += RotateImage; InitializeComponent(); }
public ActionResult Create(ImageEditorViewModel model) { try { if (ModelState.IsValid) { ImageDBEntities db = new ImageDBEntities(); var fileModel = WebFileViewModel.getEntityModel(model.FileImage); db.WebFiles.Add(fileModel); db.SaveChanges(); var entity = ImageEditorViewModel.getEnityModel(model); entity.WebImageId = fileModel.Id; entity.OrderNo = db.Galleries.Count() > 0 ? db.Galleries.Max(x => x.OrderNo) + 1 : 1; db.Galleries.Add(entity); db.SaveChanges(); return(Json(new { success = true, Caption = model.Caption })); } return(Json(new { success = false, ValidationMessage = "Please check validation messages" })); } catch (Exception ex) { return(Json(new { success = false, ExceptionMessage = "Some error here" })); } }
public ActionResult Create(ImageEditorViewModel model) { try { if (ModelState.IsValid) { BrunaContext db = new BrunaContext(); var fileModel = WebFileViewModel.getEntityModel(model.FileImage); db.WebFiles.Add(fileModel); db.SaveChanges(); var entity = ImageEditorViewModel.getEnityModel(model); entity.WebImageId = fileModel.Id; entity.OrderNo = db.Galleries.Count() > 0 ? db.Galleries.Max(x => x.OrderNo) + 1 : 1; db.Galleries.Add(entity); db.SaveChanges(); return(Json(new { success = true, Caption = model.Caption })); //ModelState.AddModelError("", "Uspešno ste naložili sliko."); //return RedirectToAction("Index", "Gallery"); } return(Json(new { success = false, ValidationMessage = "Please check validation messages" })); //ViewBag.errorMessage = "Prišlo je do napake."; //return View(); } catch (Exception) { return(Json(new { success = false, ExceptionMessage = "Some error here" })); } }
/***************** * UPDATE */ public IActionResult Edit(int galleryId, int imageId) { ImageEntity entity = imageRepository.FindById(imageId); ImageEditorViewModel viewModel = new ImageEditorViewModel(entity.Id, entity.Label, entity.Filename, entity.GalleryId); return(View("Editor", viewModel)); }
public ActionResult Create() { ImageEditorViewModel vm = new ImageEditorViewModel(); ViewBag.Action = "Create"; return(PartialView(vm)); }
private void ApplyResize_Click(object sender, RoutedEventArgs e) { ImageEditorViewModel vm = DataContext as ImageEditorViewModel; vm.ResultImage = vm.ResizeVm.ApplyTransform(); vm.RefreshBindings(); }
public ActionResult Edit(ImageEditorViewModel model) { try { if (ModelState.IsValid) { DefaultContext db = new DefaultContext(); var Item = db.Galleries.Include("Files").Where(x => x.Id == model.Id).FirstOrDefault(); if (model.FileImage != null) { var path = Server.MapPath("~/Uploads/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var File = Item.Files.Where(x => x.IsDefault == true).FirstOrDefault(); model.FileImage.SaveAs(path + Path.GetFileName(model.FileImage.FileName)); File.FilePath = "/Uploads/" + Path.GetFileName(model.FileImage.FileName); db.Entry(File).State = System.Data.Entity.EntityState.Modified; } Item.Title = model.Caption; db.Entry(Item).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); } catch (Exception ex) { return(RedirectToAction("Index")); } }
public ActionResult Create(ImageEditorViewModel model) { try { if (ModelState.IsValid) { DefaultContext db = new DefaultContext(); var fileModel = WebFileViewModel.getEntityModel(model.FileImage, Server.MapPath("~/Uploads/")); fileModel.IsDefault = true; var entity = ImageEditorViewModel.getEnityModel(model); entity.Files = new List <WebFile>(); entity.Files.Add(fileModel); entity.CreatedDate = DateTime.UtcNow; db.Galleries.Add(entity); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); } catch (Exception ex) { return(RedirectToAction("Index")); } }
/*public ImageEditor(FrameworkElement parentControl, BitmapImage image) * { * InitializeComponent(); * (DataContext as ImageEditorViewModel).ResultImage = image; * this.parentControl = parentControl; * }*/ public void EditImage(BitmapImage image) { ImageEditorViewModel vm = DataContext as ImageEditorViewModel; vm.ResultImage = image; vm.RefreshBindings(); Visibility = Visibility.Visible; }
public ActionResult Edit(int Id) { DefaultContext db = new DefaultContext(); var Item = db.Galleries.Include("Files").Where(x => x.Id == Id).FirstOrDefault(); ImageEditorViewModel vm = ImageEditorViewModel.getEnity(Item); ViewBag.Action = "Edit"; return(View(vm)); }
public ImegeEdit() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); this.navigationHelper.LoadState += navigationHelper_LoadState; this.navigationHelper.SaveState += navigationHelper_SaveState; vm = new ImageEditorViewModel(); this.DataContext = vm; }
public Boolean isValid(ImageEditorViewModel viewModel) { Boolean result = viewModel.Label != null && viewModel.Label.Length >= MIN_LENGTH && viewModel.Label.Length <= MAX_LENGTH; if (!result) { this.Message = "The label must be with length from " + MIN_LENGTH + " to " + MAX_LENGTH; } return(result); }
public IActionResult Index(ImageEditorViewModel model) { model.Images = System.IO.Directory.GetFiles(web.WebRootPath, "*.*", SearchOption.AllDirectories).Where(c => c.EndsWith(".jpg") || c.EndsWith(".bmp") || c.EndsWith(".png")).ToList(); var Count = model.Images.Count; var TotalPage = Count / (double)model.CountOnpage; model.TotalPage = (short)Math.Ceiling(TotalPage); model.Images = model.Images.Select(c => new string(c.Substring(c.IndexOf("wwwroot")).Replace("\\", "/")).Replace("wwwroot", "")).OrderBy(c => c).Skip((model.CurrentPage - 1) * model.CurrentPage).Take(model.CountOnpage).ToList(); return(View(model)); }
public ImageDisplayNodeViewModel() { this.Name = "Display"; this.Category = NodeCategory.Images; _editor = new ImageEditorViewModel(); ImageInput.Editor = _editor; ImageInput.Name = "Image"; ImageInput.ValueChanged .Select(cs => cs.Image) .BindTo(_editor, e => e.Image); this.Inputs.Add(ImageInput); }
public ImageInputNodeViewModel() { this.Name = "Input"; this.Category = NodeCategory.Images; var editor = new ImageEditorViewModel(); ImageOutput.Name = "Image"; ImageOutput.Editor = editor; ImageOutput.ReturnType = typeof(IImage); ImageOutput.Value = editor.WhenAnyValue(e => e.Image) .Select(x => new CodecState(x)); this.Outputs.Add(ImageOutput); }
public ImageEditorPage(byte[] img) { InitializeComponent(); BindingContext = ViewModel = new ImageEditorViewModel(img); //https://help.syncfusion.com/xamarin/sfimageeditor/toolbarcustomization var itemNames = ImageEditor.ToolbarSettings.ToolbarItems.Select(i => i.Name.ToLower()).Except(new[] { "transform" }).ToList(); itemNames.Add("rotate"); if (Device.RuntimePlatform == Device.iOS) { itemNames.Add("flip"); //looks like flip doesn't work on iOS after save } ImageEditor.SetToolbarItemVisibility(string.Join(",", itemNames), false); }
protected override EditorResult OnBuildEditor(Image element, ElementEditorContext context) { var viewModel = new ImageEditorViewModel(); var editor = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.Image", Model: viewModel); if (context.Updater != null) { context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null); element.MediaId = ParseImageId(viewModel.ImageId); } var imageId = element.MediaId; viewModel.CurrentImage = imageId != null?GetImage(imageId.Value) : default(ImagePart); return(Editor(context, editor)); }
public async Task <IActionResult> Save(IFormFile file, ImageEditorViewModel viewModel) { if (imageValidator.isValid(viewModel)) { if (file != null) { Task <string> task = imageFileWriter.copy(file); await task; viewModel.Filename = task.Result; } imageRepository.Save(viewModel.Id, viewModel.Label, viewModel.Filename, viewModel.GalleryId); return(Redirect("/gallery/" + viewModel.GalleryId + "/images/")); } viewModel.Message = imageValidator.GetMessage(); return(View("Editor", viewModel)); }
public ActionResult Create(ImageEditorViewModel model) { var galleryLists = from s in galleryService.LoadAll() select s; var webFileLists = from v in webFileService.LoadAll() select v; try { if (ModelState.IsValid) { var mapper = new MapperConfiguration(cfg => cfg.CreateMap <WebFileDTO, WebFilesVM>()).CreateMapper(); var fileModel = WebFileViewModel.getEntityModel(model.FileImage); var coach = mapper.Map <WebFileDTO>(fileModel); webFileService.Save(coach); var mapper3 = new MapperConfiguration(cfg => cfg.CreateMap <GalleryDTO, GalleriesVM>()).CreateMapper(); var entity = ImageEditorViewModel.getEnityModel(model); entity.WebImageId = webFileLists.Select(c => c.Id).LastOrDefault(); entity.OrderNo = galleryLists.Count() > 0 ? galleryLists.Max(x => x.OrderNo) + 1 : 1; // must be changed entity.post_like = 0; var coach3 = mapper3.Map <GalleryDTO>(entity); galleryService.Save(coach3); return(Json(new { success = true, Caption = model.Caption })); } return(Json(new { success = false, ValidationMessage = "Please check validation messages" })); } catch (Exception ex) { return(Json(new { success = false, ExceptionMessage = "Some error here" })); } }
private void RotateImageRight_Click(object sender, RoutedEventArgs e) { ImageEditorViewModel vm = DataContext as ImageEditorViewModel; switch (vm.ImageRotation) { case Rotation.Rotate0: vm.ImageRotation = Rotation.Rotate90; break; case Rotation.Rotate90: vm.ImageRotation = Rotation.Rotate180; break; case Rotation.Rotate180: vm.ImageRotation = Rotation.Rotate270; break; case Rotation.Rotate270: vm.ImageRotation = Rotation.Rotate0; break; } }
public ResizeCommand(ImageEditorViewModel viewModel) { _viewModel = viewModel; }
public PrewittCommand(ImageEditorViewModel viewModel) { _viewModel = viewModel; }
public FlipCommand(ImageEditorViewModel viewModel) { _viewModel = viewModel; }
public RotateCommand(ImageEditorViewModel viewModel) { _viewModel = viewModel; }
public SelectToolCommand(ImageEditorViewModel viewModel) { _viewModel = viewModel; }
public UndoCommand(ImageEditorViewModel viewModel) { _viewModel = viewModel; }
public Pencil(ImageEditorViewModel viewModel) : base(viewModel) { }
protected FixedPointsTool(ImageEditorViewModel viewModel) : base(viewModel) { }