Skip to content

Commit

Permalink
Double click on Order field for paused results
Browse files Browse the repository at this point in the history
   - 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.
  • Loading branch information
gerhardol committed May 3, 2016
1 parent b9ef49e commit 5e5a9ed
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Data/TrailsItemTrackSelectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private static IList<IItemTrackSelectionInfo> SetAndAdjustFromSelection
try
{
AddMarkedOrSelectedTime(tmpSel, singleSelection, sel.SelectedTime.Lower, sel.SelectedTime.Upper);
tmpSel.SelectedTime = null;
//tmpSel.SelectedTime = null;
}
catch { }
}
Expand Down Expand Up @@ -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();
Expand Down
142 changes: 105 additions & 37 deletions UI/Activity/ResultListControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public partial class ResultListControl : UserControl
private TrailResultWrapper m_summaryAverage;
private TrailResultWrapper m_lastClickedResult = null;
private IList<TrailResultWrapper> m_PersistentSelectionResults = new List<TrailResultWrapper>();
private IList<IItemTrackSelectionInfo> lastSTselectionWhenClick;

#if !ST_2_1
private IDailyActivityView m_view = null;
Expand Down Expand Up @@ -938,6 +939,9 @@ void summaryList_Click(object sender, System.EventArgs e)
}
if (clickSelected)
{
lastSTselectionWhenClick = TrailsItemTrackSelectionInfo.SetAndAdjustFromSelectionFromST(
m_view.RouteSelectionProvider.SelectedItems, new List<IActivity> { tr.Result.Activity });

IList<TrailResult> aTr = new List<TrailResult>();
//if (Data.Settings.SelectSimilarResults)
{
Expand All @@ -949,6 +953,7 @@ void summaryList_Click(object sender, System.EventArgs e)
// //The user can control what is selected - mark all
// aTr = new List<TrailResult>{tr};
//}

bool markChart = false;
if (this.m_lastClickedResult != null &&
tr.CompareTo(this.m_lastClickedResult) == 0 &&
Expand Down Expand Up @@ -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<TrailResultWrapper> { 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)
{
Expand All @@ -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<DateTime>(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<DateTime>(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<DateTime>(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<IItemTrackSelectionInfo> selectedGPS = TrailsItemTrackSelectionInfo.SetAndAdjustFromSelectionFromST(
// m_view.RouteSelectionProvider.SelectedItems, new List<IActivity> { 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<DateTime> 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;
Expand Down Expand Up @@ -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++;
}
}
}
Expand All @@ -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)
{
Expand Down

0 comments on commit 5e5a9ed

Please sign in to comment.