Пример #1
0
 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;
     }
 }
Пример #2
0
 private void OnCopyLinkClicked(object sender, RoutedEventArgs e)
 {
     if (NavigateUri != default(Uri))
     {
         var package = new DataPackage();
         package.SetText(NavigateUri.ToString());
         Clipboard.SetContent(package);
         Clipboard.Flush();
     }
 }
Пример #3
0
        protected override void OnClick()
        {
            if (NavigateUri != null)
            {
                FocusHelper.Focus(Application.Current.MainWindow);

                new Process {
                    StartInfo = new ProcessStartInfo(NavigateUri.ToString())
                }.Start();
            }

            base.OnClick();
        }
Пример #4
0
        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
            {
            }
        }
Пример #5
0
 public AutoHyperlink()
 {
     Click += (o, e) => Process.Start(NavigateUri.ToString());
 }
Пример #6
0
 void TryOpenUri()
 {
     try {
         Process.Start(NavigateUri.ToString());
     } catch (Exception) {}
 }