public void AddParagraph(string text) { Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); rtb.Text = Rtf; rtb.Document.Blocks.Add(new Paragraph(new Run(text))); Rtf = rtb.Text; }
public TextNotePlusView() { InitializeComponent(); RichTextBox.IsEnabled = false; MainGrid = SizableContent; TextBox = RichTextBox; }
public override TextNote ConvertToTextNote() { TextNote newNote = new TextNote() { ExplicitName = this.ExplicitName, IsExpanded = this.IsExpanded, IsSelected = this.IsSelected }; newNote.Ideas = Ideas; newNote.AddParagraph(Now.ToString($"Now: dddd, MMMM d{(NowYear ? ", yyy" : string.Empty)}{(NowTime ? " h:mm tt" : string.Empty)}")); newNote.AddParagraph(string.Empty); newNote.AddParagraph("Events:"); foreach (var timelineEvent in Events) { newNote.AddParagraph(timelineEvent.Date.ToString($"dddd, MMMM dd{(timelineEvent.UseYear ? ", yyy" : string.Empty)}{(timelineEvent.UseTime ? " h:mm tt" : string.Empty)}")); newNote.AddParagraph(string.Empty); Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); rtb.Text = timelineEvent.Rtf; rtb.SelectAll(); rtb.Copy(); newNote.PasteToRtf(); } return(newNote); }
public void PasteToRtf() { Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); rtb.Text = Rtf; rtb.Selection.Select(rtb.Document.ContentEnd, rtb.Document.ContentEnd); rtb.Paste(); Rtf = rtb.Text; }
private void EntryContent_GotFocus(object sender, RoutedEventArgs e) { if (sender is TextBox textBox) { lastFocusedContentBox = textBox; } else if (sender is Xceed.Wpf.Toolkit.RichTextBox rtb) { lastFocusedRichTextBox = rtb; } ViewModel.ContentFocused = true; }
private void EntryContent_LostFocus(object sender, RoutedEventArgs e) { if (sender == lastFocusedContentBox) { lastFocusedContentBox = null; } if (sender == lastFocusedRichTextBox) { lastFocusedRichTextBox = null; } if (lastFocusedContentBox == null && lastFocusedRichTextBox == null) { ViewModel.ContentFocused = false; ViewModel.ContentSelected = false; } }
public override TextNote ConvertToTextNote() { TextNote newNote = new TextNote() { ExplicitName = this.ExplicitName, IsExpanded = this.IsExpanded, IsSelected = this.IsSelected }; newNote.Ideas = Ideas; Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); string text = GetFileNameAsLink(); Hyperlink link = new Hyperlink(new Run(text), rtb.CaretPosition.GetInsertionPosition(LogicalDirection.Forward)); link.NavigateUri = new Uri(text); link.RequestNavigate += (s, args) => Process.Start(args.Uri.ToString()); newNote.Rtf = rtb.Text; return(newNote); }
public override TextNote ConvertToTextNote() { TextNote newNote = new TextNote() { ExplicitName = this.ExplicitName, IsExpanded = this.IsExpanded, IsSelected = this.IsSelected }; newNote.Ideas = Ideas; newNote.AddParagraph(Now.ToString($"Now: dddd, MMMM d{(NowYear ? ", yyy" : string.Empty)}{(NowTime ? " h:mm tt" : string.Empty)}")); newNote.AddParagraph(string.Empty); newNote.AddParagraph("Events:"); foreach (var timelineEvent in Events) { newNote.AddParagraph(timelineEvent.Date.ToString($"dddd, MMMM dd{(timelineEvent.UseYear ? ", yyy" : string.Empty)}{(timelineEvent.UseTime ? " h:mm tt" : string.Empty)}")); newNote.AddParagraph(string.Empty); Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); rtb.Text = timelineEvent.Rtf; rtb.SelectAll(); rtb.Copy(); newNote.PasteToRtf(); } return newNote; }
public TextNote NewTextNote(IdeaNote parent, int index) { TextNote newNote = new TextNote(); Application.Current.Dispatcher.Invoke(() => { Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); rtb.SelectAll(); if (Settings.Default.UseDefaultFont && Settings.Default.DefaultFont != null) { rtb.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, (FontFamily)Settings.Default.DefaultFont); if (Settings.Default.DefaultFontSize > 0) rtb.Selection.ApplyPropertyValue(TextElement.FontSizeProperty, Settings.Default.DefaultFontSize); } else if (Settings.Default.MostRecentFont != null) { rtb.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, (FontFamily)Settings.Default.MostRecentFont); rtb.Selection.ApplyPropertyValue(TextElement.FontSizeProperty, Settings.Default.MostRecentFontSize); } newNote.Rtf = rtb.Text; }); AddNote(newNote, parent, index); return newNote; }
public void ExportTextNote(string extension, string dataType) { if (CurrentIdeaNote == null || CurrentIdeaNote.IdeaNoteType != nameof(TextNote)) return; SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = Path.Combine(saveDialog.InitialDirectory, $"{CurrentIdeaNote.Name}.{extension}"); saveDialog.DefaultExt = $".{extension}"; saveDialog.Filter = $"{(extension == "rtf" ? "Rich " : string.Empty)}Text Files|*.{extension}|All Files|*.*"; saveDialog.OverwritePrompt = true; saveDialog.AddExtension = true; if (saveDialog.ShowDialog() == true) { using (FileStream stream = new FileStream(saveDialog.FileName, FileMode.OpenOrCreate)) { Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); rtb.Text = ((TextNote)CurrentIdeaNote).Rtf; TextRange text = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd); text.Save(stream, dataType); } } }
public void ConvertToTextNote() { if (CurrentIdeaNote == null) return; UndoService.Current[SaveFile].BeginChangeSetBatch("Convert to TextNote", false); TextNote note = CurrentIdeaNote.ConvertToTextNote(); Xceed.Wpf.Toolkit.RichTextBox rtb = new Xceed.Wpf.Toolkit.RichTextBox(); rtb.Text = note.Rtf; rtb.SelectAll(); if (Settings.Default.UseDefaultFont) rtb.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, (FontFamily)Settings.Default.DefaultFont); else rtb.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, (FontFamily)Settings.Default.MostRecentFont); note.Rtf = rtb.Text; ReplaceNote(CurrentIdeaNote, note); CurrentIdeaNote = note; UndoService.Current[SaveFile].EndChangeSetBatch(); }