private void generateChallengeViews() { List<ChallengeData> data = Model.LeagueInfo.ChallengeDatas; List<ChallengeProgress> progress = Model.ChallengeProgresses; int count = data.Count; if (data.Count != progress.Count) { throw new InvalidOperationException(ErrorMessages.PROGRESS_DIFFERENT_SIZE); } for (int i = 0; i < count; i++) { ChallengeData currentData = data.ElementAt(i); ChallengeProgress currentProgress = progress.ElementAt(i); ChallengeView newView = new ChallengeView(currentData, currentProgress, i); if (currentData.Type == ChallengeType.Progressable) { int subCount = currentData.SubChallenges.Count; var subProgList = currentProgress.SubChallengesProgress; while (subCount < subProgList.Count) { subProgList.RemoveAt(subProgList.Count - 1); //throw new InvalidOperationException(ErrorMessages.SUBPROGRESS_DIFFERENT_SIZE); } while (subCount > subProgList.Count) { subProgList.Add(new SubChallengeProgress()); //throw new InvalidOperationException(ErrorMessages.SUBPROGRESS_DIFFERENT_SIZE); } for (int j = 0; j < subCount; j++) { SubChallengeData subData = currentData.SubChallenges.ElementAt(j); SubChallengeProgress subProgress = currentProgress.SubChallengesProgress.ElementAt(j); SubChallengeView newSubView = new SubChallengeView(subData, subProgress); int subSubCount = subData.Infos.Count; for (int k = 0; k < subSubCount; k++) { newSubView.InfoViews.Add(new SubChallengeInfoView(subData.Infos.ElementAt(k))); } newView.addSubChallengeView(newSubView); } } challengeViews.Add(newView); //newView.PropertyChanged += view_PropertyChanged; } challengeViewsInitialized = true; }
internal void challengeIsDoneClick(ChallengeView view) { model.toogleChallengeIsDone(view.Data, view.Progress); }