public ViewModel() { Presenter = new UPnPPresenter(); Downloads = new ObservableCollection<Download>(); Favorites = new ObservableCollection<Favorite>(); PlaylistPaths = new ObservableCollection<PlaylistPath>(); DataModel = new UtilityDataModel(UtilityDataModel.ConnectionString); DataModel.SavedChanges += (sender, args) => RefreshData(); foreach (Download download in DataModel.Downloads) { Downloads.Add(download); } foreach (Favorite favorite in DataModel.Favorites) { Favorites.Add(favorite); } foreach (PlaylistPath playlistPath in PlaylistPaths) { PlaylistPaths.Add(playlistPath); } Launcher.Fire(() => { while (!Done) { Thread.Sleep(3000); RefreshData(); } }); }
public Mock() { Downloads = new ObservableCollection<Download>(); Favorites = new ObservableCollection<Favorite>(); Model = new UtilityDataModel(UtilityDataModel.ConnectionString); //Model.SavingChanges += (sender, args) => RefreshData(); foreach (var download in Model.Downloads) { Downloads.Add(download); } foreach (var favorite in Model.Favorites) { Favorites.Add(favorite); } }
private GlobalViewModel() { Presenter = new UPnPPresenter { TitlesExcludedFromImageReplacement = Settings.Default.Excluded_Folder_Names, ImageWidth = 160, ImageHeight = 100, EnableDetailsPage = true }; DebugMessage = string.Empty; Presenter.ParseBegin += OnParseBegin; Presenter.ParseEnd += OnParseEnd; GalleryViewModel = new GalleryViewModel(); GalleryViewModel.ExecuteInUIThread += OnExecuteInUIThread; PlaybackViewModel = new PlaybackViewModel(); PlaybackViewModel.ExecuteInUIThread += OnExecuteInUIThread; NavigationCommandList = new ObservableCollection<RoutedCommand> { AppNavigationCommands.BuyNowCommand, AppNavigationCommands.GoToSettingsCommand, AppNavigationCommands.GoToSupportCommand, }; Downloads = new ObservableCollection<Download>(); Favorites = new ObservableCollection<Favorite>(); PlaylistPaths = new ObservableCollection<PlaylistPath>(); DataModel = new UtilityDataModel(UtilityDataModel.ConnectionString); DataModel.SavedChanges += (sender, args) => RefreshData(); foreach (var download in DataModel.Downloads) { Downloads.Add(download); } foreach (var favorite in DataModel.Favorites) { Favorites.Add(favorite); } foreach (var playlistPath in PlaylistPaths) { PlaylistPaths.Add(playlistPath); } Launcher.Fire(() => { while (!Done) { Thread.Sleep(3000); RefreshData(); } }); _commandSink = new CommandSink(); #region currently not used _commandSink.RegisterCommand(_copyUrlCommand, CanExecuteCopyUrlCommand, ExecuteCopyUrlCommand); _commandSink.RegisterCommand(GoBackCommand, CanExecuteGoBackCommand, ExecuteGoBackCommand); _commandSink.RegisterCommand(GoHomeCommand, CanExecuteGoHomeCommand, ExecuteGoHomeCommand); _commandSink.RegisterCommand(GalleryCommand, CanExecuteGalleryCommand, ExecuteGalleryCommand); _commandSink.RegisterCommand(PlaybackCommand, CanExecutePlaybackCommand, ExecutePlaybackCommand); _commandSink.RegisterCommand(_goToPageCommand, CanExecuteGoToPageCommand, ExecuteGoToPageCommand); #endregion //_commandSink.RegisterCommand(AppNavigationCommands.GoToFavoritesCommand, CanExecuteGoToFavoritesCommand, ExecuteGoToFavoritesCommand); //_commandSink.RegisterCommand(AppNavigationCommands.GoToDownloadsCommand, CanExecuteGoToDownloadsCommand, ExecuteGoToDownloadsCommand); _commandSink.RegisterCommand(AppNavigationCommands.GoToSupportCommand, CanExecuteGoToSupportCommand, ExecuteGoToSupportCommand); _commandSink.RegisterCommand(AppNavigationCommands.GoToSettingsCommand, CanExecuteGoToSettingsCommand, ExecuteGoToSettingsCommand); _commandSink.RegisterCommand(AppNavigationCommands.BuyNowCommand, CanExecuteBuyNowCommand, ExecuteBuyNowCommand); _commandSink.RegisterCommand(AppNavigationCommands.FavoriteCommand, CanExecuteFavoriteCommand, ExecuteFavoriteCommand); _commandSink.RegisterCommand(AppNavigationCommands.DownloadCommand, CanExecuteDownloadCommand, ExecuteDownloadCommand); _commandSink.RegisterCommand(AppNavigationCommands.PlaylistCommand, CanExecutePlaylistCommand, ExecutePlaylistCommand); ReplacementPlaybackExtension = DefaultReplacementPlaybackExtension; ReplacePlaybackExtension = Settings.Default.ForceWmvPlayback; ShowNavigationZone = Settings.Default.ShowNavigationZone; ShowFeedbackZone = Settings.Default.ShowFeedbackZone; ShowTitleZone = Settings.Default.ShowTitleZone; }
private static List<Download> GetDownloadables(UtilityDataModel udm) { var download = (from dl in udm.Downloads let isDownloading = dl.IsDownloading let percentComplete = dl.PercentComplete let attemptedCount = dl.DownloadAttemptedCount let error = dl.ErrorMessage where !isDownloading && percentComplete < Constants.MIN_PERCENT_FOR_COMPLETED_DOWNLOAD && !dl.NeedsReset select dl).ToList(); return download; }