public GarminActivityProfile(GarminCategories category)
        {
            m_Category = category;

            // HR Zones (always stored in % Max)
            float currentLowHR = 0.5f;
            const float stepHR = 0.1f;
            for(int i = 0; i < Constants.GarminHRZoneCount; ++i)
            {
                m_HeartRateZones.Add(new GarminFitnessValueRange<GarminFitnessDoubleRange>(new GarminFitnessDoubleRange(currentLowHR, 0, 1),
                                                                                           new GarminFitnessDoubleRange(currentLowHR + stepHR, 0, 1)));

                currentLowHR += stepHR;
            }

            // Speed Zones
            float currentLowSpeed = 5;
            const float stepSpeed = 1;
            for(int i = 0; i < Constants.GarminSpeedZoneCount; ++i)
            {
                String zoneName = GarminFitnessView.GetLocalizedString("GTCSpeedZone" + (i + 1).ToString() + "Text");

                m_SpeedZones.Add(new GarminFitnessNamedSpeedZone(currentLowSpeed, currentLowSpeed + stepSpeed, zoneName));

                currentLowSpeed += stepSpeed;
            }
        }
        public SetupWizardEditProfileControl(ExtendedWizard wizard)
            : base(wizard)
        {
            InitializeComponent();

            GarminActivityBanner.ThemeChanged(PluginMain.GetApplication().VisualTheme);
            HRZonesTreeList.ThemeChanged(PluginMain.GetApplication().VisualTheme);
            SpeedZonesTreeList.ThemeChanged(PluginMain.GetApplication().VisualTheme);

            GarminProfileManager.Instance.ProfileChanged += new GarminProfileManager.ProfileChangedEventHandler(OnProfileChanged);
            GarminProfileManager.Instance.ActivityProfileChanged += new GarminProfileManager.ActivityProfileChangedEventHandler(OnActivityProfileChanged);

            m_CurrentCategory = GarminCategories.Running;
            m_CurrentProfile = GarminProfileManager.Instance.GetProfileForActivity(m_CurrentCategory);

            BuildTreeLists();
            RefreshProfileInfo();
            RefreshUIFromCategory();

            ExplanationLabel.Text = GarminFitnessView.GetLocalizedString("EditProfileExplanationText");
            BirthDateTimePicker.CustomFormat = CultureInfo.CreateSpecificCulture(GarminFitnessView.UICulture.Name).DateTimeFormat.ShortDatePattern;

            // User data
            ProfileNameLabel.Text = GarminFitnessView.GetLocalizedString("NameLabelText");
            GenderLabel.Text = GarminFitnessView.GetLocalizedString("GenderLabelText");
            MaleRadioButton.Text = GarminFitnessView.GetLocalizedString("MaleText");
            FemaleRadioButton.Text = GarminFitnessView.GetLocalizedString("FemaleText");
            WeightLabel.Text = GarminFitnessView.GetLocalizedString("WeightLabelText");
            WeightUnitLabel.Text = Weight.LabelAbbr(PluginMain.GetApplication().SystemPreferences.WeightUnits);
            BirthDateLabel.Text = GarminFitnessView.GetLocalizedString("BirthDateLabelText");
            RestingHeartRateLabel.Text = GarminFitnessView.GetLocalizedString("RestingHeartRateLabelText");
            RestBPMLabel.Text = CommonResources.Text.LabelBPM;

            // Activity data
            MaxHRLabel.Text = GarminFitnessView.GetLocalizedString("MaxHRLabelText");
            MaxHRBPMLabel.Text = CommonResources.Text.LabelBPM;
            GearWeightLabel.Text = GarminFitnessView.GetLocalizedString("GearWeightLabelText");
            GearWeightUnitLabel.Text = Weight.LabelAbbr(PluginMain.GetApplication().SystemPreferences.WeightUnits);

            // HR zones
            HRZonesGroupBox.Text = GarminFitnessView.GetLocalizedString("HRZonesGroupBoxText");
            BPMRadioButton.Text = CommonResources.Text.LabelBPM;
            PercentMaxRadioButton.Text = CommonResources.Text.LabelPercentOfMax;
            PercentHRRRadioButton.Text = CommonResources.Text.LabelPercentOfReserve;
            LowHRLabel.Text = GarminFitnessView.GetLocalizedString("LowLabelText");
            HighHRLabel.Text = GarminFitnessView.GetLocalizedString("HighLabelText");

            // Speed zones
            SpeedZonesGroupBox.Text = GarminFitnessView.GetLocalizedString("SpeedZonesGroupBoxText");
            SpeedRadioButton.Text = Length.LabelAbbr(m_CurrentProfile.BaseSpeedUnit) +
                                    GarminFitnessView.GetLocalizedString("PerHourText");
            PaceRadioButton.Text = GarminFitnessView.GetLocalizedString("MinuteAbbrText") + "/" +
                                   Length.LabelAbbr(m_CurrentProfile.BaseSpeedUnit);
            LowSpeedLabel.Text = GarminFitnessView.GetLocalizedString("LowLabelText");
            HighSpeedLabel.Text = GarminFitnessView.GetLocalizedString("HighLabelText");
            NameSpeedLabel.Text = GarminFitnessView.GetLocalizedString("NameLabelText");
        }
        public GarminProfileControl()
        {
            InitializeComponent();

            m_CurrentCategory = GarminCategories.Running;
            m_CurrentProfile = GarminProfileManager.Instance.GetProfileForActivity(m_CurrentCategory);
            m_CurrentBikeProfile = null;

            GarminProfileManager.Instance.ProfileChanged += new GarminProfileManager.ProfileChangedEventHandler(OnProfileChanged);
            GarminProfileManager.Instance.ActivityProfileChanged += new GarminProfileManager.ActivityProfileChangedEventHandler(OnActivityProfileChanged);

            BuildTreeLists();
        }
        public void UpdateProfile(GarminCategories category)
        {
            GarminActivityProfile profile = GarminProfileManager.Instance.GetProfileForActivity(category);

            if (profile.GetType() == typeof(GarminBikingActivityProfile))
            {
                m_Profile = (GarminBikingActivityProfile)profile;
            }
            else
            {
                m_Profile = null;
            }
        }
        public GarminBikingActivityProfile(GarminCategories category)
            : base(category)
        {
            // Power Zones
            double currentPower = 0.5;
            double powerStep = 0.2;
            for (int i = 0; i < Constants.GarminPowerZoneCount; ++i)
            {
                m_PowerZones.Add(new GarminFitnessValueRange<GarminFitnessDoubleRange>(new GarminFitnessDoubleRange(currentPower, Constants.MinPowerInPercentFTP, Constants.MaxPowerInPercentFTPInternal),
                                                                                       new GarminFitnessDoubleRange((UInt16)(currentPower + powerStep), Constants.MinPowerInPercentFTP, Constants.MaxPowerInPercentFTPInternal)));

                currentPower += powerStep;
            }

            // Bike profiles
            m_Bikes[0] = new GarminBikeProfile("Road");
            m_Bikes[1] = new GarminBikeProfile("MTB");
            m_Bikes[2] = new GarminBikeProfile("Spinner");

            for (int i = 0; i < Constants.GarminBikeProfileCount; ++i)
            {
                m_Bikes[i].BikeProfileChanged += new GarminBikeProfile.BikeProfileChangedEventHandler(OnBikeProfileChanged);
            }
        }
예제 #6
0
        public static void ExportProfileToFITSport(GarminProfile profile, GarminCategories sport, Stream exportStream)
        {
            MemoryStream dataStream = new MemoryStream();

            // Reserve size for header
            dataStream.Write(new Byte[12], 0, 12);

            // File id message
            FITMessage fileIdMessage = new FITMessage(FITGlobalMessageIds.FileId);
            FITMessageField fileType = new FITMessageField((Byte)FITFileIdFieldsIds.FileType);
            FITMessageField manufacturerId = new FITMessageField((Byte)FITFileIdFieldsIds.ManufacturerId);
            FITMessageField productId = new FITMessageField((Byte)FITFileIdFieldsIds.ProductId);
            FITMessageField serialNumber = new FITMessageField((Byte)FITFileIdFieldsIds.SerialNumber);
            FITMessageField exportDate = new FITMessageField((Byte)FITFileIdFieldsIds.ExportDate);
            FITMessageField number = new FITMessageField((Byte)FITFileIdFieldsIds.Number);

            fileType.SetEnum((Byte)FITFileTypes.Sport);
            fileIdMessage.AddField(fileType);
            manufacturerId.SetUInt16(1);
            fileIdMessage.AddField(manufacturerId);
            productId.SetUInt16(20119);
            fileIdMessage.AddField(productId);
            serialNumber.SetUInt32z(0);
            fileIdMessage.AddField(serialNumber);
            exportDate.SetUInt32((UInt32)(DateTime.Now - new DateTime(1989, 12, 31)).TotalSeconds);
            fileIdMessage.AddField(exportDate);
            number.SetUInt16(1);
            fileIdMessage.AddField(number);

            fileIdMessage.Serialize(dataStream);

            profile.SerializeToFITSport(dataStream, sport);

            // Write FIT header at the start of the stream
            GarminFitnessByteRange headerSize = new GarminFitnessByteRange(12);
            GarminFitnessByteRange protocolVersion = new GarminFitnessByteRange((Byte)((FITConstants.FITProtocolMajorVersion << 4) | FITConstants.FITProtocolMinorVersion));
            GarminFitnessUInt16Range profileVersion = new GarminFitnessUInt16Range((UInt16)((FITConstants.FITProfileMajorVersion * FITConstants.FITProfileMajorVersionMultiplier) + FITConstants.FITProfileMinorVersion));
            GarminFitnessInt32Range dataSize = new GarminFitnessInt32Range(0);

            dataStream.Seek(0, SeekOrigin.Begin);
            dataSize.Value = (int)dataStream.Length - 12;

            headerSize.Serialize(dataStream);
            protocolVersion.Serialize(dataStream);
            profileVersion.Serialize(dataStream);
            dataSize.Serialize(dataStream);
            dataStream.Write(Encoding.UTF8.GetBytes(FITConstants.FITFileDescriptor), 0, 4);

            // Write CRC
            GarminFitnessUInt16Range crc = new GarminFitnessUInt16Range(FITUtils.ComputeStreamCRC(dataStream));
            dataStream.Seek(0, SeekOrigin.End);
            crc.Serialize(dataStream);

            // Write all data to output stream
            exportStream.Write(dataStream.GetBuffer(), 0, (int)dataStream.Length);
        }
예제 #7
0
        public static FITSports GetFITSport(GarminCategories category)
        {
            if (category == GarminCategories.Biking)
            {
                return FITSports.Cycling;
            }
            else if (category == GarminCategories.Running)
            {
                return FITSports.Running;
            }

            return FITSports.Other;
        }
예제 #8
0
 public static string GetFITSportName(GarminCategories sport)
 {
     switch(sport)
     {
         case GarminCategories.Running:
         {
             return "Running";
         }
         case GarminCategories.Biking:
         {
             return "Cycling";
         }
         default:
         {
             return "Other";
         }
     }
 }
예제 #9
0
 public void SerializeToFITSport(Stream outputStream, GarminCategories category)
 {
     m_ActivityProfiles[(int)category].SerializeToFITSport(outputStream);
 }
 public GarminPowerZoneWrapper(GarminCategories category, int zoneIndex)
     : base(null, null)
 {
     UpdateProfile(category);
     m_ZoneIndex = zoneIndex;
 }
 public void UpdateProfile(GarminCategories category)
 {
     m_Profile = GarminProfileManager.Instance.GetProfileForActivity(category);
 }
예제 #12
0
 public STCategoriesInfo(IActivityCategory STCategory,
     GarminCategories garminCategory,
     bool expandInWorkoutList,
     bool showInWorkoutList)
 {
     m_STCategory = STCategory;
     m_GarminCategory = garminCategory;
     m_ExpandInWorkoutList = expandInWorkoutList;
     m_ShowInWorkoutList = showInWorkoutList;
 }
예제 #13
0
 public STCategoriesInfo(IActivityCategory STCategory,
     GarminCategories garminCategory)
     : this(STCategory, garminCategory, true, true)
 {
 }
예제 #14
0
        public void SetGarminCategory(IActivityCategory STCategory, GarminCategories GarminCategory)
        {
            bool modified = false;

            if(!m_STToGarminCategoryMap.ContainsKey(STCategory))
            {
                m_STToGarminCategoryMap[STCategory] = new STCategoriesInfo(STCategory, GarminCategory);

                modified = true;
            }

            if (m_STToGarminCategoryMap[STCategory].GarminCategory != GarminCategory)
            {
                m_STToGarminCategoryMap[STCategory].GarminCategory = GarminCategory;

                modified = true;
            }

            if (modified)
            {
                TriggerOptionsChangedEvent("STToGarminCategoryMap");
            }
        }
        public void OtherProfileEventHandler(object sender, EventArgs args)
        {
            m_CurrentCategory = GarminCategories.Other;
            m_CurrentProfile = GarminProfileManager.Instance.GetProfileForActivity(m_CurrentCategory);

            RefreshUIFromCategory();
        }
 public GarminSpeedZoneWrapper(GarminCategories category, int zoneIndex)
     : base(null, null)
 {
     m_Profile = GarminProfileManager.Instance.GetProfileForActivity(category);
     m_ZoneIndex = zoneIndex;
 }
        public void BikingProfileEventHandler(object sender, EventArgs args)
        {
            m_CurrentCategory = GarminCategories.Biking;
            m_CurrentProfile = GarminProfileManager.Instance.GetProfileForActivity(m_CurrentCategory);
            m_CurrentBikeProfile = ((GarminBikingActivityProfile)m_CurrentProfile).GetBikeProfile(m_BikeProfileIndex);

            RefreshUIFromCategory();
        }
 public GarminActivityProfile GetProfileForActivity(GarminCategories category)
 {
     return UserProfile.GetProfileForActivity(category);
 }
예제 #19
0
        public GarminActivityProfile GetProfileForActivity(GarminCategories category)
        {
            if (m_ActivityProfiles.Length == (int)GarminCategories.GarminCategoriesCount)
            {
                return m_ActivityProfiles[(int)category];
            }

            return null;
        }