public static bool IsFavorite(this ExerciseLightDTO exercise)
        {
            ExercisesReposidory.Instance.EnsureLoaded();
            var res = (from e in ExercisesReposidory.Instance.Items.Values where e.GlobalId == exercise.GlobalId && e.Profile != null && !((IBelongToUser)e).IsMine() select e).Count();

            return(res > 0);
        }
 public void Fill(ExerciseLightDTO exercise)
 {
     this.exercise = exercise;
     if (exercise != null)
     {
         fillPage(0);
     }
 }
Exemple #3
0
 public static bool IsMine(ExerciseLightDTO item)
 {
     if (Current.LoginStatus != LoginStatus.Logged || item == null || item.ProfileId == null || Current.CurrentProfile.GlobalId != item.ProfileId)
     {
         return(false);
     }
     return(true);
 }
Exemple #4
0
        public StrengthTrainingItemViewModel AddExercise(ExerciseLightDTO exercise)
        {
            StrengthTrainingItemDTO item = new StrengthTrainingItemDTO();

            item.Exercise = exercise;
            Entry.Entries.Add(item);
            item.Position = Entry.Entries.Count;
            item.StrengthTrainingEntry = Entry;
            StrengthTrainingItemViewModel itemViewModel = new StrengthTrainingItemViewModel(item);

            _exercises.Add(itemViewModel);
            return(itemViewModel);
        }
Exemple #5
0
 public ExerciseViewModel(ExerciseLightDTO exercise)
 {
     this.exercise = exercise;
 }
        //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>");
            });
        }
Exemple #7
0
 public static string GetLocalizedName(this ExerciseLightDTO exercise)
 {
     //string resKey = string.Format("{0}_Name", exercise.GlobalId.ToString().ToUpper());
     //return getLocalizedProperty(exercise.Name, resKey);
     return(exercise.Name);
 }
Exemple #8
0
 public static string GetLocalizedShortcut(this ExerciseLightDTO exercise)
 {
     //string resKey = string.Format("{0}_Shortcut", exercise.GlobalId.ToString().ToUpper());
     //return getLocalizedProperty(exercise.Shortcut, resKey);
     return(exercise.Shortcut);
 }
Exemple #9
0
 public TrainingPlanSetEditorItemViewModel(TrainingPlanEntry planEntry)
 {
     this.planEntry = planEntry;
     exercise       = planEntry.Exercise;
 }