private void UpdateTextBoxText() { string textInRange; CustomRangeStart rangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType<CustomRangeStart>().FirstOrDefault(); if (rangeStart != null) { CustomRangeEnd rangeEnd = (CustomRangeEnd)rangeStart.End; DocumentPosition start = new DocumentPosition(this.radRichTextBox.Document); start.MoveToInline(rangeStart); DocumentPosition end = new DocumentPosition(this.radRichTextBox.Document); end.MoveToInline(rangeEnd); DocumentSelection selection = new DocumentSelection(this.radRichTextBox.Document); selection.SetSelectionStart(start); selection.AddSelectionEnd(end); string text = selection.GetSelectedText(); textInRange = text; } else { textInRange = string.Empty; } this.suppressUpdate = true; this.textBox.Text = textInRange; this.suppressUpdate = false; }
private void textBox_TextChanged(object sender, TextChangedEventArgs e) { if (suppressUpdate) { return; } CustomRangeStart rangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType <CustomRangeStart>().FirstOrDefault(); if (rangeStart != null) { CustomRangeEnd rangeEnd = (CustomRangeEnd)rangeStart.End; DocumentPosition start = new DocumentPosition(this.radRichTextBox.Document); start.MoveToInline(rangeStart); DocumentPosition end = new DocumentPosition(this.radRichTextBox.Document); end.MoveToInline(rangeEnd); DocumentSelection selection = this.radRichTextBox.Document.Selection;// new DocumentSelection(this.radRichTextBox.Document); selection.SetSelectionStart(start); selection.AddSelectionEnd(end); this.radRichTextBox.Insert(this.textBox.Text); } }
private void UpdateTextBoxText() { string textInRange; CustomRangeStart rangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType <CustomRangeStart>().FirstOrDefault(); if (rangeStart != null) { CustomRangeEnd rangeEnd = (CustomRangeEnd)rangeStart.End; DocumentPosition start = new DocumentPosition(this.radRichTextBox.Document); start.MoveToInline(rangeStart); DocumentPosition end = new DocumentPosition(this.radRichTextBox.Document); end.MoveToInline(rangeEnd); DocumentSelection selection = new DocumentSelection(this.radRichTextBox.Document); selection.SetSelectionStart(start); selection.AddSelectionEnd(end); string text = selection.GetSelectedText(); textInRange = text; } else { textInRange = string.Empty; } this.suppressUpdate = true; this.textBox.Text = textInRange; this.suppressUpdate = false; }
private string ExportAnnotationRangeFragment(RadDocument document, string semanticRangeName) { RecipeRangeStart semanticRangestart = null; RecipeRangeEnd semanticRangeEnd = null; foreach (RecipeRangeStart rangeStart in document.GetAnnotationMarkersOfType<RecipeRangeStart>()) { if (rangeStart.Name == semanticRangeName) { semanticRangestart = rangeStart; semanticRangeEnd = (RecipeRangeEnd)rangeStart.End; } } if (semanticRangestart != null && semanticRangeEnd != null) { DocumentPosition startPosition = new DocumentPosition(document); startPosition.MoveToInline((InlineLayoutBox)semanticRangestart.FirstLayoutBox, 0); DocumentPosition endPosition = new DocumentPosition(document); endPosition.MoveToInline((InlineLayoutBox)semanticRangeEnd.FirstLayoutBox, 0); DocumentSelection selection = new DocumentSelection(document); selection.SetSelectionStart(startPosition); selection.AddSelectionEnd(endPosition); DocumentFragment fragment = new DocumentFragment(selection); RadDocument fragmentDocument = fragment.ToDocument(); HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider(); htmlFormatProvider.ExportSettings = new HtmlExportSettings(); htmlFormatProvider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment; htmlFormatProvider.ExportSettings.StylesExportMode = StylesExportMode.Inline; htmlFormatProvider.ExportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles; return htmlFormatProvider.Export(fragmentDocument); } return string.Empty; }