public void InitProperties() { var matches = AppDelegate.SharedAppDelegate.UoW.MatchRepo.GetActualMatches(AppDelegate.SharedAppDelegate.UoW.LeagueRepo.GetAllLeague()); SoonMatches = matches.Where(m => m.State != StateEnum.Playing).OrderBy(m => m.LeagueId); if (SoonMatches.Count() == 0) { HasSoonMatch = false; } else { HasSoonMatch = true; SoonTeams = AppDelegate.SharedAppDelegate.UoW.TeamRepo.GetTeamsByMatches(SoonMatches); SoonIndexes = CreateIndexes(SoonMatches); } LiveMatches = matches.Where(m => m.State == StateEnum.Playing).OrderBy(m => m.LeagueId); if (LiveMatches.Count() == 0) { HasLiveMatch = false; } else { HasLiveMatch = true; LiveTeams = AppDelegate.SharedAppDelegate.UoW.TeamRepo.GetTeamsByMatches(LiveMatches); LiveIndexes = CreateIndexes(LiveMatches); } }
void Instance_MatchTimeUpdated(int id) { var index = LiveMatches.ToList().IndexOf(LiveMatches.First(m => m.Id == id)); var match = AppDelegate.SharedAppDelegate.UoW.MatchRepo.GetMatchById(id); var newTime = Floorball.UIHelper.GetMatchTime(match.Time, match.State); }
private UITableViewCell CreateLeagueNameCell(UITableView tableView, Foundation.NSIndexPath indexPath, List <int> indexes) { var cell = tableView.DequeueReusableCell("LeagueNameCell", indexPath); cell.BackgroundColor = UIColor.Clear.FromHex(LightGreen.hex); var match = LiveMatches.DistinctBy(m => m.LeagueId).ElementAt(indexes.IndexOf(indexPath.Row)); var league = AppDelegate.SharedAppDelegate.UoW.LeagueRepo.GetLeagueById(match.LeagueId); (cell.ViewWithTag(101) as UIImageView).Image = UIImage.FromBundle(league.Country.ToString().ToLower()); (cell.ViewWithTag(102) as UILabel).Text = league.Name; return(cell); }
public override nint RowsInSection(UITableView tableView, nint section) { if (section == 0) { if (!HasLiveMatch) { return(1); } return(LiveMatches.Count() + LiveMatches.DistinctBy(m => m.LeagueId).Count()); } if (!HasSoonMatch) { return(1); } return(SoonMatches.Count() + SoonMatches.DistinctBy(m => m.LeagueId).Count()); }
public override void PrepareForSegue(UIStoryboardSegue segue, Foundation.NSObject sender) { switch (segue.Identifier) { case "MatchFromActual": var vc = segue.DestinationViewController as MatchViewController; if (TableView.IndexPathForSelectedRow.Section == 0) { vc.Match = LiveMatches.ElementAt(TableView.IndexPathForSelectedRow.Row - LiveIndexes.Where(i => i < TableView.IndexPathForSelectedRow.Row).Count()); } else { vc.Match = SoonMatches.ElementAt(TableView.IndexPathForSelectedRow.Row - SoonIndexes.Where(i => i < TableView.IndexPathForSelectedRow.Row).Count()); } break; default: break; } }
public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath) { if ((indexPath.Section == 0 && !HasLiveMatch) || (indexPath.Section == 1 && !HasSoonMatch)) { var cell = tableView.DequeueReusableCell("NoMatchCell"); cell.BackgroundColor = UIColor.Clear.FromHex(LightGreen.hex); return(cell); } Match match; Team homeTeam; Team awayTeam; if (indexPath.Section == 0) { if (LiveIndexes.Contains(indexPath.Row)) { return(CreateLeagueNameCell(tableView, indexPath, LiveIndexes)); } else { LiveMatchCell cell = tableView.DequeueReusableCell("LiveMatchCell", indexPath) as LiveMatchCell; cell.BackgroundColor = UIColor.Clear.FromHex(LightGreen.hex); var color = cell.ViewWithTag(500).BackgroundColor; //cell.ViewWithTag(500).BackgroundColor = cell.ViewWithTag(500).BackgroundColor.ColorWithAlpha((float)0.5);r match = LiveMatches.ElementAt(indexPath.Row - LiveIndexes.Where(i => i < indexPath.Row).Count()); homeTeam = LiveTeams.First(t => t.Id == match.HomeTeamId); awayTeam = LiveTeams.First(t => t.Id == match.AwayTeamId); if (match.State == StateEnum.Playing) { AnimateView(cell.ViewWithTag(800), true); } return(CreateActualTile(cell, match, homeTeam, awayTeam)); } } else { if (SoonIndexes.Contains(indexPath.Row)) { return(CreateLeagueNameCell(tableView, indexPath, SoonIndexes)); } else { LiveMatchCell cell = tableView.DequeueReusableCell("LiveMatchCell", indexPath) as LiveMatchCell; cell.BackgroundColor = UIColor.Clear.FromHex(LightGreen.hex); match = SoonMatches.ElementAt(indexPath.Row - SoonIndexes.Where(i => i < indexPath.Row).Count()); homeTeam = SoonTeams.First(t => t.Id == match.HomeTeamId); awayTeam = SoonTeams.First(t => t.Id == match.AwayTeamId); return(CreateActualTile(cell, match, homeTeam, awayTeam)); } } }