private void displayOldEntry(EntryObjectDTO newEntry) { oldEntry = newEntry; headerOldTrainingDate.Text = newEntry.TrainingDay.TrainingDate.ToLongDateString(); headerOldTrainingDate.Visibility = System.Windows.Visibility.Visible; ShowOldTraining(newEntry); }
public void Fill(EntryObjectDTO entry) { suplementEntry = (SuplementsEntryDTO)entry; updateReadOnly(); suplementsGrid1.Fill(suplementEntry); usrReportStatus1.Fill(entry); }
public void Fill(EntryObjectDTO entry) { sizeEntry = (SizeEntryDTO)entry; updateReadOnly(); this.usrWymiaryEditor1.Fill(sizeEntry.Wymiary); usrReportStatus1.Fill(entry); }
Brush getBrush(EntryObjectDTO entry) { Type type = entry.GetType(); if (type == typeof(StrengthTrainingEntryDTO)) { return(EntryObjectColors.StrengthTraining); } else if (type == typeof(SuplementsEntryDTO)) { return(EntryObjectColors.Supplements); } if (type == typeof(BlogEntryDTO)) { return(EntryObjectColors.Blog); } if (type == typeof(GPSTrackerEntryDTO)) { return(EntryObjectColors.GPSTracker); } if (type == typeof(A6WEntryDTO)) { return(EntryObjectColors.A6W); } if (type == typeof(SizeEntryDTO)) { return(EntryObjectColors.Measurements); } return(null); }
private void fillNewEntry(EntryObjectDTO newEntry) { var strength = newEntry as StrengthTrainingEntryDTO; var size = newEntry as SizeEntryDTO; var supple = newEntry as SuplementsEntryDTO; var blog = newEntry as BlogEntryDTO; var gps = newEntry as GPSTrackerEntryDTO; if (strength != null) { strength.StartTime = DateTime.Now; } else if (size != null) { size.Wymiary = new WymiaryDTO(); size.Wymiary.Time.DateTime = DateTime.Now; } else if (supple != null) { } else if (blog != null) { #if DEBUG throw new Exception("Blog cannot be created in WP7"); #endif } else if (gps != null) { } }
string getImage(EntryObjectDTO entry) { Type type = entry.GetType(); if (type == typeof(StrengthTrainingEntryDTO)) { return("/Images/strengthTrainingTile.jpg"); } else if (type == typeof(SuplementsEntryDTO)) { return("/Images/suppleTile.jpg"); } if (type == typeof(BlogEntryDTO)) { return("/Images/blogTile.jpg"); } if (type == typeof(GPSTrackerEntryDTO)) { return("/Images/gpsTile.jpg"); } if (type == typeof(SizeEntryDTO)) { return("/Images/sizesTile.jpg"); } return(null); }
private static void fillOldGlobalId(EntryObjectDTO newEntry, EntryObjectDTO oldEntry, bool fillOldGlobalId) { newEntry.InstanceId = oldEntry.InstanceId; if (fillOldGlobalId) { oldEntry.GlobalId = newEntry.GlobalId; } }
public bool SaveTrainingDay(bool isWindowClosing) { if (!validateControls()) { return(false); } foreach (XtraTabPage tabPage in xtraTabControl1.TabPages) { IEntryObjectControl entryControl = (IEntryObjectControl)tabPage.Controls[0]; entryControl.UpdateEntryObject(); } if (day.Id == Constants.UnsavedObjectId && day.IsEmpty) { return(true); } day = ServiceManager.SaveTrainingDay(day); foreach (var module in PluginsManager.Instance.Modules) { module.AfterSave(UserContext.SessionData, day); } if (isWindowClosing) {//optimalization - we are closing window so we don't need to refresh the tabs (code below) return(true); } for (int index = xtraTabControl1.TabPages.Count - 1; index >= 0; index--) { XtraTabPage tabPage = xtraTabControl1.TabPages[index]; IEntryObjectControl entryControl = tabPage.Controls[0] as IEntryObjectControl; if (entryControl != null) { ParentWindow.SynchronizationContext.Send(delegate { entryControl.AfterSave(isWindowClosing); EntryObjectDTO entry = (EntryObjectDTO)tabPage.Controls[0].Tag; //here we assume that training day contains only one instance of the specific entry type var newEntry = day.GetSpecifiedEntries(entry.GetType()); if (newEntry != null) { tabPage.Controls[0].Tag = newEntry; entryControl.Fill(newEntry); } else { xtraTabControl1.TabPages.Remove(tabPage); } }, null); } } return(true); }
//key is GPSTrackerEntryId //public Dictionary<Guid, GPSPointsBag> GPSCoordinates { get; set; } public void Update(EntryObjectDTO entryObject) { var entry = this.TrainingDay.Objects.Where(x => x.GlobalId == entryObject.GlobalId).SingleOrDefault(); if (entry != null) { TrainingDay.Objects.Remove(entry); TrainingDay.Objects.Add(entryObject); entryObject.TrainingDay = TrainingDay; } }
public void Fill(EntryObjectDTO entry) { filling = true; usrHtmlEditor1.ClearContent(); blogEntry = (BlogEntryDTO)entry; usrBlogComments1.Fill(blogEntry); usrHtmlEditor1.SetHtml(blogEntry.Comment); cmbAllowComments.SelectedIndex = blogEntry.AllowComments ? 0 : 1; updateReadOnly(); filling = false; }
public override void Fill(EntryObjectDTO entry) { usrReportStatus1.Fill(entry); usrApplicationName.Fill(entry); usrRemindMe.Entry = entry; txtComment.Text = entry.Comment; if (entry.RemindBefore == null && entry.TrainingDay.TrainingDate < DateTime.Now.Date) {//hide reminder box for old entries grRemindMe.SetVisible(false); } }
public override void Fill(EntryObjectDTO entry) { ctrlRemindMe.Entry = entry; usrApplicationName.Fill(entry); txtComment.Text = entry.Comment; usrReportStatus1.Fill(entry); ctrlMood.SelectedMood = ((GPSTrackerEntryDTO)entry).Mood; if (entry.RemindBefore == null && entry.TrainingDay.TrainingDate < DateTime.Now.Date) {//hide reminder box for old entries grRemindMe.SetVisible(false); } }
public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj) { ShareSocialContent content = new ShareSocialContent(); content.Caption = BlogEntryStrings.BlogModule_ShareToSocial_Caption; content.Name = BlogEntryStrings.BlogModule_ShareToSocial_Name; StringBuilder descriptionBuilder = new StringBuilder(); descriptionBuilder.AppendFormat(BlogEntryStrings.BlogModule_ShareToSocial_Description, entryObj.TrainingDay.TrainingDate.ToShortDateString()); content.Description = descriptionBuilder.ToString(); return(content); }
public override void Fill(EntryObjectDTO entry) { if (!UserContext.IsPremium) { chart.SetVisible(false); tbLicenceMsg.Text = Strings.ProgressReport_FreeLicenceMsg; } else { chart.SetVisible(true); generateProgress((SizeEntryDTO)entry); } }
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); } }
private bool createNewEntryControl(EntryObjectDTO entry, bool @select, SaveTrainingDayResult saveResult) { if (entry.IsLoaded) { try { var ctrl = (Control)Activator.CreateInstance(EntryObjectControlManager.Instance.Controls[entry.GetType()]); // var tabPage = new TabItem(); string text = entry.GetEntryObjectText(); ctrl.Tag = entry; var entryCtrl = (IEntryObjectControl)ctrl; entryCtrl.ReadOnly = ReadOnly || entry.Status == EntryObjectStatus.System; TabItemViewModel tabItem = new TabItemViewModel(); tabItem.CloseButtonVisible = !ReadOnly; tabItem.Header = text; tabItem.Content = ctrl; tabItem.IsFromReservation = entry.ReservationId.HasValue; tabItem.EntryObject = entry; tabs.Add(tabItem); xtraTabControl1.SelectedItem = tabItem; //EntryObjectDTO originalEntry = null; //if(originalDay!=null) //{ // originalEntry=originalDay.Objects.Where(x => x.GlobalId == entry.GlobalId).SingleOrDefault(); // if(originalEntry==null) // {//when originalDay is not null then we now that this is a Saving mode. So we imitate empty instance to have a comparison // originalEntry = (EntryObjectDTO)Activator.CreateInstance(entry.GetType()); // } //} entryCtrl.Fill(entry, saveResult); updateButtons(); } catch (TrainingIntegrationException ex) { ExceptionHandler.Default.Process(ex, Strings.ErrorTrainingIntegrity, ErrorWindow.MessageBox); return(false); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, Strings.ErrorUnhandledException, ErrorWindow.EMailReport); return(false); } } return(true); }
public bool PostEntryObject(EntryObjectDTO entry) { var provider = PluginsManager.Instance.GetEntryObjectProvider(entry.GetType()); if (provider != null) { var content = provider.ShareToSocial(entry); if (content != null) { PostNote(content); return(true); } } return(false); }
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 override bool ValidateControl(EntryObjectDTO entryDto) { A6WEntryDTO entry = (A6WEntryDTO)entryDto; if (entry.Status == EntryObjectStatus.Done && entry.MyTraining.TrainingEnd == TrainingEnd.NotEnded && !rbPartialCompleted.IsChecked.Value && !rbCompleted.IsChecked.Value) { BAMessageBox.ShowErrorEx(A6WEntryStrings.ErrorA6WDayResultMissing, A6WEntryStrings.EntryTypeName); return(false); } if (entry.MyTraining.TrainingEnd == TrainingEnd.NotEnded && rbPartialCompleted.IsChecked.Value && !usrA6WPartialCompleted1.Validate(entry)) { return(false); } return(true); }
public void Fill(EntryObjectDTO entry, SaveTrainingDayResult originalEntry) { isFilling = true; this.entry = entry; FillImplementation(originalEntry); if (detailsControl != null) { detailsControl.Fill(this.entry); } if (progressControl != null) { progressControl.Fill(this.entry); } isFilling = false; }
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(); }
protected override void copyAllImplementation(EntryObjectDTO oldEntry) { if (oldEntry != null) { var itemsToCopy = lstOldItems.SelectedItems.Cast <SupplementItemViewModel>().Select(x => x.Item).ToList(); foreach (var itemDto in itemsToCopy) { var newItem = itemDto.Copy(true); Entry.Items.Add(newItem); newItem.SuplementsEntry = Entry; } show(true); } }
public void PrepareNewEntryObject(SessionData sessionData, EntryObjectDTO obj, TrainingDayDTO day) { var a6w = (A6WEntryDTO)obj; if (a6w.MyTraining == null) { var trainings = ServiceManager.GetStartedTrainings(A6WEntryDTO.EntryTypeId); if (trainings.Count > 0) { a6w.MyTraining = trainings[0]; } } if (a6w.MyTraining == null) { a6w.MyTraining = new MyTrainingDTO(); a6w.MyTraining.ProfileId = UserContext.CurrentProfile.Id; a6w.MyTraining.Name = A6WEntryStrings.EntryTypeName; a6w.MyTraining.StartDate = day.TrainingDate; a6w.MyTraining.TypeId = A6WEntryDTO.EntryTypeId; a6w.DayNumber = 1; } else { if (day.TrainingDate.Date < a6w.MyTraining.StartDate.Date) { throw new TrainingIntegrationException(string.Format(A6WEntryStrings.ErrorA6WTrainingAlreadyStarted, a6w.MyTraining.StartDate)); } } if (a6w.Id == Constants.UnsavedObjectId) { var myEntries = ServiceManager.GetMyTrainingEntries(a6w.MyTraining); if (myEntries.Count > 0) { var maxDate = myEntries.Max(x => x.TrainingDay.TrainingDate); if (maxDate > day.TrainingDate) { throw new TrainingIntegrationException("You cannot insert new A6W entry in the middle of training"); } } a6w.DayNumber = a6w.GetNextDayNumber(myEntries); a6w.MyTraining.Tag = myEntries; } }
//checks if this entry is already saved (to the server or local only) public bool IsSaved(EntryObjectDTO entry) { bool isAlreadySavedInLocal = false; if (entry.IsNew) { isAlreadySavedInLocal = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(entry.TrainingDay.TrainingDate); if (isAlreadySavedInLocal) { TrainingDayInfo dayInfo = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[entry.TrainingDay.TrainingDate]; var entrySavedInLocal = dayInfo.TrainingDay.Objects.Where(x => x.InstanceId == entry.InstanceId).SingleOrDefault(); isAlreadySavedInLocal = entrySavedInLocal != null; } } bool emptyEntry = entry.IsNew && !isAlreadySavedInLocal; return(!emptyEntry); }
HyperlinkButton addButton(Type entryObjectType, EntryObjectDTO existingObject) { HyperlinkButton link = new HyperlinkButton(); link.Style = (Style)Application.Current.Resources["EmptyButtonStyle"]; HubTile content = new HubTile(); content.Tag = link.Tag = existingObject; link.Content = content; if (prepareButton(link, entryObjectType)) { TranslateTransform transform = new TranslateTransform(); content.RenderTransform = transform; pnlMain.Children.Add(link); content.Tap += content_Tap; return(link); } return(null); }
public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj) { A6WEntryDTO a6W = (A6WEntryDTO)entryObj; ShareSocialContent content = new ShareSocialContent(); content.Caption = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_Caption"); content.Name = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_Name"); var daysToFinish = A6WManager.Days.Count - a6W.Day.DayNumber; if (daysToFinish == 0) { content.Description = string.Format(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_Finished_Description"), a6W.Day.DayNumber, a6W.TrainingDay.TrainingDate.ToShortDateString()); } else { content.Description = string.Format(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.A6W:A6WEntryStrings:A6WModule_ShareToSocial_NotFinished_Description"), a6W.Day.DayNumber, a6W.TrainingDay.TrainingDate.ToShortDateString(), daysToFinish); } return(content); }
public void Fill(EntryObjectDTO entry) { this.entry = (A6WEntryDTO)entry; usrReportStatus1.Fill(entry); if (this.entry.MyTraining.Id == Constants.UnsavedObjectId) { FMMessageBox.ShowInfo(A6WEntryStrings.StartNewTrainingText); } if (entry.Id != Constants.UnsavedObjectId) { rbCompleted.Checked = this.entry.Completed; rbPartialCompleted.Checked = !this.entry.Completed; } ReadOnly = ReadOnly || this.entry.MyTraining.TrainingEnd != TrainingEnd.NotEnded; txtComment.Text = entry.Comment; fillDaysCombo(); usrMyTrainingStatus1.Fill(this.entry.MyTraining); usrA6WPartialCompleted1.Fill(this.entry); lvA6W.Items[this.entry.DayNumber - 1].BackColor = selectedDayColor; }
public ShareSocialContent ShareToSocial(EntryObjectDTO entryObj) { var supple = (SuplementsEntryDTO)entryObj; ShareSocialContent content = new ShareSocialContent(); content.Caption = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Caption"); content.Name = EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Name"); StringBuilder descriptionBuilder = new StringBuilder(); descriptionBuilder.AppendFormat(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Date"), entryObj.TrainingDay.TrainingDate.ToShortDateString()); descriptionBuilder.AppendFormat("<br/>"); foreach (var item in supple.Items) { if (item.Suplement != null) { descriptionBuilder.AppendFormat(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:SupplementsModule_ShareToSocial_Dosage"), item.Suplement.Name, item.Name.Trim(), item.Dosage, EnumLocalizer.Default.Translate(item.DosageType)); } } content.Description = descriptionBuilder.ToString(); return(content); }
public override void Fill(EntryObjectDTO entryDto) { A6WEntryDTO entry = (A6WEntryDTO)entryDto; usrApplicationName.Fill(entry); usrReportStatus1.Fill(entry); usrA6WPartialCompleted1.Fill(entry); if (entry.Status == EntryObjectStatus.Done) { rbPartialCompleted.IsChecked = !entry.Completed; rbCompleted.IsChecked = entry.Completed; } if (entry.RemindBefore == null && entry.TrainingDay.TrainingDate < DateTime.Now.Date) {//hide reminder box for old entries grRemindMe.SetVisible(false); } usrReminder.Entry = entry; txtComment.Text = entry.Comment; usrMyTrainingStatus1.Fill(a6wControl.MyTraining); }
protected void showOldTraining() { if (ApplicationState.Current == null) { return; } if (oldEntry != null) { ShowOldTraining(oldEntry); return; } var oldTrainingDate = ApplicationState.Current.TrainingDay.TrainingDay.TrainingDate.AddDays(-6); oldEntry = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.Values.Where(x => x.TrainingDay.TrainingDate <= oldTrainingDate).SelectMany(x => x.TrainingDay.Objects).OrderByDescending(x => x.TrainingDay.TrainingDate).Where(x => x.GetType() == EntryType && !x.IsSame(Entry)).FirstOrDefault(); if (oldEntry != null) { displayOldEntry(oldEntry); } else { btnShowOldPrevious_Click(this, EventArgs.Empty); } }