2016-02-23 05:43:37 +08:00
|
|
|
|
using System.Collections.Generic;
|
2016-03-28 10:09:57 +08:00
|
|
|
|
using System.Linq;
|
2016-01-06 14:45:08 +08:00
|
|
|
|
using System.Runtime.Remoting.Contexts;
|
2016-03-28 10:09:57 +08:00
|
|
|
|
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;
|
2014-01-29 18:33:24 +08:00
|
|
|
|
using Wox.Plugin;
|
2016-02-18 19:31:15 +08:00
|
|
|
|
using Wox.ViewModel;
|
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]
|
2016-02-21 22:22:34 +08:00
|
|
|
|
public partial class ResultListBox
|
2013-12-22 19:35:21 +08:00
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
public void AddResults(List<Result> newRawResults)
|
2013-12-22 19:35:21 +08:00
|
|
|
|
{
|
2016-05-06 10:24:14 +08:00
|
|
|
|
var vm = (ResultsViewModel) DataContext;
|
2016-03-28 10:09:57 +08:00
|
|
|
|
var newResults = newRawResults.Select(r => new ResultViewModel(r)).ToList();
|
|
|
|
|
vm.Results.Update(newResults);
|
2016-05-06 10:24:14 +08:00
|
|
|
|
vm.SelectedIndex = 0;
|
2014-01-04 20:26:13 +08:00
|
|
|
|
}
|
2016-02-18 19:31:15 +08:00
|
|
|
|
|
2014-01-04 20:26:13 +08:00
|
|
|
|
|
2016-02-21 22:22:34 +08:00
|
|
|
|
public ResultListBox()
|
2013-12-22 19:35:21 +08:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-02-19 22:50:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-06 10:24:14 +08: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 22:53:32 +08: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 10:24:14 +08:00
|
|
|
|
private void OnMouseEnter(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
((ListBoxItem) sender).IsSelected = true;
|
|
|
|
|
}
|
2013-12-22 19:35:21 +08:00
|
|
|
|
}
|
2013-12-23 23:53:38 +08:00
|
|
|
|
}
|