/// <summary>
        /// Occurs each time the average speed changes.  Allows for UI update by marshalling the call accordingly.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MetricsChangedEventHandler(object sender, NormalizedPower.MetricsChangedEventArgs e)
        {
            //if (!m_dispatcher.CheckAccess()) // are we currently on the UI thread?
            //{
            //    // We're not in the UI thread, ask the dispatcher to call this same method in the UI thread, then exit
            //    m_dispatcher.BeginInvoke(new MetricsChangedEventHandlerDelegate(MetricsChangedEventHandler), new object[] { sender, e });
            //    return;
            //}

            lock (this.lvOverall)
            {
                SummaryListViewItem listViewItem = m_summaryHelper.SummaryListViewItem;
                SummaryItem         summaryItem  = listViewItem.SummaryItem;

                summaryItem.Average = e.OverallPower.ToString();

                if (m_currentUser.WeightAsKgs > 0)
                {
                    summaryItem.AverageWkg = Math.Round(e.OverallPower / m_currentUser.WeightAsKgs, 2).ToString("#.00");
                }


                summaryItem.Speed    = e.AverageMph.ToString("#.0");
                summaryItem.SpeedKph = e.AverageKph.ToString("#.0");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Occurs each time the average speed changes.  Allows for UI update by marshalling the call accordingly.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MetricsChangedEventHandler(object sender, NormalizedPower.MetricsChangedEventArgs e)
        {
            //if (!m_dispatcher.CheckAccess()) // are we currently on the UI thread?
            //{
            //    // We're not in the UI thread, ask the dispatcher to call this same method in the UI thread, then exit
            //    m_dispatcher.BeginInvoke(new MetricsChangedEventHandlerDelegate(MetricsChangedEventHandler), new object[] { sender, e });
            //    return;
            //}

            string Average;
            string AverageWkg = "";
            string Speed;
            string SpeedKph;

            Average = e.OverallPower.ToString();

            if (CurrentUser.WeightAsKgs > 0)
            {
                AverageWkg = Math.Round(e.OverallPower / CurrentUser.WeightAsKgs, 2).ToString("#.00");
            }


            Speed    = e.AverageMph.ToString("#.0");
            SpeedKph = e.AverageKph.ToString("#.0");

            this.UpdateSummaryMetrics(Average, AverageWkg, Speed, SpeedKph);
        }