private void DoSearch() { try { if (IsSearching) { ClearSearch(); } else { if (SearchFilter == null || string.IsNullOrEmpty(SearchFilter.Trim())) { throw new Exception("No search string entered"); } items.Clear(); List <IDataItem> results = DataManager.Instance().DataStore.Search(SearchFilter); foreach (var i in results) { Items.Add(new ItemViewModel(i, SVMLookup[i.GetSource()])); } } SortedView.Refresh(); IsSearching = !IsSearching; RefreshViewModel(); } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
private void MarkSelected(object selected) { List <IDataItem> updated = new List <IDataItem>(); var items = selected as System.Collections.IList; foreach (ItemViewModel ivm in items) { if (ivm.Data.New) { ivm.Data.SetNew(false); updated.Add(ivm.Data); } } DataManager.Instance().DataStore.UpdateItem(updated); SortedView.Refresh(); }
private void MarkAll() { if (MessageBox.Show("Mark all items as read?", "Mark All Read", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } List <IDataItem> updated = new List <IDataItem>(); foreach (ItemViewModel ivm in items) { if (ivm.Data.New) { ivm.Data.SetNew(false); updated.Add(ivm.Data); } } DataManager.Instance().DataStore.UpdateItem(updated); SortedView.Refresh(); }
public void PerformItemAction(object sender) { var o = SelectedItem; if (o != null) { var provider = DataManager.Instance().GetProviders().First(x => x.ProviderId == o.Provider); if (provider != null) { try { provider.DoAction(o.Data); o.Data.SetNew(false); DataManager.Instance().DataStore.UpdateItem(o.Data); SortedView.Refresh(); } catch (Exception e) { MessageBoxFactory.ShowError("Cannot perform action on: " + o.Data, "Cannot Perform Action"); } } } }