private static DateTimeGroupInfo GetTimeGroupForItem(EntryListItemViewModel x) { return DateTimeGrouping.GetGroup(x.DateAdded, DateTime.Now); }
private void DeleteEntryFromTimeGroup(EntryListItemViewModel entryVm) { EntryListItemTimeGroupViewModel groupViewModel; if (itemGroupDictionary.TryGetValue(entryVm, out groupViewModel)) { groupViewModel.Items.Remove(entryVm); if (groupViewModel.Items.Count == 0) { groupsDictionary.Remove(groupViewModel.GroupName); TimeGroupViewModels.Remove(groupViewModel); } } }
private void AddEntryToGroup(EntryListItemViewModel viewModel) { var group = GetTimeGroupForItem(viewModel); EntryListItemTimeGroupViewModel groupViewModel; if (!groupsDictionary.TryGetValue(group.GroupName, out groupViewModel)) { groupViewModel = new EntryListItemTimeGroupViewModel(group.GroupName); groupViewModel.Items = new ObservableCollection<EntryListItemViewModel>(); TimeGroupViewModels.Insert(0, groupViewModel); groupsDictionary.Add(group.GroupName, groupViewModel); } groupViewModel.Items.Insert(0, viewModel); if (!itemGroupDictionary.ContainsKey(viewModel)) { itemGroupDictionary.Add(viewModel, groupViewModel); } }
public void AddEntry(EntryListItemViewModel viewModel) { EntryViewModels.Insert(0, viewModel); AddEntryToGroup(viewModel); }
private EntryListItemViewModel CreateListItemViewModel(Entry newEntry, bool justAdded = false) { var result = new EntryListItemViewModel(newEntry, EventAggregator, justAdded: justAdded); return result; }
public void AddEntry(EntryListItemViewModel viewModel) { if (RandomEntryViewModels.Count == EntriesToDisplayCount) { RandomEntryViewModels.RemoveAt(0); } RandomEntryViewModels.Insert(0, viewModel); UpdateDisplayedIndexes(); Observable.Timer(TimeSpan.FromSeconds(1)).ObserveOnDispatcher().Subscribe(_ => { viewModel.ShowTranslation(); }); }