Пример #1
0
        public MainViewModel(TvDbSeriesRepository repository, ConnectivityService connectivityService, ReminderService reminderService, AgentScheduler agentScheduler)
        {
            this.connectivityService          = connectivityService;
            this.reminderService              = reminderService;
            this.agentScheduler               = agentScheduler;
            connectivityService.InternetDown += connectivityService_InternetDown;
            connectivityService.InternetUp   += connectivityService_InternetUp;

            Series = new SelfSortingObservableCollection <TvDbSeries, DateTime?>(s => s.NextEpisodeAirDateTime, new SoonestFirstComparer());
            repository.Subscribed   += (sender, args) => DispatcherHelper.UIDispatcher.BeginInvoke(() => Series.Add(args.Series));
            repository.Unsubscribed += (sender, args) => DispatcherHelper.UIDispatcher.BeginInvoke(() => Series.Remove(args.Series));

            AlphabeticalSortingEnabled = AppSettings.Instance.AlphabeticalSortingEnabled;

            if (!IsInDesignMode)
            {
                this.repository    = repository;
                IsSearchBoxEnabled = true;
                searchResults      = new SelfSortingObservableCollection <TvDbSeries, float>(s => s.Rating, order: SortOrder.Desc);
                ltUpdater          = new LiveTileUpdater(this);

                MessengerInstance.Register <AppSettings>(this, s => AlphabeticalSortingEnabled = s.AlphabeticalSortingEnabled);
                //series = new SelfSortingObservableCollection<TvDbSeries, string>(s => s.Title);
            }
            else if (IsInDesignMode)
            {
                searchResults = new ObservableCollection <TvDbSeries>();

                Search = "Simpsons";
                Series.Add(new TvDbSeries()
                {
                    Title    = "Futurama",
                    Image    = "http://thetvdb.com/banners/posters/73871-2.jpg",
                    Rating   = 5,
                    AirsTime = "11 PM",
                    Episodes = new ObservableCollection <TvDbSeriesEpisode>()
                    {
                        new TvDbSeriesEpisode()
                        {
                            Name          = "Episode 1",
                            FirstAired    = DateTime.Now.AddDays(14).AddHours(5),
                            SeriesNumber  = "1",
                            EpisodeNumber = "1",
                            Description   = "bla bla bla bla bla lba",
                            Image         = "http://thetvdb.com/banners/episodes/121361/3254641.jpg"
                        },
                        new TvDbSeriesEpisode()
                        {
                            Name          = "Episode 2",
                            FirstAired    = DateTime.Now.AddDays(7),
                            SeriesNumber  = "1",
                            EpisodeNumber = "2",
                            Description   = "bla bla bla bla bla lba",
                            Image         = "http://thetvdb.com/banners/episodes/121361/3254641.jpg"
                        },
                        new TvDbSeriesEpisode()
                        {
                            Name          = "Episode 1",
                            FirstAired    = DateTime.Now,
                            SeriesNumber  = "2",
                            EpisodeNumber = "1",
                            Description   = "bla bla bla bla bla lba",
                            Image         = "http://thetvdb.com/banners/episodes/121361/3254641.jpg"
                        }
                    }
                });

                Series.Add(new TvDbSeries()
                {
                    Title  = "Simpsons",
                    Image  = "http://thetvdb.com/banners/posters/71663-10.jpg",
                    Rating = 10
                });

                searchResults = series;

                AlphabeticalSortingEnabled = true;
            }
        }
Пример #2
0
 public TvDb(ConnectivityService connectivityService)
 {
     this.connectivityService = connectivityService;
 }