Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.General_Compiled);
            //get controls from layout
            bDeleteData          = FindViewById <Button>(Resource.Id.bDeleteData);
            bDeleteData.Click   += ButtonClicked;
            gridTeams            = FindViewById <GridView>(Resource.Id.gridViewTeam);
            gridTeams.ItemClick += gridClicked;
            textRecent           = FindViewById <TextView>(Resource.Id.textEvent);
            viewDataHeight       = FindViewById <LinearLayout>(Resource.Id.viewDataHeight);
            //get current compiled data
            currentCompiled = eData.GetCurrentCompiled();
            SpannableString[] textDisp = new SpannableString[]
            {
                FormatString.setNormal("Viewing Data for Event: \n"),
                FormatString.setBold("'" + currentCompiled.officialName + "'"),
                FormatString.setNormal(" as of "),
                FormatString.setBold(currentCompiled.dateMod),
                FormatString.setNormal(" at "),
                FormatString.setBold(currentCompiled.timeMod)
            };
            //set title display text
            textRecent.TextFormatted = TextUtils.ConcatFormatted(textDisp);
            //column titles
            properties = new string[]
            {
                "Team",
                "Recommend %",
                "Record",
                "Cargo/Hatch %",
                "        Climb?\n(Lvl 2%/Lvl 3%)",
                "Good Drivers (%)",
                "'Table' %"
            };
            //get general data for all teams
            List <int>             teamNumbers = currentCompiled.getTeamNumbersArray();
            List <int>             recPerc     = currentCompiled.getRecPercentArray();
            List <string>          record      = currentCompiled.getWinRecordArray();
            List <int>             cargoPerc   = currentCompiled.getCargoPercentArray();
            List <int>             hatchPerc   = currentCompiled.getHatchPercentArray();
            List <int>             climbPerc2  = currentCompiled.getClimb2PercentArray();
            List <int>             climbPerc3  = currentCompiled.getClimb3PercentArray();
            List <int>             driversPerc = currentCompiled.getDriversPercentArray();
            List <int>             tablePerc   = currentCompiled.getTablePercentArray();
            List <int>             winPerc     = currentCompiled.getWinPercentArray();
            List <SpannableString> display     = new List <SpannableString>();

            //format data in the right order for the grid based on values
            for (int i = 0; i < properties.Length; i++)
            {
                display.Add(FormatString.setBold(properties[i]));
            }
            for (int i = 0; i < currentCompiled.compileData().Count; i++)
            {
                //add the team number
                display.Add(FormatString.setBold(teamNumbers[i].ToString()));
                //recommendation percent
                if (recPerc[i] >= Constants.recommendThreshHigh)
                {
                    display.Add(FormatString.setColorBold(recPerc[i].ToString() + "%", Constants.appGreen));
                }
                else if (recPerc[i] <= Constants.recommendThreshLow)
                {
                    display.Add(FormatString.setColorBold(recPerc[i].ToString() + "%", Constants.appRed));
                }
                else
                {
                    display.Add(FormatString.setNormal(recPerc[i].ToString() + "%"));
                }
                //win-loss-tie record
                if (winPerc[i] >= Constants.winThreshHigh)
                {
                    display.Add(FormatString.setColorBold(record[i], Constants.appGreen));
                }
                else if (winPerc[i] <= Constants.winThreshLow)
                {
                    display.Add(FormatString.setColorBold(record[i], Constants.appRed));
                }
                else
                {
                    display.Add(FormatString.setNormal(record[i]));
                }
                //cargo/hatch percents
                if (cargoPerc[i] >= Constants.hatch_cargoThreshHigh)
                {
                    display.Add(FormatString.setColorBold(cargoPerc[i].ToString() + "% / " + hatchPerc[i].ToString() + "%", Constants.appGreen));
                }
                else if (cargoPerc[i] <= Constants.hatch_cargoThreshLow)
                {
                    display.Add(FormatString.setColorBold(cargoPerc[i].ToString() + "% / " + hatchPerc[i].ToString() + "%", Constants.appRed));
                }
                else
                {
                    display.Add(FormatString.setNormal(cargoPerc[i].ToString() + "% / " + hatchPerc[i].ToString() + "%"));
                }
                //climbing percents
                List <SpannableString> climbDisplay = new List <SpannableString>();
                if (climbPerc2[i] >= Constants.climb2Thresh)
                {
                    climbDisplay.Add(FormatString.setColorBold(climbPerc2[i].ToString() + "% / ", Constants.appGreen));
                }
                else
                {
                    climbDisplay.Add(FormatString.setNormal(climbPerc2[i].ToString() + "% / "));
                }
                if (climbPerc3[i] >= Constants.climb3Thresh)
                {
                    climbDisplay.Add(FormatString.setColorBold(climbPerc3[i].ToString() + "%", Constants.appGreen));
                }
                else
                {
                    climbDisplay.Add(FormatString.setNormal(climbPerc3[i].ToString() + "%"));
                }
                display.Add(new SpannableString(TextUtils.ConcatFormatted(climbDisplay.ToArray())));
                //driveteam percents
                if (driversPerc[i] >= Constants.driversThreshHigh)
                {
                    display.Add(FormatString.setColorBold(driversPerc[i].ToString() + "%", Constants.appGreen));
                }
                else if (driversPerc[i] <= Constants.driversThreshLow)
                {
                    display.Add(FormatString.setColorBold(driversPerc[i].ToString() + "%", Constants.appRed));
                }
                else
                {
                    display.Add(FormatString.setNormal(driversPerc[i].ToString() + "%"));
                }
                //table percent
                if (tablePerc[i] >= Constants.tableTresh)
                {
                    display.Add(FormatString.setColorBold(tablePerc[i].ToString() + "%", Constants.appRed));
                }
                else
                {
                    display.Add(FormatString.setColorBold(tablePerc[i].ToString() + "%", Constants.appGreen));
                }
            }
            //display data in the grid
            ArrayAdapter gridAdapt = new ArrayAdapter <SpannableString>(this, Android.Resource.Layout.SimpleListItem1, display);

            gridTeams.Adapter = gridAdapt;
            float scale = this.Resources.DisplayMetrics.Density;

            FrameLayout.LayoutParams _params = new FrameLayout.LayoutParams((int)(1200 * scale), LinearLayout.LayoutParams.WrapContent);
            viewDataHeight.LayoutParameters = _params;
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Team_Details);
            //get controls from layout
            gridStats     = FindViewById <GridView>(Resource.Id.gridViewStats);
            gridSandstorm = FindViewById <GridView>(Resource.Id.gridViewSandstorm);
            gridMatches   = FindViewById <GridView>(Resource.Id.gridViewMatches);
            textTitle     = FindViewById <TextView>(Resource.Id.textTeam);
            linearMatches = FindViewById <LinearLayout>(Resource.Id.linearMatches);
            //get current compiled data
            currentCompiled = eData.GetCurrentCompiled();
            //put matches in order for team
            CompiledEventData[] compiledPreSort = eData.GetCompiledEventDataForIndex(eData.getTeamIndex().ID).ToArray();
            Array.Sort(compiledPreSort, delegate(CompiledEventData data1, CompiledEventData data2)
            {
                return(data1.matchNumber.CompareTo(data2.matchNumber));
            });
            Array.Reverse(compiledPreSort);
            List <CompiledEventData> compiled = compiledPreSort.ToList();
            int currentTeam = compiled[0].teamNumber;

            //display current team in the title
            textTitle.TextFormatted = TextUtils.ConcatFormatted(FormatString.setNormal("Viewing Stats for Team: '"), FormatString.setBold(currentTeam.ToString()), FormatString.setNormal("'"));
            //get team-specific details from compiled data
            int    recPerc            = currentCompiled.getRecPercentForTeam(currentTeam);
            string record             = currentCompiled.getWinRecordForTeam(currentTeam);
            int    cargoPerc          = currentCompiled.getCargoPercentForTeam(currentTeam);
            int    hatchPerc          = currentCompiled.getHatchPercentForTeam(currentTeam);
            int    climbPerc2         = currentCompiled.getClimb2PercentForTeam(currentTeam);
            int    climbPerc3         = currentCompiled.getClimb3PercentForTeam(currentTeam);
            int    driversPerc        = currentCompiled.getDriversPercentForTeam(currentTeam);
            int    tablePerc          = currentCompiled.getTablePercentForTeam(currentTeam);
            int    winPerc            = currentCompiled.getWinPercentForTeam(currentTeam);
            int    cargoSandstormPerc = currentCompiled.getCargoSandstormPercentForTeam(currentTeam);
            int    hatchSandstormPerc = currentCompiled.getHabSandstormPercentForTeam(currentTeam);
            int    habPerc            = currentCompiled.getHabSandstormPercentForTeam(currentTeam);
            int    autoPerc           = currentCompiled.getAutoPercentForTeam(currentTeam);
            int    teleopPerc         = currentCompiled.getTeleopPercentForTeam(currentTeam);
            int    nothingPerc        = currentCompiled.getNothingPercentForTeam(currentTeam);
            //first two rows
            List <SpannableString> statsDisp = new List <SpannableString>()
            {
                FormatString.setNormal("Cargo / Hatch"),
                FormatString.setNormal("Climb Level 2 / Level 3"),
                FormatString.setNormal("Recommendation %"),
                FormatString.setBold(cargoPerc.ToString() + "% / " + hatchPerc.ToString() + "%"),
                FormatString.setBold(climbPerc2.ToString() + "% / " + climbPerc3.ToString() + "%"),
                FormatString.setBold(recPerc.ToString() + "%"),
            };

            //third row (decide)
            //cargo or hatch bot
            if (cargoPerc >= Constants.hatch_cargoMin && hatchPerc >= Constants.hatch_cargoMin)
            {
                statsDisp.Add(FormatString.setColorBold("Both", Constants.appGreen));
            }
            else if (cargoPerc >= Constants.hatch_cargoMin)
            {
                statsDisp.Add(FormatString.setColorBold("Cargo", Constants.appGreen));
            }
            else if (hatchPerc >= Constants.hatch_cargoMin)
            {
                statsDisp.Add(FormatString.setColorBold("Hatch", Constants.appGreen));
            }
            else
            {
                statsDisp.Add(FormatString.setColorBold("Neither", Constants.appRed));
            }
            //what kind of climber
            if (climbPerc2 >= Constants.climb2Min && climbPerc3 >= Constants.climb3Min)
            {
                statsDisp.Add(FormatString.setColorBold("Level 2/3 Climber", Constants.appGreen));
            }
            else if (climbPerc3 >= Constants.climb3Min)
            {
                statsDisp.Add(FormatString.setColorBold("Level 3 Climber", Constants.appGreen));
            }
            else if (climbPerc2 >= Constants.climb2Min)
            {
                statsDisp.Add(FormatString.setColorBold("Level 2 Climber", Constants.appGreen));
            }
            else
            {
                statsDisp.Add(FormatString.setColorBold("No reliable climber", Constants.appRed));
            }
            //recommendation
            if (recPerc >= Constants.recommendThreshHigh)
            {
                statsDisp.Add(FormatString.setColorBold("Recommended", Constants.appGreen));
            }
            else if (recPerc <= Constants.recommendThreshLow)
            {
                statsDisp.Add(FormatString.setColorBold("Not Recommended", Constants.appRed));
            }
            else
            {
                statsDisp.Add(FormatString.setColorBold("Possible Recommend", Constants.appYellow));
            }
            //display general stats in first grid box
            ArrayAdapter gridStatsAdapt = new ArrayAdapter <SpannableString>(this, Android.Resource.Layout.SimpleListItem1, statsDisp);

            gridStats.Adapter = gridStatsAdapt;
            //figure out which sandstorm mode they use the most often
            SpannableString primaryMode;

            if (autoPerc > teleopPerc && autoPerc > nothingPerc)
            {
                primaryMode = FormatString.setColorBold("Auto", Constants.appGreen);
            }
            else if (teleopPerc > autoPerc && teleopPerc > nothingPerc)
            {
                primaryMode = FormatString.setColorBold("Teleop w/Camera", Constants.appGreen);
            }
            else
            {
                primaryMode = FormatString.setColorBold("Nothing", Constants.appRed);
            }
            SpannableString cargo = FormatString.setColorBold("NO (" + cargoSandstormPerc.ToString() + "%) ", Constants.appRed);
            SpannableString hatch = FormatString.setColorBold("NO (" + hatchSandstormPerc.ToString() + "%) ", Constants.appRed);
            SpannableString hab   = FormatString.setColorBold("NO (" + habPerc.ToString() + "%) ", Constants.appRed);

            if (cargoSandstormPerc >= Constants.sandstorm_Hatch_CargoThresh)
            {
                cargo = FormatString.setColorBold("YES (" + cargoSandstormPerc.ToString() + "%) ", Constants.appGreen);
            }
            if (hatchSandstormPerc >= Constants.sandstorm_Hatch_CargoThresh)
            {
                hatch = FormatString.setColorBold("YES (" + hatchSandstormPerc.ToString() + "%) ", Constants.appGreen);
            }
            if (habPerc >= Constants.sandstorm_Hatch_CargoThresh)
            {
                hab = FormatString.setColorBold("YES (" + habPerc.ToString() + "%) ", Constants.appGreen);
            }
            List <SpannableString> sandstormDisp = new List <SpannableString>()
            {
                FormatString.setBold("Primary Sandstorm Mode: "),
                primaryMode,
                FormatString.setBold("Cargo? "),
                cargo,
                FormatString.setBold("Hatch? "),
                hatch,
                FormatString.setBold("Crossed Hab Line? "),
                hab,
            };
            //display sandstorm stats in the second grid
            ArrayAdapter gridSandstormAdapt = new ArrayAdapter <SpannableString>(this, Android.Resource.Layout.SimpleListItem1, sandstormDisp);

            gridSandstorm.Adapter = gridSandstormAdapt;
            //display a list of matches the team was in and the details from each one
            string[] properties = new string[]
            {
                "Result of Team's Alliance",
                "Position",
                "Table",
                "Started Off Level",
                "Sandstorm Mode",
                "Hatch in Sandstorm",
                "Cargo in Sandstorm",
                "Crossed Hab Line",
                "Can do Cargo",
                "Does Cargo Well",
                "Barely Does Cargo",
                "Can do Hatches",
                "Does Hatches Well",
                "Barely Does Hatches",
                "Climbing Level",
                "Good Driveteam",
                "Recommended"
            };
            gridMatches.NumColumns = compiled.Count + 1;
            List <SpannableString> display = new List <SpannableString>();

            compiled.Reverse();
            //rows
            {
                display.Add(FormatString.setBold("Match Number:"));
                for (int i = 0; i < compiled.Count; i++)
                {
                    display.Add(FormatString.setBold(compiled[i].matchNumber.ToString()));
                }
                int p = 0;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].result == 0)
                    {
                        display.Add(FormatString.setColor(compiled[j].getResult(), Constants.appGreen));
                    }
                    else if (compiled[j].result == 1)
                    {
                        display.Add(FormatString.setColor(compiled[j].getResult(), Constants.appRed));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].getResult(), Constants.appYellow));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].position >= 3)
                    {
                        display.Add(FormatString.setColor(compiled[j].getPosition(), Constants.appBlue));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].getPosition(), Constants.appOrange));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].isTable)
                    {
                        display.Add(FormatString.setColorBold(compiled[j].isTable.ToString().ToUpper(), Constants.appRed));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].isTable.ToString().ToUpper(), Constants.appGreen));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].sandstormStartLevel == 1)
                    {
                        display.Add(FormatString.setNormal("Level " + compiled[j].sandstormStartLevel.ToString()));
                    }
                    else
                    {
                        display.Add(FormatString.setColor("Level " + compiled[j].sandstormStartLevel.ToString(), Constants.appGreen));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].sandstormMode == 0 || compiled[j].sandstormMode == 1)
                    {
                        display.Add(FormatString.setColor(compiled[j].getSandstormMode(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].getSandstormMode(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].sandstormHatch)
                    {
                        display.Add(FormatString.setColor(compiled[j].sandstormHatch.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].sandstormHatch.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].sandstormCargo)
                    {
                        display.Add(FormatString.setColor(compiled[j].sandstormCargo.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].sandstormCargo.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].sandstormLine)
                    {
                        display.Add(FormatString.setColor(compiled[j].sandstormLine.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].sandstormLine.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].cargo)
                    {
                        display.Add(FormatString.setColor(compiled[j].cargo.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].cargo.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].cargoWell)
                    {
                        display.Add(FormatString.setColor(compiled[j].cargoWell.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].cargoWell.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].cargoBarely)
                    {
                        display.Add(FormatString.setColor(compiled[j].cargoBarely.ToString(), Constants.appRed));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].cargoBarely.ToString(), Constants.appGreen));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].hatch)
                    {
                        display.Add(FormatString.setColor(compiled[j].hatch.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].hatch.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].hatchWell)
                    {
                        display.Add(FormatString.setColor(compiled[j].hatchWell.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].hatchWell.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].hatchBarely)
                    {
                        display.Add(FormatString.setColor(compiled[j].hatchBarely.ToString(), Constants.appRed));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].hatchBarely.ToString(), Constants.appGreen));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].climb == 3)
                    {
                        display.Add(FormatString.setColorBold(compiled[j].getClimb(), Constants.appGreen));
                    }
                    else if (compiled[j].climb == 2)
                    {
                        display.Add(FormatString.setColor(compiled[j].getClimb(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].getClimb(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].goodDrivers)
                    {
                        display.Add(FormatString.setColor(compiled[j].goodDrivers.ToString(), Constants.appGreen));
                    }
                    else
                    {
                        display.Add(FormatString.setColor(compiled[j].goodDrivers.ToString(), Constants.appRed));
                    }
                }
                p++;
                display.Add(FormatString.setBold(properties[p]));
                for (int j = 0; j < compiled.Count; j++)
                {
                    if (compiled[j].wouldRecommend == 0)
                    {
                        display.Add(FormatString.setColorBold(compiled[j].getRecommendation(), Constants.appGreen));
                    }
                    else if (compiled[j].wouldRecommend == 1)
                    {
                        display.Add(FormatString.setColorBold(compiled[j].getRecommendation(), Constants.appRed));
                    }
                    else
                    {
                        display.Add(FormatString.setColorBold(compiled[j].getRecommendation(), Constants.appYellow));
                    }
                }
            }
            //put matches in the third grid
            ArrayAdapter gridMatchesAdapt = new ArrayAdapter <SpannableString>(this, Android.Resource.Layout.SimpleListItem1, display);

            gridMatches.Adapter = gridMatchesAdapt;
            float scale = this.Resources.DisplayMetrics.Density;

            FrameLayout.LayoutParams _params = new FrameLayout.LayoutParams((int)(compiled.Count * 300 * scale), LinearLayout.LayoutParams.WrapContent);
            linearMatches.LayoutParameters = _params;
        }