Ejemplo n.º 1
0
 async void onClick(Object sender, EventArgs args)
 {
     if (bScore == false)
     {
         saveDefense();
     }
     else
     {
         
         saveDefense();
         REST neo = new REST();
         if (OffenseColor == Color.Blue)
         {
             await neo.scoreTeam(blueAlliance[0], blueScore[0], MatchListPage.opt.teamNumber, MatchListPage.opt.name);
             await neo.scoreTeam(blueAlliance[1], blueScore[1], MatchListPage.opt.teamNumber, MatchListPage.opt.name);
             await neo.scoreTeam(blueAlliance[2], blueScore[2], MatchListPage.opt.teamNumber, MatchListPage.opt.name);
         }
         else
         {
             await neo.scoreTeam(redAlliance[0], redScore[0], MatchListPage.opt.teamNumber, MatchListPage.opt.name);
             await neo.scoreTeam(redAlliance[1], redScore[1], MatchListPage.opt.teamNumber, MatchListPage.opt.name);
             await neo.scoreTeam(redAlliance[2], redScore[2], MatchListPage.opt.teamNumber, MatchListPage.opt.name);
         }
     }
     Device.BeginInvokeOnMainThread(async () =>
         {
             mainPage.refreshEntries(null, null);
             //mainPage.matchListView.ScrollTo(scrollTo, ScrollToPosition.Center, true);// HUH?
         });
     Navigation.PopModalAsync();
 }
Ejemplo n.º 2
0
        async void saveDefense()
        {
            match.redDef1 = redDefense[0];
            match.redDef2 = redDefense[1];
            match.redDef3 = redDefense[2];
            match.redDef4 = redDefense[3];
            match.redDef5 = redDefense[4];

            match.blueDef1 = blueDefense[0];
            match.blueDef2 = blueDefense[1];
            match.blueDef3 = blueDefense[2];
            match.blueDef4 = blueDefense[3];
            match.blueDef5 = blueDefense[4];
            // S save the defense background colors

            if (OffenseColor == Color.Blue)
            {
                match.RedCol1 = D1.BackgroundColor;
                match.RedCol2 = D2.BackgroundColor;
                match.RedCol3 = D3.BackgroundColor;
                match.RedCol4 = D4.BackgroundColor;
                match.RedCol5 = D5.BackgroundColor;
            }
            else
            {
                match.BlueCol1 = D1.BackgroundColor;
                match.BlueCol2 = D2.BackgroundColor;
                match.BlueCol3 = D3.BackgroundColor;
                match.BlueCol4 = D4.BackgroundColor;
                match.BlueCol5 = D5.BackgroundColor;
            }                

            REST neo = new REST();
            neo.updateMatch(match, MatchListPage.opt.teamNumber);            
        }
Ejemplo n.º 3
0
        public async void getTeams()
        {
            blueAlliance.Clear();
            redAlliance.Clear();
            blueScore.Clear();
            redScore.Clear();
            try
            {
                REST neo = new REST();
                // Get Team's for this match
                var result = neo.getTeam(int.Parse(match.blue1));
                Team t = await result;
                blueAlliance.Insert(0, t);

                result = neo.getTeam(int.Parse(match.blue2));
                t = await result;
                blueAlliance.Insert(1, t);

                result = neo.getTeam(int.Parse(match.blue3));
                t = await result;
                blueAlliance.Insert(2, t);


                result = neo.getTeam(int.Parse(match.red1));
                t = await result;
                redAlliance.Insert(0, t);

                result = neo.getTeam(int.Parse(match.red2));
                t = await result;
                redAlliance.Insert(1, t);

                result = neo.getTeam(int.Parse(match.red3));
                t = await result;
                redAlliance.Insert(2, t);

                // Get Score's recorded by this team
                var res = neo.getScore(int.Parse(match.blue1), MatchListPage.opt.teamNumber);
                Score s = await res;
                if (s == null)
                    s = new Score();
                blueScore.Insert(0, s);
                if (s.tNum == 0)
                {
                    blueScore[0].tNum = int.Parse(match.blue1);
                    blueScore[0].scoringTeam = MatchListPage.opt.teamNumber;
                }
                
                res = neo.getScore(int.Parse(match.blue2), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                blueScore.Insert(1, s);
                if (s.tNum == 0)
                {
                    blueScore[1].tNum = int.Parse(match.blue2);
                    blueScore[1].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.blue3), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                blueScore.Insert(2, s);
                if (s.tNum == 0)
                {
                    blueScore[2].tNum = int.Parse(match.blue3);
                    blueScore[2].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.red1), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                redScore.Insert(0, s);
                if (s.tNum == 0)
                {
                    redScore[0].tNum = int.Parse(match.red1);
                    redScore[0].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.red2), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                redScore.Insert(1, s);
                if (s.tNum == 0)
                {
                    redScore[1].tNum = int.Parse(match.red2);
                    redScore[1].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.red3), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                redScore.Insert(2, s);
                if (s.tNum == 0)
                {
                    redScore[2].tNum = int.Parse(match.red3);
                    redScore[2].scoringTeam = MatchListPage.opt.teamNumber;
                }


                whatColor();


            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 4
0
        void doDone(Object sender, EventArgs args)
        {

            REST neo = new REST();
            Match m = new Match();
            Team t = new Team();
            int i = 0;
			if (mNum.Text == null || mNum.Text == "" || RedTeam1.Text==null || RedTeam1.Text=="" || RedTeam2.Text==null || RedTeam2.Text=="" || RedTeam3.Text==null || RedTeam3.Text=="" || BlueTeam1.Text==null || BlueTeam1.Text=="" || BlueTeam2.Text==null || BlueTeam2.Text=="" || BlueTeam3.Text==null || BlueTeam3.Text=="")
				return;
            if (RedTeam1.Text != null && RedTeam1.Text.Length > 0)
            {
                m.red1 = RedTeam1.Text;
				if (int.TryParse(RedTeam1.Text, out i)==false)
				{
					DisplayAlert ("Error", " Red Team 1 number is not a number", "Ok");
					return;
				}
                t.setNum(i);
                neo.createTeam(t);
            }

            if (RedTeam2.Text != null && RedTeam2.Text.Length > 0)
            {
                m.red2 = RedTeam2.Text;
				if (int.TryParse(RedTeam2.Text, out i)==false)
				{
					DisplayAlert ("Error", "Red Team 2 number is not a number", "Ok");
					return;
				}
                t.setNum(i);
                neo.createTeam(t);
            }

            if (RedTeam3.Text != null && RedTeam3.Text.Length > 0)
            {
                m.red3 = RedTeam3.Text;
				if (int.TryParse(RedTeam3.Text, out i)==false)
				{
					DisplayAlert ("Error", "Red Team 3 number is not a number", "Ok");
					return;
				}
                t.setNum(i);
                neo.createTeam(t);
            }

            if (BlueTeam1.Text != null && BlueTeam1.Text.Length > 0)
            {
                m.blue1 = BlueTeam1.Text;
				if (int.TryParse(BlueTeam1.Text, out i)==false)
				{
					DisplayAlert ("Error", "Blue Team 1 number is not a number", "Ok");
					return;
				}
				t.setNum(i);
                neo.createTeam(t);
            }

            if (BlueTeam2.Text != null && BlueTeam2.Text.Length > 0)
            {
                m.blue2 = BlueTeam2.Text;
				if (int.TryParse(BlueTeam2.Text, out i)==false)
				{
					DisplayAlert ("Error", "Blue Team 2 number is not a number", "Ok");
					return;
				}
				t.setNum(i);
                neo.createTeam(t);
            }

            if (BlueTeam3.Text != null && BlueTeam3.Text.Length > 0)
            {
                m.blue3 = BlueTeam3.Text;
				if (int.TryParse(BlueTeam3.Text, out i)==false)
				{
					DisplayAlert ("Error", "Blue Team 3 number is not a number", "Ok");
					return;
				}
				t.setNum(i);
                neo.createTeam(t);
            }
            if (mNum.Text != null)
                m.number = mNum.Text;

            neo.createMatch(m, MatchListPage.opt.teamNumber);
            Navigation.PopModalAsync();
        }
Ejemplo n.º 5
0
 async void getMatches()
 {
     REST neo = new REST();
     var result = neo.getMatches(opt.teamNumber);
     ObservableCollection<Match> mts = await result;
     matches.Clear();
     foreach (Match m in mts)
         matches.Add(m);
 }
Ejemplo n.º 6
0
        public async Task refreshEntries(object sender, EventArgs e)
        {
            REST neo = new REST();

            Task<ObservableCollection<Match>> result = neo.getMatches(opt.teamNumber);
            ObservableCollection<Match> st = await result;
            if (st.Count > 0)
            {
                addEntries(st);
                try
                {
                    //Device.BeginInvokeOnMainThread(async () =>
                    //    {
                    matchListView.ScrollTo(matches[scrollTo], ScrollToPosition.Center, false);// HUH?
                    //    });
                    
                }
                catch (ArgumentException ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }

        }