Exemplo n.º 1
0
        /// <summary>
        /// Occurs each time a lap gets updated or completes.  Allows for UI update by marshalling the call accordingly.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LapEventHandler(object sender, LapsManager.LapEventArgs 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 LapEventHandlerDelegate(LapEventHandler), new object[] { sender, e });
                return;
            }

            LapDetailItem LapItem = new(e.LapNumber, e.LapTime, e.LapDistanceKm, e.LapAvgWatts, e.TotalTime);

            if (lvLaps.Items.ContainsKey(LapItem.LapNumber.ToString()))
            {
                LapListViewItem item = (LapListViewItem)lvLaps.Items[LapItem.LapNumber.ToString()];
                item.LapItem = LapItem; // Replace with current LapDetailItem object and refresh
                item.Refresh(ZAMsettings.Settings.Laps.MeasurementSystemSetting, this.CurrentPowerUom);
            }
            else
            {
                LapListViewItem item = new LapListViewItem(LapItem, ZAMsettings.Settings.Laps.MeasurementSystemSetting, this.CurrentPowerUom);
                lvLaps.Items.Add(item);
                lvLaps.Sort();

                // On first item added make sure the column headings match the data fields
                if (lvLaps.Items.Count == 1)
                {
                    item.Refresh(ZAMsettings.Settings.Laps.MeasurementSystemSetting, this.CurrentPowerUom);
                }
            }

            Logger.LogInformation($"LapEventHandler {LapItem.LapNumber}, {LapItem.LapTime}, {LapItem.LapSpeedKph}km/h, {LapItem.LapDistanceKm}km, {LapItem.TotalTime}");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Occurs each time split gets completed.  Allows for UI update by marshalling the call accordingly.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LapCompletedEventHandler(object sender, LapsManager.LapEventArgs 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 LapCompletedEventHandlerDelegate(LapCompletedEventHandler), new object[] { sender, e });
                return;
            }

            var form = new EventCompletion();

            form.InitLapEventCompletion(new LapViewControl.LapDetailItem(e.LapNumber, e.LapTime, e.LapDistanceKm, e.LapAvgWatts, e.TotalTime));

            DialogResult result = form.ShowDialog(this);
        }