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]; } } } }
private void mnuJoinSuperSet_Click(object sender, EventArgs e) { TrainingPlanDay day = null; foreach (ListViewItem selectedItem in exercisesTrainingPlanListView1.SelectedItems) { TrainingPlanEntry entry = (TrainingPlanEntry)selectedItem.Tag; if (day != null && entry.Day != day) { FMMessageBox.ShowError(StrengthTrainingEntryStrings.ErrorCannotCreateSuperSetDifferentDays); return; } day = entry.Day; } foreach (ListViewItem selectedItem in exercisesTrainingPlanListView1.SelectedItems) { TrainingPlanEntry entry = (TrainingPlanEntry)selectedItem.Tag; var superSet = day.GetSuperSet(entry); if (superSet != null) { superSet.SuperSets.Remove(entry); } } SuperSet newSet = new SuperSet(); foreach (ListViewItem selectedItem in exercisesTrainingPlanListView1.SelectedItems) { TrainingPlanEntry entry = (TrainingPlanEntry)selectedItem.Tag; newSet.SuperSets.Add(entry); } day.SuperSets.Add(newSet); //clear empty supersets or with only one exercise TrainingPlanChecker checker = new TrainingPlanChecker(); checker.Process(plan); exercisesTrainingPlanListView1.Fill(plan); }
private void buildDetails(StringBuilder builder) { 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) { ExerciseDTO exercise = ObjectsReposidory.GetExercise(planEntry.ExerciseId); string superSetBgColor = ""; //get special color for superset entry var superSet = day.GetSuperSet(planEntry); if (superSet != null) { var color = superSetManager.GetSuperSetColor(superSet.SuperSetId.ToString()); superSetBgColor = string.Format("bgcolor='{0}'", color.ToKnownColor().ToString()); } 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 > 0) { restTime = planEntry.RestSeconds; } //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; buildSet(builder, serie); } } alt = !alt; } /*+++*/ builder.AppendLine("</tr>"); } builder.Append("</tr>"); builder.AppendLine("</table></td></tr>"); }); }