private void Hyperlink_Click(object sender, RoutedEventArgs e) { try { HitHighlightedPageLink l = sender as HitHighlightedPageLink; if (l != null) { HitHighlightedPageLinkModel model = l.DataContext as HitHighlightedPageLinkModel; _model.NavigateTo(model.PageID); if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { int ndx = foundPagesList.SelectedItems.IndexOf(model); if (ndx >= 0) { foundPagesList.SelectedItems.RemoveAt(ndx); } else { foundPagesList.SelectedItems.Add(model); } } else { // select the link foundPagesList.SelectedItem = model; } e.Handled = true; } } catch (System.Exception ex) { TraceLogger.Log(TraceCategory.Error(), "Navigation to OneNote page failed: {0}", ex); TraceLogger.ShowGenericErrorBox(Properties.Resources.TagSearch_Error_PageNavigation, ex); } }
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { HitHighlightedPageLink link = sender as HitHighlightedPageLink; HitHighlightedPageLinkModel model = e.NewValue as HitHighlightedPageLinkModel; // build the highlighted inline Text // rebuild the hithighlighted Title link.hithighlightedTitle.Inlines.Clear(); foreach (TextFragment f in model.HighlightedTitle) { Run r = new Run(f.Text); if (f.IsMatch) { r.Background = Brushes.Yellow; } link.hithighlightedTitle.Inlines.Add(r); } // rebuild the hit highlighted Tooltip ToolTip tt = new ToolTip(); tt.Style = new Style(); // override the global style StackPanel stack = new StackPanel(); stack.Orientation = Orientation.Vertical; tt.Content = stack; TextBlock path = new TextBlock(); path.Foreground = Brushes.Gray; //path.FontSize = 10; path.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; path.VerticalAlignment = System.Windows.VerticalAlignment.Center; foreach (var he in model.Path) { if (path.Inlines.Count > 0) { Run r = new Run(" ñ "); r.FontFamily = new FontFamily("Symbol"); r.FontWeight = FontWeights.ExtraBold; r.Foreground = Brushes.Black; path.Inlines.Add(r); } path.Inlines.Add(new Run(he.Name)); } stack.Children.Add(path); TextBlock tb = new TextBlock(); tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; foreach (Run r in link.hithighlightedTitle.Inlines) { Run newR = new Run(r.Text); newR.Background = r.Background; newR.FontSize = r.FontSize + 2; newR.FontWeight = FontWeights.Medium; tb.Inlines.Add(newR); } stack.Children.Add(tb); ToolTip = tt; ToolTipService.SetShowDuration(link, 10000); }