public void FillTrainingFromPlan(TrainingPlanDay planDay, StrengthTrainingEntryDTO strengthEntry) { strengthEntry.Entries.Clear(); foreach (TrainingPlanEntry trainingPlanEntry in planDay.Entries) { var strengthItem = new StrengthTrainingItemDTO(); strengthItem.ExerciseId = trainingPlanEntry.ExerciseId; strengthItem.TrainingPlanItemId = trainingPlanEntry.GlobalId; strengthEntry.AddEntry(strengthItem); foreach (var set in trainingPlanEntry.Sets) { var serie = new SerieDTO(); if (FillRepetitionNumber && set.RepetitionNumberMax.HasValue && set.RepetitionNumberMin.HasValue && set.RepetitionNumberMax == set.RepetitionNumberMin) { serie.RepetitionNumber = set.RepetitionNumberMax.Value; } serie.DropSet = set.DropSet; serie.SetType = (SetType)set.RepetitionsType; serie.TrainingPlanItemId = set.GlobalId; strengthItem.AddSerie(serie); } } strengthEntry.TrainingPlanItemId = planDay.GlobalId; strengthEntry.TrainingPlanId = planDay.TrainingPlan.GlobalId; fillSuperSets(planDay, strengthEntry); }
public void PrepareCopiedStrengthTraining(StrengthTrainingEntryDTO entry, CopyStrengthTrainingMode mode) { foreach (var dto in entry.Entries) { PrepareCopiedStrengthTraining(dto, mode); } }
public static void ResetPositions(StrengthTrainingEntryDTO entry) { for (int index = 0; index < entry.Entries.Count; index++) { var itemDto = entry.Entries[index]; itemDto.Position = index; } }
public void Fill(StrengthTrainingEntryDTO entry, TrainingPlanDay planDay, bool readOnly) { ReadOnly = readOnly; this.planDay = planDay; this.strengthEntry = entry; exerciseCellController = new ExerciseCellValueChangedController(this, strengthEntry); refreshGridLayout(readOnly); updateToolbar(); }
public void SetPreviewSets(StrengthTrainingEntryDTO origEntry, StrengthTrainingEntryDTO entry) { var origSets = origEntry.Entries.SelectMany(x => x.Series).ToList(); var copiedSets = entry.Entries.SelectMany(x => x.Series).ToList(); for (int i = 0; i < origSets.Count; i++) { copiedSets[i].Tag = origSets[i]; } }
public void Fill(StrengthTrainingEntryDTO strengthEntry) { this.strengthEntry = strengthEntry; updateGui(false); if (!WorkoutPlansReposidory.Instance.IsLoaded) { return; } setTrainingPlans(FillWorkoutPlans(false)); }
private void copyStrengthTrainingProperties(StrengthTrainingEntryDTO strength, StrengthTrainingEntryDTO oldStrength) { if (strength.Intensity == Intensity.NotSet) {//if intensity is not set then we assume that user didn't set this property so we can copy all other values from previous day strength.Intensity = oldStrength.Intensity; strength.ReportStatus = oldStrength.ReportStatus; //strength.MyPlace = oldStrength.MyPlace;//uncommnt this or not:) strength.TrainingPlanId = oldStrength.TrainingPlanId; strength.TrainingPlanItemId = oldStrength.TrainingPlanItemId; } }
public void CleanSingleSupersets(StrengthTrainingEntryDTO entry) { var entries = entry.Entries.Where(x => !string.IsNullOrEmpty(x.SuperSetGroup)).ToList(); foreach (var item in entries) { if (entry.Entries.Count(x => x.SuperSetGroup == item.SuperSetGroup) < 2) { item.SuperSetGroup = null; } } }
void checkSuperSets(StrengthTrainingEntryDTO entry) { //get all entries with GroupName (superset) var entries = entry.Entries.Where(x => !string.IsNullOrEmpty(x.SuperSetGroup)).ToList(); foreach (var item in entries) { if (entry.Entries.Count(x => x.SuperSetGroup == item.SuperSetGroup) < 2) { item.SuperSetGroup = null; } } }
protected override void PrepareCopiedEntry(EntryObjectDTO origEntry, EntryObjectDTO entry) { StrengthTrainingEntryDTO strength = entry as StrengthTrainingEntryDTO; if (strength != null) { var oldStrength = (StrengthTrainingEntryDTO)origEntry; copyStrengthTrainingProperties(strength, oldStrength); TrainingBuilder builder = new TrainingBuilder(); builder.PrepareCopiedStrengthTraining(strength, Settings.CopyStrengthTrainingMode); builder.SetPreviewSets(oldStrength, strength); } }
void fillSuperSets(TrainingPlanDay planDay, StrengthTrainingEntryDTO strengthEntry) { foreach (SuperSet superSet in planDay.SuperSets) { foreach (var trainingPlanEntry in superSet.SuperSets) { var item1 = findStrengthTrainingItemByTrainingPlanItemId(trainingPlanEntry.GlobalId, strengthEntry); if (item1 != null) { item1.SuperSetGroup = superSet.SuperSetId.ToString(); } } } }
public StrengthWorkoutViewModel(StrengthTrainingEntryDTO entry) { this.entry = entry; _exercises = new ObservableCollection <StrengthTrainingItemViewModel>(); if (entry.Entries == null) { entry.Entries = new List <StrengthTrainingItemDTO>(); } foreach (var item in entry.Entries) { _exercises.Add(new StrengthTrainingItemViewModel(item)); } }
public override void UpdateEntryObject(EntryObjectDTO entryDto) { StrengthTrainingEntryDTO entry = (StrengthTrainingEntryDTO)entryDto; usrReportStatus1.Save(entry); entry.Comment = txtComment.Text; entry.Mood = ctrlMood.SelectedMood; entry.Intensity = usrIntensity1.Intensity; entry.StartTime = DateHelper.GetCorrectDateTime(tpStart.Value.Value); entry.EndTime = DateHelper.GetCorrectDateTime(tpEnd.Value.Value); if (cmbMyPlaces.SelectedValue != null) { entry.MyPlace = (MyPlaceLightDTO)cmbMyPlaces.SelectedItem; } }
public void Fill(EntryObjectDTO entry) { strengthEntry = (StrengthTrainingEntryDTO)entry; txtComment.Text = strengthEntry.Comment; teStart.Time = strengthEntry.StartTime.HasValue ? strengthEntry.StartTime.Value : DateHelper.NullDateTime; teEndTime.Time = strengthEntry.EndTime.HasValue ? strengthEntry.EndTime.Value : DateHelper.NullDateTime; usrIntensity1.Intensity = strengthEntry.Intensity; usrReportStatus1.Fill(entry); usrWorkoutPlansChooser1.Fill(strengthEntry); usrTrainingDaySourceGrid1.Fill(strengthEntry, usrWorkoutPlansChooser1.SelectedPlanDay, ReadOnly); updateReadOnlyMode(); }
public static IList <SerieDTO> GetIncorrectSets(StrengthTrainingEntryDTO entry) { List <SerieDTO> incorrectSets = new List <SerieDTO>(); if (entry == null) {//we delete this entry return(incorrectSets); } SerieValidator validator = new SerieValidator(); foreach (var item in entry.Entries) { incorrectSets.AddRange(validator.GetIncorrectSets(item)); } return(incorrectSets); }
private void fillStrengthTrainingEntryWithPlan(TrainingPlanDay planDay) { if (ApplicationState.Current.CurrentBrowsingTrainingDays.IsMine) { if (!EntryObjectPageBase.EnsureRemoveEntryTypeFromToday(typeof(StrengthTrainingEntryDTO))) {//cancel overwrite return; } var strengthTraining = new StrengthTrainingEntryDTO(); strengthTraining.StartTime = DateTime.Now; ApplicationState.Current.TrainingDay.TrainingDay.Objects.Add(strengthTraining); strengthTraining.TrainingDay = ApplicationState.Current.TrainingDay.TrainingDay; ApplicationState.Current.CurrentEntryId = new LocalObjectKey(strengthTraining); TrainingBuilder builder = new TrainingBuilder(); builder.FillTrainingFromPlan(planDay, strengthTraining); //apply setting related with copy sets data builder.PrepareCopiedStrengthTraining(strengthTraining, Settings.CopyStrengthTrainingMode); this.GetParent <PhoneApplicationPage>().Navigate("/Pages/StrengthWorkoutPage.xaml"); } }
public void FillTrainingFromPlan(TrainingPlanDay planDay, StrengthTrainingEntryDTO strengthEntry) { strengthEntry.Entries.Clear(); foreach (TrainingPlanEntry trainingPlanEntry in planDay.Entries) { var strengthItem = new StrengthTrainingItemDTO(); strengthItem.Exercise = trainingPlanEntry.Exercise; strengthItem.DoneWay = trainingPlanEntry.DoneWay; strengthItem.SuperSetGroup = trainingPlanEntry.GroupName; strengthItem.TrainingPlanItemId = trainingPlanEntry.GlobalId; strengthEntry.AddEntry(strengthItem); foreach (var set in trainingPlanEntry.Sets) { var serie = new SerieDTO(); if (strengthItem.Exercise.ExerciseType == ExerciseType.Cardio) { if (FillRepetitionNumber && set.RepetitionNumberMin.HasValue) { serie.Weight = set.RepetitionNumberMin.Value; } } else { if (FillRepetitionNumber && set.RepetitionNumberMax.HasValue && set.RepetitionNumberMin.HasValue && set.RepetitionNumberMax == set.RepetitionNumberMin) { serie.RepetitionNumber = set.RepetitionNumberMax.Value; } } serie.IsSuperSlow = set.IsSuperSlow; serie.IsRestPause = set.IsRestPause; serie.DropSet = set.DropSet; serie.SetType = (SetType)set.RepetitionsType; serie.TrainingPlanItemId = set.GlobalId; strengthItem.AddSerie(serie); } } strengthEntry.TrainingPlanItemId = planDay.GlobalId; strengthEntry.TrainingPlanId = planDay.TrainingPlan.GlobalId; }
string getStrengthTrainingMessage(StrengthTrainingEntryDTO strength) { Dictionary <ExerciseType, int> exerciseCounter = new Dictionary <ExerciseType, int>(); foreach (StrengthTrainingItemDTO list in strength.Entries) { var exerciseType = list.Exercise.ExerciseType; if (!exerciseCounter.ContainsKey(exerciseType)) { exerciseCounter.Add(exerciseType, 0); } exerciseCounter[exerciseType] = exerciseCounter[exerciseType] + list.Series.Count; } StringBuilder builder = new StringBuilder(); foreach (KeyValuePair <ExerciseType, int> keyValuePair in exerciseCounter) { builder.AppendLine(EnumLocalizer.Default.Translate(keyValuePair.Key) + ": " + keyValuePair.Value); } return(builder.ToString()); }
public void TestFillEmptyEntryObjectWithoutRepetitions() { TrainingPlan plan = getTrainingPlanWithSets(); var entry = new StrengthTrainingEntryDTO(); TrainingBuilder builder = new TrainingBuilder(); Assert.AreEqual(0, entry.Entries.Count); Assert.AreEqual(null, entry.TrainingPlanItemId); builder.FillTrainingFromPlan(plan.Days[0], entry); Assert.AreEqual(plan.Days[0].Entries.Count, entry.Entries.Count); Assert.AreEqual(plan.Days[0].GlobalId, entry.TrainingPlanItemId); for (int i = 0; i < plan.Days[0].Entries.Count; i++) { Assert.AreEqual(plan.Days[0].Entries[i].Exercise, entry.Entries[i].Exercise); Assert.AreEqual(plan.Days[0].Entries[i].Sets.Count, entry.Entries[i].Series.Count); for (int j = 0; j < plan.Days[0].Entries[i].Sets.Count; j++) { Assert.AreEqual(null, entry.Entries[i].Series[j].RepetitionNumber); } } }
public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj) { ShareSocialContent content = new ShareSocialContent(); content.Caption = "StrengthTrainingModule_ShareSocialContent_Caption_BodyArchitect".TranslateStrength(); content.Name = "StrengthTrainingModule_ShareSocialContent_Name_NewEntry".TranslateStrength(); StringBuilder descriptionBuilder = new StringBuilder(); StrengthTrainingEntryDTO strengthEntry = (StrengthTrainingEntryDTO)entryObj; descriptionBuilder.AppendFormat("StrengthTrainingModule_ShareSocialContent_Date".TranslateStrength(), strengthEntry.TrainingDay.TrainingDate.ToShortDateString()); foreach (var exerciseType in strengthEntry.Entries.Where(x => x.Exercise != null).Select(x => x.Exercise.ExerciseType).Distinct()) { var exercises = strengthEntry.Entries.Where(x => x.Exercise != null && x.Exercise.ExerciseType == exerciseType); descriptionBuilder.AppendFormat(@"<br/><b>{0}</b>", EnumLocalizer.Default.Translate(exerciseType)); foreach (var item in exercises) { descriptionBuilder.AppendFormat(@"<br/>{0}: <i>", item.Exercise.Name); foreach (var set in item.Series) { if (set.IsRecord) { descriptionBuilder.AppendFormat(" <b>{0}</b>", set.GetDisplayText(WorkoutPlanOperationHelper.SetDisplayMode.Medium)); } else { descriptionBuilder.AppendFormat(" {0}", set.GetDisplayText(WorkoutPlanOperationHelper.SetDisplayMode.Medium)); } } descriptionBuilder.Append("</i>"); } descriptionBuilder.Append(@"<br/>"); } content.Description = descriptionBuilder.ToString(); return(content); }
public override void Fill(EntryObjectDTO entryDto) { StrengthTrainingEntryDTO entry = (StrengthTrainingEntryDTO)entryDto; txtComment.Text = entry.Comment; ctrlMood.SelectedMood = entry.Mood; tpStart.Value = entry.StartTime.HasValue ? entry.StartTime.Value : BAHelper.NullDateTime; tpEnd.Value = entry.EndTime.HasValue ? entry.EndTime.Value : BAHelper.NullDateTime; usrIntensity1.Intensity = entry.Intensity; usrReminder.Entry = entryDto; if (entry.MyPlace != null) { cmbMyPlaces.SelectedValue = entry.MyPlace.GlobalId; cmbMyPlaces.Text = entry.MyPlace.Name; } usrWorkoutPlansChooser1.Fill(entry); usrReportStatus1.Fill(entry); usrApplicationName.Fill(entry); if (entry.RemindBefore == null && entry.TrainingDay.TrainingDate < DateTime.Now.Date) {//hide reminder box for old entries grRemindMe.SetVisible(false); } }
public void EntryObjectCreated(EntryObjectDTO entryObject) { if (reservation != null) { entryObject.ReservationId = reservation.GlobalId; } StrengthTrainingEntryDTO strength = entryObject as StrengthTrainingEntryDTO; SizeEntryDTO size = entryObject as SizeEntryDTO; if (strength != null) { strength.StartTime = scheduleEntry.StartTime.ToLocalTime(); strength.EndTime = scheduleEntry.EndTime.ToLocalTime(); if (scheduleEntry.MyPlaceId.HasValue) { var myPlacesCache = MyPlacesReposidory.GetCache(null); strength.MyPlace = myPlacesCache.GetItem(scheduleEntry.MyPlaceId.Value); } } if (size != null) { size.Wymiary.Time.DateTime = scheduleEntry.StartTime.ToLocalTime(); } }
void generateProgress(StrengthTrainingEntryDTO entry) { progressIndicator1.IsRunning = true; tbLicenceMsg.Text = Strings.ProgressReport_Generating; chart.SetVisible(!progressIndicator1.IsRunning); var reportBuilder = new ExerciseWeightReportBuilder(); var report = reportBuilder.CreateReport(); var settings = (ExerciseWeightReportSettings)report.SettingsControl; settings.usrDateRange1.DateFrom = DateTime.UtcNow.AddYears(-1); chart.Series.Clear(); chart.ResetBarAndColumnCaches(); chart.LegendPosition = LegendPosition.OutsideBottomLeft; ReportExerciseWeightParams param = new ReportExerciseWeightParams(); param.UserId = entry.TrainingDay.ProfileId; if (entry.TrainingDay.CustomerId.HasValue) { param.CustomerId = entry.TrainingDay.CustomerId.Value; } if (entry.MyPlace != null) { param.MyPlaces.Add(entry.MyPlace.GlobalId); } param.StartDate = DateTime.UtcNow.AddYears(-1); foreach (var strengthTrainingItemDto in entry.Entries) { if (strengthTrainingItemDto.Exercise.ExerciseType == ExerciseType.Cardio) {//skip cardio exercise because they not use kg - but time continue; } if (!param.Exercises.Contains(strengthTrainingItemDto.Exercise.GlobalId)) { param.Exercises.Add(strengthTrainingItemDto.Exercise.GlobalId); } if (!param.DoneWays.Contains(strengthTrainingItemDto.DoneWay)) { param.DoneWays.Add(strengthTrainingItemDto.DoneWay); } settings.Items.Add(new CheckListItem <ExerciseLightDTO>(strengthTrainingItemDto.Exercise.Name, strengthTrainingItemDto.Exercise) { IsChecked = true }); } ThreadPool.QueueUserWorkItem(new WaitCallback((h) => { try { Helper.EnsureThreadLocalized(); var data = report.RetrieveReportData(param); Helper.Delay(2000); UIHelper.BeginInvoke(() => { report.GenerateReport(chart, data); progressIndicator1.IsRunning = false; chart.SetVisible(!progressIndicator1.IsRunning); tbLicenceMsg.Text = ""; }, Dispatcher); } catch (Exception) { UIHelper.BeginInvoke(() => { progressIndicator1.IsRunning = false; chart.SetVisible(!progressIndicator1.IsRunning); tbLicenceMsg.Text = Strings.ProgressReport_Error; }, Dispatcher); } })); }
public ExerciseCellValueChangedController(usrStrengthTrainingSourceGridBase parent, StrengthTrainingEntryDTO strengthEntry) { this.parent = parent; this.strengthEntry = strengthEntry; }
public void Fill(StrengthTrainingEntryDTO strengthEntry) { this.strengthEntry = strengthEntry; setTrainingPlans(fillWorkoutPlans(false)); }
StrengthTrainingItemDTO findStrengthTrainingItemByTrainingPlanItemId(Guid trainingPlanItemId, StrengthTrainingEntryDTO strengthEntry) { foreach (var strengthTrainingItem in strengthEntry.Entries) { if (strengthTrainingItem.TrainingPlanItemId == trainingPlanItemId) { return(strengthTrainingItem); } } return(null); }
public void Fill(StrengthTrainingEntryDTO entry) { this.entry = entry; RebuildViewModel(); }
public void Fill(StrengthTrainingEntryDTO entry, StrengthTrainingViewModel viewModel) { this.entry = entry; this.viewModel = viewModel; ItemsSource = viewModel.Items; }