private async void Yes_Clicked(object sender, EventArgs e) { var context = Confirmation.BindingContext as TMDBContainer; lock (NetworkDatabase.ShowIDs) { NetworkDatabase.ShowIDs[show] = context.ID; NetworkDatabase.ShowDescriptions[context.ID] = context.Description; NetworkDatabase.IMDBList[context.ID] = ""; NetworkDatabase.ShowImages[context.ID] = context.BaseImage; Application.Current.Properties["SHOWID " + show] = context.ID; } NetworkDatabase.backup = true; var NewestShow = NetworkDatabase.NetworkList.AsParallel().SelectMany(x => x.shows).Where(x => x.Name == show).OrderByDescending(x => x.year).ThenBy(x => x.Season).First(); var Network = NetworkDatabase.NetworkList.Where(x => x.shows.Contains(NewestShow)).First(); //var Adjustments = Network.model.GetAdjustments(true); var Average = Network.model.GetAverageThreshold(true); var Prediction = new PredictionContainer(NewestShow, Network, Average); await(Parent.Parent as ViewPage).Navigation.PushModalAsync(new ShowDetailPage(Prediction, true)); await(Parent.Parent as ViewPage).Navigation.PopAsync(); }
public Toolbar(ContentPage page, PredictionContainer p) //ShowDetail Page Without Network { prediction = p; UsePrediction = true; Parent = page; }
public ScoreBoard(PredictionContainer p) { UsePrediction = true; prediction = p; Load(p.network); }
public Toolbar(ContentPage page, MiniNetwork n, PredictionContainer p) //ShowDetailPage with Network { network = n; UseNetwork = true; prediction = p; UsePrediction = true; Parent = page; }
public ShowDetailPage(PredictionContainer p, bool RemoveStackAfterLoad = false) { var network = p.network; var MenuItems = new ObservableCollection <ShowDetailMenuItem>(); if (p.UseNetwork) { foreach (ToolbarItem t in new Toolbar(this, network, p).ToolBarItems) { MenuItems.Add(new ShowDetailMenuItem(t)); } } else { foreach (ToolbarItem t in new Toolbar(this, p).ToolBarItems) { MenuItems.Add(new ShowDetailMenuItem(t)); } } BindingContext = p; show = p; InitializeComponent(); if (Device.RuntimePlatform == Device.UWP) { Back.IsVisible = NetworkDatabase.mainpage.home.Navigation.NavigationStack.Count == 1; } BindableLayout.SetItemsSource(OptionsMenuHidden, MenuItems); OptionsMenu.ItemsSource = MenuItems; OptionsMenuHidden.SizeChanged += OptionsMenuHidden_SizeChanged; Bar.Title = p.Name; SearchResults.NavigationParent = this; ShowImage.Source = null; SideColumn.SizeChanged += SideColumn_SizeChanged; SidePanel.PanelOpened += SidePanel_PanelOpened; LoadImage(p); if (RemoveStackAfterLoad) { Appearing += ShowDetailPage_Appearing; } }
public FixShow(PredictionContainer p) { var DisplayYear = p.DisplayYear; p.DisplayYear = false; show = p.Name; p.DisplayYear = DisplayYear; IsInitialized = true; prediction = p; InitializeComponent(); ShowName.Text = show; LoadSearch(); }
public About(PredictionContainer p) { UsePrediction = true; prediction = p; InitializeComponent(); }
public ViewPage(ContentView View, string Title) { foreach (ToolbarItem t in new Toolbar(this, View).ToolBarItems) { ToolbarItems.Add(t); } InitializeComponent(); var isFix = (View is FixShow); SearchResults = new ResultsList(isFix) { IsVisible = false }; SearchResults.NavigationParent = this; if (View is FixShow) { SearchResults.ClickResult += SearchResults_ClickResult; if ((View as FixShow).IsInitialized) { MainGrid.Children.Add(View); view = (View as FixShow); IsFixShowDisplayed = true; } else { MainGrid.Children.Add(new Label() { Text = "If a show is displaying the wrong image/description, please use the search button above to select the show that needs correcting.", FontSize = Device.GetNamedSize(NamedSize.Subtitle, typeof(Label)), Margin = 25 }); } } else { MainGrid.Children.Add(View); } if (View is Settings) { var settings = View as Settings; UsePrediction = settings.UsePrediction; if (UsePrediction) { prediction = settings.prediction; } } else if (View is About) { var about = View as About; UsePrediction = about.UsePrediction; if (UsePrediction) { prediction = about.prediction; } } else if (View is FixShow) { var fix = View as FixShow; UsePrediction = fix.IsInitialized; if (UsePrediction) { prediction = fix.prediction; } } MainGrid.Children.Add(SearchResults); Bar.Title = Title; }
async void LoadImage(PredictionContainer p) { //bool reload = false; //if (!NetworkDatabase.ShowIDs.ContainsKey(p.show.Name) && Application.Current.Properties.ContainsKey("SHOWID " + p.show.Name)) // reload = true; var ID = await NetworkDatabase.GetShowID(p.show.Name, p.network.name); if (ID > 0) { if (Device.RuntimePlatform == Device.UWP) { var uri = await NetworkDatabase.GetImageURI(ID); ShowImageUri = uri.AbsoluteUri; ShowImage.BindingContext = this; ShowImage.SetBinding(ImageEffect.TextProperty, new Binding("ShowImageUri")); p.IsLoaded = true; ShowImage.IsVisible = true; //ImageLoading.IsVisible = false; } else { ShowImage.Source = new UriImageSource { Uri = await NetworkDatabase.GetImageURI(ID), CachingEnabled = true, CacheValidity = new TimeSpan(90, 0, 0, 0) }; if (ShowImage.Source != null) { p.IsLoaded = true; ShowImage.IsVisible = true; ImageLoading.IsVisible = false; } } p.Overview = NetworkDatabase.ShowDescriptions[ID]; } //if (reload) //{ // ID = await NetworkDatabase.GetShowID(p.show.Name, p.network.name, true); // if (ID > 0) // { // ShowImage.Source = new UriImageSource // { // Uri = await NetworkDatabase.GetImageURI(ID), // CachingEnabled = true, // CacheValidity = new TimeSpan(90, 0, 0, 0) // }; // p.Overview = NetworkDatabase.ShowDescriptions[ID]; // } //} var TMDBText = "This product uses the TMDb API but is not endorsed or certified by TMDb."; var Formatted = new FormattedString(); Formatted.Spans.Add(new Span { Text = TMDBText }); if (NetworkDatabase.TMDBerror) { Formatted.Spans.Add(new Span() { Text = "Error connecting to TMDB! Some show details and/or images may temporarily be unavailable.", TextColor = Color.DarkRed }); } TMDBNotice.FormattedText = Formatted; DelayedScroll.Elapsed += DelayedScroll_Elapsed; DelayedScroll.AutoReset = false; ScrollTo(); CheckVisible.Elapsed += CheckVisible_Elapsed; }
private async void ShowsList_ItemTapped(object sender, ItemTappedEventArgs e) { var p = ShowsList.SelectedItem as PredictionContainer; if (PreviousItem != null && PreviousItem != p) { PreviousItem.ShowDetails = false; if (SidePanel.BreakdownView != null) { FadeOut(false); } } SidePanel.BindingContext = p; SidePanel.IsVisible = true; SidePanel_PanelOpened(this, new EventArgs()); if (!isDesktop) { p.ShowDetails = !p.ShowDetails; if (!p.ShowDetails) { ShowsList.SelectedItem = null; } } else { p.ShowDetails = false; ShowImage.Source = null; ShowImageUri = null; ImageLoading.IsVisible = true; //var ID = await NetworkDatabase.GetShowID(p.Name, p.network.name); //if (ID > 0) //{ // ShowImage.Source = new UriImageSource // { // Uri = await NetworkDatabase.GetImageURI(ID), // CachingEnabled = true, // CacheValidity = new TimeSpan(90, 0, 0, 0) // }; // p.Overview = NetworkDatabase.ShowDescriptions[ID]; // if (ShowImage.Source != null) // { // p.IsLoaded = true; // ShowImage.IsVisible = true; // ImageLoading.IsVisible = false; // } //} //bool reload = false; //if (!NetworkDatabase.ShowIDs.ContainsKey(p.Name) && Application.Current.Properties.ContainsKey("SHOWID " + p.Name)) // reload = true; var ID = await NetworkDatabase.GetShowID(p.show.Name, p.network.name); if (ID > 0) { if (Device.RuntimePlatform == Device.UWP) { var uri = await NetworkDatabase.GetImageURI(ID); ShowImageUri = uri.AbsoluteUri; ShowImage.BindingContext = this; ShowImage.SetBinding(ImageEffect.TextProperty, new Binding("ShowImageUri")); p.IsLoaded = true; ShowImage.IsVisible = true; //ImageLoading.IsVisible = false; } else { ShowImage.Source = new UriImageSource { Uri = await NetworkDatabase.GetImageURI(ID), CachingEnabled = true, CacheValidity = new TimeSpan(90, 0, 0, 0) }; if (ShowImage.Source != null) { p.IsLoaded = true; ShowImage.IsVisible = true; ImageLoading.IsVisible = false; } } p.Overview = NetworkDatabase.ShowDescriptions[ID]; } //if (reload) //{ // ID = await NetworkDatabase.GetShowID(p.Name, p.network.name, true); // if (ID > 0) // { // ShowImage.Source = new UriImageSource // { // Uri = await NetworkDatabase.GetImageURI(ID), // CachingEnabled = true, // CacheValidity = new TimeSpan(90, 0, 0, 0) // }; // p.Overview = NetworkDatabase.ShowDescriptions[ID]; // } //} var TMDBText = "This product uses the TMDb API but is not endorsed or certified by TMDb."; var Formatted = new FormattedString(); Formatted.Spans.Add(new Span { Text = TMDBText }); if (NetworkDatabase.TMDBerror) { Formatted.Spans.Add(new Span() { Text = "Error connecting to TMDB! Some show details and/or images may temporarily be unavailable.", TextColor = Color.DarkRed }); } TMDBNotice.FormattedText = Formatted; DelayedScroll.Elapsed += DelayedScroll_Elapsed; DelayedScroll.AutoReset = false; DelayedScroll.Start(); CheckVisible.Elapsed += CheckVisible_Elapsed; } PreviousItem = p; }
public async void LoadHighlights() { if (!Application.Current.Properties.ContainsKey("EnableHighlights") || (bool)Application.Current.Properties["EnableHighlights"]) { var year = NetworkDatabase.YearList[CurrentYear].year; var Thresholds = new Dictionary <string, double>(); foreach (MiniNetwork n in NetworkDatabase.NetworkList) { Thresholds[n.name] = n.model.GetNetworkRatingsThreshold(year); } HighlightsList.BindingContext = this; await Task.Run(async() => { try { await Device.InvokeOnMainThreadAsync(() => HighlightsList.IsVisible = true); var NewShows = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => x.year == year && x.OldOdds == 0 && x.OldRating == 0).OrderByDescending(x => x.PredictedOdds); foreach (Show s in NewShows) { var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]); var highlight = new ShowHighlights(prediction, 0); await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight)); } var RenewedOrCanceledShows = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => x.year == year && (x.Renewed || x.Canceled) && x.FinalPrediction == x.OldOdds).OrderByDescending(x => x.PredictedOdds); foreach (Show s in RenewedOrCanceledShows) { var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]); var highlight = new ShowHighlights(prediction, 1); await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight)); } var PredictionChanged = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => x.year == year && x.RenewalStatus == "" && ((int)(x.OldOdds / 0.5) != (int)(x.PredictedOdds / 0.5)) && (x.OldOdds > 0 || x.OldRating > 0)).OrderByDescending(x => x.PredictedOdds); foreach (Show s in PredictionChanged) { var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]); var highlight = new ShowHighlights(prediction, 2); await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight)); } var UpgradedOrDownGradedShows = NetworkDatabase.NetworkList.SelectMany(x => x.shows).Where(x => !PredictionChanged.Contains(x) && x.year == year && x.RenewalStatus == "" && ((int)(x.OldOdds / 0.2) != (int)(x.PredictedOdds / 0.2)) && (x.OldOdds > 0 || x.OldRating > 0)).OrderByDescending(x => x.PredictedOdds); foreach (Show s in UpgradedOrDownGradedShows) { var prediction = new PredictionContainer(s, s.network, Thresholds[s.network.name]); var highlight = new ShowHighlights(prediction, 2); await Device.InvokeOnMainThreadAsync(() => Highlights.Add(highlight)); } } catch (Exception ex) { string error = ex.ToString(); } }); } if (NetworkDatabase.YearList[NetworkDatabase.CurrentYear] == NetworkDatabase.MaxYear) { UnhideHighlights(); } }
public ShowHighlights(PredictionContainer p, int category) { show = p; GetImage(); switch (category) { case 0: NewShow = (show.show.Season == 1) ? "Series Premiere" : "Season Premiere"; Prediction = show.Status == "" ? show.Category : show.Status; if (show.Status == "") { if (show.show.PredictedOdds == 0.5) { RenewalIndex = (show.show.ShowIndex > show.show._calculatedThreshold) ? 1 : -1; } else { RenewalIndex = show.show.PredictedOdds > 0.5 ? 1 : -1; } } else { RenewalIndex = 0; } Description = show.Season; break; case 1: Prediction = show.Status; RenewalIndex = show.show.Renewed ? 1 : -1; { var correct = (show.show.Renewed && show.show.FinalPrediction >= 0.5) || (show.show.Canceled && show.show.FinalPrediction <= 0.5); var formats = new FormattedString(); var part1 = new Span { Text = correct ? "Prediction was correct " : "Prediction was incorrect " }; var part2 = correct ? new Span { Text = "✔", TextColor = Color.Green } : new Span { Text = "❌", TextColor = Color.Red }; formats.Spans.Add(part1); formats.Spans.Add(part2); Description = formats; } break; case 2: Prediction = show.Category; if (show.show.PredictedOdds == 0.5) { RenewalIndex = (show.show.ShowIndex > show.show._calculatedThreshold) ? 1 : -1; } else { RenewalIndex = show.show.PredictedOdds > 0.5 ? 1 : -1; } { string OldCategory; if (show.show.OldOdds > 0.8) { OldCategory = "Certain Renewal"; } else if (show.show.OldOdds > 0.6) { OldCategory = "Likely Renewal"; } else if (show.show.OldOdds > 0.5) { OldCategory = "Leaning Towards Renewal"; } else if (show.show.OldOdds == 0.5) { if (show.show.ShowIndex > show.show._calculatedThreshold) { OldCategory = "Leaning Towards Renewal"; } else { OldCategory = "Leaning Towards Cancellation"; } } else if (show.show.OldOdds > 0.4) { OldCategory = "Leaning Towards Cancellation"; } else if (show.show.OldOdds > 0.2) { OldCategory = "Likely Cancellation"; } else { OldCategory = "Certain Cancellation"; } Description = (show.show.PredictedOdds > show.show.OldOdds ? "Upgraded from " : "Downgraded from ") + OldCategory; } break; } }