private void ShowResults()
        {
            lstResults.Title   = "Results";
            lstResults.Columns = new List <ListColumn>()
            {
                new ListColumn(LangResources.CurLang.League, 175),
                new ListColumn(LangResources.CurLang.Home, 250),
                new ListColumn(" ", 50, HorizontalAlignment.Center),
                new ListColumn(LangResources.CurLang.Away, 250, HorizontalAlignment.Right)
            };

            List <ListRow> rows = new List <ListRow>();
            TeamAdapter    ta   = new TeamAdapter();
            LeagueAdapter  la   = new LeagueAdapter();

            foreach (Fixture f in SetupData.FixtureData)
            {
                rows.Add(new ListRow(f.UniqueID, new List <object>()
                {
                    la.GetLeague(f.LeagueID).Name,
                    ta.GetTeam(f.TeamIDs[0]).Name,
                    string.Format("{0} - {1}", f.Score[0].ToString(), f.Score[1].ToString()),
                    ta.GetTeam(f.TeamIDs[1]).Name
                }));
            }

            lstResults.Rows          = rows;
            lstResults.SelectionMode = SelectMode.Highlight;
        }
        public CreateGame()
        {
            InitializeComponent();

            for (int i = 1; i <= 31; i++)
            {
                cboDOBDay.Items.Add(i.ToString());
            }
            for (int i = 1; i <= 12; i++)
            {
                cboDOBMonth.Items.Add(new DateTime(1979, i, 1).ToString("MMMM", CultureInfo.InvariantCulture));
            }
            for (int i = 1900; i <= DateTime.Now.Year; i++)
            {
                cboDOBYear.Items.Add(i.ToString());
            }

            LeagueAdapter la = new LeagueAdapter();

            Leagues = la.GetLeagues();

            foreach (League l in Leagues)
            {
                LeaguePaging.Items.Add(new PagingItem()
                {
                    ID = l.UniqueID, Name = l.Name
                });
            }

            LeaguePaging.DisplayItem(0);

            SetupText();
            SetupList();
            UpdateTeams();
        }
Beispiel #3
0
        private void UpdateLeagueTable()
        {
            // Headings[] should contain: Pos,Team,P,W,D,L,F,A,GD,Pts, or equivalent
            string[] Headings = LangResources.CurLang.LeagueTableHeadings.Split(new string[] { "," }, StringSplitOptions.None);

            LeagueAdapter la = new LeagueAdapter();

            lstLeague.Title   = la.GetLeague(SetupData.TeamData.LeagueID).Name;
            lstLeague.Columns = new List <ListColumn>()
            {
                new ListColumn(Headings[0], 75),
                new ListColumn(Headings[1], 300),
                new ListColumn(Headings[2], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[3], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[4], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[5], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[6], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[7], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[8], 75, HorizontalAlignment.Right),
                new ListColumn(Headings[9], 75, HorizontalAlignment.Right),
            };


            List <LeagueTableRecord> table = la.LeagueTable(SetupData.TeamData.LeagueID);

            List <ListRow> rows = new List <ListRow>();

            for (int i = 0; i < table.Count(); i++)
            {
                LeagueTableRecord t = table[i];

                rows.Add(new ListRow(t.TeamID, new List <object>()
                {
                    (i + 1).ToString(),
                    t.Name,
                    t.SeasonStatistics.GamesPlayed.ToString(),
                    t.SeasonStatistics.Won.ToString(),
                    t.SeasonStatistics.Drawn.ToString(),
                    t.SeasonStatistics.Lost.ToString(),
                    t.SeasonStatistics.GoalsScored.ToString(),
                    t.SeasonStatistics.GoalsConceded.ToString(),
                    t.SeasonStatistics.GoalDifference.ToString(),
                    t.SeasonStatistics.Points.ToString()
                }));
            }

            lstLeague.Rows               = rows;
            lstLeague.SelectionMode      = SelectMode.Callback;
            lstLeague.Callback_ItemClick = () => SetupData.Parent.ShowTeamScreen(lstLeague.SelectedID);
        }
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                RequestWindowFeature(WindowFeatures.NoTitle);

                base.OnCreate(bundle);
                LoggerMobile.Instance.logMessage("Opening LeaguesActibity", LoggerEnum.message);
                SetContentView(Resource.Layout.PublicLeagues);
                LegacyBar = FindViewById<LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);
                LegacyBar.SetHomeLogo(Resource.Drawable.icon);
                LegacyBar.SeparatorColor = Color.Purple;

                LegacyBarAction azAction = new MenuAction(this, null, Resource.Drawable.a_z);
                LegacyBar.AddAction(azAction);

                LegacyBar = FindViewById<LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);
                AddHomeAction(typeof(Main), Resource.Drawable.icon);
                // Get our button from the layout resource,
                // and attach an event to it

                Action<LeaguesJson> leagues = new Action<LeaguesJson>(UpdateAdapter);
                LegacyBar.ProgressBarVisibility = ViewStates.Visible;
                League.PullLeagues(lastPagePulled, PAGE_COUNT, "", (Context)this, leagues);


                skaterList = FindViewById<ListView>(Resource.Id.leagueList);
                initialArray = new LeaguesJson();
                Action pullMore= new Action(PullMore);
                ListAdapter = new LeagueAdapter(this, initialArray.Leagues, pullMore);
                skaterList.Adapter = ListAdapter;
                skaterList.FastScrollEnabled = true;


                skaterList.ItemClick += skaterList_ItemClick;
                var myString = new SpannableStringBuilder("lol");
                Selection.SelectAll(myString); // needs selection or Index Out of bounds
                _dialog = new MyCharacterPickerDialog(this, new View(this), myString, options, false);
                _dialog.Clicked += (sender, args) =>
                {
                    lastPagePulled = 0;
                    lastLetterPulled = args.Text;
                    LegacyBar.ProgressBarVisibility = ViewStates.Visible;
                    League.PullLeagues(0, PAGE_COUNT, lastLetterPulled, (Context)this, leagues);
                    initialArray.Leagues.Clear();
                };
                search_leagues = FindViewById<EditText>(Resource.Id.search_leagues);
                search_leagues.TextChanged += search_skaters_TextChanged;
                var searchMenuItemAction = new SearchAction(this, null, Resource.Drawable.ic_action_search, search_leagues);
                LegacyBar.AddAction(searchMenuItemAction);

                LegacyBarAction infoAction = new DefaultLegacyBarAction(this, CreateInfoIntent(), Resource.Drawable.action_about);
                LegacyBar.AddAction(infoAction);

                m_AdView = FindViewById(Resource.Id.adView);
                if (SettingsMobile.Instance.User != null && SettingsMobile.Instance.User.IsValidSub)
                {
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.Android, (Context)this);
            }
        }
Beispiel #5
0
        public void CreateSeasonFixtures()
        {
            // First find first available Saturday
            WorldAdapter wa             = new WorldAdapter();
            DateTime     FirstMatchDate = wa.MainSeasonDate;

            while (FirstMatchDate.DayOfWeek != DayOfWeek.Saturday)
            {
                FirstMatchDate = FirstMatchDate.AddDays(1);
            }

            FixtureAdapter fa = new FixtureAdapter();

            fa.ClearFixtures();

            LeagueAdapter la      = new LeagueAdapter();
            List <League> Leagues = la.GetLeagues();

            foreach (League L in Leagues)
            {
                // Get teams in the league we're looking at.
                TeamAdapter ta       = new TeamAdapter();
                List <Team> TeamList = ta.GetTeamsByLeague(L.UniqueID);

                // Create that league's fixtures (Circle Method)
                // https://en.wikipedia.org/wiki/Round-robin_tournament

                int NumberOfTeams = TeamList.Count();
                int Half          = NumberOfTeams / 2;

                int[] TeamIDs = new int[NumberOfTeams + 1]; // Create a grid with an additional blank space to allow rotation
                for (int i = 0; i < TeamList.Count(); i++)
                {
                    TeamIDs[i] = TeamList[i].UniqueID;
                }
                TeamIDs[NumberOfTeams] = -999; // For debugging

                DateTime MatchDate = FirstMatchDate;

                for (int HomeAwayLeg = 1; HomeAwayLeg <= 2; HomeAwayLeg++)
                {
                    bool homeFirst = (HomeAwayLeg == 1);

                    for (int wk = 1; wk <= NumberOfTeams - 1; wk++)
                    {
                        // Make the week's fixtures
                        for (int gridpos = 0; gridpos < Half; gridpos++)
                        {
                            Fixture f = new Fixture();
                            f.Date     = MatchDate;
                            f.LeagueID = L.UniqueID;
                            if (homeFirst)
                            {
                                f.TeamIDs[0] = TeamIDs[gridpos];
                                f.TeamIDs[1] = TeamIDs[gridpos + Half];
                            }
                            else
                            {
                                f.TeamIDs[1] = TeamIDs[gridpos];
                                f.TeamIDs[0] = TeamIDs[gridpos + Half];
                            }

                            fa.AddFixture(f);
                        }

                        // Rotate the grid! (Clockwise, as opposed to the description in the wiki link)
                        // Top "row" (first half) need to move L to R
                        // Bottom "row" (second half) need to move R to L
                        // Bottom left cell moves into position 1 and position 0 doesn't move
                        // Comments below refer to 16 teams, grid positions 0-7 (top), 8-15 (bottom), 16 spare.

                        TeamIDs[NumberOfTeams] = TeamIDs[Half - 1]; // Top right cell to bottom row, spare cell
                        for (int i = Half - 2; i >= 1; i--)         // Move top row, except cell zero and rightmost cell, right one
                        {
                            TeamIDs[i + 1] = TeamIDs[i];
                        }
                        TeamIDs[1] = TeamIDs[Half];                     // Bottom left cell to position 1
                        for (int i = Half; i <= NumberOfTeams - 1; i++) // Shift entire bottom row (including spare, excluding bottom left) left by one cell
                        {
                            TeamIDs[i] = TeamIDs[i + 1];
                        }

                        // Go to next date
                        MatchDate = MatchDate.AddDays(7);
                        homeFirst = !homeFirst;
                    }
                }
            }
        }