void AddButton(Training aTraining) { DateTime timeForTraining = DateTime.ParseExact(aTraining.Date, "yyyyMMddHHmmss", CultureInfo.InvariantCulture); DateTime timeForTrainingEnd = DateTime.ParseExact(aTraining.EndDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture); string bgColor = "549fb3"; if (aTraining.isTeamTraining != null) { if (bool.Parse(aTraining.isTeamTraining) == true) { bgColor = "619e60"; } } string h = timeForTraining.Hour.ToString(); string m = timeForTraining.Minute.ToString(); string h2 = timeForTrainingEnd.Hour.ToString(); string m2 = timeForTrainingEnd.Minute.ToString(); if (timeForTraining.Hour < 10) { h = "0" + timeForTraining.Hour.ToString(); } if (timeForTraining.Minute < 10) { m = "0" + timeForTraining.Minute.ToString(); } if (timeForTraining.Hour < 10) { h2 = "0" + timeForTrainingEnd.Hour.ToString(); } if (timeForTraining.Minute < 10) { m2 = "0" + timeForTrainingEnd.Minute.ToString(); } Button button; Button button2; if (Device.OS == TargetPlatform.iOS) { string button2color = "2e2e2e"; string evaluatedText = ""; button2 = new TestLayoutProblem.MyButton { TextColor = Color.FromHex("c7a07c"), FontFamily = "Lato-Light", BackgroundColor = Color.FromHex(button2color), Text = timeForTraining.Month.ToString() + "/" + timeForTraining.Day.ToString() + " " + aTraining.Name + evaluatedText, HeightRequest = 45, BorderRadius = 0, }; button = new TestLayoutProblem.MyButton { BorderRadius = 0, WidthRequest = 100, HeightRequest = 50, TextColor = Color.White, FontFamily = "Lato-Light", BackgroundColor = Color.FromHex(bgColor), FontSize = 13, Text = h + ":" + m + " - " + h2 + ":" + m2, }; } else { string button2color = "2e2e2e"; string evaluatedText = ""; button2 = new TestLayoutProblem.MyButton2 { TextColor = Color.FromHex("c7a07c"), FontFamily = "Lato-Light", BackgroundColor = Color.FromHex(button2color), Text = timeForTraining.Month.ToString() + "/" + timeForTraining.Day.ToString() + " " + aTraining.Name + evaluatedText, HeightRequest = 45, BorderRadius = 0, }; button = new TestLayoutProblem.MyButton2 { BorderRadius = 0, WidthRequest = 100, HeightRequest = 50, TextColor = Color.White, FontFamily = "Lato-Light", BackgroundColor = Color.FromHex(bgColor), FontSize = 13, Text = h + ":" + m + " - " + h2 + ":" + m2, }; } if (aTraining.HasBeenEvaluated == false) { button.Clicked += OnDoQuestionairClickedDiarySummary; button2.Clicked += OnDoQuestionairClickedDiarySummary; } else { button.Clicked += OnAlreadyEvaluated; button2.Clicked += OnAlreadyEvaluated; } allButtons.Add(button); //allButtons.Add(button2); StackLayout s1 = new StackLayout { BackgroundColor = Color.FromHex("2e2e2e"), Orientation = StackOrientation.Horizontal, Children = { button, button2 } }; if (aTraining.HasBeenEvaluated == true) { Button buttonDone = new Button { Image = "done.png", FontFamily = "Lato-Light", Text = "", WidthRequest = 32, HeightRequest = 32, MinimumHeightRequest = 32, MinimumWidthRequest = 32, BorderRadius = 0, Margin = 10, BackgroundColor = Color.FromHex("2e2e2e"), HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; buttonDone.Clicked += OnAlreadyEvaluated; s1.Children.Add(buttonDone); } ((StackLayout)ButtonStackLayout).Children.Add(s1); ButtonAndTraining bat = new ButtonAndTraining(); bat.TrainingButton = button; bat.TrainingButton2 = button2; bat.TrainingID = aTraining.PraticeID; bat.isTeamTraining = bool.Parse(aTraining.isTeamTraining); bat.HasBeenEvaluated = aTraining.HasBeenEvaluated; ButtonAndTrainingList.Add(bat); }
public async static Task <bool> GetUserData(string PlayerID) { string userData = await Backend_GetUserData(PlayerID); string[] splitData = userData.Split(','); //"ID:" //"14" //"faceID:" //"2147483647" //"age:" //"25" //"name:" //"Patrik" //"Bertilsson" //"teamID:" //"12" //"false" //"ID: 14 faceID: 2147483647 age: 25 name: Patrik Bertilsson teamID: 12 false" //"123123124,22,Patrik Bertilsson,5,true" //string[] splitData = userData.Split(','); //"boll,12/29/2016 1,12/29/2016 1,6,gym,12/30/2016 1,12/30/2016 1,7,bad,12/31/2016 1,12/31/2016 1,8," Database.CurrentAthlete = new User(); Database.CurrentAthlete.Age = int.Parse(splitData[2]); Database.CurrentAthlete.Name = splitData[3]; Database.CurrentAthlete.PlayerID = splitData[0]; Database.CurrentAthlete.TeamID = int.Parse(splitData[4]); Database.CurrentAthlete.Trainings = new List <Training>(); bool isAdmin = bool.Parse(splitData[5]); string teamCoach = await GetCoachForTeamID(Database.CurrentAthlete.TeamID.ToString()); if (teamCoach == PlayerID) { Database.CurrentAthlete.isCoach = true; } else { Database.CurrentAthlete.isCoach = false; } DatabaseTraining.Clear(); string praticeData = await Backend_GetTrainingsForTeam(Database.CurrentAthlete.TeamID.ToString()); string[] praticeSplitData = praticeData.Split(','); for (int i = 0; i < praticeSplitData.Length - 1; i += 6) { string name = praticeSplitData[i]; string date = praticeSplitData[i + 1]; string dateTo = praticeSplitData[i + 2]; string praticeId = praticeSplitData[i + 3]; string creatorIDTraining = praticeSplitData[i + 4]; string isTeamEvent = praticeSplitData[i + 5]; Training s = new Training(); s.TeamID = Database.CurrentAthlete.TeamID.ToString(); s.PraticeID = praticeId; s.Name = name; s.Date = date; s.EndDate = dateTo; s.CreatorID = creatorIDTraining; s.isTeamTraining = isTeamEvent; bool hasBeenEvaluated = await Backend_CheckIfDiaryInputCompletedForPraticeAndUserID(Database.FacebookProfile.Id, praticeId); s.HasBeenEvaluated = hasBeenEvaluated; DatabaseTraining.Add(s); } //string coachForCurrentTeam = await GetCoachForTeamID(Database.CurrentAthlete.TeamID.ToString()); string injurysData = await Database.GetInjurys(); InjuryIdList.Clear(); InjuryIDDictonary.Clear(); InjuryLabelList.Clear(); InjuryDictonary.Clear(); LatestInjuryIdList.Clear(); string[] injury = injurysData.Split(','); int injuryListCount = 0; for (int i = 1; i < injury.Length - 1; i += 2) { //qp.LabelList[labelListCount].Text = questions[i]; InjuryIdList.Add(injury[i - 1]); InjuryLabelList.Add(injury[i]); InjuryDictonary.Add(injury[i], injury[i - 1]); InjuryIDDictonary.Add(injury[i - 1], injury[i]); injuryListCount++; } string LatestInjurysData = await Database.GetLatestInjurys(Database.FacebookProfile.Id); string[] latestinjury = LatestInjurysData.Split(','); for (int i = 0; i < latestinjury.Length - 1; i++) { LatestInjuryIdList.Add(latestinjury[i]); } //await HomePage.LoadPerformanceData(); return(true); //for (int i = 0; i < Database.DatabaseAthlete.Count; i++) //{ // if (Database.DatabaseAthlete[i].PlayerID == PlayerID) // { // Database.CurrentAthlete = Database.DatabaseAthlete[i]; // } //} }