public static IDuration Create(IDuration.DurationType type, RegularStep parent)
        {
            IDuration newDuration;

            switch (type)
            {
                case IDuration.DurationType.LapButton:
                    {
                        newDuration = new LapButtonDuration(parent);
                        break;
                    }
                case IDuration.DurationType.Time:
                    {
                        newDuration = new TimeDuration(parent);
                        break;
                    }
                case IDuration.DurationType.Distance:
                    {
                        newDuration = new DistanceDuration(parent);
                        break;
                    }
                case IDuration.DurationType.HeartRateAbove:
                    {
                        newDuration = new HeartRateAboveDuration(parent);
                        break;
                    }
                case IDuration.DurationType.HeartRateBelow:
                    {
                        newDuration = new HeartRateBelowDuration(parent);
                        break;
                    }
                case IDuration.DurationType.Calories:
                    {
                        newDuration = new CaloriesDuration(parent);
                        break;
                    }
                case IDuration.DurationType.PowerAbove:
                    {
                        newDuration = new PowerAboveDuration(parent);
                        break;
                    }
                case IDuration.DurationType.PowerBelow:
                    {
                        newDuration = new PowerBelowDuration(parent);
                        break;
                    }
                default:
                    {
                        Debug.Assert(false);
                        newDuration = null;
                        break;
                    }
            }

            parent.Duration = newDuration;

            return newDuration;
        }
示例#2
0
 void OnDurationChanged(RegularStep modifiedStep, IDuration durationChanged, PropertyChangedEventArgs changedProperty)
 {
     if (ConcreteWorkout.StepDurationChanged != null)
     {
         ConcreteWorkout.StepDurationChanged(this, modifiedStep, durationChanged, changedProperty);
     }
 }
 void OnWorkoutStepDurationChanged(IWorkout modifiedWorkout, RegularStep modifiedStep, IDuration modifiedDuration, PropertyChangedEventArgs changedProperty)
 {
     UpdateWorkoutStepsCopy();
 }
        public static string FormatDurationDescription(IDuration duration)
        {
            string result;
            string baseString;
            IDuration.DurationType type = duration.Type;
            FieldInfo fieldInfo = type.GetType().GetField(Enum.GetName(type.GetType(), type));
            StepDescriptionStringProviderAttribute providerAttribute = (StepDescriptionStringProviderAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(StepDescriptionStringProviderAttribute));

            baseString = GarminFitnessView.GetLocalizedString(providerAttribute.StringName);

            switch(type)
            {
                case IDuration.DurationType.LapButton:
                    {
                        result = baseString;
                        break;
                    }
                case IDuration.DurationType.Distance:
                    {
                        DistanceDuration concreteDuration = duration as DistanceDuration;
                        result = String.Format(baseString, concreteDuration.GetDistanceInBaseUnit(), Length.LabelAbbr(concreteDuration.BaseUnit));
                        break;
                    }
                case IDuration.DurationType.Time:
                    {
                        TimeDuration concreteDuration = duration as TimeDuration;
                        result = String.Format(baseString, concreteDuration.Hours, concreteDuration.Minutes, concreteDuration.Seconds);
                        break;
                    }
                case IDuration.DurationType.HeartRateAbove:
                    {
                        HeartRateAboveDuration concreteDuration = duration as HeartRateAboveDuration;
                        string unitsString;

                        if(concreteDuration.IsPercentageMaxHeartRate)
                        {
                            unitsString = CommonResources.Text.LabelPercentOfMax;
                        }
                        else
                        {
                            unitsString = CommonResources.Text.LabelBPM;
                        }

                        result = String.Format(baseString, concreteDuration.MaxHeartRate, unitsString);
                        break;
                    }
                case IDuration.DurationType.HeartRateBelow:
                    {
                        HeartRateBelowDuration concreteDuration = duration as HeartRateBelowDuration;
                        string unitsString;

                        if(concreteDuration.IsPercentageMaxHeartRate)
                        {
                            unitsString = CommonResources.Text.LabelPercentOfMax;
                        }
                        else
                        {
                            unitsString = CommonResources.Text.LabelBPM;
                        }

                        result = String.Format(baseString, concreteDuration.MinHeartRate, unitsString);
                        break;
                    }
                case IDuration.DurationType.Calories:
                    {
                        CaloriesDuration concreteDuration = duration as CaloriesDuration;
                        result = String.Format(baseString, concreteDuration.CaloriesToSpend);
                        break;
                    }
                case IDuration.DurationType.PowerAbove:
                    {
                        PowerAboveDuration concreteDuration = duration as PowerAboveDuration;
                        string unitsString;

                        if (concreteDuration.IsPercentFTP)
                        {
                            unitsString = GarminFitnessView.GetLocalizedString("PercentFTPText");
                        }
                        else
                        {
                            unitsString = CommonResources.Text.LabelWatts;
                        }

                        result = String.Format(baseString, concreteDuration.MaxPower, unitsString);
                        break;
                    }
                case IDuration.DurationType.PowerBelow:
                    {
                        PowerBelowDuration concreteDuration = duration as PowerBelowDuration;
                        string unitsString;

                        if (concreteDuration.IsPercentFTP)
                        {
                            unitsString = GarminFitnessView.GetLocalizedString("PercentFTPText");
                        }
                        else
                        {
                            unitsString = CommonResources.Text.LabelWatts;
                        }

                        result = String.Format(baseString, concreteDuration.MinPower, unitsString);
                        break;
                    }
                default:
                    {
                        Debug.Assert(false);
                        result = String.Empty;
                        break;
                    }
            }

            return result;
        }
示例#5
0
 private void OnDurationChanged(IDuration modifiedDuration, PropertyChangedEventArgs changedProperty)
 {
     TriggerDurationChangedEvent(modifiedDuration, changedProperty);
 }
示例#6
0
        protected void TriggerDurationChangedEvent(IDuration duration, PropertyChangedEventArgs args)
        {
            Debug.Assert(Type == StepType.Regular);

            if (DurationChanged != null)
            {
                DurationChanged((RegularStep)this, duration, args);
            }
        }
示例#7
0
 public RegularStep(string name, IDuration duration, ITarget target, Workout parent)
     : this(duration, target, parent)
 {
     Name = name;
 }
示例#8
0
 public RegularStep(IDuration duration, ITarget target, Workout parent)
     : base(StepType.Regular, parent)
 {
     Duration = duration;
     Target = target;
 }
        void OnWorkoutStepDurationChanged(IWorkout modifiedWorkout, RegularStep modifiedStep, IDuration modifiedDuration, PropertyChangedEventArgs changedProperty)
        {
            if (InvokeRequired)
            {
                Invoke(new WorkoutStepDurationChangedDelegate(OnWorkoutStepDurationChanged),
                       new object[] { modifiedWorkout, modifiedStep, modifiedDuration, changedProperty });
            }
            else
            {
                if (SelectedWorkout == modifiedWorkout)
                {
                    // Refresh the steps list so it updates the name/description
                    StepsList.Invalidate();

                    if (modifiedStep == SelectedStep)
                    {
                        UpdateUIFromDuration();
                    }
                }
            }
        }