public static ImportResult ImportImage(ProjectTree projectTree, string imageFileName, string arrangerKey) { Console.Write($"Importing '{imageFileName}' to '{arrangerKey}'..."); if (!File.Exists(imageFileName)) { Console.WriteLine($"File does not exist"); return(ImportResult.MissingFile); } if (!projectTree.TryGetItem(arrangerKey, out ScatteredArranger arranger)) { Console.WriteLine($"Resource key does not exist or is not a {nameof(ScatteredArranger)}"); return(ImportResult.BadResourceKey); } if (arranger.ColorType == PixelColorType.Indexed) { var image = new IndexedImage(arranger); image.ImportImage(imageFileName, new ImageSharpFileAdapter(), ColorMatchStrategy.Exact); image.SaveImage(); } else if (arranger.ColorType == PixelColorType.Direct) { var image = new DirectImage(arranger); image.ImportImage(imageFileName, new ImageSharpFileAdapter()); image.SaveImage(); } Console.WriteLine("Completed successfully"); return(ImportResult.Success); }
public override void SaveChanges() { try { _directImage.SaveImage(); UndoHistory.Clear(); RedoHistory.Clear(); NotifyOfPropertyChange(() => CanUndo); NotifyOfPropertyChange(() => CanRedo); IsModified = false; var changeEvent = new ArrangerChangedEvent(_projectArranger, ArrangerChange.Pixels); _events.PublishOnUIThread(changeEvent); } catch (Exception ex) { _windowManager.ShowMessageBox($"Could not save the pixel arranger contents\n{ex.Message}\n{ex.StackTrace}", "Save Error"); } }