async void matchTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
        {
            int jsonIndex = Matches.matchesList.IndexOf(e.Item as Matches.MatchesListFormat);

            await Task.Run(async() => {
                JObject val        = JObject.Parse(MatchesDetailView.returnMatchJSONText(jsonIndex));
                JObject parameters = new JObject();
                foreach (var x in val)
                {
                    if (!x.Key.Equals("numEvents"))
                    {
                        parameters.Add(x.Key, x.Value);
                    }
                    else
                    {
                        break;
                    }
                }
                Preferences.Set("tempParams", JsonConvert.SerializeObject(parameters.ToObject <MatchFormat.EntryParams> ()));
                NewMatchStart.events = MatchFormat.JSONEventsToObject(val);
                NewMatchStart.saveEvents();
                Preferences.Set("timerValue", Convert.ToInt32(val.Property("timerValue").Value));
                Preferences.Set("teamStart", (int)val.Property("team"));
                Device.BeginInvokeOnMainThread(() => {
                    Navigation.PushAsync(new MatchEntryEditTab()
                    {
                        Title = AdapterMethods.getTeamString((int)val.Property("team").Value)
                    });
                });
            });
        }
示例#2
0
 async void openClicked(object sender, System.EventArgs e)
 {
     await Task.Run(async() => {
         JObject val        = JObject.Parse(returnMatchJSONText(jsonIndex));
         JObject parameters = new JObject();
         foreach (var x in val)
         {
             if (!x.Key.Equals("numEvents"))
             {
                 parameters.Add(x.Key, x.Value);
             }
             else
             {
                 break;
             }
         }
         Preferences.Set("tempParams", JsonConvert.SerializeObject(parameters.ToObject <MatchFormat.EntryParams> ()));
         NewMatchStart.events = MatchFormat.JSONEventsToObject(val);
         NewMatchStart.saveEvents();
         Preferences.Set("timerValue", Convert.ToInt32(val.Property("timerValue").Value));
         Preferences.Set("teamStart", val.Property("team").Value.ToString());
         Device.BeginInvokeOnMainThread(() => {
             Navigation.PushAsync(new MatchEntryEditTab()
             {
                 Title = AdapterMethods.getTeamString(Convert.ToInt32(val.Property("team").Value))
             });
         });
     });
 }
示例#3
0
 protected override void OnAppearing()
 {
     if (!teamName.Equals(Preferences.Get("teamStart", 0)))
     {
         teamName   = Preferences.Get("teamStart", -1);
         this.Title = AdapterMethods.getTeamString(teamName);
     }
 }
示例#4
0
        async void teamClicked(object sender, Xamarin.Forms.ItemTappedEventArgs e)
        {
            String teamName  = e.Item.ToString();
            int    teamnum   = AdapterMethods.getTeamInt(teamName, App.teamsList);
            JArray pitValues = (JArray)JObject.Parse(Preferences.Get(ConstantVars.APP_DATA_STORAGE, "")) ["PitNotes"];

            Preferences.Set("teamStart", teamnum);
            await Navigation.PushAsync(new PitEntry (false, teamnum, true) { Title = teamName });
        }
示例#5
0
 protected override void OnAppearing()
 {
     if (!teamName.Equals(Preferences.Get("teamStart", 0)))
     {
         newName    = Preferences.Get("teamStart", 0);
         this.Title = AdapterMethods.getTeamString(newName);
     }
     eventName = Preferences.Get(ConstantVars.CURRENT_EVENT_NAME, "");
 }
        async void teamClicked(object sender, Xamarin.Forms.ItemTappedEventArgs e)
        {
            var x       = (listView.ItemsSource as IEnumerable <RankStruct>).ToList();
            int teamnum = AdapterMethods.getTeamInt(((RankStruct)e.Item).Key, App.teamsList);

            //String item = x.Find (y => y.Equals (teamnum)).Key;
            teamSend = teamnum;
            Debug.WriteLine("befrore send" + ((RankStruct)e.Item).Key);
            await Navigation.PushAsync(new RankingsDetailView (mainRank.returnTeamTimes(teamnum)) { Title = ((RankStruct)e.Item).Key });
        }
        /*
         * This is the order in which the array is ordered
         * overall, cargoTime, hatchTime, climb, lvl1, lvl2, lvl3
         */
        public RankingsDetailView(String[] times)
        {
            InitializeComponent();
            setScoreValues(times);
            string teamString = AdapterMethods.getTeamString(Rankings.teamSend);

            pitButton.IsVisible = Rankings.pitTeams.Contains(teamString);
            String team = Rankings.teamSend.ToString();

            listView.ItemsSource = Matches.matchesList.Where(matchesList => matchesList.teamNameAndSide.ToLower().Contains(team.ToLower() + " - "));
        }
示例#8
0
        public static List <string> getListVals(JObject input)
        {
            List <string> teamsInclude = new List <string> ();

            if (input.ContainsKey("PitNotes"))
            {
                JArray pits = (JArray)input["PitNotes"];
                foreach (var x in pits)
                {
                    teamsInclude.Add(AdapterMethods.getTeamString((int)x["team"]));
                }
            }
            return(teamsInclude);
        }
 void matchConfirm()
 {
     if (!Preferences.ContainsKey("appState"))
     {
         appRestore = false;
         Preferences.Set("appState", 0);
         Preferences.Set("teamStart", 0);
         Preferences.Set("timerValue", (int)0);
         Preferences.Set("tempParams", "");
         Preferences.Set("tempMatchEvents", "");
         Preferences.Set("tempPitNotes", "");
         Preferences.Set(ConstantVars.CURRENT_EVENT_NAME, "");
     }
     else if (!String.IsNullOrWhiteSpace(Preferences.Get("tempMatchEvents", "")) || !String.IsNullOrWhiteSpace(Preferences.Get("tempParams", "")))       //App.Current.Properties["appState"].ToString() == "1"
     {
         appRestore = true;
         NavigationPage.SetHasNavigationBar(this, false);
         Navigation.PushAsync(new MatchEntryEditTab()
         {
             Title = AdapterMethods.getTeamString(Preferences.Get("teamStart", 0))
         });
     }
     else if (!String.IsNullOrWhiteSpace(Preferences.Get("tempPitNotes", "")))
     {
         appRestore = true;
         NavigationPage.SetHasNavigationBar(this, false);
         Navigation.PushAsync(new PitEntry(true, Preferences.Get("teamStart", 0), true)
         {
             Title = AdapterMethods.getTeamString(Preferences.Get("teamStart", 0))
         });
     }
     else if (Preferences.Get("appState", 0) == 0)
     {
         appRestore = false;
         Preferences.Set("appState", 0);
         Preferences.Set("timerValue", (int)0);
         Preferences.Set("teamStart", 0);
         Preferences.Set("tempMatchEvents", "");
         Preferences.Set("tempParams", "");
         Preferences.Set("tempPitNotes", "");
     }
     if (!Preferences.ContainsKey(ConstantVars.APP_DATA_STORAGE))
     {
         Preferences.Set(ConstantVars.APP_DATA_STORAGE, "");
         Preferences.Set("tempMatchEvents", "");
         Preferences.Set("tempPitNotes", "");
     }
     populateMatchesList();
 }
        //Updates events with given enum
        private void updateEvents()
        {
            //Updates string data from matches
            Debug.WriteLine(Preferences.Get(ConstantVars.APP_DATA_STORAGE, "reee"));
            //JObject temp = JObject.Parse(Preferences.Get(ConstantVars.APP_DATA_STORAGE, "{}"));
            //Debug.WriteLine(temp);
            //if (temp.ContainsKey(eventName))
            //{
            //    temp = (JObject)temp[eventName];
            //}
            //else
            //{
            //    temp = new JObject();
            //}
            mainRank.setData(App.getCompJson(Preferences.Get(ConstantVars.APP_DATA_STORAGE, "{}"), eventName));
            //Gets all data and sets it into ascending order based on each team's average time
            Dictionary <int, double> x     = mainRank.getRank(rankChoice);
            Dictionary <int, double> y     = new Dictionary <int, double>(x);
            List <RankStruct>        ranks = new List <RankStruct> ();

            if (!(rankPicker.SelectedIndex == 7))
            {
                y = (from pair in x orderby pair.Value descending select pair).ToDictionary(pair => pair.Key, pair => pair.Value);
            }
            else
            {
                try {
                    y = (from pair in x orderby pair.Key ascending select pair).ToDictionary(pair => pair.Key, pair => pair.Value);
                } catch {
                    y = new Dictionary <int, double> ();
                }
            }

            foreach (var s in y)
            {
                ranks.Add(new RankStruct {
                    Key = AdapterMethods.getTeamString(s.Key), Value = s.Value, color = getTeamColor(s.Key)
                });
            }
            listView.ItemsSource = ranks;
            rankList             = ranks;
            setListVisibility(y.Count());
        }
        async void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
        {
            teamName = e.Item.ToString();
            int teamnum;

            try
            {
                teamnum = AdapterMethods.getTeamInt(teamName, App.teamsList);
                Preferences.Set("teamStart", teamnum);
                switch (goToMatch)
                {
                case ConstantVars.TEAM_SELECTION_TYPES.match:
                    await Navigation.PushAsync(new MatchEntryEditTab()
                    {
                        Title = teamName
                    });

                    Navigation.RemovePage(this);
                    break;

                case ConstantVars.TEAM_SELECTION_TYPES.pit:
                    await Navigation.PushAsync(new PitEntry(true, teamnum, true) { Title = teamName });

                    Navigation.RemovePage(this);
                    break;

                case ConstantVars.TEAM_SELECTION_TYPES.teamSelection:
                    await Navigation.PopAsync();

                    break;
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Failed to get team number from the list", "", "OK");

                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
 async void pitClicked(object sender, System.EventArgs e)
 {
     Preferences.Set("teamStart", Rankings.teamSend);
     await Navigation.PushAsync(new PitEntry (true, Rankings.teamSend, false) { Title = AdapterMethods.getTeamString(Rankings.teamSend) });
 }
        private async Task addMatchItemsChecker(JObject data, JObject importJSON, string comp)
        {
            int           tooMuch    = 0;
            int           mode       = 0; // 1 for overwite all, 2 for ignore all
            JArray        importTemp = (JArray)importJSON["Matches"];
            List <JToken> tempList   = new List <JToken>();

            if (data.ContainsKey(comp) && (JArray)data[comp]["Matches"] != null)
            {
                tempList = ((JArray)data[comp]["Matches"]).ToList();
            }
            else if (!data.ContainsKey(comp))
            {
                data[comp]            = new JObject();
                data[comp]["Matches"] = new JArray();
            }
            else
            {
                data[comp]["Matches"] = new JArray();
            }
            JArray temp = (JArray)data[comp]["Matches"];

            foreach (var match in importTemp.ToList())
            {
                Debug.WriteLine("hi" + match);
                if (tempList.Exists(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"])))
                {
                    var item = tempList.Find(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"]));
                    if (!item["team"].Equals(match["team"]))
                    {
                        if (mode == 1)
                        {
                            temp.Remove(item);
                            temp.Add(match);
                        }
                        else if (mode == 0)
                        {
                            tooMuch++;
                            if (tooMuch <= 1)
                            {
                                var add = await DisplayAlert("Warning!",
                                                             "\nEvent: " + AdapterMethods.getEventName(comp) +
                                                             "Match: " + item["matchNum"] +
                                                             "\nTeam: " + item["team"] +
                                                             "\nSide: " + MatchFormat.matchSideFromEnum(Convert.ToInt32(item["side"])) +
                                                             "\nConflicts with Existing Match", "Overwite", "Ignore");

                                if (add)
                                {
                                    temp.Remove(item);
                                    temp.Add(match);
                                }
                            }
                            else
                            {
                                var add = await DisplayActionSheet("Warning!",
                                                                   "Event: " + AdapterMethods.getEventName(comp) +
                                                                   "\nMatch: " + item["matchNum"] +
                                                                   "\nTeam: " + item["team"] +
                                                                   "\nSide: " + MatchFormat.matchSideFromEnum(Convert.ToInt32(item["side"])) +
                                                                   "\nConflicts with Existing Match", null, null, "Overwite", "Ignore", "Overwite All", "Ignore All");

                                if (add.Equals("Overwite"))
                                {
                                    temp.Remove(item);
                                    temp.Add(match);
                                }
                                else if (add.Equals("Overwite All"))
                                {
                                    temp.Remove(item);
                                    temp.Add(match);
                                    mode = 1;
                                }
                                else if (add.Equals("Ignore All"))
                                {
                                    mode = 2;
                                }
                            }
                        }
                    }
                }
                else
                {
                    temp.Add(match);
                }
            }
            //return data;
        }