public void Fill(TrainingPlan plan) { this.plan = plan; GridView gridView = (GridView)lvExercises.View; gridView.Columns.Clear(); GridViewColumn colExercise = new GridViewColumn(); colExercise.Header = StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_ExerciseColumn; Binding binding = new Binding("ExerciseName"); colExercise.DisplayMemberBinding = binding; colExercise.Width = 200; gridView.Columns.Add(colExercise); GridViewColumn colExerciseType = new GridViewColumn(); colExerciseType.DisplayMemberBinding = new Binding("ExerciseType"); colExerciseType.Header = StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_MuscleColumn; gridView.Columns.Add(colExerciseType); for (int i = 0; i < plan.GetMaximumSeriesCount(); i++) { GridViewColumn colSet = new GridViewColumn(); colSet.DisplayMemberBinding = new Binding(i.ToString()); colSet.Header = string.Format(StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_SetColumn, i + 1); gridView.Columns.Add(colSet); } SuperSetViewManager superSetManager = new SuperSetViewManager(); List <TrainingPlanSetEditorItemViewModel> items = new List <TrainingPlanSetEditorItemViewModel>(); for (int i = 0; i < plan.Days.Count; i++) { TrainingPlanDay day = plan.Days[i]; foreach (var planEntry in day.Entries) { var itemViewModel = new TrainingPlanSetEditorItemViewModel(planEntry); if (!string.IsNullOrEmpty(planEntry.GroupName)) { var color = superSetManager.GetSuperSetColor(planEntry.GroupName); itemViewModel.Background = new SolidColorBrush(color); } items.Add(itemViewModel); } } lvExercises.ItemsSource = items; CollectionView myView = (CollectionView)CollectionViewSource.GetDefaultView(lvExercises.ItemsSource); PropertyGroupDescription groupDescription = new PropertyGroupDescription("Day"); myView.GroupDescriptions.Add(groupDescription); }
public void Fill(TrainingPlan plan) { SuperSetViewManager superSetManager = new SuperSetViewManager(); Clear(); Columns.Add("colExercise", StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_ExerciseColumn, 200); Columns.Add("colExerciseType", StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_MuscleColumn); for (int i = 0; i < plan.GetMaximumSeriesCount(); i++) { int setNumber = i + 1; Columns.Add("colSet" + setNumber, string.Format(StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_SetColumn, setNumber)); } for (int i = 0; i < plan.Days.Count; i++) { TrainingPlanDay day = plan.Days[i]; ListViewGroup group = new ListViewGroup(string.IsNullOrEmpty(day.Name) ? StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_EmptyDayName : day.Name); Groups.Add(group); bool alt = false; foreach (var planEntry in day.Entries) { ExerciseDTO exercise = ObjectsReposidory.GetExercise(planEntry.ExerciseId); ListViewItem item = new ListViewItem(new string[] { exercise.GetLocalizedName(), EnumLocalizer.Default.Translate(exercise.ExerciseType) }); if (alt && UseAlternateRows) { item.BackColor = Color.LightGray; } alt = !alt; //get special color for superset entry var superSet = day.GetSuperSet(planEntry); if (superSet != null) { item.BackColor = superSetManager.GetSuperSetColor(superSet.SuperSetId.ToString()); } item.Group = group; Items.Add(item); item.Tag = planEntry; for (int j = 0; j < planEntry.Sets.Count; j++) { ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(); item.SubItems.Add(subItem); subItem.Text = planEntry.Sets[j].GetDisplayText(); subItem.Tag = planEntry.Sets[j]; } } } }
//bool shouldPrintDay(TrainingPlanDay day) //{ // return Array.IndexOf(GetPrintDaysIds(), day.GlobalId) > -1; //} protected override void BuildDetails(StringBuilder builder) { //TODO:Finish //if(GetPrintDaysIds().Length==0) //{//user doesn't want to print any days so we can skip whole code here // return; //} SuperSetViewManager superSetManager = new SuperSetViewManager(); addGroupTable(builder, StrengthTrainingEntryStrings.TrainingPlanHtml_Details, delegate(StringBuilder stringBuilder) { string exerciseTypeHeader = ""; if (PrintExerciseType) { exerciseTypeHeader = string.Format("<th>{0}</th>", StrengthTrainingEntryStrings.TrainingPlanHtml_MuscleColumn); } string entryComment = ""; if (PrintEntriesComment) { entryComment = string.Format("<th class='commentColumn'>{0}</th>", StrengthTrainingEntryStrings.TrainingPlanHtml_CommentColumn); } builder.AppendLine("<tr><td colspan='2'><table class='exercises'>"); builder.AppendFormat("<tr><th>{0}</th>{1}<th>{2}</th>{3}", StrengthTrainingEntryStrings.TrainingPlanHtml_ExerciseColumn, exerciseTypeHeader, StrengthTrainingEntryStrings.TrainingPlanHtml_RestTimeColumn, entryComment); int maxSets = TrainingPlan.GetMaximumSeriesCount(); if (!PrintRequiredSetsOnly) { maxSets = Math.Max(maxSets, SetsNumberToPrint); } for (int i = 0; i < maxSets; i++) { int setNumber = i + 1; builder.AppendFormat("<th>{0} {1}</th>", StrengthTrainingEntryStrings.TrainingPlanHtml_SetColumn, setNumber); } for (int i = 0; i < TrainingPlan.Days.Count; i++) { TrainingPlanDay day = TrainingPlan.Days[i]; //if (!shouldPrintDay(day)) //{ // continue; //} int colSpan = maxSets + 2; if (PrintExerciseType) { colSpan++; } if (PrintEntriesComment) { colSpan++; } builder.AppendFormat("<tr><td height='8' colspan='{0}'></td></tr>", colSpan); /*+++*/ builder.AppendFormat("<tr><td class='dayHeader' colspan='{0}'>{1}</td></tr>", colSpan, string.IsNullOrEmpty(day.Name) ? StrengthTrainingEntryStrings.ExercisesTrainingPlanListView_EmptyDayName : day.Name); bool alt = false; foreach (var planEntry in day.Entries) { ExerciseLightDTO exercise = planEntry.Exercise; string superSetBgColor = ""; //get special color for superset entry if (!string.IsNullOrEmpty(planEntry.GroupName)) { var color = superSetManager.GetSuperSetColor(planEntry.GroupName); superSetBgColor = string.Format("bgcolor='{0}'", color.GetKnownColorName()); } string exerciseName = exercise.GetLocalizedName(); if (PrintExerciseShortcut && exercise.GlobalId != Constants.UnsavedGlobalId) {//put shortcut only when this exercise is not deleted exerciseName += string.Format("-({0})", exercise.Shortcut); } string exerciseTypeColumn = ""; if (PrintExerciseType) { exerciseTypeColumn = string.Format("<td>{0}</td>", EnumLocalizer.Default.Translate(exercise.ExerciseType)); } string entriesComment = ""; if (PrintEntriesComment) { entriesComment = string.Format("<td class='commentColumn'>{0}</td>", planEntry.Comment); } int restTime = TrainingPlan.RestSeconds; //if rest time for this exercise is set then we should show this time (not global rest time) if (planEntry.RestSeconds.HasValue) { restTime = planEntry.RestSeconds.Value; } //string exerciseName = exercise.GlobalId !=Constants.UnsavedGlobalId? exercise.Name: "(Deleted)"; builder.AppendFormat("<tr class='{2}'><td {3}>{0}</td>{1}<td>{4}</td>{5}", exerciseName, exerciseTypeColumn, alt && UseAlternateRows ? "exercisesAlt" : "exercises", superSetBgColor, string.Format(StrengthTrainingEntryStrings.TrainingPlanHtml_RestTimeValue, restTime), entriesComment); for (int j = 0; j < maxSets; j++) { if (planEntry.Sets.Count > j || !PrintRequiredSetsOnly) { var serie = planEntry.Sets.Count > j ? planEntry.Sets[j] : null; bool isCardio = planEntry.Exercise.ExerciseType == ExerciseType.Cardio; buildSet(builder, serie, isCardio); } } alt = !alt; } /*+++*/ builder.AppendLine("</tr>"); } builder.Append("</tr>"); builder.AppendLine("</table></td></tr>"); }); }