public void Bike1ProfileEventHandler(object sender, EventArgs args)
        {
            m_BikeProfileIndex = 0;
            m_CurrentBikeProfile = ((GarminBikingActivityProfile)m_CurrentProfile).GetBikeProfile(m_BikeProfileIndex);

            RefreshUIFromProfile();
        }
        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 SetupWizardEditBikingProfileControl(ExtendedWizard wizard)
            : base(wizard)
        {
            InitializeComponent();

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

            BikeProfileActionBanner.ThemeChanged(PluginMain.GetApplication().VisualTheme);
            PowerZonesTreeList.ThemeChanged(PluginMain.GetApplication().VisualTheme);

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

            ExplanationLabel.Text = GarminFitnessView.GetLocalizedString("BikeProfileExplanationText");

            // Power zones
            FTPLabel.Text = GarminFitnessView.GetLocalizedString("FTPLabelText");
            FTPUnitsLabel.Text = CommonResources.Text.LabelWatts;
            PowerZonesGroupBox.Text = GarminFitnessView.GetLocalizedString("PowerZonesGroupBoxText");
            LowPowerLabel.Text = GarminFitnessView.GetLocalizedString("LowLabelText");
            HighPowerLabel.Text = GarminFitnessView.GetLocalizedString("HighLabelText");

            // Bike profiles
            BikeNameLabel.Text = GarminFitnessView.GetLocalizedString("NameLabelText");
            OdometerLabel.Text = GarminFitnessView.GetLocalizedString("OdometerLabelText");
            OdometerUnitsLabel.Text = Length.LabelAbbr(m_CurrentProfile.BaseSpeedUnit);
            BikeWeightLabel.Text = GarminFitnessView.GetLocalizedString("WeightLabelText");
            BikeWeightUnitLabel.Text = Weight.LabelAbbr(PluginMain.GetApplication().SystemPreferences.WeightUnits);
            HasCadenceCheckBox.Text = GarminFitnessView.GetLocalizedString("HasCadenceText");
            HasPowerCheckBox.Text = GarminFitnessView.GetLocalizedString("HasPowerText");
            WheelSizeGroupBox.Text = GarminFitnessView.GetLocalizedString("WheelSizeGroupBoxText");
            AutoWheelSizeCheckBox.Text = GarminFitnessView.GetLocalizedString("AutoText");
            WheelSizeLabel.Text = GarminFitnessView.GetLocalizedString("WheelSizeLabelText");
            WheelSizeUnitLabel.Text = GarminFitnessView.GetLocalizedString("MillimeterText");

            BuildTreeLists();
            RefreshUIFromProfile();
        }
        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);
            }
        }
        private void RefreshUIFromProfile()
        {
            // Power Zones
            PowerZonesTreeList.Invalidate();
            PowerZonePanel.Enabled = m_SelectedPowerZone != null;
            if (m_CurrentProfile.GetType() == typeof(GarminBikingActivityProfile))
            {
                GarminBikingActivityProfile concreteProfile = (GarminBikingActivityProfile)m_CurrentProfile;
                m_CurrentBikeProfile = ((GarminBikingActivityProfile)m_CurrentProfile).GetBikeProfile(m_BikeProfileIndex);

                FTPTextBox.Text = concreteProfile.FTP.ToString();

                if (m_SelectedPowerZone != null)
                {
                    LowPowerTextBox.Text = m_SelectedPowerZone.Low;
                    HighPowerTextBox.Text = m_SelectedPowerZone.High;
                }

                // Bike profiles
                string baseMenuItemName;

                baseMenuItemName = GarminFitnessView.GetLocalizedString("BikeProfileMenuItemText");
                BikeProfileActionBanner.Text = String.Format(baseMenuItemName, (m_BikeProfileIndex + 1).ToString(), m_CurrentBikeProfile.Name);

                BikeNameTextBox.Text = m_CurrentBikeProfile.Name;
                HasCadenceCheckBox.Checked = m_CurrentBikeProfile.HasCadenceSensor;
                HasPowerCheckBox.Checked = m_CurrentBikeProfile.HasPowerSensor;
                OdometerTextBox.Text = Length.Convert(m_CurrentBikeProfile.OdometerInMeters, Length.Units.Meter, m_CurrentProfile.BaseSpeedUnit).ToString("0.0");
                BikeWeightTextBox.Text = Weight.Convert(m_CurrentBikeProfile.WeightInPounds, Weight.Units.Pound, PluginMain.GetApplication().SystemPreferences.WeightUnits).ToString("0.0");
                WheelSizeGroupBox.Enabled = m_CurrentBikeProfile.HasCadenceSensor;
                AutoWheelSizeCheckBox.Checked = m_CurrentBikeProfile.AutoWheelSize;
                WheelSizePanel.Enabled = !m_CurrentBikeProfile.AutoWheelSize;
                WheelSizeTextBox.Text = m_CurrentBikeProfile.WheelSize.ToString();
            }
        }
        private void RefreshUIFromProfile()
        {
            RefreshTreeLists();

            MaxHRTextBox.Text = m_CurrentProfile.MaximumHeartRate.ToString();
            GearWeightTextBox.Text = Weight.Convert(m_CurrentProfile.GearWeightInPounds, Weight.Units.Pound, PluginMain.GetApplication().SystemPreferences.WeightUnits).ToString("0.0");

            // HR Zones
            PercentMaxRadioButton.Checked = m_CurrentProfile.HRZonesReferential == GarminActivityProfile.HRReferential.HRReferential_PercentMax;
            PercentHRRRadioButton.Checked = m_CurrentProfile.HRZonesReferential == GarminActivityProfile.HRReferential.HRReferential_PercentHRR;
            BPMRadioButton.Checked = m_CurrentProfile.HRZonesReferential == GarminActivityProfile.HRReferential.HRReferential_BPM;
            HRZonesTreeList.Invalidate();
            HRZonePanel.Enabled = m_SelectedHRZone != null;
            if (m_SelectedHRZone != null)
            {
                LowHRTextBox.Text = m_SelectedHRZone.Low;
                HighHRTextBox.Text = m_SelectedHRZone.High;
            }

            // Speed Zones
            PaceRadioButton.Checked = m_CurrentProfile.SpeedIsInPace;
            SpeedRadioButton.Checked = !m_CurrentProfile.SpeedIsInPace;
            SpeedZonesTreeList.Invalidate();
            SpeedZonePanel.Enabled = m_SelectedSpeedZone != null;
            if (m_SelectedSpeedZone != null)
            {
                LowSpeedTextBox.Text = m_SelectedSpeedZone.Low;
                HighSpeedTextBox.Text = m_SelectedSpeedZone.High;
                SpeedNameTextBox.Text = m_SelectedSpeedZone.Name;
            }

            // Power Zones
            BikingProfilePanel.Visible = m_CurrentProfile is GarminBikingActivityProfile;
            PowerZonesTreeList.Invalidate();
            PowerZonePanel.Enabled = m_SelectedPowerZone != null;
            if (m_CurrentProfile is GarminBikingActivityProfile)
            {
                GarminBikingActivityProfile concreteProfile = (GarminBikingActivityProfile)m_CurrentProfile;
                m_CurrentBikeProfile = ((GarminBikingActivityProfile)m_CurrentProfile).GetBikeProfile(m_BikeProfileIndex);

                FTPTextBox.Text = concreteProfile.FTP.ToString();

                WattsRadioButton.Checked = !concreteProfile.PowerZonesInPercentFTP;
                PercentFTPRadioButton.Checked = concreteProfile.PowerZonesInPercentFTP;

                if (m_SelectedPowerZone != null)
                {
                    LowPowerTextBox.Text = m_SelectedPowerZone.Low;
                    HighPowerTextBox.Text = m_SelectedPowerZone.High;
                }

                // Bike profiles
                string baseMenuItemName;

                baseMenuItemName = GarminFitnessView.GetLocalizedString("BikeProfileMenuItemText");
                BikeProfileActionBanner.Text = String.Format(baseMenuItemName, (m_BikeProfileIndex + 1).ToString(), m_CurrentBikeProfile.Name);

                BikeNameTextBox.Text = m_CurrentBikeProfile.Name;
                HasCadenceCheckBox.Checked = m_CurrentBikeProfile.HasCadenceSensor;
                HasPowerCheckBox.Checked = m_CurrentBikeProfile.HasPowerSensor;
                OdometerTextBox.Text = Length.Convert(m_CurrentBikeProfile.OdometerInMeters, Length.Units.Meter, m_CurrentProfile.BaseSpeedUnit).ToString("0.0");
                BikeWeightTextBox.Text = Weight.Convert(m_CurrentBikeProfile.WeightInPounds, Weight.Units.Pound, PluginMain.GetApplication().SystemPreferences.WeightUnits).ToString("0.0");
                WheelSizeGroupBox.Enabled = m_CurrentBikeProfile.HasCadenceSensor;
                AutoWheelSizeCheckBox.Checked = m_CurrentBikeProfile.AutoWheelSize;
                WheelSizeFlowLayoutPanel.Enabled = !m_CurrentBikeProfile.AutoWheelSize;
                WheelSizeTextBox.Text = m_CurrentBikeProfile.WheelSize.ToString();
            }
        }
        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();
        }
 void OnBikeProfileChanged(GarminBikeProfile sender, PropertyChangedEventArgs changedProperty)
 {
     TriggerChangedEvent(new PropertyChangedEventArgs("BikeProfile"));
 }