Example #1
0
 public async void Delete(Markdown.Item item)
 {
     if (item.Parent == null)
     {
         if (!await DisplayAlert(Strings.Loc.ViewerPage_ClearTitle, Strings.Loc.ViewerPage_ClearConfirm, Strings.Loc.ViewerPage_Yes, Strings.Loc.ViewerPage_No))
         {
             return;
         }
         NoteNavigator.Document.Root.Childs.Clear();
         await DeviceServices.SaveDocumentAsync();
     }
     else
     {
         if (!await DisplayAlert(Strings.Loc.ViewerPage_DeleteTitle, String.Format(Strings.Loc.ViewerPage_DeleteConfirm, item.Title), Strings.Loc.ViewerPage_Yes, Strings.Loc.ViewerPage_No))
         {
             return;
         }
         Markdown.Item newCurrent = NoteNavigator.CurrentNote;
         if (NoteNavigator.CurrentNote == item)
         {
             newCurrent = item.Parent;
         }
         NoteNavigator.Document.RemoveContent(item);
         NoteNavigator.BuildPathToNote(newCurrent);
         await DeviceServices.SaveDocumentAsync();
     }
     RefreshWebView();
 }
Example #2
0
 protected override void OnDisappearing()
 {
     editingNote = null;
     parents.Clear();
     base.OnDisappearing();
     onClose();
 }
Example #3
0
        public void AddNote(Markdown.Item parent, Action onCloseAction, string defaultCaption = "", string defaultContent = "", string unsortedHeader = null)
        {
            onClose             = onCloseAction;
            editingNote         = new Markdown.Item();
            editingNote.Content = defaultContent;
            editingNote.Title   = defaultCaption;
            UnsortedHeader      = unsortedHeader;
            ScanParents();
            if (parent == null)
            {
                if (unsortedHeader != null)
                {
                    parent = unsortedCategory;
                }
                else
                {
                    parent = NoteNavigator.Document.Root;
                }
            }
            noteCategory.SelectedItem = parent;
            noteTitle.Text            = editingNote.Title;
            noteContent.Text          = editingNote.Content;

            noteTitle.IsVisible    = true;
            noteCategory.IsVisible = true;
            Title = Strings.Loc.EditorPage_AddTitle;
        }
Example #4
0
 private static string buildTitle(Markdown.Item item)
 {
     if (item == null)
     {
         return("");
     }
     return(item.Title.Length > 0 ? item.Title : Strings.Loc.NotesIndex);
 }
Example #5
0
 private void releaseChilds(Markdown.Item parent)
 {
     foreach (Markdown.Item child in parent.Childs)
     {
         releaseChilds(child);
     }
     parent.Childs.Clear();
 }
Example #6
0
 public void Share(Markdown.Item item)
 {
     Plugin.Share.CrossShare.Current.Share(new Plugin.Share.Abstractions.ShareMessage
     {
         Title = item.Parent != null ? item.Title : NoteNavigator.FileName,
         Text  = item.HtmlForm
     });
 }
Example #7
0
        public void ScanParents()
        {
            noteCategory.ItemsSource = null;
            parents.Clear();
            unsortedCategory = null;
            fillChilds(NoteNavigator.Document.Root);

            if ((unsortedCategory == null) && (UnsortedHeader != null))
            {
                unsortedCategory = NoteNavigator.Document.AddContent(NoteNavigator.Document.Root, UnsortedHeader, "");
                parents.Add(unsortedCategory);
            }
            noteCategory.ItemsSource = parents;
        }
Example #8
0
        public void EditNote(Markdown.Item note, Action onCloseAction)
        {
            onClose     = onCloseAction;
            editingNote = note;
            ScanParents();

            noteCategory.SelectedItem = editingNote.Parent;
            noteTitle.Text            = editingNote.Title;
            noteContent.Text          = editingNote.Content;

            noteTitle.IsVisible    = editingNote.Parent != null;
            noteCategory.IsVisible = editingNote.Parent != null;

            Title = Strings.Loc.EditorPage_EditTitle;
        }
Example #9
0
 private static string buildParentsPath(Markdown.Item startItem, int i)
 {
     if (startItem.Parent != null)
     {
         string parents = buildParentsPath(startItem.Parent, i + 1);
         if (parents.Length > 0)
         {
             parents += " / ";
         }
         return(parents + "<a href='parent_" + i.ToString() + "'>" +
                buildTitle(startItem.Parent) +
                "</a>");
     }
     return("");
 }
Example #10
0
 public static void BuildPathToNote(Markdown.Item newCurrentNote)
 {
     CurrentPath.Clear();
     while (newCurrentNote.Parent != null)
     {
         int i = newCurrentNote.Parent.Childs.IndexOf(newCurrentNote);
         if (i >= 0)
         {
             CurrentPath.Insert(0, i);
         }
         else
         {
             break;
         }
         newCurrentNote = newCurrentNote.Parent;
     }
 }
Example #11
0
        private void fillChilds(Markdown.Item startingPoint)
        {
            if (startingPoint == editingNote)
            {
                return;
            }
            if (UnsortedHeader != null)
            {
                if (startingPoint.Title.Equals(UnsortedHeader))
                {
                    unsortedCategory = startingPoint;
                }
            }
            parents.Add(startingPoint);

            foreach (Markdown.Item item in startingPoint.Childs)
            {
                fillChilds(item);
            }
        }
Example #12
0
        public static string Get(Markdown.Item item)
        {
            string childStr = "";

            for (int i = 0; i < item.Childs.Count; i++)
            {
                Markdown.Item child         = item.Childs[i];
                string        childTemplate = child.IsMarked ? MarkedTemplate : NoteTemplate;
                childStr += childTemplate.Replace("{NoteTitle}", child.Title).Replace("{NoteId}", i.ToString()).Replace("{NoteContent}", Settings.PreviewMode ? child.HtmlForm : "");
            }

            string pathStr = buildParentsPath(item, 1);

            return(RootTemplate.
                   Replace("{Theme}", ThemeFile).Replace("{BaseSize}", Settings.BaseFontSize.ToString()).
                   Replace("{NoteTitle}", item.Title).
                   Replace("{NoteContent}", item.HtmlForm).
                   Replace("{NoteChilds}", childStr).
                   Replace("{Parent}", pathStr));
        }
Example #13
0
 public void Edit(Markdown.Item item)
 {
     EditorPage.Editor.EditNote(item, RefreshWebView);
     MainPage.Navigator.PushAsync(EditorPage.Editor, true);
 }