private bool DeleteTrail(ActivityTrail at) { bool result = false; if (at != null) { //Only the primary trail deleted at.Init(); if (TrailData.DeleteTrail(at.Trail)) { this.m_CurrentOrderedTrails.Remove(at); this.m_currentActivityTrails.Remove(at); this.m_prevSelectedTrails.Remove(at); at = null; result = true; } } return(result); }
private void RefreshResult(bool recalculate) { if (Controller.TrailController.Instance.ReferenceActivity != null) { if (recalculate || this.m_trailResult == null) { ActivityTrail at = new ActivityTrail(this.m_TrailToEdit); at.CalcResults(new List <IActivity> { Controller.TrailController.Instance.ReferenceActivity }, this.m_TrailToEdit.MaxRequiredMisses, true, null); if (at.Results.Count > 0) { this.m_trailResult = at.Results[0].Result; } else { at.Init(); at.CalcResults(new List <IActivity> { Controller.TrailController.Instance.ReferenceActivity }, 99, true, null); if (at.Results.Count > 0) { //The best result is the result with most matches //forward may be better than reverse, but those should be sorted first anyway int currMaxRes = -1; foreach (TrailResultWrapper tr in at.Results) { int res = 0; foreach (DateTime d in tr.Result.TrailPointDateTime) { if (d > DateTime.MinValue) { res++; } } if (res > currMaxRes) { currMaxRes = res; this.m_trailResult = tr.Result; } } } else { if (at.IncompleteResults.Count > 0) { //Result is already sorted after no of matches this.m_trailResult = at.IncompleteResults[0]; } else { this.m_trailResult = null; } } } at.Init(); } } IList <EditTrailRow> l = EditTrailRow.getEditTrailRows(this.m_TrailToEdit, this.m_trailResult); int sel = EList_SelectedRow(); //Get one of the selected, if any this.EList.RowData = l; if (sel >= 0) { //This is incorrect if the trail was reversed this.EList.SelectedItems = new object[] { l[sel] }; } foreach (EditTrailRow t in (IList <EditTrailRow>) this.EList.RowData) { //Note: For reverse results, this is incorrect (but reverse results are only for incomplete, so no impact) this.EList.SetChecked(t, t.TrailGPS.Required); } }