Refactoring ContextMenu

1. Remove ItemDropEvent
2. Remove ShowContextMenus from API
3. Fix context menu item can't be opened ( #535 ), bug introduced from PR #494 (commit 45dbb50)
4. Move open result command and load context menu command back to
MainViewModel
5. unify load context menu logic
6. other performance enhancement and potential bug fixed
This commit is contained in:
bao-qian 2016-03-26 01:20:42 +00:00
parent fbc6f78cb5
commit 5ac0837be3
11 changed files with 192 additions and 314 deletions

View File

@ -22,7 +22,6 @@ namespace Wox.Plugin.Folder
{
this.context = context;
this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent;
this.context.API.ResultItemDropEvent += ResultDropEvent;
InitialDriverList();
if (FolderStorage.Instance.FolderLinks == null)
{
@ -31,38 +30,6 @@ namespace Wox.Plugin.Folder
}
}
void ResultDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
{
if (dropObject.GetDataPresent(DataFormats.FileDrop))
{
HanldeFilesDrop(result, dropObject);
}
e.Handled = true;
}
private void HanldeFilesDrop(Result targetResult, IDataObject dropObject)
{
List<string> files = ((string[])dropObject.GetData(DataFormats.FileDrop, false)).ToList();
context.API.ShowContextMenu(context.CurrentPluginMetadata, GetContextMenusForFileDrop(targetResult, files));
}
private static List<Result> GetContextMenusForFileDrop(Result targetResult, List<string> files)
{
List<Result> contextMenus = new List<Result>();
string folderPath = ((FolderLink) targetResult.ContextData).Path;
contextMenus.Add(new Result
{
Title = "Copy to this folder",
IcoPath = "Images/copy.png",
Action = _ =>
{
MessageBox.Show("Copy");
return true;
}
});
return contextMenus;
}
private void ApiBackKeyDownEvent(WoxKeyDownEventArgs e)
{
string query = e.Query;

View File

@ -61,7 +61,6 @@ namespace Wox.Plugin.Program
public void Init(PluginInitContext context)
{
this.context = context;
this.context.API.ResultItemDropEvent += ResultDropEvent;
Stopwatch.Debug("Preload programs", () =>
{
programs = ProgramCacheStorage.Instance.Programs;
@ -70,12 +69,6 @@ namespace Wox.Plugin.Program
Stopwatch.Debug("Program Index", IndexPrograms);
}
void ResultDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
{
e.Handled = true;
}
public static void IndexPrograms()
{
lock (lockObject)

View File

@ -229,20 +229,33 @@ namespace Wox.Core.Plugin
public static List<Result> GetContextMenusForPlugin(Result result)
{
var pluginPair = _contextMenuPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID);
var plugin = (IContextMenu)pluginPair?.Plugin;
if (plugin != null)
if (pluginPair != null)
{
var metadata = pluginPair.Metadata;
var plugin = (IContextMenu)pluginPair?.Plugin;
try
{
return plugin.LoadContextMenus(result);
var results = plugin.LoadContextMenus(result);
foreach (var r in results)
{
r.PluginDirectory = metadata.PluginDirectory;
r.PluginID = metadata.ID;
r.OriginQuery = result.OriginQuery;
}
return results;
}
catch (Exception e)
{
Log.Error(new WoxPluginException(pluginPair.Metadata.Name, $"Couldn't load plugin context menus", e));
Log.Error(new WoxPluginException(metadata.Name, "Couldn't load plugin context menus", e));
return new List<Result>();
}
}
else
{
return new List<Result>();
}
return new List<Result>();
}
public static void UpdateActionKeywordForPlugin(PluginPair plugin, string oldActionKeyword, string newActionKeyword)

View File

@ -15,12 +15,6 @@ namespace Wox.Plugin
/// <param name="results"></param>
void PushResults(Query query, PluginMetadata plugin, List<Result> results);
/// <summary>
/// Show context menu with giving results
/// </summary>
/// <param name="results"></param>
void ShowContextMenu(PluginMetadata plugin, List<Result> results);
/// <summary>
/// Change Wox query
/// </summary>
@ -115,11 +109,5 @@ namespace Wox.Plugin
/// if you want to hook something like Ctrl+R, you should use this event
/// </summary>
event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
/// <summary>
/// Fired after drop to result item of current plugin
/// </summary>
/// todo: ResultItem -> Result
event ResultItemDropEventHandler ResultItemDropEvent;
}
}

View File

@ -27,7 +27,8 @@
d:DataContext="{d:DesignInstance vm:MainViewModel, IsDesignTimeCreatable=True}">
<Window.Resources>
<DataTemplate DataType="{x:Type vm:ResultsViewModel}">
<wox:ResultListBox></wox:ResultListBox>
<wox:ResultListBox PreviewMouseDown="OnPreviewMouseButtonDown">
</wox:ResultListBox>
</DataTemplate>
</Window.Resources>
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown">
@ -43,10 +44,8 @@
<ToolTip IsOpen="{Binding IsProgressBarTooltipVisible}"></ToolTip>
</Line.ToolTip>
</Line>
<ContentControl Content="{Binding Results}" Visibility="{Binding ResultListBoxVisibility}">
</ContentControl>
<ContentControl Content="{Binding ContextMenu}" Visibility="{Binding ContextMenuVisibility}">
</ContentControl>
<ContentControl Content="{Binding Results}" Visibility="{Binding ResultListBoxVisibility}"/>
<ContentControl Content="{Binding ContextMenu}" Visibility="{Binding ContextMenuVisibility}"/>
</StackPanel>
</Border>
</Window>

View File

@ -4,6 +4,7 @@ using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Controls;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Core.Updater;
@ -35,9 +36,9 @@ namespace Wox
private void OnClosing(object sender, CancelEventArgs e)
{
UserSettingStorage.Instance.WindowLeft = Left;
UserSettingStorage.Instance.WindowTop = Top;
UserSettingStorage.Instance.Save();
UserSettingStorage.Instance.WindowLeft = Left;
UserSettingStorage.Instance.WindowTop = Top;
UserSettingStorage.Instance.Save();
e.Cancel = true;
}
@ -71,12 +72,13 @@ namespace Wox
}
else
{
UserSettingStorage.Instance.WindowLeft = Left;
UserSettingStorage.Instance.WindowTop = Top;
UserSettingStorage.Instance.Save();
UserSettingStorage.Instance.WindowLeft = Left;
UserSettingStorage.Instance.WindowTop = Top;
UserSettingStorage.Instance.Save();
}
};
// happlebao todo delete
vm.Left = GetWindowsLeft();
vm.Top = GetWindowsTop();
vm.MainWindowVisibility = Visibility.Visible;
@ -160,7 +162,6 @@ namespace Wox
private void OnPreviewKeyDown(object sender, KeyEventArgs e)
{
var vm = DataContext as MainViewModel;
if (null == vm) return;
//when alt is pressed, the real key should be e.SystemKey
var key = (e.Key == Key.System ? e.SystemKey : e.Key);
@ -202,10 +203,22 @@ namespace Wox
case Key.O:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
vm.CtrlOCommand.Execute(null);
vm.LoadContextMenuCommand.Execute(null);
}
break;
case Key.Enter:
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
{
vm.LoadContextMenuCommand.Execute(null);
}
else
{
vm.OpenResultCommand.Execute(null);
}
e.Handled = true;
break;
case Key.Down:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
@ -262,18 +275,6 @@ namespace Wox
vm.StartHelpCommand.Execute(null);
break;
case Key.Enter:
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
{
vm.ShiftEnterCommand.Execute(null);
}
else
{
vm.OpenResultCommand.Execute(null);
}
e.Handled = true;
break;
case Key.D1:
if (GlobalHotkey.Instance.CheckModifiers().AltPressed)
@ -315,10 +316,45 @@ namespace Wox
vm.OpenResultCommand.Execute(5);
}
break;
}
}
private void OnPreviewMouseButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender != null && e.OriginalSource != null)
{
var r = (ResultListBox)sender;
var d = (DependencyObject)e.OriginalSource;
var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem;
var result = (ResultViewModel)item?.DataContext;
if (result != null)
{
var vm = DataContext as MainViewModel;
if (vm != null)
{
if (vm.ContextMenuVisibility.IsVisible())
{
vm.ContextMenu.SelectResult(result);
}
else
{
vm.Results.SelectResult(result);
}
if (e.ChangedButton == MouseButton.Left)
{
vm.OpenResultCommand.Execute(null);
}
else if (e.ChangedButton == MouseButton.Right)
{
vm.LoadContextMenuCommand.Execute(null);
}
}
}
}
}
private void OnDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))

View File

@ -30,9 +30,10 @@ namespace Wox
GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
MainVM.ListeningKeyPressed += (o, e) => {
MainVM.ListeningKeyPressed += (o, e) =>
{
if(e.KeyEventArgs.Key == Key.Back)
if (e.KeyEventArgs.Key == Key.Back)
{
BackKeyDownEvent?.Invoke(new WoxKeyDownEventArgs
{
@ -158,20 +159,6 @@ namespace Wox
MainVM.UpdateResultView(results, plugin, query);
}
public void ShowContextMenu(PluginMetadata plugin, List<Result> results)
{
if (results != null && results.Count > 0)
{
results.ForEach(o =>
{
o.PluginDirectory = plugin.PluginDirectory;
o.PluginID = plugin.ID;
});
MainVM.ShowContextMenu(results, plugin.ID);
}
}
#endregion
#region Private Methods

View File

@ -16,18 +16,14 @@
<DataTemplate.DataType>
<x:Type TypeName="vm:ResultViewModel" />
</DataTemplate.DataType>
<Button Command="{Binding OpenResultListBoxItemCommand}">
<Button.InputBindings>
<MouseBinding Command="{Binding OpenContextMenuItemCommand}" MouseAction="RightClick"></MouseBinding>
</Button.InputBindings>
<Button>
<Button.Template>
<ControlTemplate>
<ContentPresenter Content="{TemplateBinding Button.Content}"></ContentPresenter>
</ControlTemplate>
</Button.Template>
<Button.Content>
<Grid HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Stretch" Margin="5"
Cursor="Hand">
<Grid HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Stretch" Margin="5" Cursor="Hand">
<Grid.Resources>
<converters:ImagePathConverter x:Key="ImageConverter" />
</Grid.Resources>

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
@ -9,6 +8,7 @@ using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Wox.Plugin;
using Wox.Storage;
using Stopwatch = Wox.Infrastructure.Stopwatch;
@ -19,8 +19,6 @@ namespace Wox.ViewModel
{
#region Private Fields
private string _queryText;
private bool _isProgressBarTooltipVisible;
private double _left;
private double _top;
@ -31,10 +29,10 @@ namespace Wox.ViewModel
private Visibility _mainWindowVisibility;
private bool _queryHasReturn;
private Query _lastQuery = new Query();
private Query _lastQuery;
private bool _ignoreTextChange;
private List<Result> _currentContextMenus = new List<Result>();
private string _textBeforeEnterContextMenuMode;
private string _queryTextBeforeLoadContextMenu;
private string _queryText;
#endregion
@ -42,11 +40,13 @@ namespace Wox.ViewModel
public MainViewModel()
{
_queryTextBeforeLoadContextMenu = "";
_queryText = "";
_lastQuery = new Query();
InitializeResultListBox();
InitializeContextMenu();
InitializeKeyCommands();
_queryHasReturn = false;
}
#endregion
@ -67,7 +67,10 @@ namespace Wox.ViewModel
{
_queryText = value;
OnPropertyChanged();
HandleQueryTextUpdated();
if (_queryText != _queryTextBeforeLoadContextMenu)
{
HandleQueryTextUpdated();
}
}
}
@ -111,6 +114,7 @@ namespace Wox.ViewModel
}
public Visibility ContextMenuVisibility
{
get
{
@ -120,6 +124,19 @@ namespace Wox.ViewModel
{
_contextMenuVisibility = value;
OnPropertyChanged();
if (!value.IsVisible())
{
QueryText = _queryTextBeforeLoadContextMenu;
ResultListBoxVisibility = Visibility.Visible;
OnCursorMovedToEnd();
}
else
{
_queryTextBeforeLoadContextMenu = QueryText;
QueryText = "";
ResultListBoxVisibility = Visibility.Collapsed;
}
}
}
@ -160,24 +177,18 @@ namespace Wox.ViewModel
_mainWindowVisibility = value;
OnPropertyChanged();
MainWindowVisibilityChanged?.Invoke(this, new EventArgs());
if (!value.IsVisible() && ContextMenuVisibility.IsVisible())
{
BackToSearchMode();
}
}
}
public ICommand EscCommand { get; set; }
public ICommand SelectNextItemCommand { get; set; }
public ICommand SelectPrevItemCommand { get; set; }
public ICommand CtrlOCommand { get; set; }
public ICommand DisplayNextQueryCommand { get; set; }
public ICommand DisplayPrevQueryCommand { get; set; }
public ICommand SelectNextPageCommand { get; set; }
public ICommand SelectPrevPageCommand { get; set; }
public ICommand StartHelpCommand { get; set; }
public ICommand ShiftEnterCommand { get; set; }
public ICommand LoadContextMenuCommand { get; set; }
public ICommand OpenResultCommand { get; set; }
public ICommand BackCommand { get; set; }
#endregion
@ -190,7 +201,7 @@ namespace Wox.ViewModel
{
if (ContextMenuVisibility.IsVisible())
{
BackToSearchMode();
ContextMenuVisibility = Visibility.Collapsed;
}
else
{
@ -222,17 +233,7 @@ namespace Wox.ViewModel
}
});
CtrlOCommand = new RelayCommand(_ =>
{
if (ContextMenuVisibility.IsVisible())
{
BackToSearchMode();
}
else
{
ShowContextMenu(Results.SelectedResult.RawResult);
}
});
DisplayNextQueryCommand = new RelayCommand(_ =>
{
@ -261,22 +262,48 @@ namespace Wox.ViewModel
Process.Start("http://doc.getwox.com");
});
ShiftEnterCommand = new RelayCommand(_ =>
{
if (!ContextMenuVisibility.IsVisible() && null != Results.SelectedResult)
{
ShowContextMenu(Results.SelectedResult.RawResult);
}
});
OpenResultCommand = new RelayCommand(o =>
{
var results = ContextMenuVisibility.IsVisible() ? ContextMenu : Results;
if (o != null)
{
var index = int.Parse(o.ToString());
Results.SelectResult(index);
results.SelectResult(index);
}
var result = results.SelectedResult.RawResult;
bool hideWindow = result.Action(new ActionContext
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
if (hideWindow)
{
MainWindowVisibility = Visibility.Collapsed;
}
UserSelectedRecordStorage.Instance.Add(result);
QueryHistoryStorage.Instance.Add(result.OriginQuery.RawQuery);
});
LoadContextMenuCommand = new RelayCommand(_ =>
{
if (!ContextMenuVisibility.IsVisible())
{
var result = Results.SelectedResult.RawResult;
var pluginID = result.PluginID;
var contextMenuResults = PluginManager.GetContextMenusForPlugin(result);
contextMenuResults.Add(GetTopMostContextMenu(result));
ContextMenu.Clear();
ContextMenu.AddResults(contextMenuResults, pluginID);
ContextMenuVisibility = Visibility.Visible;
}
else
{
ContextMenuVisibility = Visibility.Collapsed;
}
Results.SelectedResult?.OpenResultListBoxItemCommand.Execute(null);
});
BackCommand = new RelayCommand(_ =>
@ -291,69 +318,6 @@ namespace Wox.ViewModel
ResultListBoxVisibility = Visibility.Collapsed;
}
private void ShowContextMenu(Result result)
{
if (result == null) return;
ShowContextMenu(result, PluginManager.GetContextMenusForPlugin(result));
}
private void ShowContextMenu(Result result, List<Result> actions)
{
actions.ForEach(o =>
{
o.PluginDirectory = PluginManager.GetPluginForId(result.PluginID).Metadata.PluginDirectory;
o.PluginID = result.PluginID;
o.OriginQuery = result.OriginQuery;
});
actions.Add(GetTopMostContextMenu(result));
DisplayContextMenu(actions, result.PluginID);
}
private void DisplayContextMenu(List<Result> actions, string pluginID)
{
_textBeforeEnterContextMenuMode = QueryText;
ContextMenu.Clear();
ContextMenu.AddResults(actions, pluginID);
_currentContextMenus = actions;
ContextMenuVisibility = Visibility.Visible;
ResultListBoxVisibility = Visibility.Collapsed;
QueryText = "";
}
private Result GetTopMostContextMenu(Result result)
{
if (TopMostRecordStorage.Instance.IsTopMost(result))
{
return new Result(InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), "Images\\down.png")
{
PluginDirectory = WoxDirectroy.Executable,
Action = _ =>
{
TopMostRecordStorage.Instance.Remove(result);
App.API.ShowMsg("Succeed");
return false;
}
};
}
else
{
return new Result(InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), "Images\\up.png")
{
PluginDirectory = WoxDirectroy.Executable,
Action = _ =>
{
TopMostRecordStorage.Instance.AddOrUpdate(result);
App.API.ShowMsg("Succeed");
return false;
}
};
}
}
private void InitializeContextMenu()
{
@ -363,12 +327,6 @@ namespace Wox.ViewModel
private void HandleQueryTextUpdated()
{
if (_ignoreTextChange)
{
_ignoreTextChange = false;
return;
}
IsProgressBarTooltipVisible = false;
if (ContextMenuVisibility.IsVisible())
{
@ -393,23 +351,20 @@ namespace Wox.ViewModel
private void QueryContextMenu()
{
var contextMenuId = "Context Menu Id";
ContextMenu.Clear();
var query = QueryText.ToLower();
if (string.IsNullOrEmpty(query))
{
ContextMenu.AddResults(_currentContextMenus, contextMenuId);
}
else
if (!string.IsNullOrEmpty(query))
{
List<Result> filterResults = new List<Result>();
foreach (Result contextMenu in _currentContextMenus)
foreach (var contextMenu in ContextMenu.Results)
{
if (StringMatcher.IsMatch(contextMenu.Title, query)
|| StringMatcher.IsMatch(contextMenu.SubTitle, query))
{
filterResults.Add(contextMenu);
filterResults.Add(contextMenu.RawResult);
}
}
ContextMenu.Clear();
ContextMenu.AddResults(filterResults, contextMenuId);
}
}
@ -470,14 +425,6 @@ namespace Wox.ViewModel
() => { Results.AddResults(list, metadata.ID); });
}
private void BackToSearchMode()
{
QueryText = _textBeforeEnterContextMenuMode;
ContextMenuVisibility = Visibility.Collapsed;
ResultListBoxVisibility = Visibility.Visible;
OnCursorMovedToEnd();
}
private void DisplayQueryHistory(HistoryItem history)
{
if (history != null)
@ -507,7 +454,35 @@ namespace Wox.ViewModel
}, historyMetadata);
}
}
private Result GetTopMostContextMenu(Result result)
{
if (TopMostRecordStorage.Instance.IsTopMost(result))
{
return new Result(InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), "Images\\down.png")
{
PluginDirectory = WoxDirectroy.Executable,
Action = _ =>
{
TopMostRecordStorage.Instance.Remove(result);
App.API.ShowMsg("Succeed");
return false;
}
};
}
else
{
return new Result(InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), "Images\\up.png")
{
PluginDirectory = WoxDirectroy.Executable,
Action = _ =>
{
TopMostRecordStorage.Instance.AddOrUpdate(result);
App.API.ShowMsg("Succeed");
return false;
}
};
}
}
#endregion
#region Public Methods
@ -535,11 +510,6 @@ namespace Wox.ViewModel
}
}
public void ShowContextMenu(List<Result> actions, string pluginID)
{
DisplayContextMenu(actions, pluginID);
}
#endregion
public event EventHandler<ListeningKeyPressedEventArgs> ListeningKeyPressed;
@ -556,18 +526,15 @@ namespace Wox.ViewModel
{
TextBoxSelected?.Invoke(this, new EventArgs());
}
}
public class ListeningKeyPressedEventArgs : EventArgs
{
public KeyEventArgs KeyEventArgs { get; private set; }
public ListeningKeyPressedEventArgs(KeyEventArgs keyEventArgs)
{
KeyEventArgs = keyEventArgs;
}
}
}

View File

@ -1,4 +1,5 @@
using Wox.Core.Plugin;
using System;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
@ -22,41 +23,6 @@ namespace Wox.ViewModel
if (result != null)
{
RawResult = result;
OpenResultListBoxItemCommand = new RelayCommand(_ =>
{
bool hideWindow = result.Action(new ActionContext
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
if (hideWindow)
{
App.API.HideApp();
UserSelectedRecordStorage.Instance.Add(RawResult);
QueryHistoryStorage.Instance.Add(RawResult.OriginQuery.RawQuery);
}
});
OpenContextMenuItemCommand = new RelayCommand(_ =>
{
var actions = PluginManager.GetContextMenusForPlugin(result);
var pluginMetaData = PluginManager.GetPluginForId(result.PluginID).Metadata;
actions.ForEach(o =>
{
o.PluginDirectory = pluginMetaData.PluginDirectory;
o.PluginID = result.PluginID;
o.OriginQuery = result.OriginQuery;
});
actions.Add(GetTopMostContextMenu(result));
App.API.ShowContextMenu(pluginMetaData, actions);
});
}
}
@ -81,51 +47,12 @@ namespace Wox.ViewModel
}
}
public RelayCommand OpenResultListBoxItemCommand { get; set; }
public RelayCommand OpenContextMenuItemCommand { get; set; }
#endregion
#region Properties
public Result RawResult { get; }
#endregion
#region Private Methods
private Result GetTopMostContextMenu(Result result)
{
if (TopMostRecordStorage.Instance.IsTopMost(result))
{
return new Result(InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), "Images\\down.png")
{
PluginDirectory = WoxDirectroy.Executable,
Action = _ =>
{
TopMostRecordStorage.Instance.Remove(result);
App.API.ShowMsg("Succeed");
return false;
}
};
}
else
{
return new Result(InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), "Images\\up.png")
{
PluginDirectory = WoxDirectroy.Executable,
Action = _ =>
{
TopMostRecordStorage.Instance.AddOrUpdate(result);
App.API.ShowMsg("Succeed");
return false;
}
};
}
}
#endregion
public override bool Equals(object obj)

View File

@ -104,6 +104,12 @@ namespace Wox.ViewModel
}
}
public void SelectResult(ResultViewModel result)
{
int i = Results.IndexOf(result);
SelectResult(i);
}
public void SelectNextResult()
{
if (SelectedResult != null)
@ -185,8 +191,7 @@ namespace Wox.ViewModel
{
lock (_resultsUpdateLock)
{
var newResults = new List<ResultViewModel>();
newRawResults.ForEach((re) => { newResults.Add(new ResultViewModel(re)); });
var newResults = newRawResults.Select(r => new ResultViewModel(r)).ToList();
// todo use async to do new result calculation
var resultsCopy = Results.ToList();
var oldResults = resultsCopy.Where(r => r.RawResult.PluginID == resultId).ToList();