Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Run] Tooltips fix and improvement #31361

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal static List<Result> GetResultList(in IEnumerable<RegistryEntry> list, i

result.Action = (_) => ContextMenuHelper.TryToOpenInRegistryEditor(entry);
result.ContextData = entry;
result.ToolTipData = new ToolTipData(Resources.RegistryKey, $"{Resources.KeyName}\t{result.Title}");
result.ToolTipData = new ToolTipData(Resources.RegistryKey, $"{Resources.KeyName} {result.Title}");

resultList.Add(result);
}
Expand Down Expand Up @@ -198,10 +198,10 @@ internal static string GetTruncatedText(string text, in int maxLength, TruncateS
/// <returns>A tool-tip text</returns>
private static string GetToolTipTextForRegistryValue(RegistryKey key, KeyValuePair<string, object> valueEntry)
{
return $"{Resources.KeyName}\t{key.Name}{Environment.NewLine}"
+ $"{Resources.Name}\t{valueEntry.Key}{Environment.NewLine}"
+ $"{Resources.Type}\t{ValueHelper.GetType(key, valueEntry.Key)}{Environment.NewLine}"
+ $"{Resources.Value}\t{ValueHelper.GetValue(key, valueEntry.Key)}";
return $"{Resources.KeyName} {key.Name}{Environment.NewLine}"
+ $"{Resources.Name} {valueEntry.Key}{Environment.NewLine}"
+ $"{Resources.Type} {ValueHelper.GetType(key, valueEntry.Key)}{Environment.NewLine}"
+ $"{Resources.Value} {ValueHelper.GetValue(key, valueEntry.Key)}";
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/modules/launcher/PowerLauncher/ResultList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@
FontWeight="SemiBold"
Style="{DynamicResource CollapsableTextblock}"
Text="{Binding Result.ToolTipData.Title}"
TextAlignment="Left"
TextWrapping="Wrap" />
<TextBlock
Margin="0,4,0,0"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Style="{DynamicResource CollapsableTextblock}"
Text="{Binding Result.ToolTipData.Text}"
TextAlignment="Left"
TextWrapping="Wrap" />
</StackPanel>
</ToolTip>
Expand Down
16 changes: 9 additions & 7 deletions src/modules/launcher/PowerLauncher/ResultList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ResultList()

// From https://learn.microsoft.com/dotnet/desktop/wpf/data/how-to-find-datatemplate-generated-elements
private TypeChildItem FindVisualChild<TypeChildItem>(DependencyObject obj)
where TypeChildItem : DependencyObject
where TypeChildItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
Expand Down Expand Up @@ -80,20 +80,22 @@ private void ContextMenuListView_SelectionChanged(object sender, SelectionChange
}
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using StringComparison.InvariantCulture since this is user facing")]
private void ToolTip_Opened(object sender, RoutedEventArgs e)
{
if (string.Equals(sender.GetType().FullName, "System.Windows.Controls.ToolTip", System.StringComparison.InvariantCulture))
if (string.Equals(sender.GetType().FullName, "System.Windows.Controls.ToolTip", System.StringComparison.Ordinal))
{
HideCurrentToolTip();
_previouslyOpenedToolTip = (ToolTip)sender;
var openedToolTip = (ToolTip)sender;
if (_previouslyOpenedToolTip != openedToolTip)
{
HideCurrentToolTip();
_previouslyOpenedToolTip = openedToolTip;
}
}
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using StringComparison.InvariantCulture since this is user facing")]
private void SuggestionsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (string.Equals(((ListView)e.OriginalSource).Name, "SuggestionsList", System.StringComparison.InvariantCulture))
if (string.Equals(((ListView)e.OriginalSource).Name, "SuggestionsList", System.StringComparison.Ordinal))
{
HideCurrentToolTip();
}
Expand Down
Loading