private void Update() { Gtk.HTMLStream stream = this.Begin(null, "text/html; charset=utf-8", Gtk.HTMLBeginFlags.Scroll); string bg = Color(this.Style.Background(Gtk.StateType.Active)); string fg = Color(this.Style.Foreground(Gtk.StateType.Active)); string ig = Color(this.Style.Base(Gtk.StateType.Active)); stream.Write("<table width=100% cellpadding=5 cellspacing=0>"); bool empty = true; bool missing = false; System.Exception error = null; if (exif_info != null) { foreach (Exif.ExifContent content in exif_info.GetContents()) { Exif.ExifEntry [] entries = content.GetEntries(); if (entries.Length > 0) { empty = false; break; } } if (exif_info.Data.Length > 0) { stream.Write(String.Format("<tr><td colspan=2 align=\"center\" bgcolor=\"{0}\">" + "<img center src=\"exif:thumbnail\"></td></tr>", ig)); } int i = 0; foreach (Exif.ExifContent content in exif_info.GetContents()) { Exif.ExifEntry [] entries = content.GetEntries(); i++; if (entries.Length < 1) { continue; } stream.Write("<tr><th align=left bgcolor=\"" + ig + "\" colspan=2>" + Exif.ExifUtil.GetIfdNameExtended((Exif.Ifd)i - 1) + "</th><tr>"); foreach (Exif.ExifEntry entry in entries) { stream.Write("<tr><td valign=top align=right bgcolor=\"" + bg + "\"><small><font color=\"" + fg + "\">"); if (entry.Title != null) { stream.Write(entry.Title); } else { stream.Write("<Unknown Tag ID=" + entry.Tag.ToString() + ">"); } stream.Write("</font></small></td><td>"); string s = entry.Value; if (s != null && s != String.Empty) { stream.Write(s); } stream.Write("</td><tr>"); } } } if (photo != null) { MetadataStore store = new MetadataStore(); try { using (ImageFile img = ImageFile.Create(photo.DefaultVersionUri)) { if (img is SemWeb.StatementSource) { StatementSource source = (StatementSource)img; source.Select(store); } } } catch (System.IO.FileNotFoundException) { missing = true; } catch (System.Exception e) { // Sometimes we don't get the right exception, check for the file if (!System.IO.File.Exists(photo.DefaultVersionUri.LocalPath)) { missing = true; } else { // if the file is there but we still got an exception display it. error = e; } } if (store.StatementCount > 0) { #if false using (System.IO.Stream xmpstream = System.IO.File.OpenWrite("tmp.xmp")) { xmpstream.Length = 0; FSpot.Xmp.XmpFile file; file = new FSpot.Xmp.XmpFile(); store.Select(file); file.Save(xmpstream); } #endif empty = false; stream.Write("<tr><th align=left bgcolor=\"" + ig + "\" colspan=2>" + Catalog.GetString("Extended Metadata") + "</th></tr>"); foreach (Statement stmt in store) { // Skip anonymous subjects because they are // probably part of a collection if (stmt.Subject.Uri == null && store.SelectSubjects(null, stmt.Subject).Length > 0) { continue; } string title; string value; Description.GetDescription(store, stmt, out title, out value); stream.Write("<tr><td valign=top align=right bgcolor=\"" + bg + "\"><small><font color=\"" + fg + "\">"); stream.Write(title); stream.Write("</font></small></td><td width=100%>"); if (value != null) { value = Escape(value); } else { MemoryStore substore = store.Select(new Statement((Entity)stmt.Object, null, null, null)).Load(); WriteCollection(substore, stream); } if (value != null && value != String.Empty) { stream.Write(value); } stream.Write("</td></tr>"); } } if (Core.Database != null && photo is Photo) { stream.Write("<tr><th align=left bgcolor=\"" + ig + "\" colspan=2>" + Catalog.GetString("Exported Locations") + "</th></tr>"); Photo p = photo as Photo; foreach (ExportItem export in Core.Database.Exports.GetByImageId(p.Id, p.DefaultVersionId)) { string url = GetExportUrl(export); string label = GetExportLabel(export); if (url == null || label == null) { continue; } stream.Write("<tr colspan=2><td width=100%>"); stream.Write(String.Format("<a href=\"{0}\">{1}</a>", url, label)); stream.Write("</font></small></td></tr>"); } } } if (empty) { string msg; if (photo == null) { // FIXME we should pass the full selection to the info display and let it // handle multiple items however it wants. msg = String.Format("<tr><td valign=top align=center bgcolor=\"{0}\">" + "<b>{1}</b></td></tr>", ig, Catalog.GetString("No active photo")); } else if (missing) { string text = String.Format(Catalog.GetString("The photo \"{0}\" does not exist"), photo.DefaultVersionUri); msg = String.Format("<tr><td valign=top align=center bgcolor=\"{0}\">" + "<b>{1}</b></td></tr>", ig, text); } else { msg = String.Format("<tr><td valign=top align=center bgcolor=\"{0}\">" + "<b>{1}</b></td></tr>", ig, Catalog.GetString("No metadata available")); if (error != null) { String.Format("<pre>{0}</pre>", error); } } stream.Write(msg); } stream.Write("</table>"); End(stream, Gtk.HTMLStreamStatus.Ok); }
private void Update () { Gtk.HTMLStream stream = this.Begin (null, "text/html; charset=utf-8", Gtk.HTMLBeginFlags.Scroll); string bg = Color (this.Style.Background (Gtk.StateType.Active)); string fg = Color (this.Style.Foreground (Gtk.StateType.Active)); string ig = Color (this.Style.Base (Gtk.StateType.Active)); stream.Write ("<table width=100% cellpadding=5 cellspacing=0>"); bool empty = true; bool missing = false; System.Exception error = null; if (exif_info != null) { foreach (Exif.ExifContent content in exif_info.GetContents ()) { Exif.ExifEntry [] entries = content.GetEntries (); if (entries.Length > 0) { empty = false; break; } } if (exif_info.Data.Length > 0) stream.Write (String.Format ("<tr><td colspan=2 align=\"center\" bgcolor=\"{0}\">" + "<img center src=\"exif:thumbnail\"></td></tr>", ig)); int i = 0; foreach (Exif.ExifContent content in exif_info.GetContents ()) { Exif.ExifEntry [] entries = content.GetEntries (); i++; if (entries.Length < 1) continue; stream.Write ("<tr><th align=left bgcolor=\"" + ig + "\" colspan=2>" + Exif.ExifUtil.GetIfdNameExtended ((Exif.Ifd)i - 1) + "</th><tr>"); foreach (Exif.ExifEntry entry in entries) { stream.Write ("<tr><td valign=top align=right bgcolor=\""+ bg + "\"><small><font color=\"" + fg + "\">"); if (entry.Title != null) stream.Write (entry.Title); else stream.Write ("<Unknown Tag ID=" + entry.Tag.ToString () + ">"); stream.Write ("</font></small></td><td>"); string s = entry.Value; if (s != null && s != String.Empty) stream.Write (s); stream.Write ("</td><tr>"); } } } if (photo != null) { MetadataStore store = new MetadataStore (); try { using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri)) { if (img is SemWeb.StatementSource) { StatementSource source = (StatementSource)img; source.Select (store); } } } catch (System.IO.FileNotFoundException) { missing = true; } catch (System.Exception e){ // Sometimes we don't get the right exception, check for the file if (!System.IO.File.Exists (photo.DefaultVersionUri.LocalPath)) { missing = true; } else { // if the file is there but we still got an exception display it. error = e; } } if (store.StatementCount > 0) { #if false using (System.IO.Stream xmpstream = System.IO.File.OpenWrite ("tmp.xmp")) { xmpstream.Length = 0; FSpot.Xmp.XmpFile file; file = new FSpot.Xmp.XmpFile (); store.Select (file); file.Save (xmpstream); } #endif empty = false; stream.Write ("<tr><th align=left bgcolor=\"" + ig + "\" colspan=2>" + Catalog.GetString ("Extended Metadata") + "</th></tr>"); foreach (Statement stmt in store) { // Skip anonymous subjects because they are // probably part of a collection if (stmt.Subject.Uri == null && store.SelectSubjects (null, stmt.Subject).Length > 0) continue; string title; string value; Description.GetDescription (store, stmt, out title, out value); stream.Write ("<tr><td valign=top align=right bgcolor=\""+ bg + "\"><small><font color=\"" + fg + "\">"); stream.Write (title); stream.Write ("</font></small></td><td width=100%>"); if (value != null) value = Escape (value); else { MemoryStore substore = store.Select (new Statement ((Entity)stmt.Object, null, null, null)).Load(); WriteCollection (substore, stream); } if (value != null && value != String.Empty) stream.Write (value); stream.Write ("</td></tr>"); } } if (Core.Database != null && photo is Photo) { stream.Write ("<tr><th align=left bgcolor=\"" + ig + "\" colspan=2>" + Catalog.GetString ("Exported Locations") + "</th></tr>"); Photo p = photo as Photo; foreach (ExportItem export in Core.Database.Exports.GetByImageId (p.Id, p.DefaultVersionId)) { string url = GetExportUrl (export); string label = GetExportLabel (export); if (url == null || label == null) continue; stream.Write ("<tr colspan=2><td width=100%>"); stream.Write (String.Format ("<a href=\"{0}\">{1}</a>", url, label)); stream.Write ("</font></small></td></tr>"); } } } if (empty) { string msg; if (photo == null) { // FIXME we should pass the full selection to the info display and let it // handle multiple items however it wants. msg = String.Format ("<tr><td valign=top align=center bgcolor=\"{0}\">" + "<b>{1}</b></td></tr>", ig, Catalog.GetString ("No active photo")); } else if (missing) { string text = String.Format (Catalog.GetString ("The photo \"{0}\" does not exist"), photo.DefaultVersionUri); msg = String.Format ("<tr><td valign=top align=center bgcolor=\"{0}\">" + "<b>{1}</b></td></tr>", ig, text); } else { msg = String.Format ("<tr><td valign=top align=center bgcolor=\"{0}\">" + "<b>{1}</b></td></tr>", ig, Catalog.GetString ("No metadata available")); if (error != null) { String.Format ("<pre>{0}</pre>", error); } } stream.Write (msg); } stream.Write ("</table>"); End (stream, Gtk.HTMLStreamStatus.Ok); }