示例#1
0
        public bool Fill(ExerciseDTO exercise, IEnumerable <ExerciseDTO> exercises, bool readOnly = false)
        {
            bool isReadOnly = readOnly || exercise.Status != PublishStatus.Private || (exercise.Profile == null && exercise.GlobalId != Guid.Empty);

            setReadOnly(isReadOnly);
            this.exercise                  = exercise.Clone();
            txtUrl.Text                    = exercise.GetLocalizedUrl();
            txtDescription.Text            = exercise.GetLocalizedDescription();
            txtName.Text                   = exercise.GetLocalizedName();
            txtShortcut.Text               = exercise.GetLocalizedShortcut();
            cmbExerciseType.EditValue      = exercise.ExerciseType;
            cmbMechanicsType.SelectedIndex = (int)exercise.MechanicsType;
            cmbForce.SelectedIndex         = (int)exercise.ExerciseForceType;
            zoomDifficuilt.Value           = (int)exercise.Difficult;
            if (exercises != null)
            {
                this.exercises = exercises;
            }

            bool showComments = exercise.Status != PublishStatus.Private && exercise.GlobalId != Guid.Empty;

            tpComments.PageVisible = showComments;
            if (showComments && xtraTabControl.SelectedTabPage == tpComments)
            {
                usrWorkoutCommentsList1.CannotVote = exercise.IsMine();
                usrWorkoutCommentsList1.Fill(exercise);
            }

            validateData();
            return(isReadOnly);
        }
        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];
                    }
                }
            }
        }
示例#3
0
 public void Fill(ExerciseDTO exercise, IEnumerable <ExerciseDTO> exercises)
 {
     this.exercise = exercise;
     setReadOnly();
     Url          = exercise.GetLocalizedUrl();
     Description  = exercise.GetLocalizedDescription();
     ExerciseName = exercise.GetLocalizedName();
     Shortcut     = exercise.GetLocalizedShortcut();
     ExerciseType = exercise.ExerciseType;
     Mechanics    = exercise.MechanicsType;
     Force        = exercise.ExerciseForceType;
     Met          = exercise.Met;
     Difficult    = (double)exercise.Difficult;
     if (exercises != null)
     {
         this.exercises = exercises;
     }
 }
示例#4
0
        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>");
            });
        }