2016-05-22 18:18:32 +00:00
|
|
|
|
using System.Runtime.Remoting.Contexts;
|
2019-02-22 19:36:21 +00:00
|
|
|
|
using System.Windows;
|
2013-12-22 11:35:21 +00:00
|
|
|
|
using System.Windows.Controls;
|
2016-05-06 02:24:14 +00:00
|
|
|
|
using System.Windows.Input;
|
2013-12-22 11:35:21 +00:00
|
|
|
|
|
2014-01-29 10:33:24 +00:00
|
|
|
|
namespace Wox
|
2013-12-22 11:35:21 +00:00
|
|
|
|
{
|
2015-11-06 21:30:38 +00:00
|
|
|
|
[Synchronization]
|
2016-02-21 14:22:34 +00:00
|
|
|
|
public partial class ResultListBox
|
2013-12-22 11:35:21 +00:00
|
|
|
|
{
|
2019-02-22 19:36:21 +00:00
|
|
|
|
private Point _lastpos;
|
|
|
|
|
|
private ListBoxItem curItem = null;
|
2016-02-21 14:22:34 +00:00
|
|
|
|
public ResultListBox()
|
2013-12-22 11:35:21 +00:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2014-02-19 14:50:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-06 02:24:14 +00:00
|
|
|
|
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
2014-02-19 14:50:15 +00:00
|
|
|
|
{
|
2014-03-17 16:25:27 +00:00
|
|
|
|
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
2014-02-19 14:50:15 +00:00
|
|
|
|
{
|
2016-02-21 14:53:32 +00:00
|
|
|
|
ScrollIntoView(e.AddedItems[0]);
|
2014-02-19 14:50:15 +00:00
|
|
|
|
}
|
2014-01-03 15:52:36 +00:00
|
|
|
|
}
|
2014-03-05 14:32:21 +00:00
|
|
|
|
|
2016-05-06 02:24:14 +00:00
|
|
|
|
private void OnMouseEnter(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
2019-02-22 19:36:21 +00:00
|
|
|
|
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 02:24:14 +00:00
|
|
|
|
}
|
2013-12-22 11:35:21 +00:00
|
|
|
|
}
|
2019-02-22 19:36:21 +00:00
|
|
|
|
}
|