Exemplo n.º 1
0
        private void ValidateHyperlink()
        {
            bool validText = 0 < this.HyperlinkText.Trim().Length;

            this.errorInfo.Clear();
            if (!validText)
            {
                this.errorInfo["HyperlinkText"] = Properties.Resources.ErrorHyperlinkText;
            }
            bool validUrl = DialogHyperlink.IsValidUrl(this.HyperlinkUrl);

            if (!validUrl)
            {
                this.errorInfo["HyperlinkUrl"] = Properties.Resources.ErrorHyperlinkUrl;
            }
            this.IsValidHyperlink = validText && validUrl;
            if (0 < this.errorInfo.Count)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (string error in this.errorInfo.Values)
                {
                    stringBuilder.AppendLine(error);
                }
                this.Error = stringBuilder.ToString();
            }
            else
            {
                this.Error = string.Empty;
            }
        }
Exemplo n.º 2
0
 private void ButtonOkClick(object sender, RoutedEventArgs e)
 {
     try {
         if (0 < this.HyperlinkText.Length && DialogHyperlink.IsValidUrl(this.HyperlinkUrl))
         {
             this.textBox.Selection.Text = this.HyperlinkText;
             Hyperlink  h       = new Hyperlink(this.textBox.Selection.Start, this.textBox.Selection.End);
             UriBuilder builder = new UriBuilder(this.HyperlinkUrl);
             h.NavigateUri = new Uri(builder.Uri.AbsoluteUri);
             this.Close();
         }
     } catch (Exception exception) {
         App.Mainframe.ReportException(exception);
     }
 }