2020-03-20 09:43:42 -07:00
|
|
|
|
using System.Windows;
|
2013-12-22 19:35:21 +08:00
|
|
|
|
using System.Windows.Controls;
|
2016-05-06 03:24:14 +01: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
|
|
|
|
{
|
2016-02-21 14:22:34 +00:00
|
|
|
|
public partial class ResultListBox
|
2013-12-22 19:35:21 +08:00
|
|
|
|
{
|
2019-02-22 20:36:21 +01:00
|
|
|
|
private Point _lastpos;
|
|
|
|
|
|
private ListBoxItem curItem = null;
|
2016-02-21 14:22:34 +00:00
|
|
|
|
public ResultListBox()
|
2013-12-22 19:35:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2014-02-19 22:50:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-06 03:24:14 +01:00
|
|
|
|
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
2014-02-19 22:50:15 +08:00
|
|
|
|
{
|
2014-03-18 00:25:27 +08:00
|
|
|
|
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
2014-02-19 22:50:15 +08:00
|
|
|
|
{
|
2016-02-21 14:53:32 +00:00
|
|
|
|
ScrollIntoView(e.AddedItems[0]);
|
2014-02-19 22:50:15 +08:00
|
|
|
|
}
|
2014-01-03 23:52:36 +08:00
|
|
|
|
}
|
2014-03-05 22:32:21 +08:00
|
|
|
|
|
2016-05-06 03:24:14 +01:00
|
|
|
|
private void OnMouseEnter(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
2020-03-25 16:34:56 -07:00
|
|
|
|
curItem = (ListBoxItem)sender;
|
|
|
|
|
|
var p = e.GetPosition((IInputElement)sender);
|
|
|
|
|
|
_lastpos = p;
|
2019-02-22 20:36:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnMouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
2020-03-25 16:34:56 -07:00
|
|
|
|
var p = e.GetPosition((IInputElement)sender);
|
|
|
|
|
|
if (_lastpos != p)
|
2019-02-22 20:36:21 +01:00
|
|
|
|
{
|
2020-03-25 16:34:56 -07:00
|
|
|
|
((ListBoxItem)sender).IsSelected = true;
|
2019-02-22 20:36:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
2020-03-25 16:34:56 -07:00
|
|
|
|
if (curItem != null)
|
2019-02-22 20:36:21 +01:00
|
|
|
|
{
|
2020-03-25 16:34:56 -07:00
|
|
|
|
curItem.IsSelected = true;
|
2019-02-22 20:36:21 +01:00
|
|
|
|
}
|
2016-05-06 03:24:14 +01:00
|
|
|
|
}
|
2013-12-22 19:35:21 +08:00
|
|
|
|
}
|
2019-02-22 20:36:21 +01:00
|
|
|
|
}
|