Beispiel #1
0
        public NicoSearchViewModel()
        {
            AddLoadTask(() =>
            {
                Videos = new ObservableCollection <NicoVideoViewModel>();

                Genres = new ObservableCollection <ComboboxItemModel>(
                    NicoUtil.Combos
                    .Where(combo => combo.Group == "rank_genre")
                    );
                SelectedGenre = Genres.FirstOrDefault(genre => genre.Value == AppSetting.Instance.NicoRankingGenre) ?? Genres.First();

                Periods = new ObservableCollection <ComboboxItemModel>(
                    NicoUtil.Combos
                    .Where(combo => combo.Group == "rank_period")
                    );
                SelectedPeriod = Periods.FirstOrDefault(period => period.Value == AppSetting.Instance.NicoRankingPeriod) ?? Periods.First();

                _initialize = false;

                Reload();
            });

            Disposed += (sender, e) =>
            {
                AppSetting.Instance.NicoRankingGenre  = SelectedGenre.Value;
                AppSetting.Instance.NicoRankingPeriod = SelectedPeriod.Value;
                AppSetting.Instance.Save();

                Videos.ForEach(x => x.Dispose());
                Videos.ClearOnUI();
            };
        }
        public NicoFavoriteDetailViewModel(string mylistid) : this()
        {
            AddLoadTask(() =>
            {
                Text = mylistid;
            });

            Disposed += (sender, e) =>
            {
                Videos.ForEach(x => x.Dispose());
                Videos.ClearOnUI();
            };
        }
        public NicoTemporaryViewModel()
        {
            AddLoadTask(() =>
            {
                Videos = NicoUtil.Temporaries.ToSyncedSynchronizationContextCollection(
                    x => new NicoVideoViewModel(x.VideoId),
                    System.Threading.SynchronizationContext.Current
                    );
            });

            Disposed += (sender, e) =>
            {
                Videos.ForEach(x => x.Dispose());
                Videos.ClearOnUI();
            };
        }