/// <summary> /// Occurs each time a goal split gets completed. Allows for UI update by marshalling the call accordingly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SplitGoalCompletedEventHandler(object sender, SplitsManagerV2.SplitEventArgs 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 SplitGoalCompletedEventHandlerDelegate(SplitGoalCompletedEventHandler), new object[] { sender, e }); return; } // do normal update to split window this.SplitEventHandler(sender, e); if (!e.DeltaTime.HasValue) // should always have a value as it's a goal split { return; } // Positive number is bad, negative good //lvSplits.BackColor = e.DeltaTime.Value.TotalSeconds >= 1 ? RED : GREEN; // when timer expires color will revert to normal //this.backcolorTimer.Enabled = true; //Logger.LogInformation($"SplitGoalCompletedEventHandler {splitItem.SplitNumber}, {splitItem.Time}, {splitItem.Speed}, {splitItem.TotalDistance}, {splitItem.TotalTime}"); }
/// <summary> /// Occurs each time a split gets updated or completes. Allows for UI update by marshalling the call accordingly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SplitEventHandler(object sender, SplitsManagerV2.SplitEventArgs 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 SplitEventHandlerDelegate(SplitEventHandler), new object[] { sender, e }); return; } SplitItem splitItem = new SplitItem(e.SplitNumber, e.SplitTimeStr, e.SplitSpeedStr, e.TotalDistanceStr, e.TotalTimeStr, e.DeltaTimeStr, e.SplitsInKm, e.AheadOfGoalTime); //SplitItem splitItem = new SplitItem(e.SplitNumber) //{ // SplitNumber = e.SplitNumberStr, // Time = e.SplitTimeStr, // Speed = e.SplitSpeedStr, // TotalDistance = e.TotalDistanceStr, // TotalTime = e.TotalTimeStr, // Delta = e.DeltaTimeStr, // will return empty string if not a goal based split // SplitsInKm = e.SplitsInKm, // AheadOfGoalTime = e.AheadOfGoalTime // null if not a goal based split //}; if (lvSplits.Items.ContainsKey(splitItem.SplitNumber)) { SplitListViewItem item = (SplitListViewItem)lvSplits.Items[splitItem.SplitNumber]; item.SplitItem = splitItem; // Replace with current splitItem object and refresh item.Refresh(); } else { if (e.SplitNumber > 1) { // remove any color coding from previous split string prevSplit = (e.SplitNumber - 1).ToString(); if (lvSplits.Items.ContainsKey(prevSplit)) { SplitListViewItem item = (SplitListViewItem)lvSplits.Items[prevSplit]; item.ClearDeltaBackground(); } } lvSplits.Items.Add(new SplitListViewItem(splitItem)); lvSplits.Sort(); } //Logger.LogInformation($"SplitEventHandler {splitItem.SplitNumber}, {splitItem.Time}, {splitItem.Speed}, {splitItem.TotalDistance}, {splitItem.TotalTime}"); }
/// <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 SplitCompletedEventHandler(object sender, SplitsManagerV2.SplitEventArgs 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 SplitCompletedEventHandlerDelegate(SplitCompletedEventHandler), new object[] { sender, e }); return; } //if (!this.IsControlAtFront(SplitsView)) //{ // tsbSplits.PerformClick(); // m_splitsViewDisplayTime = DateTime.Now; //} var form = new EventCompletion(); form.InitSplitEventCompletion(new SplitsViewControl.SplitItem(e.SplitNumber, e.SplitTimeStr, e.SplitSpeedStr, e.TotalDistanceStr, e.TotalTimeStr, e.DeltaTimeStr, e.SplitsInKm, e.AheadOfGoalTime)); DialogResult result = form.ShowDialog(this); //Logger.LogInformation($"SplitGoalCompletedEventHandler {e.SplitNumberStr}, {e.SplitTimeStr}, {e.SplitSpeedStr}, {e.TotalDistanceStr}, {e.TotalTimeStr}"); }