Beispiel #1
0
        public CollectionViewModel(
            INotificationCenter notification,
            IUserDatabase userDatabase,
            ICardDatabase cardDatabase,
            IApplicationSettings applicationSettings)
        {
            _notification        = notification;
            _userDatabase        = userDatabase;
            _cardDatabase        = cardDatabase;
            _applicationSettings = applicationSettings;
            Collections          = _userDatabase
                                   .GetAllCollections()
                                   .Select(c => new SingleCollectionViewModell(notification, _userDatabase, _cardDatabase, c));

            ISingleCollectionViewModel loadedCollection = null;

            Task.Factory.StartNew(() =>
            {
                var currentCollectionName = _applicationSettings.GetCurrentCollection();
                var found        = Collections.FirstOrDefault(c => c.CollectionName == currentCollectionName);
                loadedCollection = LoadCollection(found);
            }).ContinueWith((task) =>
            {
                SelectedCollection = loadedCollection;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }