From 5e5a9ed554d4a42852cd79b3f0d28a05e0556e2b Mon Sep 17 00:00:00 2001 From: gerhardol Date: Tue, 3 May 2016 23:51:47 +0200 Subject: [PATCH] Double click on Order field for paused results - Double clicking the Order column for a result will open a popup to modify both paused an normal results to timer pauses, splits or remove pauses (depending on the result type). - Selecting a section in the chart or route and double clicking will open a popup to add a pause or split. --- Data/TrailsItemTrackSelectionInfo.cs | 4 +- UI/Activity/ResultListControl.cs | 142 ++++++++++++++++++++------- 2 files changed, 107 insertions(+), 39 deletions(-) diff --git a/Data/TrailsItemTrackSelectionInfo.cs b/Data/TrailsItemTrackSelectionInfo.cs index b34cebe..8d0aebc 100644 --- a/Data/TrailsItemTrackSelectionInfo.cs +++ b/Data/TrailsItemTrackSelectionInfo.cs @@ -240,7 +240,7 @@ private static IList SetAndAdjustFromSelection try { AddMarkedOrSelectedTime(tmpSel, singleSelection, sel.SelectedTime.Lower, sel.SelectedTime.Upper); - tmpSel.SelectedTime = null; + //tmpSel.SelectedTime = null; } catch { } } @@ -444,7 +444,7 @@ public override string ToString() return string.Empty; } - private TrailsItemTrackSelectionInfo FirstSelection() + public TrailsItemTrackSelectionInfo FirstSelection() { //Many commands can only handle one selection - this will set only one of them TrailsItemTrackSelectionInfo res = new TrailsItemTrackSelectionInfo(); diff --git a/UI/Activity/ResultListControl.cs b/UI/Activity/ResultListControl.cs index 023abd7..282927e 100644 --- a/UI/Activity/ResultListControl.cs +++ b/UI/Activity/ResultListControl.cs @@ -51,6 +51,7 @@ public partial class ResultListControl : UserControl private TrailResultWrapper m_summaryAverage; private TrailResultWrapper m_lastClickedResult = null; private IList m_PersistentSelectionResults = new List(); + private IList lastSTselectionWhenClick; #if !ST_2_1 private IDailyActivityView m_view = null; @@ -938,6 +939,9 @@ void summaryList_Click(object sender, System.EventArgs e) } if (clickSelected) { + lastSTselectionWhenClick = TrailsItemTrackSelectionInfo.SetAndAdjustFromSelectionFromST( + m_view.RouteSelectionProvider.SelectedItems, new List { tr.Result.Activity }); + IList aTr = new List(); //if (Data.Settings.SelectSimilarResults) { @@ -949,6 +953,7 @@ void summaryList_Click(object sender, System.EventArgs e) // //The user can control what is selected - mark all // aTr = new List{tr}; //} + bool markChart = false; if (this.m_lastClickedResult != null && tr.CompareTo(this.m_lastClickedResult) == 0 && @@ -993,31 +998,22 @@ void summaryList_DoubleClick(object sender, System.EventArgs e) if (trw != null) { TreeList.Column selectedColumn = getColumn(l, e2.X + l.HScrollBar.Value); - if (selectedColumn.Id == TrailResultColumnIds.Order) - { - TrailResultWrapper parent = trw.GetParent(); - if (parent != null) - { - parent.RefreshChildren(); - } - m_page.RefreshData(true); - } - else if ((selectedColumn.Id == TrailResultColumnIds.LapInfo_Rest || selectedColumn.Id == TrailResultColumnIds.Order) - && trw.Result.LapInfo != null) + if (selectedColumn.Id == TrailResultColumnIds.LapInfo_Rest && trw.Result.LapInfo != null) { + //Unofficial, see also Order below DialogResult popRes = MessageDialog.Show(string.Format("Set to {0}?", !trw.Result.LapInfo.Rest), "Toggle rest on lap", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (popRes == DialogResult.OK) { trw.Result.LapInfo.Rest = !trw.Result.LapInfo.Rest; - //this.summaryList.RefreshElements(new List { tr }); - TrailResultWrapper parent = trw.GetParent(); - if (parent != null) - { - parent.RefreshChildren(); - } - m_page.RefreshData(true); } + + TrailResultWrapper parent = trw.GetParent(); + if (parent != null) + { + parent.RefreshChildren(); + } + m_page.RefreshData(true); } else if (selectedColumn.Id == TrailResultColumnIds.MetaData_Source && trw.Result.Activity != null) { @@ -1031,16 +1027,91 @@ void summaryList_DoubleClick(object sender, System.EventArgs e) //{ // TBD //} - //else if (tr.Result.Activity != null && tr.Result is PausedChildTrailResult) - //{ - // DialogResult popRes = MessageDialog.Show("Remove clicked pause from result?", - // "Remove Pause", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); - // if (popRes == DialogResult.OK) - // { - // tr.Result.Pauses.Remove(new ValueRange(tr.Result.StartTime, tr.Result.EndTime)); - // m_page.RefreshData(false); - // } - //} + else if (selectedColumn.Id == TrailResultColumnIds.Order) + { + //Unofficial(?) + if (trw.Result.Activity != null) + { + if (trw.Result is PausedChildTrailResult && (trw.Result as PausedChildTrailResult).pauseType == PauseType.Timer) + { + DialogResult popRes = MessageDialog.Show( + string.Format("To remove timer pause select {0}, to set as rest lap select {1}", CommonResources.Text.ActionYes, CommonResources.Text.ActionNo), + "Remove Pause", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (popRes == DialogResult.Yes || popRes == DialogResult.No) + { + TrackUtil.removePause(trw.Result.Activity.TimerPauses, trw.Result.StartTime, trw.Result.EndTime); + TrackUtil.removePause(trw.Result.Pauses, trw.Result.StartTime, trw.Result.EndTime); + if (popRes == DialogResult.No) + { + InsertRestLap(trw.Result.Activity.Laps, trw.Result.StartTime, trw.Result.Duration); + } + } + } + else if (trw.Result.LapInfo != null) + { + DialogResult popRes = MessageDialog.Show( + string.Format("To set split as timer pause select {0}, to set rest to {2} select {1}", + CommonResources.Text.ActionYes, CommonResources.Text.ActionNo, !trw.Result.LapInfo.Rest), + "Update Split", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (popRes == DialogResult.Yes) + { + trw.Result.Activity.TimerPauses.Add(new ValueRange(trw.Result.StartTime, trw.Result.EndTime)); + } + else if (popRes == DialogResult.No) + { + trw.Result.LapInfo.Rest = !trw.Result.LapInfo.Rest; + } + } + else if (trw.Result is ChildTrailResult) + { + DialogResult popRes = MessageDialog.Show( + string.Format("To set result as timer pause select {0}, to set as split select {1}", + CommonResources.Text.ActionYes, CommonResources.Text.ActionNo), + "Update Result", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (popRes == DialogResult.Yes) + { + trw.Result.Activity.TimerPauses.Add(new ValueRange(trw.Result.StartTime, trw.Result.EndTime)); + } + else if (popRes == DialogResult.No) + { + InsertRestLap(trw.Result.Activity.Laps, trw.Result.StartTime, trw.Result.Duration); + } + } + else if (trw.Result is ParentTrailResult) + { + //TBD last selection? + //IList selectedGPS = TrailsItemTrackSelectionInfo.SetAndAdjustFromSelectionFromST( + // m_view.RouteSelectionProvider.SelectedItems, new List { trw.Result.Activity }); + if (TrailsItemTrackSelectionInfo.ContainsData(lastSTselectionWhenClick)) + { + DialogResult popRes = MessageDialog.Show( + string.Format("To set selection as timer pause select {0}, to set as split select {1}", + CommonResources.Text.ActionYes, CommonResources.Text.ActionNo), + "Update Result", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + foreach (IValueRange v in lastSTselectionWhenClick[0].MarkedTimes) + { + if (popRes == DialogResult.Yes) + { + trw.Result.Activity.TimerPauses.Add(v); + } + else if (popRes == DialogResult.No) + { + InsertRestLap(trw.Result.Activity.Laps, v.Lower, v.Upper - v.Lower); + } + } + } + else + { } + } + } + + TrailResultWrapper parent = trw.GetParent(); + if (parent != null) + { + parent.RefreshChildren(); + } + m_page.RefreshData(true); + } else if (trw.Result.Activity != null && trw.Result is ParentTrailResult) { Guid view = GUIDs.DailyActivityView; @@ -1681,15 +1752,12 @@ void summaryList_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { foreach (TrailResultWrapper tr in atr) { - if (tr.Result is ChildTrailResult) + if (tr.Result is PausedChildTrailResult && (tr.Result as PausedChildTrailResult).pauseType == PauseType.Timer) { - if (tr.Result is PausedChildTrailResult && (tr.Result as PausedChildTrailResult).pauseType == PauseType.Timer) - { - TrackUtil.removePause(tr.Result.Activity.TimerPauses, tr.Result.StartTime, tr.Result.EndTime); - TrackUtil.removePause(tr.Result.Pauses, tr.Result.StartTime, tr.Result.EndTime); - InsertRestLap(tr.Result.Activity.Laps, tr.Result.StartTime, tr.Result.Duration); - res++; - } + TrackUtil.removePause(tr.Result.Activity.TimerPauses, tr.Result.StartTime, tr.Result.EndTime); + TrackUtil.removePause(tr.Result.Pauses, tr.Result.StartTime, tr.Result.EndTime); + InsertRestLap(tr.Result.Activity.Laps, tr.Result.StartTime, tr.Result.Duration); + res++; } } } @@ -1700,7 +1768,7 @@ void summaryList_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) else if (e.Modifiers == (Keys.Alt | Keys.Shift)) { //Unofficial - DialogResult popRes = MessageDialog.Show("Set marked laps as pauses?", + DialogResult popRes = MessageDialog.Show("Set marked results as pauses?", "Add Pause", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (popRes == DialogResult.OK) {