コード例 #1
0
 private static DateTimeGroupInfo GetTimeGroupForItem(EntryListItemViewModel x)
 {
     return DateTimeGrouping.GetGroup(x.DateAdded, DateTime.Now);
 }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public void AddEntry(EntryListItemViewModel viewModel)
        {
            EntryViewModels.Insert(0, viewModel);

            AddEntryToGroup(viewModel);
        }
コード例 #5
0
        private EntryListItemViewModel CreateListItemViewModel(Entry newEntry, bool justAdded = false)
        {
            var result = new EntryListItemViewModel(newEntry, EventAggregator, justAdded: justAdded);

            return result;
        }
コード例 #6
0
        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(); });
        }