async void OnSaveAsAppBarButtonClick(object sender, RoutedEventArgs args) { FileSavePicker picker = new FileSavePicker(); picker.DefaultFileExtension = ".rtf"; picker.FileTypeChoices.Add("Rich Text Document", new List <string> { ".rtf" }); picker.FileTypeChoices.Add("Text Document", new List <string> { ".txt" }); StorageFile storageFile = await picker.PickSaveFileAsync(); // If user presses Cancel, result is null if (storageFile == null) { return; } TextGetOptions textOptions = TextGetOptions.None; if (storageFile.ContentType != "text/plain") { textOptions = TextGetOptions.FormatRtf; } string message = null; try { IRandomAccessStream stream = await storageFile.OpenAsync(FileAccessMode.ReadWrite); richEditBox.Document.SaveToStream(textOptions, stream); } catch (Exception exc) { message = exc.Message; } if (message != null) { MessageDialog msgdlg = new MessageDialog("The file could not be saved. " + "Windows reports the following error: " + message, "RichTextEditor"); await msgdlg.ShowAsync(); } }
private async void Save_Click(object sender, RoutedEventArgs e) { string editorcontent = ""; Windows.UI.Text.TextGetOptions textGetOptions = new TextGetOptions(); homeditor.Document.GetText(textGetOptions, out editorcontent); var Announcement = await Database.Context.Notes.SingleOrDefaultAsync(m => m.Id == App.thisnote.Id); if (Announcement != null) { Announcement.Title = Titlebox.Text; Announcement.Content = editorcontent; await Database.Context.SaveChangesAsync(); } HomeFrame.Navigate(typeof(Home)); }
private async void Notes_Click(object sender, RoutedEventArgs e) { string editorcontent = ""; Windows.UI.Text.TextGetOptions textGetOptions = new TextGetOptions(); editor.Document.GetText(textGetOptions, out editorcontent); if (title.Text != null || editorcontent != null) { var n = new Note { Id = App.NewNoteId, UserId = App.ThisUserId, Title = title.Text, Content = editorcontent, }; Database.Context.Notes.Add(n); await Database.Context.SaveChangesAsync(); } }
public static TextGetOptions ToUwp(this QuickPadTextGetOptions options) { return(TextGetOptions.TryParse <TextGetOptions>(options.ToString(), out var result) ? result : default);
public void SaveToStream(TextGetOptions options, Windows.Storage.Streams.IRandomAccessStream value) { throw new NotImplementedException(); }
public void GetText(TextGetOptions options, out string value) { value = Text; }
public void GetText(TextGetOptions options, out string value) { throw new NotImplementedException(); }