コード例 #1
0
        private void CreateNodeTitle(IGlymaNode node, ref Paragraph paragraph)
        {
            if (node.NodeType.Equals(MapManager.NodeTypes["CompendiumMapNode"]))
            {
                var text = new Span(string.IsNullOrEmpty(node.Name) ? "(No Name)" : node.Name)
                {
                    //ForeColor = Colors.DodgerBlue,
                    UnderlineDecoration = UnderlineTypes.Line
                };

                var hyperlinkStart = new HyperlinkRangeStart();
                var hyperlinkEnd   = new HyperlinkRangeEnd();
                hyperlinkEnd.PairWithStart(hyperlinkStart);
                var hyperlinkInfo = new HyperlinkInfo
                {
                    NavigateUri = node.Id.ToLongString(),
                    Target      = HyperlinkTargets.Self,
                    IsAnchor    = true
                };
                hyperlinkStart.HyperlinkInfo = hyperlinkInfo;

                paragraph.Inlines.Add(hyperlinkStart);
                paragraph.Inlines.Add(text);
                paragraph.Inlines.Add(hyperlinkEnd);
            }
            else
            {
                var text = new Span(node.Name);
                paragraph.Inlines.Add(text);
            }
        }
コード例 #2
0
    /// <summary>
    /// 获取超链接解析后的最后输出文本
    /// </summary>
    /// <returns></returns>
    protected virtual string GetOutputText(string outputText)
    {
        s_TextBuilder.Length = 0;
        m_HrefInfos.Clear();
        var indexText = 0;

        foreach (Match match in s_HrefRegex.Matches(outputText))
        {
            s_TextBuilder.Append(outputText.Substring(indexText, match.Index - indexText));
            s_TextBuilder.Append("<color=blue>");  // 超链接颜色

            var group    = match.Groups[1];
            var hrefInfo = new HyperlinkInfo
            {
                startIndex = s_TextBuilder.Length * 4, // 超链接里的文本起始顶点索引
                endIndex   = (s_TextBuilder.Length + match.Groups[2].Length - 1) * 4 + 3,
                name       = group.Value
            };
            m_HrefInfos.Add(hrefInfo);

            s_TextBuilder.Append(match.Groups[2].Value);
            s_TextBuilder.Append("</color>");
            indexText = match.Index + match.Length;
        }
        s_TextBuilder.Append(outputText.Substring(indexText, outputText.Length - indexText));
        return(s_TextBuilder.ToString());
    }
コード例 #3
0
 public void AddNewHyperlink()
 {
     #region radspreadsheet-features-hyperlink_3
     Workbook             workbook             = new Workbook();
     Worksheet            worksheet            = workbook.Worksheets.Add();
     HyperlinkInfo        webAddres            = HyperlinkInfo.CreateHyperlink("http://google.com", "Google");
     CellIndex            a1Index              = new CellIndex(0, 0);
     SpreadsheetHyperlink spreadsheetHyperlink = worksheet.Hyperlinks.Add(a1Index, webAddres);
     #endregion
 }
コード例 #4
0
        private async Task DownloadFileAsync(HyperlinkInfo linkInfo, Action <string> fileDownloadedCallback)
        {
            string filename = GetValidFileName(linkInfo.Title);

            using (var client = new WebClient())
            {
                Uri uri = new Uri(linkInfo.Link);
                client.DownloadFileCompleted += DownloadFileCompleted(fileDownloadedCallback, filename);
                await client.DownloadFileTaskAsync(uri, filename);
            }
        }
        protected override void ExportFieldCodeStartRun(FieldCodeStartRun run)
        {
            base.ExportFieldCodeStartRun(run);
            HyperlinkInfo hyperlinkInfo = GetHyperlinkInfo(run);

            if (hyperlinkInfo == null)
            {
                return;
            }

            DocumentContentWriter.Write(string.Format("[url={0}]", hyperlinkInfo.NavigateUri));
            hyperlinkExporting = true;
        }
        HyperlinkInfo GetHyperlinkInfo(TextRun run)
        {
            RunIndex runIndex = run.GetRunIndex();
            Field    field    = PieceTable.FindFieldByRunIndex(runIndex);

            System.Diagnostics.Debug.Assert(field != null);
            HyperlinkInfo hyperlinkInfo = null;

            if (PieceTable.HyperlinkInfos.TryGetHyperlinkInfo(field.Index, out hyperlinkInfo))
            {
                return(hyperlinkInfo);
            }
            return(null);
        }
コード例 #7
0
        protected override void ExportFieldCodeStartRun(FieldCodeStartRun run)
        {
            base.ExportFieldCodeStartRun(run);

            HyperlinkInfo hyperlinkInfo = GetHyperlinkInfo(run);

            if (hyperlinkInfo == null)
            {
                return;
            }

            DocumentContentWriter.Write($"<a href=\"{hyperlinkInfo.NavigateUri}\">");
            hyperlinkExporting = true;
        }
コード例 #8
0
        //get an instance of a worksheet. May be link to the UI documentation that shows:
        //Worksheet worksheet = this.radSpreadsheet.ActiveWorksheet;

        public void CreateHyperlink()
        {
            //Create a hyperlink to a web address:
            #region radspreadsheet-features-hyperlink_0
            HyperlinkInfo webAddres = HyperlinkInfo.CreateHyperlink("http://google.com", "Google");
            #endregion

            //Create a hyperlink to a cell range somewhere in the document:
            #region radspreadsheet-features-hyperlink_1
            HyperlinkInfo inDocument = HyperlinkInfo.CreateInDocumentHyperlink("A1:B3", "Go to A1:B3");
            #endregion

            //Create a hyperlink to an email address:
            #region radspreadsheet-features-hyperlink_2
            HyperlinkInfo mailto = HyperlinkInfo.CreateMailtoHyperlink("*****@*****.**", "someSubject", "Mail to someOne");
            #endregion
        }
コード例 #9
0
        //------------------------------------------------------
        string CalcHrefInfo(string originText, int lineCount)
        {
            s_TextBuilder.Length = 0;
            var indexText = 0;

            m_HrefInfos.Clear();

            foreach (Match match in s_HrefRegex.Matches(originText))
            {
                s_TextBuilder.Append(originText.Substring(indexText, match.Index - indexText));
                //Debug.Log("CalcHrefInfo line:" + lineCount);

                if (lineCount > 1)
                {
                    s_TextBuilder.Append("<color=");  // 超链接颜色
                    s_TextBuilder.Append(m_LinkColor);
                    s_TextBuilder.Append(">");
                }

                var linkGroup = match.Groups[1];

                var hrefInfo = new HyperlinkInfo
                {
                    startIndex = s_TextBuilder.Length * 4, // 超链接里的文本起始顶点索引
                    endIndex   = (s_TextBuilder.Length + match.Groups[2].Length - 1) * 4 + 3,
                    name       = linkGroup.Value,
                };

                //Debug.Log("startIndex:" + hrefInfo.startIndex + ",endIndex:" + hrefInfo.endIndex + ",name:" + hrefInfo.name);
                m_HrefInfos.Add(hrefInfo);

                if (lineCount <= 1)                  //单行的时候,再计算完startIndex后,再进行添加富文本
                {
                    s_TextBuilder.Append("<color="); // 超链接颜色
                    s_TextBuilder.Append(m_LinkColor);
                    s_TextBuilder.Append(">");
                }
                s_TextBuilder.Append(match.Groups[2].Value);
                s_TextBuilder.Append("</color>");
                indexText = match.Index + match.Length;
            }
            s_TextBuilder.Append(originText.Substring(indexText, originText.Length - indexText));
            return(s_TextBuilder.ToString());;
        }
コード例 #10
0
        internal static long HLINK(BinaryWriter output, HyperlinkInfo link)
        {
            long position = output.BaseStream.Position;
            int  num      = 40 + (link.Label.Length + 1) * 2 + (link.URL.Length + 1) * 2;

            if (!link.IsBookmark)
            {
                num += 16;
            }
            WriteHeader(output, 440, num);
            link.WriteToStream(output);
            output.Write(new Guid("79EAC9D0-BAF9-11CE-8C82-00AA004BA90B").ToByteArray(), 0, 16);
            output.Write(2u);
            if (link.IsBookmark)
            {
                output.Write(28u);
            }
            else
            {
                output.Write(23u);
            }
            output.Write((uint)(link.Label.Length + 1));
            byte[] bytes = m_uniEncoding.GetBytes(link.Label);
            output.Write(bytes, 0, bytes.Length);
            output.Write((ushort)0);
            if (!link.IsBookmark)
            {
                output.Write(new Guid("79EAC9E0-BAF9-11CE-8C82-00AA004BA90B").ToByteArray(), 0, 16);
            }
            if (link.IsBookmark)
            {
                output.Write((uint)(link.URL.Length + 1));
            }
            else
            {
                output.Write((uint)((link.URL.Length + 1) * 2));
            }
            bytes = m_uniEncoding.GetBytes(link.URL);
            output.Write(bytes, 0, bytes.Length);
            output.Write((ushort)0);
            return(output.BaseStream.Position - position);
        }
コード例 #11
0
        public Hyperlink CreateHyperlink(string text, string anchorId, string style = null, int?size = null)
        {
            RunProperties rp = new RunProperties();

            if (!string.IsNullOrEmpty(style))
            {
                rp.Append(
                    new RunStyle()
                {
                    Val = style,
                });
            }

            if (size != null)
            {
                rp.Append(
                    new FontSize()
                {
                    Val = new StringValue((2 * size).ToString())
                });
            }

            // Ensure a hyperlink info is recorded if needed for future use
            HyperlinkInfo hyperlinkInfo = this.FindOrAddInternalId(anchorId);

            Hyperlink hyperlink = new Hyperlink()
            {
                Anchor = anchorId
            };

            hyperlink.Append(new ProofError()
            {
                Type = ProofingErrorValues.GrammarStart
            });
            hyperlink.Append(
                new Run(rp, new Text(text)));

            return(hyperlink);
        }
コード例 #12
0
        //get an instance of a worksheet. May be link to the UI documentation that shows:
        //Worksheet worksheet = this.radSpreadsheet.ActiveWorksheet;

        public void CreateHyperlink()
        {
            //Create a hyperlink to a web address:
            #region radspreadprocessing-features-hyperlink_0
            HyperlinkInfo webAddres = HyperlinkInfo.CreateHyperlink("http://telerik.com", "Telerik");
            #endregion

            //Create a hyperlink to a cell range somewhere in the document:
            #region radspreadprocessing-features-hyperlink_1
            HyperlinkInfo inDocument = HyperlinkInfo.CreateInDocumentHyperlink("A1:B3", "Go to A1:B3");
            #endregion

            //Create a hyperlink to an email address:
            #region radspreadprocessing-features-hyperlink_2
            HyperlinkInfo mailto = HyperlinkInfo.CreateMailtoHyperlink("*****@*****.**", "someSubject", "Mail to someOne");
            #endregion

            #region radspreadprocessing-features-hyperlink_3
            CellIndex            a1Index = new CellIndex(0, 0);
            SpreadsheetHyperlink spreadsheetHyperlink = worksheet.Hyperlinks.Add(a1Index, webAddres);
            #endregion
        }
コード例 #13
0
        private void CreateLink(string link, ref Paragraph paragraph)
        {
            var hyperlinkStart = new HyperlinkRangeStart();
            var hyperlinkEnd   = new HyperlinkRangeEnd();

            hyperlinkEnd.PairWithStart(hyperlinkStart);
            link = link.Replace(" ", "20%");
            Uri uri;

            if (Uri.TryCreate(link, UriKind.Absolute, out uri))
            {
                var hyperlinkInfo = new HyperlinkInfo
                {
                    NavigateUri = link,
                    Target      = HyperlinkTargets.Blank
                };
                hyperlinkStart.HyperlinkInfo = hyperlinkInfo;

                paragraph.Inlines.Add(hyperlinkStart);
                var spanLink = new Span(link)
                {
                    FontSize            = 12,
                    ForeColor           = Colors.DodgerBlue,
                    UnderlineDecoration = UnderlineTypes.Line
                };
                paragraph.Inlines.Add(spanLink);
                paragraph.Inlines.Add(hyperlinkEnd);
            }
            else
            {
                var spanLink = new Span(link)
                {
                    FontSize            = 12,
                    ForeColor           = Colors.DodgerBlue,
                    UnderlineDecoration = UnderlineTypes.Line
                };
                paragraph.Inlines.Add(spanLink);
            }
        }
コード例 #14
0
        private void ShowDialogInternal(string text, HyperlinkInfo currentHyperlinkInfo, IEnumerable <string> bookmarkNames, Action <string, HyperlinkInfo> insertHyperlinkCallback, Action cancelCallback, RadRichTextBox owner)
        {
            this.ResetDialog();

            this.comboBookmarks.DataContext = bookmarkNames;
            this.insertHyperlinkCallback    = insertHyperlinkCallback;
            this.cancelCallback             = cancelCallback;
            this.callbackCalled             = false;
            this.SetOwner(owner);

            if (text == null)
            {
                this.txtText.IsEnabled = false;
                this.txtText.Text      = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_SelectionInDocument");
            }
            else
            {
                this.txtText.IsEnabled = true;
                this.txtText.Text      = text;
            }

            if (currentHyperlinkInfo != null)
            {
                this.PreselectTarget(currentHyperlinkInfo.Target);

                if (!currentHyperlinkInfo.IsAnchor)
                {
                    this.txtAddress.Text = (currentHyperlinkInfo.NavigateUri != null)? currentHyperlinkInfo.NavigateUri: string.Empty;
                }
                else
                {
                    this.PreselectBookmark(currentHyperlinkInfo.NavigateUri);
                    this.rbBookmark.IsChecked = true;
                    this.ChangeUriUIVisibility(true);
                }
            }

            this.ShowDialog();
        }
コード例 #15
0
        public void AddAnchorAround(OpenXmlElement parent, string id, params OpenXmlElement[] children)
        {
            HyperlinkInfo hyperlinkInfo = this.FindOrAddInternalId(id);

            if (hyperlinkInfo.AnchorCreated)
            {
                throw new Exception("An anchor has already been created for this id");
            }

            hyperlinkInfo.AnchorCreated = true;

            var bookmarkStart = new BookmarkStart()
            {
                Id   = hyperlinkInfo.InternalId.ToString(),
                Name = id
            };

            parent.Append(bookmarkStart);
            parent.Append(children);
            parent.Append(new BookmarkEnd()
            {
                Id = bookmarkStart.Id
            });
        }
コード例 #16
0
        private void OnOkClicked()
        {
            txtValidation.Text = string.Empty;

            if (txtText.IsEnabled)
            {
                if (string.IsNullOrEmpty(txtText.Text))
                {
                    txtValidation.Text = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_InvalidText");
                    return;
                }
            }

            bool isUrl = (this.rbURL.IsChecked == true);

            if (isUrl)
            {
                if (string.IsNullOrEmpty(txtAddress.Text.Trim()))
                {
                    txtValidation.Text = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_InvalidAddress");
                    return;
                }
            }
            else
            {
                if (comboBookmarks.SelectedValue == null)
                {
                    txtValidation.Text = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_InvalidBookmark");
                    return;
                }
            }

            HyperlinkInfo hyperlinkInfo = new HyperlinkInfo();

            if (isUrl)
            {
                string navigateUri = txtAddress.Text.Trim();
                if (!Regex.IsMatch(navigateUri, this.HyperlinkPattern))
                {
                    navigateUri = InsertHyperlinkDialog.httpProtocol + navigateUri;
                }
                hyperlinkInfo.NavigateUri = navigateUri;
            }
            else
            {
                hyperlinkInfo.NavigateUri = (string)comboBookmarks.SelectedValue;
                hyperlinkInfo.IsAnchor = true;
            }

            string targetStr = ((RadComboBoxItem)this.comboTarget.SelectedItem).Tag.ToString();
            hyperlinkInfo.Target = (HyperlinkTargets)Enum.Parse(typeof(HyperlinkTargets), targetStr, false);

            string hyperlinkText = this.txtText.IsEnabled ? this.txtText.Text : string.Empty;
            if (this.insertHyperlinkCallback != null)
            {
                this.insertHyperlinkCallback(hyperlinkText, hyperlinkInfo);
            }
            this.callbackCalled = true;
            this.Close();
        }
コード例 #17
0
 /// <summary>
 /// Shows the dialog for inserting hyperlinks.
 /// </summary>
 /// <param name="text">The text of the hyperlink.</param>
 /// <param name="currentHyperlinkInfo">The current hyperlink info. Null if we are not in edit mode.</param>
 /// <param name="bookmarkNames">Names of all existing bookmarks.</param>
 /// <param name="insertHyperlinkCallback">The callback that will be called on confirmation to insert the hyperlink.</param>
 /// <param name="cancelCallback">The callback that will be called on cancelation.</param>
 public void ShowDialog(string text, HyperlinkInfo currentHyperlinkInfo, IEnumerable<string> bookmarkNames, Action<string, HyperlinkInfo> insertHyperlinkCallback, Action cancelCallback)
 {
     this.ShowDialogInternal(text, currentHyperlinkInfo, bookmarkNames, insertHyperlinkCallback, cancelCallback, null);
 }
コード例 #18
0
        private void ShowDialogInternal(string text, HyperlinkInfo currentHyperlinkInfo, IEnumerable<string> bookmarkNames, Action<string, HyperlinkInfo> insertHyperlinkCallback, Action cancelCallback, RadRichTextBox owner)
        {
            this.ResetDialog();

            this.comboBookmarks.DataContext = bookmarkNames;
            this.insertHyperlinkCallback = insertHyperlinkCallback;
            this.cancelCallback = cancelCallback;
            this.callbackCalled = false;
            this.SetOwner(owner);

            if (text == null)
            {
                this.txtText.IsEnabled = false;
                this.txtText.Text = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_SelectionInDocument");
            }
            else
            {
                this.txtText.IsEnabled = true;
                this.txtText.Text = text;
            }

            if (currentHyperlinkInfo != null)
            {
                this.PreselectTarget(currentHyperlinkInfo.Target);

                if (!currentHyperlinkInfo.IsAnchor)
                {
                    this.txtAddress.Text = (currentHyperlinkInfo.NavigateUri != null)? currentHyperlinkInfo.NavigateUri: string.Empty;
                }
                else
                {
                    this.PreselectBookmark(currentHyperlinkInfo.NavigateUri);
                    this.rbBookmark.IsChecked = true;
                    this.ChangeUriUIVisibility(true);
                }
            }

            this.ShowDialog();
        }
コード例 #19
0
 /// <summary>
 /// Shows the dialog for inserting hyperlinks.
 /// </summary>
 /// <param name="text">The text of the hyperlink.</param>
 /// <param name="currentHyperlinkInfo">The current hyperlink info. Null if we are not in edit mode.</param>
 /// <param name="bookmarkNames">Names of all existing bookmarks.</param>
 /// <param name="insertHyperlinkCallback">The callback that will be called on confirmation to insert the hyperlink.</param>
 /// <param name="cancelCallback">The callback that will be called on cancelation.</param>
 public void ShowDialog(string text, HyperlinkInfo currentHyperlinkInfo, IEnumerable <string> bookmarkNames, Action <string, HyperlinkInfo> insertHyperlinkCallback, Action cancelCallback)
 {
     this.ShowDialogInternal(text, currentHyperlinkInfo, bookmarkNames, insertHyperlinkCallback, cancelCallback, null);
 }
コード例 #20
0
        private void OnOkClicked()
        {
            txtValidation.Text = string.Empty;

            if (txtText.IsEnabled)
            {
                if (string.IsNullOrEmpty(txtText.Text))
                {
                    txtValidation.Text = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_InvalidText");
                    return;
                }
            }

            bool isUrl = (this.rbURL.IsChecked == true);

            if (isUrl)
            {
                if (string.IsNullOrEmpty(txtAddress.Text.Trim()))
                {
                    txtValidation.Text = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_InvalidAddress");
                    return;
                }
            }
            else
            {
                if (comboBookmarks.SelectedValue == null)
                {
                    txtValidation.Text = LocalizationManager.GetString("Documents_InsertHyperlinkDialog_InvalidBookmark");
                    return;
                }
            }

            HyperlinkInfo hyperlinkInfo = new HyperlinkInfo();

            if (isUrl)
            {
                string navigateUri = txtAddress.Text.Trim();
                if (!Regex.IsMatch(navigateUri, this.HyperlinkPattern))
                {
                    navigateUri = InsertHyperlinkDialog.httpProtocol + navigateUri;
                }
                hyperlinkInfo.NavigateUri = navigateUri;
            }
            else
            {
                hyperlinkInfo.NavigateUri = (string)comboBookmarks.SelectedValue;
                hyperlinkInfo.IsAnchor    = true;
            }

            string targetStr = ((RadComboBoxItem)this.comboTarget.SelectedItem).Tag.ToString();

            hyperlinkInfo.Target = (HyperlinkTargets)Enum.Parse(typeof(HyperlinkTargets), targetStr, false);

            string hyperlinkText = this.txtText.IsEnabled ? this.txtText.Text : string.Empty;

            if (this.insertHyperlinkCallback != null)
            {
                this.insertHyperlinkCallback(hyperlinkText, hyperlinkInfo);
            }
            this.callbackCalled = true;
            this.Close();
        }
コード例 #21
0
        private void CreateNodeTitle(IGlymaNode node, ref Paragraph paragraph)
        {
            if (node.NodeType.Equals(MapManager.NodeTypes["CompendiumMapNode"]))
            {
                var text = new Span(string.IsNullOrEmpty(node.Name) ? "(No Name)" : node.Name)
                {
                    //ForeColor = Colors.DodgerBlue,
                    UnderlineDecoration = UnderlineTypes.Line
                };

                var hyperlinkStart = new HyperlinkRangeStart();
                var hyperlinkEnd = new HyperlinkRangeEnd();
                hyperlinkEnd.PairWithStart(hyperlinkStart);
                var hyperlinkInfo = new HyperlinkInfo
                {
                    NavigateUri = node.Id.ToLongString(),
                    Target = HyperlinkTargets.Self,
                    IsAnchor = true
                };
                hyperlinkStart.HyperlinkInfo = hyperlinkInfo;

                paragraph.Inlines.Add(hyperlinkStart);
                paragraph.Inlines.Add(text);
                paragraph.Inlines.Add(hyperlinkEnd);
            }
            else
            {
                var text = new Span(node.Name);
                paragraph.Inlines.Add(text);
            }
        }
コード例 #22
0
        private void CreateLink(string link, ref Paragraph paragraph)
        {
            var hyperlinkStart = new HyperlinkRangeStart();
            var hyperlinkEnd = new HyperlinkRangeEnd();
            hyperlinkEnd.PairWithStart(hyperlinkStart);
            link = link.Replace(" ", "20%");
            Uri uri;
            if (Uri.TryCreate(link, UriKind.Absolute, out uri))
            {
                var hyperlinkInfo = new HyperlinkInfo
                {
                    NavigateUri = link,
                    Target = HyperlinkTargets.Blank
                };
                hyperlinkStart.HyperlinkInfo = hyperlinkInfo;

                paragraph.Inlines.Add(hyperlinkStart);
                var spanLink = new Span(link)
                {
                    FontSize = 12,
                    ForeColor = Colors.DodgerBlue,
                    UnderlineDecoration = UnderlineTypes.Line
                };
                paragraph.Inlines.Add(spanLink);
                paragraph.Inlines.Add(hyperlinkEnd);
            }
            else
            {
                var spanLink = new Span(link)
                {
                    FontSize = 12,
                    ForeColor = Colors.DodgerBlue,
                    UnderlineDecoration = UnderlineTypes.Line
                };
                paragraph.Inlines.Add(spanLink);
            }
        }
コード例 #23
0
        private void radRichTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Space)
            {
                double originalOffset = radRichTextBox.VerticalOffset;
                double originalY      = this.radRichTextBox.Document.CaretPosition.Location.Y;
                using (DocumentPosition originalCaretPosition =
                           new DocumentPosition(this.radRichTextBox.Document.CaretPosition, true))
                {
                    Paragraph currentParagraph = radRichTextBox.Document.CaretPosition.GetCurrentParagraph();

                    // remove any extant links, so that we can reparse them
                    IEnumerable <HyperlinkRangeStart> links = this.radRichTextBox.Document.CaretPosition
                                                              .GetCurrentParagraph().EnumerateChildrenOfType <HyperlinkRangeStart>();
                    foreach (HyperlinkRangeStart link in links)
                    {
                        RadDocumentEditor documentEditor = new RadDocumentEditor(radRichTextBox.Document);
                        documentEditor.DeleteAnnotationRange(link);
                    }

                    foreach (Inline inline in currentParagraph.Inlines)
                    {
                        string currentBook    = string.Empty;
                        uint   currentChapter = 0;
                        uint   currentVerse   = 0;


                        DocumentTextSearch search = new DocumentTextSearch(radRichTextBox.Document);
                        radRichTextBox.Document.CaretPosition.MoveToFirstPositionInParagraph();
                        DocumentPosition startDocPos = radRichTextBox.Document.CaretPosition;
                        radRichTextBox.Document.CaretPosition.MoveToLastPositionInParagraph();
                        DocumentPosition endDocPos = radRichTextBox.Document.CaretPosition;
                        radRichTextBox.Document.CaretPosition.MoveToFirstPositionInParagraph();

                        foreach (TextRange textRange in search.FindAll("(\\b((1|2|3|I|II|III|i|ii|iii) )?[\\w']+\\b\\s\\d+:\\d*[\\d \\-:]{0,300}\\d)|(, ?\\d+:\\d+)[\\-]*\\d*[\\d \\-:]{0,300}\\d|(, ?\\d+)[\\-]*\\d*|(v\\d{1,3})", startDocPos, originalCaretPosition))
                        {
                            // textRange will represent a string in one of the following formats:
                            // 1: book chapter:verse (with the possible suffix of "-{chapter:}verse
                            // 2: , chapter:verse (with the possible suffix of "-{chapter:}verse
                            // 3: , verse  (with the possible suffix of "-{chapter:}verse
                            // 4: v[verse]



                            RadDocumentEditor documentEditor = new RadDocumentEditor(radRichTextBox.Document);
                            radRichTextBox.Document.Selection.Ranges.Clear();
                            radRichTextBox.Document.Selection.AddSelectionStart(textRange.StartPosition);
                            radRichTextBox.Document.Selection.AddSelectionEnd(textRange.EndPosition);
                            string currentWord = radRichTextBox.Document.Selection.GetSelectedText();

                            Debug.WriteLine($"trying to parse {currentWord}");

                            ParsedReference result = ProcessReference(currentWord, currentBook, currentChapter, currentVerse);

                            if (result.WasParsedSuccessfully)
                            {
                                HyperlinkInfo info = new HyperlinkInfo()
                                {
                                    NavigateUri = $"kgb://book={result.Book}&chap={result.Chapter}&verse={result.Verse}",
                                    Target      = HyperlinkTargets.Blank,
                                    IsAnchor    = false
                                };


                                documentEditor.InsertHyperlink(info);
                                currentBook    = result.Book;
                                currentChapter = result.Chapter;
                                currentVerse   = result.Verse;
                            }

                            radRichTextBox.Document.Selection.Ranges.Clear();
                        }
                    }

                    radRichTextBox.Document.CaretPosition.MoveToPosition(originalCaretPosition);
                    radRichTextBox.Document.Selection.Ranges.Clear();
                    radRichTextBox.ActiveEditorPresenter.ScrollToVerticalOffset(originalOffset - originalY + this.radRichTextBox.Document.CaretPosition.Location.Y);
                }
            }
            radRichTextBox.UpdateEditorLayout(false);
        }