private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            Paragraph urlMessageParagraph = new Paragraph();

            try
            {
                Uri    tempUri   = null;
                Run    temprun   = null;
                string urlString = string.Empty;
                urlString = txtURL.Text.ToString().Trim();
                if (urlString != string.Empty || urlString != "")
                {
                    if (IsHyperlink(urlString))
                    {
                        tempUri = new Uri(urlString, UriKind.RelativeOrAbsolute);

                        if (!tempUri.IsAbsoluteUri)
                        {
                            tempUri = new Uri(@"http://" + urlString, UriKind.Absolute);
                        }
                        if (tempUri != null && tempUri.ToString() != string.Empty)
                        {
                            if (string.IsNullOrEmpty(txtText.Text))
                            {
                                txtText.Text = "Click Here";
                            }
                            //temprun = new Run(txtText.Text);
                            //Hyperlink hl = new Hyperlink(temprun);
                            //hl.Foreground = Brushes.Blue;
                            //hl.NavigateUri = new Uri(tempUri.ToString());
                            //urlMessageParagraph.Inlines.Add(hl);
                            LinkSelected.Invoke(txtText.Text, tempUri);
                            editorDataContext.contextMenuUC.StaysOpen = false;
                            editorDataContext.contextMenuUC.IsOpen    = false;
                        }
                        else
                        {
                            lblError.Content = "It is not a Valid URL  '" + txtURL.Text.ToString() + "'";
                            txtURL.Focus();
                        }
                    }
                    else
                    {
                        lblError.Content = "It is not a Valid URL  '" + txtURL.Text.ToString() + "'";
                        txtURL.Focus();
                    }
                }
                else
                {
                    lblError.Content = "Enter the URL";
                    txtURL.Focus();
                }
            }
            catch //(Exception generalException)
            {
            }
        }
Ejemplo n.º 2
0
 internal virtual void OnLinkSelected(FrameworkElement link)
 {
     LinkSelected?.Invoke(this, new LinkSelectedEventArgs(link));
 }
Ejemplo n.º 3
0
        private void LinkCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var link = (Page)e.AddedItems.First();

            LinkSelected?.Invoke(link.Id);
        }