public override Uri ResolveUri(Uri baseUri, string relativeUri) { string noteTitleLowered = relativeUri.ToLower(); if (_resolvedNotes.Contains(noteTitleLowered)) { return(new Uri("")); } Note note = _manager.Find(relativeUri); if (note != null) { _resolvedNotes.Add(noteTitleLowered); return(new Uri(note.Uri)); } return(new Uri("")); }
public string FindNote(string linked_title) { Note note = note_manager.Find(linked_title); return((note == null) ? String.Empty : note.Uri); }
/// <summary> /// Determines the relative path between two exported files, can optionally be used /// by the subclass. /// </summary> /// <param name="title_from"> /// The note we're finding the relative path from. /// </param> /// <param name="title_to"> /// The title of the note we're finding the relative path to. /// </param> /// <returns> /// A <see cref="System.String"/> /// </returns> public string ResolveRelativePath(Note note_from, string title_to) { NoteManager manager = Tomboy.DefaultNoteManager; Note note_to = manager.Find(title_to); string title_from = SanitizeNoteTitle(note_from.Title); if (note_to != null) { title_to = SanitizeNoteTitle(note_to.Title); Logger.Debug("Found linked note '{0}', sanitized title: '{1}'", note_to.Title, title_to); } else { Logger.Error("Could not find note titled '{0}' to construct a link to it", title_to); return(""); } if (exporting_single_notebook) { //If there is only one notebook being exported if (NotebookManager.GetNotebookFromNote(note_from) == NotebookManager.GetNotebookFromNote(note_to)) { return(title_to + "." + export_file_suffix); } else { return(""); } } else { //If all notebooks are available if (NotebookManager.GetNotebookFromNote(note_from) == NotebookManager.GetNotebookFromNote(note_to)) { //Both notes are in the same notebook return(title_to + "." + export_file_suffix); } else { //Unfiled notes are a special case because they're in the root directory and will // throw an exception from the notebookmanager string notebook_from; string notebook_to; try { notebook_from = NotebookManager.GetNotebookFromNote(note_from).NormalizedName; } catch (Exception ex) { notebook_from = "___NotebookManager___UnfiledNotes__Notebook___"; //TODO: Ugly! } try { notebook_to = NotebookManager.GetNotebookFromNote(note_to).NormalizedName; } catch (Exception ex) { notebook_to = "___NotebookManager___UnfiledNotes__Notebook___"; } if (notebook_to == "___NotebookManager___UnfiledNotes__Notebook___") { return(".." + System.IO.Path.DirectorySeparatorChar + title_to + "." + export_file_suffix); } else if (notebook_from == "___NotebookManager___UnfiledNotes__Notebook___") { return(SanitizePath(notebook_to) + System.IO.Path.DirectorySeparatorChar + title_to + "." + export_file_suffix); } else { return(".." + System.IO.Path.DirectorySeparatorChar + SanitizePath(notebook_to) + System.IO.Path.DirectorySeparatorChar + title_to + "." + export_file_suffix); } } } }