public IEnumerable <RuleAction> GetRulesMenuForProgram(TvProgram program) { var rule = GetRuleForProgram(program); var ruleType = rule == null ? RuleType.Undefined : rule.Type; var actions = new List <RuleAction>(); if (ruleType == RuleType.Highlight) { actions.Add(new RuleAction(rule, RuleActionType.Remove)); } else if (ruleType == RuleType.Hide) { actions.Add(new RuleAction(rule, RuleActionType.Remove)); } else { if (program.Type == TvProgram.ProgramType.SerieTv) { AddRules(actions, new TvSeriesSelector(program.Title), ProgramRuleCompatibility.Both); } else if (program.Type == TvProgram.ProgramType.Film) { if (!string.IsNullOrEmpty(program.Genre)) { AddRules(actions, new MovieGenreSelector(program.Genre), ProgramRuleCompatibility.Both); } } else { AddRules(actions, new SpecificProgramSelector(program.Title), ProgramRuleCompatibility.Both); } if (ProgramSelector.InformationProgramSelector.Matches(program)) { AddRules(actions, ProgramSelector.InformationProgramSelector, ProgramRuleCompatibility.CanHide); } if (ProgramSelector.DocumentarySelector.Matches(program)) { AddRules(actions, ProgramSelector.DocumentarySelector, ProgramRuleCompatibility.Both); } if (ProgramSelector.TopicalProgramSelector.Matches(program)) { AddRules(actions, ProgramSelector.TopicalProgramSelector, ProgramRuleCompatibility.Both); } if (ProgramSelector.ItalianMovieSelector.Matches(program)) { AddRules(actions, ProgramSelector.ItalianMovieSelector, ProgramRuleCompatibility.CanHide); } if (ProgramSelector.ItalianSeriesSelector.Matches(program)) { AddRules(actions, ProgramSelector.ItalianSeriesSelector, ProgramRuleCompatibility.CanHide); } } return(actions.OrderBy(x => x.DisplayName)); }
public static TvProgram FromHtml(VirtualString html, DateTime day, TvChannel channel) { TvProgram prog; prog = new TvProgram(html, day); prog.Channel = channel; return(prog); }
public ProgramRule GetRuleForProgram(TvProgram program) { var matchingRules = GetAllMatchingRulesForProgram(program).ToList(); if (!matchingRules.Any()) { return(null); } var activeRule = matchingRules[0]; for (int i = 1; i < matchingRules.Count; i++) { var currRule = matchingRules[i]; if (currRule.Type == activeRule.Type) { activeRule = currRule; } } return(activeRule); }
public IOrderedEnumerable <ProgramRule> GetAllMatchingRulesForProgram(TvProgram program) { return(ProgramRules .Where(x => x.Matches(program)) .OrderByDescending(x => x.ProgramType.Strength)); }
public IEnumerable <TvProgram> GetProgramsFromSavedHtmlIfAvailable() { if (_html == null) { return(Enumerable.Empty <TvProgram>()); } var p = new QuickTextParser(_html.BetweenS("<body", "class=\"piedipagina\""), "<div style=\"font-size:180%; text-align:right; "); var programs = new List <TvProgram>(); bool midnightPassed = false; double time_prev = 0; double time_curr = 0; TvProgram previousProgram = null; foreach (var t in p) { if (!t.Contains("<strong>Ore")) { continue; } TvProgram prog; try { prog = TvProgram.FromHtml(t, Day, Channel); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Errore TvProgram: " + ex.Message); continue; } time_curr = prog.TimeOfDay.TotalSeconds; if (time_curr < time_prev) { if (midnightPassed) { throw new InvalidDataException("Channels are not correctly ordered."); } else { midnightPassed = true; } } if (midnightPassed) { prog.FixToNextDay(); } time_prev = time_curr; if (previousProgram != null) { previousProgram.Duration = prog.Date - previousProgram.Date; } previousProgram = prog; // if (!midnightPassed && prog.time) programs.Add(prog); //if (t.Contains("ATTENZIONE: i seguenti programmi si riferiscono al giorno dopo.")) ; } return(programs); }
public ProgramControl(TvProgram p) { InitializeComponent(); program = p; // lblDate.Content = p.Date.ToString("ddd dd"); lblProgramType.Text = GetProgramTypeDisplayName(p.Type); lblProgramType.Background = GetProgramTypeDisplayColor(p.Type); lblProgramType.Foreground = GetProgramTypeTextColor(p.Type); lblTime.Content = p.Date.ToString("HH:mm"); lblTitle.Text = p.Title; if (p.Channel.Logo != null) { try { picChannelLogo.Source = ConvertToBitmapSource((System.Drawing.Bitmap)p.Channel.Logo); } catch { } } if (program.Genre != null) { lblGenre.Text = program.Genre; } else { lblGenre.Visibility = System.Windows.Visibility.Collapsed; } if (program.Year != null) { lblYear.Text = "(" + program.Year + ")"; } else { lblYear.Visibility = System.Windows.Visibility.Collapsed; } if (program.Rating != null) { var rating = ""; for (double i = 0; i < program.Rating; i += 0.2) { rating += "«"; } lblRating.Text = rating; byte v = (byte)(program.Rating * 255); if (program.Cast != null) { lblCast.Content = program.Cast; } // lblRating.Foreground = new SolidColorBrush(Color.FromArgb((byte)255, (byte)(255 - v), v, (byte)0)); } else { lblRating.Visibility = System.Windows.Visibility.Collapsed; } // if (program.Type != TvProgram.ProgramType.SerieTv && program.Type != TvProgram.ProgramType.Film) //if(program is Movie) if(antiufo.TvGuide.Program.ProgramSuggestions.Utils.IsItalianCast((program as Movie).Cast) ) Collapsed = true; // Collapsed = true; UpdateViewState(); // this.isEven = isEven; //this.Background = StandardBackgroundColor; }