protected internal override void OnMouseDown(MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left && !e.Handled && LinkIsClickable()) { RequestNavigateEventArgs args = new RequestNavigateEventArgs(NavigateUri, TargetName); args.RoutedEvent = Hyperlink.RequestNavigateEvent; FrameworkElement element = e.Source as FrameworkElement; if (element != null) { // allow user code to handle the navigation request element.RaiseEvent(args); } if (!args.Handled) { try { Process.Start(new ProcessStartInfo { FileName = NavigateUri.ToString(), UseShellExecute = true }); } catch { // ignore all kinds of errors during web browser start } } e.Handled = true; } }
private void OnCopyLinkClicked(object sender, RoutedEventArgs e) { if (NavigateUri != default(Uri)) { var package = new DataPackage(); package.SetText(NavigateUri.ToString()); Clipboard.SetContent(package); Clipboard.Flush(); } }
protected override void OnClick() { if (NavigateUri != null) { FocusHelper.Focus(Application.Current.MainWindow); new Process { StartInfo = new ProcessStartInfo(NavigateUri.ToString()) }.Start(); } base.OnClick(); }
private void Navigate() { Uri uri = NavigateUri; string processName = ProcessName; if (uri != null) { var args = new ProcessStartInfo(NavigateUri.ToString()); Start(args); } else if (processName != null) { var args = new ProcessStartInfo(processName, ProcessStartArguments); Start(args); } else { } }
public AutoHyperlink() { Click += (o, e) => Process.Start(NavigateUri.ToString()); }
void TryOpenUri() { try { Process.Start(NavigateUri.ToString()); } catch (Exception) {} }