PowerToys/src/modules/launcher/PowerLauncher/ResultList.xaml.cs

103 lines
3.9 KiB
C#
Raw Normal View History

// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
Somil55/merge wpf to master (#3840) * Basic WPF searchbox working * Updated key navigation and removed coldstart for searhbox * refactored and added code back in commented * Removed XAML Island references * Basic searchbox+listview working * Getting a bit more back * got color there * Result list bit better now * Added image loader for WPF Image * Partially got the context menus rendering again * adjusting coldstart to load, control will load with main form * getting context menus back * mouse over works now * Click now works, started to remove Win.XAML references * being a bit more forcusful on focus * Shadow text is not aligned * fixing focus if listbox was used * small tweak to fix shadow text * inputs don't work but gotta figure out why. commenting out * preview text * adding back in delay * fixed height issue * Applied the correct context button styles * Created custom ItemContainerStyle to fix the blue highlights behind the command buttons * Applied the correct highlight / mouseover styling * Removed vertical scrollbar in listview * fixed for alt-space prompt * Fixed right click focus issue * Somil55/wpf modifier keys (#3378) * Removed DPI change as it was not required * Global key hooks for context menu items * Updated Key for shell, folder and indexer plugin * Updated key mapping for indexer plugin * Somil55/wpf context menu selection (#3389) * Removed DPI change as it was not required * Global key hooks for context menu items * Updated Key for shell, folder and indexer plugin * Updated key mapping for indexer plugin * Add trigger to selection on tabbing * Minor shadow adjustments so its more similiar to default shell shadow. Added intro/outro animations * Added UWP-like scrollbar style for the results list * Fixed formating and naming * Removed Powerlauncher UI project * Update PowerToys.sln * Commented out scrollbar and fade in/out animations * Added missing features from UWP branch * Fixed formatting for Product.wxs * Add dragging to WPF window Co-authored-by: Clint Rutkas <clint@rutkas.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2020-06-02 03:35:37 +08:00
namespace PowerLauncher
{
/// <summary>
/// Interaction logic for ResultList.xaml
/// </summary>
public partial class ResultList : UserControl
{
public ResultList()
{
InitializeComponent();
}
private ToolTip _previouslyOpenedToolTip;
// From https://docs.microsoft.com/en-us/dotnet/desktop/wpf/data/how-to-find-datatemplate-generated-elements
private TypeChildItem FindVisualChild<TypeChildItem>(DependencyObject obj)
where TypeChildItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is TypeChildItem)
{
return (TypeChildItem)child;
}
else
{
TypeChildItem childOfChild = FindVisualChild<TypeChildItem>(child);
if (childOfChild != null)
{
return childOfChild;
}
}
}
return null;
}
private void HideCurrentToolTip()
{
if (_previouslyOpenedToolTip != null)
{
_previouslyOpenedToolTip.IsOpen = false;
}
}
private void ContextMenuListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var listView = sender as ListView;
if (listView.SelectedItem != null)
{
ListBoxItem listBoxItem = (ListBoxItem)listView.ItemContainerGenerator.ContainerFromItem(listView.SelectedItem);
if (listBoxItem != null)
{
ContentPresenter contentPresenter = FindVisualChild<ContentPresenter>(listBoxItem);
DataTemplate dataTemplate = contentPresenter.ContentTemplate;
Button button = (Button)dataTemplate.FindName("commandButton", contentPresenter);
ToolTip tooltip = button.ToolTip as ToolTip;
tooltip.PlacementTarget = button;
tooltip.Placement = System.Windows.Controls.Primitives.PlacementMode.Right;
tooltip.PlacementRectangle = new Rect(0, button.Height, 0, 0);
tooltip.IsOpen = true;
}
else
{
HideCurrentToolTip();
}
}
else
{
HideCurrentToolTip();
}
}
[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))
{
HideCurrentToolTip();
_previouslyOpenedToolTip = (ToolTip)sender;
}
}
[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))
{
HideCurrentToolTip();
}
}
Somil55/merge wpf to master (#3840) * Basic WPF searchbox working * Updated key navigation and removed coldstart for searhbox * refactored and added code back in commented * Removed XAML Island references * Basic searchbox+listview working * Getting a bit more back * got color there * Result list bit better now * Added image loader for WPF Image * Partially got the context menus rendering again * adjusting coldstart to load, control will load with main form * getting context menus back * mouse over works now * Click now works, started to remove Win.XAML references * being a bit more forcusful on focus * Shadow text is not aligned * fixing focus if listbox was used * small tweak to fix shadow text * inputs don't work but gotta figure out why. commenting out * preview text * adding back in delay * fixed height issue * Applied the correct context button styles * Created custom ItemContainerStyle to fix the blue highlights behind the command buttons * Applied the correct highlight / mouseover styling * Removed vertical scrollbar in listview * fixed for alt-space prompt * Fixed right click focus issue * Somil55/wpf modifier keys (#3378) * Removed DPI change as it was not required * Global key hooks for context menu items * Updated Key for shell, folder and indexer plugin * Updated key mapping for indexer plugin * Somil55/wpf context menu selection (#3389) * Removed DPI change as it was not required * Global key hooks for context menu items * Updated Key for shell, folder and indexer plugin * Updated key mapping for indexer plugin * Add trigger to selection on tabbing * Minor shadow adjustments so its more similiar to default shell shadow. Added intro/outro animations * Added UWP-like scrollbar style for the results list * Fixed formating and naming * Removed Powerlauncher UI project * Update PowerToys.sln * Commented out scrollbar and fade in/out animations * Added missing features from UWP branch * Fixed formatting for Product.wxs * Add dragging to WPF window Co-authored-by: Clint Rutkas <clint@rutkas.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2020-06-02 03:35:37 +08:00
}
}