コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 protected override void CopyContentFromOverride(DocumentElement fromElement)
 {
     CustomRangeStart other = (CustomRangeStart)fromElement;
     // Copy your custom properties from other to this here.
 }