PowerToys/Wox/ResultListBox.xaml.cs

51 lines
1.3 KiB
C#
Raw Normal View History

2016-05-23 02:18:32 +08:00
using System.Runtime.Remoting.Contexts;
using System.Windows;
2013-12-22 19:35:21 +08:00
using System.Windows.Controls;
2016-05-06 10:24:14 +08:00
using System.Windows.Input;
2013-12-22 19:35:21 +08:00
2014-01-29 18:33:24 +08:00
namespace Wox
2013-12-22 19:35:21 +08:00
{
2015-11-07 05:30:38 +08:00
[Synchronization]
public partial class ResultListBox
2013-12-22 19:35:21 +08:00
{
private Point _lastpos;
private ListBoxItem curItem = null;
public ResultListBox()
2013-12-22 19:35:21 +08:00
{
InitializeComponent();
}
2016-05-06 10:24:14 +08:00
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
{
2016-02-21 22:53:32 +08:00
ScrollIntoView(e.AddedItems[0]);
}
2014-01-03 23:52:36 +08:00
}
2016-05-06 10:24:14 +08:00
private void OnMouseEnter(object sender, MouseEventArgs e)
{
curItem = (ListBoxItem)sender;
var p = e.GetPosition((IInputElement)sender);
_lastpos = p;
}
private void OnMouseMove(object sender, MouseEventArgs e)
{
var p = e.GetPosition((IInputElement)sender);
if (_lastpos != p)
{
((ListBoxItem) sender).IsSelected = true;
}
}
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (curItem != null)
{
curItem.IsSelected = true;
}
2016-05-06 10:24:14 +08:00
}
2013-12-22 19:35:21 +08:00
}
}