private void displayOldEntry(EntryObjectDTO newEntry)
 {
     oldEntry = newEntry;
     headerOldTrainingDate.Text       = newEntry.TrainingDay.TrainingDate.ToLongDateString();
     headerOldTrainingDate.Visibility = System.Windows.Visibility.Visible;
     ShowOldTraining(newEntry);
 }
Exemplo n.º 2
0
 public void Fill(EntryObjectDTO entry)
 {
     suplementEntry = (SuplementsEntryDTO)entry;
     updateReadOnly();
     suplementsGrid1.Fill(suplementEntry);
     usrReportStatus1.Fill(entry);
 }
Exemplo n.º 3
0
 public void Fill(EntryObjectDTO entry)
 {
     sizeEntry = (SizeEntryDTO)entry;
     updateReadOnly();
     this.usrWymiaryEditor1.Fill(sizeEntry.Wymiary);
     usrReportStatus1.Fill(entry);
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 7
0
 private static void fillOldGlobalId(EntryObjectDTO newEntry, EntryObjectDTO oldEntry, bool fillOldGlobalId)
 {
     newEntry.InstanceId = oldEntry.InstanceId;
     if (fillOldGlobalId)
     {
         oldEntry.GlobalId = newEntry.GlobalId;
     }
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        //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;
            }
        }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 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);
     }
 }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
 public override void Fill(EntryObjectDTO entry)
 {
     if (!UserContext.IsPremium)
     {
         chart.SetVisible(false);
         tbLicenceMsg.Text = Strings.ProgressReport_FreeLicenceMsg;
     }
     else
     {
         chart.SetVisible(true);
         generateProgress((SizeEntryDTO)entry);
     }
 }
Exemplo n.º 15
0
        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);
            }
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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;
            }
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 21
0
        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();
        }
Exemplo n.º 22
0
        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);
            }
        }
Exemplo n.º 23
0
        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;
            }
        }
Exemplo n.º 24
0
        //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);
        }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 26
0
        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);
        }
Exemplo n.º 27
0
        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;
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
        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);
            }
        }