Ejemplo n.º 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();
 }
Ejemplo n.º 2
0
 protected override bool OnBackButtonPressed()
 {
     if (NoteNavigator.CanGoBack)
     {
         NoteNavigator.GoBack();
         RefreshWebView();
         return(true);
     }
     else
     {
         return(base.OnBackButtonPressed());
     }
 }
Ejemplo n.º 3
0
        public async Task ReadDocumentAsync()
        {
            if (String.IsNullOrEmpty(Settings.CurrentFile))
            {
                await DeviceServices.ExitAsync();

                return;
            }
            Windows.Storage.StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(Settings.CurrentFile);

            NoteNavigator.Reset();
            NoteNavigator.Document.Parse(new System.IO.StringReader(await Windows.Storage.FileIO.ReadTextAsync(file)));
            mdOrganizer.Services.NoteNavigator.FileName = file.DisplayName;
        }
Ejemplo n.º 4
0
        public async void SaveNote()
        {
            //TODO Validation
            if ((editingNote.Parent != null) || (editingNote != NoteNavigator.Document.Root))
            {
                if (editingNote.Parent != noteCategory.SelectedItem)
                {
                    NoteNavigator.Document.ChangeParent(editingNote, (Markdown.Item)noteCategory.SelectedItem);
                }
                editingNote.Title = noteTitle.Text;
            }
            NoteNavigator.Document.UpdateContent(editingNote, noteContent.Text);
            NoteNavigator.BuildPathToNote(editingNote);

            await DeviceServices.SaveDocumentAsync();

            await Navigation.PopAsync(true);

            onClose();
        }
Ejemplo n.º 5
0
 private void WebView_Navigating(object sender, WebNavigatingEventArgs e)
 {
     if (e.Url.Equals("about:blank"))
     {
         return;
     }
     e.Cancel = true;
     if (e.Url.StartsWith(htmlSource.BaseUrl))
     {
         string command = e.Url.Substring(htmlSource.BaseUrl.Length);
         if (command.StartsWith("parent_"))
         {
             NoteNavigator.GoBack(int.Parse(command.Substring(7)));
         }
         if (command.StartsWith("goto_"))
         {
             if (command.StartsWith("goto_parent"))
             {
                 NoteNavigator.GoBack();
             }
             else
             {
                 NoteNavigator.CurrentPath.Add(int.Parse(command.Substring(5)));
             }
         }
         if (command.StartsWith("edit_"))
         {
             if (command.StartsWith("edit_current"))
             {
                 Edit(NoteNavigator.CurrentNote);
             }
             else
             {
                 Edit(NoteNavigator.CurrentNote.Childs[int.Parse(command.Substring(5))]);
             }
             return;
         }
         if (command.StartsWith("delete_"))
         {
             if (command.StartsWith("delete_current"))
             {
                 Delete(NoteNavigator.CurrentNote);
             }
             else
             {
                 Delete(NoteNavigator.CurrentNote.Childs[int.Parse(command.Substring(7))]);
             }
             return;
         }
         if (command.StartsWith("share_"))
         {
             if (command.StartsWith("share_current"))
             {
                 Share(NoteNavigator.CurrentNote);
             }
             else
             {
                 Share(NoteNavigator.CurrentNote.Childs[int.Parse(command.Substring(6))]);
             }
             return;
         }
         if (command.StartsWith("add"))
         {
             Add();
         }
         if (command.StartsWith("back"))
         {
             NoteNavigator.GoBack();
         }
         RefreshWebView();
     }
     else
     {
         Device.OpenUri(new Uri(e.Url));
     }
 }