/// <summary> /// Creates report for a single picture /// </summary> /// <param name="pic"></param> public static void Create(IPictureViewModel pic) { var pdf = new PdfWriter("Report"); pdf.Title($"Report of {pic.FileName}"); pdf.Image(pic.FilePath); pdf.Heading1("EXIF Information"); pdf.Line($"Make: {pic.EXIF.Make}"); pdf.Line($"f-Number: {pic.EXIF.FNumber}"); pdf.Line($"Exposure Time: {pic.EXIF.ExposureTime}"); pdf.Line($"Flash: {pic.EXIF.Flash}"); pdf.Line($"ISO Value: {pic.EXIF.ISOValue}"); pdf.Line($"Exposure Program: {pic.EXIF.ExposureProgram}"); pdf.Heading1("IPTC Information"); pdf.Line($"Keywords: {pic.IPTC.Keywords}"); pdf.Line($"Caption: {pic.IPTC.Caption}"); pdf.Line($"By-Line: {pic.IPTC.ByLine}"); pdf.Line($"Copyright Notice: {pic.IPTC.CopyrightNotice}"); pdf.Line($"Headline: {pic.IPTC.Headline}"); // Save the document... var pdfName = $"{pic.FileName.TrimEnd(".jpg".ToCharArray())}.pdf"; var dir = Path.Combine(AppContext.Instance.WorkingDirectory, "Reports"); Directory.CreateDirectory(dir); pdf.Save(Path.Combine(dir, pdfName)); //TODO Display Photographer //TODO error handling if file is currently open }
public void PictureViewModel_Sets_CameraForExif() { MainWindowViewModel controller = new MainWindowViewModel(); IPictureViewModel pictureViewModel = controller.CurrentPicture; Assert.That(pictureViewModel.EXIF.Camera != null); }
public void PictureViewModel_should_return_IPTCViewModel() { IPictureModel mdl = ueb.GetPictureModel("test.jpg"); AssertNotNull("GetPictureModel", mdl); IPictureViewModel vmdl = ueb.GetPictureViewModel(mdl); AssertNotNull("GetPictureViewModel", vmdl); AssertNotNull("vmdl.IPTC", vmdl.IPTC); }
public void PictureViewModel_should_reflect_Model() { IPictureModel mdl = ueb.GetPictureModel("test.jpg"); AssertNotNull("GetPictureModel", mdl); IPictureViewModel vmdl = ueb.GetPictureViewModel(mdl); AssertNotNull("GetPictureViewModel", vmdl); AssertEquals("test.jpg", vmdl.FileName); }
public void PictureViewModel_should_return_DisplayName() { IPictureModel mdl = ueb.GetPictureModel("test.jpg"); AssertNotNull("GetPictureModel", mdl); IPictureViewModel vmdl = ueb.GetPictureViewModel(mdl); AssertNotNull("GetPictureViewModel", vmdl); AssertTrue("DisplayName ~ ^.* (by .*)$", new Regex("^.* \\(by .*\\)$").Match(vmdl.DisplayName).Success); }
private void BtnSaveIPTC_Click(object sender, RoutedEventArgs e) { IPictureViewModel currentPicture = _controller.CurrentPicture; currentPicture.IPTC.Keywords = UI_IPTC_Keywords.Text; currentPicture.IPTC.ByLine = UI_IPTC_ByLine.Text; currentPicture.IPTC.CopyrightNotice = UI_IPTC_CopyrightNotice.Text; currentPicture.IPTC.Headline = UI_IPTC_Headline.Text; currentPicture.IPTC.Caption = UI_IPTC_Caption.Text; _controller.SaveCurrentPicture(); }
public PictureModel(IPictureViewModel viewModel) { ID = viewModel.ID; FileName = viewModel.FileName; IPTC = new IPTCModel(viewModel.IPTC); EXIF = new EXIFModel(viewModel.EXIF); if (viewModel.Camera != null) { Camera = new CameraModel(viewModel.Camera); } if (viewModel.Photographer != null) { Photographer = new PhotographerModel(viewModel.Photographer); } }
public void PictureViewModel_should_reflect_Camera() { IPictureModel mdl = ueb.GetPictureModel("test.jpg"); AssertNotNull("GetPictureModel", mdl); IPictureViewModel vmdl = ueb.GetPictureViewModel(mdl); AssertNotNull("GetPictureViewModel", vmdl); ICameraModel c_mdl = ueb.GetCameraModel("Canon", "EOS 20D"); AssertNotNull("GetCameraModel", c_mdl); mdl.Camera = c_mdl; AssertNotNull("vmdl.Camera", vmdl.Camera); AssertEquals("Canon", mdl.Camera.Producer); AssertEquals("EOS 20D", mdl.Camera.Make); }
public void Hello_Empty_PictureViewModel() { IPictureViewModel obj = ueb.GetEmptyPictureViewModel(); AssertNotNull("GetEmptyPictureViewModel", obj); }
/// <summary> /// Useless function /// </summary> /// <param name="currentPicture"></param> public void CurrentPictureChanged(IPictureViewModel currentPicture) { }
public static BitmapImage LoadBitmapImage(IPictureViewModel pic) => LoadBitmapImage(pic?.FilePath);
/// <summary> /// save picture changes to database /// </summary> /// <param name="currentPicture"></param> internal void CurrentPictureChanged(IPictureViewModel currentPicture) { PictureViewModel pvm = (PictureViewModel)currentPicture; Save(pvm.PictureModel); }
/// <summary> /// Creates a report of a single picture. /// </summary> /// <param name="picture"></param> public void CreateReport(IPictureViewModel picture) { var report = new PdfDocument(); var page = report.AddPage(); var filename = picture.FileName + $"_Report{DateTime.Now.Ticks}.pdf"; var gfx = XGraphics.FromPdfPage(page); if (!File.Exists(picture.FilePath)) { throw new FileNotFoundException(); } var image = XImage.FromFile(picture.FilePath); // Print Headline var font = new XFont("Times New Roman", 20, XFontStyle.Regular); XRect rect = new XRect(20, 20, page.Width - 20, 220); gfx.DrawRectangle(XBrushes.White, rect); gfx.DrawString(picture.FileName, font, XBrushes.Black, rect, XStringFormats.TopCenter); // Print Image gfx.DrawImage(image, page.Width / 6, 50, page.Width / 1.5, page.Height / 3); // Print EXIF double infoYCoord = (rect.Y + page.Width / 1.8); double infoHeight = (page.Height - (rect.Height + page.Height / 3)) / 2; // Get Height that has already been used and only take half of it string exifContent = string.Format("{0}\n" + "{1}: {2}\n" + "{3}: {4}\n" + "{5}: {6}\n" + "{7}: {8}\n" + "{9}: {10}\n" + "{11}: {12}\n" + "{13}: {14}\n" + "{15}: {16}", "EXIF", "Make", picture.EXIF.Make, "FNumber", picture.EXIF.FNumber, "ExposureTime", picture.EXIF.ExposureTime, "ISOValue", picture.EXIF.ISOValue, "ISORating", picture.EXIF.ISORating, "Flash", picture.EXIF.Flash, "ExposureProgram", picture.EXIF.ExposureProgram, "Exp.Pro.Resource", picture.EXIF.ExposureProgramResource ); font = new XFont("Times New Roman", 14, XFontStyle.Regular); rect = new XRect(60, infoYCoord, page.Width / 2 - 20, infoHeight); XTextFormatter tf = new XTextFormatter(gfx); tf.DrawString(exifContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); // Print IPTC string iptcContent = string.Format("{0}\n" + "{1}: {2}\n" + "{3}: {4}\n" + "{5}: {6}\n" + "{7}: {8}\n" + "{9}: {10}\n", "IPTC", "Keywords", picture.IPTC.Keywords, "ByLine", picture.IPTC.ByLine, "CopyrightNotice", picture.IPTC.CopyrightNotice, "Headline", picture.IPTC.Headline, "Caption", picture.IPTC.Caption); rect = new XRect(page.Width / 2 + 50, infoYCoord, page.Width / 2 - 20, infoHeight); tf.DrawString(iptcContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); // Print Photographer string photographerContent = string.Format("{0}\n" + "{1}: {2}\n" + "{3}: {4}\n" + "{5}: {6}\n", "Photographer", "Full name", picture.Photographer.FirstName + " " + picture.Photographer.LastName, "Birthday", picture.Photographer.BirthDay.ToString(), "Notes", picture.Photographer.Notes); rect = new XRect(60, infoYCoord + 10 * 14, page.Width - 100, infoHeight); tf.DrawString(photographerContent, font, XBrushes.Black, rect, XStringFormats.TopLeft); report.Save(GlobalInformation.ReportPath + "\\" + filename); }