private void ViewShow_Click_1(object sender, RoutedEventArgs e) { ListItemViewModel model = (ListItemViewModel)((MenuItem)sender).DataContext; lastModel = model; Animation.NavigateToFadeOut(this, LayoutRoot, new Uri("/ViewShow.xaml?id=" + model.Tvdb, UriKind.Relative)); }
private void RelatedImage_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ListItemViewModel model = (ListItemViewModel)((Image)sender).DataContext; App.ShowViewModel = null; Animation.NavigateToFadeOut(this, LayoutRoot, new Uri("/ViewShow.xaml?id=" + model.Tvdb, UriKind.Relative)); }
private async void CheckinEpisode_Click(object sender, RoutedEventArgs e) { this.progressBarLoading.Visibility = System.Windows.Visibility.Visible; lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; App.TrackEvent("ViewShow", "Checkin context"); if (await episodeController.checkinEpisode(lastModel.Tvdb, App.ShowViewModel.Name, Int16.Parse(App.ShowViewModel.Year), lastModel.Season, lastModel.Episode)) { lastModel.Watched = true; TraktShow show = await showController.getShowByTVDBID(lastModel.Tvdb); try { App.MainPage.ShowWatchingNowShow(await episodeController.getEpisodeByTvdbAndSeasonInfo(lastModel.Tvdb, lastModel.Season, lastModel.Episode, show), show, DateTime.UtcNow); } catch (NullReferenceException) { } ToastNotification.ShowToast("Show", "Checked in!"); } else { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed; }
private void EpisodeRate_Click(object sender, RoutedEventArgs e) { ListItemViewModel model = (ListItemViewModel)((MenuItem)sender).DataContext; lastModel = model; NavigationService.Navigate(new Uri("/RatingSelector.xaml?type=episode&imdb=" + model.Imdb + "&tvdb=" + model.Tvdb + "&year=" + model.Year + "&title=" + model.Name + "&season=" + model.Season + "&episode=" + model.Episode, UriKind.Relative)); }
private void RecentlyWatched_Click_1(object sender, RoutedEventArgs e) { ListItemViewModel model = (ListItemViewModel)((MenuItem)sender).DataContext; lastModel = model; Animation.NavigateToFadeOut(this, LayoutRoot, new Uri("/CheckinHistory.xaml", UriKind.Relative)); }
private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (lastModel == null) { ListItemViewModel model = (ListItemViewModel)((StackPanel)sender).DataContext; Animation.NavigateToFadeOut(this, LayoutRoot, new Uri("/ViewEpisode.xaml?id=" + model.Tvdb + "&season=" + model.Season + "&episode=" + model.Episode, UriKind.Relative)); } }
public void loadRecent() { if (!Loading) { this.EmptyRecent.Visibility = System.Windows.Visibility.Collapsed; this.indicator = App.ShowLoading(this); this.Loading = true; App.ViewModel.clearRecent(); TraktShow[] shows = showController.getRecentShows(); TraktMovie[] movies = movieController.getRecentMovies(); List <Object> mergedList = new List <object>(); mergedList.AddRange(shows); mergedList.AddRange(movies); mergedList.Sort((x, y) => DateTime.Compare(DateTime.Parse(y.ToString()), (DateTime.Parse(x.ToString())))); foreach (Object movieOrShow in mergedList) { if (App.ViewModel.RecentItems.Count == 12) { break; } if (typeof(TraktShow) == movieOrShow.GetType()) { TraktShow show = (TraktShow)movieOrShow; ListItemViewModel newModel = new ListItemViewModel() { ImageSource = show.Images.Poster, Tvdb = show.tvdb_id, Type = "show" }; App.ViewModel.RecentItems.Add(newModel); newModel.LoadPosterImage(); } else { TraktMovie movie = (TraktMovie)movieOrShow; ListItemViewModel newModel = new ListItemViewModel() { ImageSource = movie.Images.Poster, Imdb = movie.imdb_id, Type = "movie" }; App.ViewModel.RecentItems.Add(newModel); newModel.LoadPosterImage(); } } if (App.ViewModel.RecentItems.Count == 0) { this.EmptyRecent.Visibility = System.Windows.Visibility.Visible; } App.ViewModel.NotifyPropertyChanged("RecentItems"); this.indicator.IsVisible = false; this.Loading = false; } }
public void addShout(ListItemViewModel model) { if (this.ShoutItems == null) { this.ShoutItems = new ObservableCollection <ListItemViewModel>(); } this.ShoutItems.Add(model); NotifyPropertyChanged("ShoutItems"); }
public static string GetCaptionGroup(ListItemViewModel model) { char key = char.ToLower(model.Name[0]); if (key < 'a' || key > 'z') { key = '#'; } return(key.ToString()); }
private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ListItemViewModel model = (ListItemViewModel)((Image)sender).DataContext; if (model.Type.Equals("show")) { Animation.NavigateToFadeOut(this, LayoutRoot, new Uri("/ViewShow.xaml?id=" + model.Tvdb, UriKind.Relative)); } else { Animation.NavigateToFadeOut(this, LayoutRoot, new Uri("/ViewMovie.xaml?id=" + model.Imdb, UriKind.Relative)); } }
private async void CheckinMovie_Click(object sender, RoutedEventArgs e) { lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; if (await movieController.checkinMovie(lastModel.Imdb, lastModel.Name, lastModel.Year)) { ShowWatchingNowMovie(await movieController.getMovieByImdbId(lastModel.Imdb), DateTime.UtcNow); ToastNotification.ShowToast("Movie", "Checked in!"); } else { ToastNotification.ShowToast("Movie", "There is already a checkin in progress."); } }
private async void WatchlistMovie_Click(object sender, RoutedEventArgs e) { lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; if (await movieController.addMovieToWatchlist(lastModel.Imdb, lastModel.Name, lastModel.Year)) { lastModel.InWatchList = true; ToastNotification.ShowToast("Movie", "Movie added to watchlist."); } else { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; }
private void WatchlistMovie_Click(object sender, RoutedEventArgs e) { lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; var watchlistClient = new WebClient(); watchlistClient.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadMovieWatchlistStringCompleted); WatchlistAuth auth = new WatchlistAuth(); auth.Movies = new TraktMovie[1]; auth.Movies[0] = new TraktMovie(); auth.Movies[0].imdb_id = lastModel.Imdb; auth.Movies[0].Title = lastModel.Name; auth.Movies[0].year = Int16.Parse(lastModel.SubItemText); watchlistClient.UploadStringAsync(new Uri("https://api.trakt.tv/movie/watchlist/9294cac7c27a4b97d3819690800aa2fedf0959fa"), AppUser.createJsonStringForAuthentication(typeof(WatchlistAuth), auth)); }
private async void SeenMovie_Click(object sender, RoutedEventArgs e) { lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; if (await movieController.markMovieAsSeen(lastModel.Imdb, lastModel.Name, lastModel.Year)) { lastModel.Watched = true; ToastNotification.ShowToast("Movie", "Movie marked as watched."); } else { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; }
private void client_UploadMovieSeenStringCompleted(object sender, UploadStringCompletedEventArgs e) { try { String jsonString = e.Result; lastModel.Watched = true; ToastNotification.ShowToast("Movie", "Movie marked as watched."); } catch (WebException) { ErrorManager.ShowConnectionErrorPopup(); } catch (TargetInvocationException) { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; }
private void ViewEpisodeNow_Click(object sender, RoutedEventArgs e) { ListItemViewModel model = (ListItemViewModel)((MenuItem)sender).DataContext; switch (model.Type) { case "episode": NavigationService.Navigate(new Uri("/ViewEpisode.xaml?id=" + model.Tvdb + "&season=" + model.Season + "&episode=" + model.Episode, UriKind.Relative)); break; case "movie": NavigationService.Navigate(new Uri("/ViewMovie.xaml?id=" + model.Imdb, UriKind.Relative)); break; } }
void client_UploadMovieWatchlistStringCompleted(object sender, UploadStringCompletedEventArgs e) { try { String jsonString = e.Result; lastModel.InWatchList = true; ToastNotification.ShowToast("Movie", "Movie added to watchlist."); } catch (WebException) { ErrorManager.ShowConnectionErrorPopup(); } catch (TargetInvocationException) { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; }
private async void SeenEpisode_Click(object sender, RoutedEventArgs e) { this.progressBarLoading.Visibility = System.Windows.Visibility.Visible; App.TrackEvent("ViewShow", "Seen context"); lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; if (await episodeController.markEpisodeAsSeen(lastModel.Tvdb, App.ShowViewModel.Imdb, App.ShowViewModel.Name, Int16.Parse(App.ShowViewModel.Year), lastModel.Season, lastModel.Episode)) { lastModel.Watched = true; ToastNotification.ShowToast("Show", "Episode marked as watched."); } else { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed; }
private async void LoadRelatedShows() { this.progressBarLoading.Visibility = System.Windows.Visibility.Visible; TraktShow[] relatedShows = await showController.getRelatedShows(this.Show.tvdb_id); foreach (TraktShow relatedShow in relatedShows) { ListItemViewModel newModel = new ListItemViewModel() { ImageSource = relatedShow.Images.Poster, Tvdb = relatedShow.tvdb_id, Type = "show" }; App.ShowViewModel.RelatedShows.Add(newModel); newModel.LoadPosterImage(); } App.ShowViewModel.RefreshRelatedShows(); this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed; }
private async void RemoveWatchlistEpisode_Click(object sender, RoutedEventArgs e) { App.TrackEvent("ViewShow", "Unwatchlist context"); this.progressBarLoading.Visibility = System.Windows.Visibility.Visible; lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; if (await episodeController.removeEpisodeFromWatchlist(lastModel.Tvdb, App.ShowViewModel.Imdb, App.ShowViewModel.Name, Int16.Parse(App.ShowViewModel.Year), lastModel.Season, lastModel.Episode)) { lastModel.InWatchList = false; ToastNotification.ShowToast("Show", "Episode removed from watchlist."); } else { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed; }
public async void ShowWatchingNowMovie(TraktMovie movie, DateTime watchTime) { this.WatchingNowGrid.Visibility = System.Windows.Visibility.Visible; if ((AppUser.Instance.BackgroundWallpapersEnabled || (AppUser.Instance.ImagesWithWIFI && StorageController.IsConnectedToWifi()))) { this.LayoutRoot.Background = new ImageBrush { ImageSource = await movieController.getFanartImage(movie.imdb_id, movie.Images.Fanart), Opacity = 0.0, Stretch = Stretch.UniformToFill, }; } App.ViewModel.clearWatching(); this.WatchingNowGrid.Visibility = System.Windows.Visibility.Visible; ListItemViewModel model = new ListItemViewModel() { Type = "movie", Year = movie.year, Name = movie.Title, ImageSource = movie.Images.Fanart, Imdb = movie.imdb_id, SubItemText = movie.year.ToString() }; model.LoadScreenImage(); TimeSpan percentageCompleteTimeSpan = DateTime.UtcNow - watchTime; model.WatchedCompletion = ((Double)percentageCompleteTimeSpan.TotalMinutes / (Double)(movie.Runtime)) * 100; if (Double.IsInfinity(model.WatchedCompletion)) { model.WatchedCompletion = 0; } App.ViewModel.WatchingNow = model; if (this.LayoutRoot.Background != null) { Animation.ImageFadeIn(this.LayoutRoot.Background); } Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { App.ViewModel.NotifyPropertyChanged("WatchingNow"); })); }
public async void ShowWatchingNowShow(TraktEpisode episode, TraktShow show, DateTime watchTime) { this.WatchingNowGrid.Visibility = System.Windows.Visibility.Visible; this.LayoutRoot.Background = new ImageBrush { ImageSource = await showController.getFanartImage(show.tvdb_id, show.Images.Fanart), Opacity = 0.0, Stretch = Stretch.UniformToFill, }; App.ViewModel.clearWatching(); this.WatchingNowGrid.Visibility = System.Windows.Visibility.Visible; ListItemViewModel model = new ListItemViewModel() { Type = "episode", Year = show.year, Name = show.Title, ImageSource = episode.Images.Screen, Imdb = show.tvdb_id + episode.Season + episode.Number, SubItemText = "Season " + episode.Season + ", Episode " + episode.Number, Episode = episode.Number, Season = episode.Season, Tvdb = show.tvdb_id, Watched = episode.Watched, Rating = episode.MyRatingAdvanced, InWatchList = episode.InWatchlist }; model.LoadScreenImage(); TimeSpan percentageCompleteTimeSpan = DateTime.UtcNow - watchTime; model.WatchedCompletion = ((Double)percentageCompleteTimeSpan.TotalMinutes / (Double)(show.Runtime)) * 100; if (Double.IsInfinity(model.WatchedCompletion)) { model.WatchedCompletion = 0; } App.ViewModel.WatchingNow = model; if (this.LayoutRoot.Background != null) { Animation.ImageFadeIn(this.LayoutRoot.Background); } Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { App.ViewModel.NotifyPropertyChanged("WatchingNow"); })); }
private void CheckinMovie_Click(object sender, RoutedEventArgs e) { lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; var checkinClient = new WebClient(); checkinClient.UploadStringCompleted += new UploadStringCompletedEventHandler(checkinClient_UploadStringCompleted); CheckinAuth auth = new CheckinAuth(); auth.imdb_id = lastModel.Imdb; auth.Title = lastModel.Name; auth.year = Int16.Parse(lastModel.SubItemText); auth.AppDate = AppUser.getReleaseDate(); var assembly = Assembly.GetExecutingAssembly().FullName; var fullVersionNumber = assembly.Split('=')[1].Split(',')[0]; auth.AppVersion = fullVersionNumber; checkinClient.UploadStringAsync(new Uri("https://api.trakt.tv/movie/checkin/9294cac7c27a4b97d3819690800aa2fedf0959fa"), AppUser.createJsonStringForAuthentication(typeof(CheckinAuth), auth)); }
private void SeenMovie_Click(object sender, RoutedEventArgs e) { lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; var seenClient = new WebClient(); seenClient.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadMovieSeenStringCompleted); WatchedAuth auth = new WatchedAuth(); auth.Movies = new TraktMovieRequest[1]; auth.Movies[0] = new TraktMovieRequest(); auth.Movies[0].imdb_id = lastModel.Imdb; auth.Movies[0].Title = lastModel.Name; auth.Movies[0].year = Int16.Parse(lastModel.SubItemText); auth.Movies[0].Plays = 1; DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); auth.Movies[0].LastPlayed = (long)(DateTime.UtcNow - UnixEpoch).TotalSeconds; seenClient.UploadStringAsync(new Uri("https://api.trakt.tv/movie/seen/9294cac7c27a4b97d3819690800aa2fedf0959fa"), AppUser.createJsonStringForAuthentication(typeof(WatchedAuth), auth)); }
void checkinClient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e) { try { String jsonString = e.Result; if (jsonString.Contains("failure")) { ToastNotification.ShowToast("Movie", "There is already a checkin in progress."); } else { ToastNotification.ShowToast("Movie", "Checked in!"); } } catch (WebException) { ErrorManager.ShowConnectionErrorPopup(); } catch (TargetInvocationException) { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; }
private async void Grid_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ListItemViewModel model = (ListItemViewModel)((Grid)sender).DataContext; String id; NavigationContext.QueryString.TryGetValue("id", out id); if (!String.IsNullOrEmpty(id)) { ContactBindingManager bindingManager = await ContactBindings.GetAppContactBindingManagerAsync(); ContactBinding entity = await bindingManager.GetContactBindingByRemoteIdAsync(model.Name);; await bindingManager.CreateContactBindingTileAsync(id, entity); NavigationService.Navigate(new Uri("/Friend.xaml?friendid=" + model.Name + "&assigned=true" + "&isKnown=true", UriKind.Relative)); } else { Animation.NavigateToFadeOut(this, LayoutRoot, new Uri("/Friend.xaml?friendid=" + model.Name + "&isKnown=true", UriKind.Relative)); } }
private void EpisodeList_ItemUnrealized(object sender, ItemRealizationEventArgs e) { ListItemViewModel model = (ListItemViewModel)e.Container.DataContext; model.ScreenImage = null; }
private async void LoadUnwatchedEpisodeData() { this.progressBarLoading.Visibility = System.Windows.Visibility.Visible; App.ShowViewModel.UnWatchedEpisodeItems = new ObservableCollection <ListItemViewModel>(); App.ShowViewModel.RefreshUnwatchedEpisodes(); TraktEpisode[] episodes = await this.showController.getAllUnwatchedEpisodesOfShow(this.Show); if (episodes.Length > 0) { Dictionary <Int16, List <TraktEpisode> > seasonEpisodes = new Dictionary <Int16, List <TraktEpisode> >(); int counter = 0; foreach (TraktEpisode episodeIt in episodes) { if (counter++ < 60) { if (seasonEpisodes.ContainsKey(Int16.Parse(episodeIt.Season))) { seasonEpisodes[Int16.Parse(episodeIt.Season)].Add(episodeIt); } else { seasonEpisodes.Add(Int16.Parse(episodeIt.Season), new List <TraktEpisode>()); seasonEpisodes[Int16.Parse(episodeIt.Season)].Add(episodeIt); } } else { break; } } foreach (KeyValuePair <Int16, List <TraktEpisode> > keyvalue in seasonEpisodes.OrderBy(item => item.Key)) { Boolean isHeader = true; foreach (TraktEpisode episode in seasonEpisodes[keyvalue.Key]) { ListItemViewModel model = new ListItemViewModel() { Name = episode.Title, ImageSource = (AppUser.Instance.SmallScreenshotsEnabled || (AppUser.Instance.ImagesWithWIFI && StorageController.IsConnectedToWifi())) ? episode.Images.Screen : null, Imdb = this.Show.imdb_id + episode.Season + episode.Number, SubItemText = "Season " + episode.Season + ", Episode " + episode.Number, Episode = episode.Number, Season = episode.Season, Tvdb = this.Show.tvdb_id, Watched = episode.Watched, Rating = episode.MyRatingAdvanced, InWatchList = episode.InWatchlist }; if (isHeader) { model.HasHeader = true; model.Header = "Season " + keyvalue.Key; isHeader = false; } App.ShowViewModel.UnWatchedEpisodeItems.Add(model); } } App.ShowViewModel.RefreshUnwatchedEpisodes(); } else { NoUnWatchedEpisodes.Visibility = System.Windows.Visibility.Visible; } this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed; }
private void Grid_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ListItemViewModel model = (ListItemViewModel)((Grid)sender).DataContext; NavigationService.Navigate(new Uri("/Friend.xaml?friendid=" + model.Name + "&isKnown=false", UriKind.Relative)); }
private void LongListSelector_ItemUnrealized(object sender, ItemRealizationEventArgs e) { ListItemViewModel model = (ListItemViewModel)e.Container.DataContext; model.PosterImage = null; }