Exemplo n.º 1
0
 private static Hyperlink SelectedHyperlink(RichTextBox textBox)
 {
     if (textBox.Selection.IsEmpty)
     {
         return(DialogHyperlink.SelectedHyperlink(textBox.Selection.Start));
     }
     else
     {
         Hyperlink h1 = DialogHyperlink.SelectedHyperlink(textBox.Selection.Start);
         Hyperlink h2 = DialogHyperlink.SelectedHyperlink(textBox.Selection.End);
         if (h1 == h2 && h1 != null)
         {
             return(h1);
         }
         if (h1 != null)
         {
             return(h1);
         }
         if (h2 != null)
         {
             return(h2);
         }
         h1 = DialogHyperlink.FindHyperlink(textBox.Selection.Start, LogicalDirection.Forward);
         h2 = DialogHyperlink.FindHyperlink(textBox.Selection.End, LogicalDirection.Backward);
         if (h1 == h2)
         {
             return(h1);
         }
     }
     return(null);
 }