public void AddNote(TextSelection range, string name) { int startOffset = TextBox.MainControl.Document.ContentStart.GetOffsetToPosition(range.Start); // new TextRange(TextBox.MainControl.Document.ContentStart, TextBox.MainControl.Selection.Start).Text.Length; int endOffset = TextBox.MainControl.Document.ContentStart.GetOffsetToPosition(range.End); //new TextRange(TextBox.MainControl.Document.ContentStart, TextBox.MainControl.Selection.End).Text.Length; string text = range.Text; NotesBrowser.AddItem(new Note(name, text, new TextRange(range.Start, range.End), startOffset, endOffset)); }
void ButtonAddNote_MouseUp(object sender, MouseButtonEventArgs e) { var range = TextBox.MainControl.Selection; string name = NotesBrowser.GenerateName("Note"); // range.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.PaleGreen); AddFlag(range, name); AddNote(range, name); NotesBrowser.MainControl.Items.Refresh(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Notes = ((Controls.NotesBrowser)(target)); return; case 2: this.TextBox = ((Controls.SuperRichTextBox)(target)); return; case 3: this.Format = ((Controls.FormatPanel)(target)); return; } this._contentLoaded = true; }