/// <summary> /// To avoid deadlock, this method should not called from main thread /// </summary> public void UpdateResultView(List <Result> list, PluginMetadata metadata, Query originQuery) { if (list == null) { throw new ArgumentNullException(nameof(list)); } if (metadata == null) { throw new ArgumentNullException(nameof(metadata)); } if (originQuery == null) { throw new ArgumentNullException(nameof(originQuery)); } foreach (var result in list) { if (_topMostRecord.IsTopMost(result)) { result.Score = int.MaxValue; } else { result.Score += _userSelectedRecord.GetSelectedCount(result) * 5; } } if (originQuery.RawQuery == _lastQuery.RawQuery) { Results.AddResults(list, metadata.ID); } }
/// <summary> /// To avoid deadlock, this method should not called from main thread /// </summary> public void UpdateResultView(List <Result> list, Query originQuery, CancellationToken ct) { if (list == null) { throw new ArgumentNullException(nameof(list)); } if (originQuery == null) { throw new ArgumentNullException(nameof(originQuery)); } foreach (var result in list) { if (_topMostRecord.IsTopMost(result)) { result.Score = int.MaxValue; } else { result.Score += _userSelectedRecord.GetSelectedCount(result) * 5; } } if (originQuery.RawQuery == _currentQuery.RawQuery) { ct.ThrowIfCancellationRequested(); Results.AddResults(list, ct); } }
/// <summary> /// To avoid deadlock, this method should not called from main thread /// </summary> public void UpdateResultView(List <Result> list, string originQuery, CancellationToken ct) { if (list == null) { throw new ArgumentNullException(nameof(list)); } if (originQuery == null) { throw new ArgumentNullException(nameof(originQuery)); } foreach (var result in list) { if (_topMostRecord.IsTopMost(result)) { result.Score = int.MaxValue; } else { result.Score += _userSelectedRecord.GetSelectedCount(result) * 5; } } // Using CurrentCultureIgnoreCase since this is user facing if (originQuery.Equals(_currentQuery, StringComparison.CurrentCultureIgnoreCase)) { ct.ThrowIfCancellationRequested(); Results.AddResults(list, ct); } }
private Result ContextMenuTopMost(Result result) { Result menu; if (_topMostRecord.IsTopMost(result)) { menu = new Result { Title = InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), IcoPath = "Images\\down.png", PluginDirectory = Constant.ProgramDirectory, Action = _ => { _topMostRecord.Remove(result); App.API.ShowMsg("Succeed"); return(false); } }; } else { menu = new Result { Title = InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), IcoPath = "Images\\up.png", PluginDirectory = Constant.ProgramDirectory, Action = _ => { _topMostRecord.AddOrUpdate(result); App.API.ShowMsg("Succeed"); return(false); } }; } return(menu); }
/// <summary> /// To avoid deadlock, this method should not called from main thread /// </summary> public void UpdateResultView(List <Result> list, PluginMetadata metadata, Query originQuery) { foreach (var result in list) { if (_topMostRecord.IsTopMost(result)) { result.Score = int.MaxValue; } else { result.Score += _userSelectedRecord.GetSelectedCount(result) * 5; } } if (originQuery.RawQuery == _lastQuery.RawQuery) { Results.AddResults(list, metadata.ID); } if (Results.Visibility != Visibility.Visible && list.Count > 0) { Results.Visibility = Visibility.Visible; } }