Ejemplo n.º 1
0
        // Column specific sort
        public int CompareTo(RecordWrapper a2, RecordComparer.ComparisonType comparisonMethod, RecordComparer.Order sortOrder)
        {
            int result = 0;

            switch (comparisonMethod)
            {
            case RecordComparer.ComparisonType.Distance:
                if (ActualDistance != a2.ActualDistance)
                {
                    result = ActualDistance.CompareTo(a2.ActualDistance);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.StartDistance:
                if (StartDistance != a2.StartDistance)
                {
                    result = StartDistance.CompareTo(a2.StartDistance);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.EndDistance:
                if (EndDistance != a2.EndDistance)
                {
                    result = EndDistance.CompareTo(a2.EndDistance);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.Location:
                if (Location != a2.Location)
                {
                    result = Location.CompareTo(a2.Location);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.ElevationChange:
                if (ElevationChange != a2.ElevationChange)
                {
                    result = ElevationChange.CompareTo(a2.ElevationChange);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.TotalAscend:
                if (TotalAscend != a2.TotalAscend)
                {
                    result = TotalAscend.CompareTo(a2.TotalAscend);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.TotalDescend:
                if (TotalDescend != a2.TotalDescend)
                {
                    result = TotalDescend.CompareTo(a2.TotalDescend);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.Temp:
                if (Temp != a2.Temp)
                {
                    result = Temp.CompareTo(a2.Temp);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.Rank:
                if (Rank != a2.Rank)
                {
                    result = Rank.CompareTo(a2.Rank);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.AvgPace:
                if (AvgPace != a2.AvgPace)
                {
                    result = AvgPace.CompareTo(a2.AvgPace);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.AvgSpeed:
                if (Speed != a2.Speed)
                {
                    result = Speed.CompareTo(a2.Speed);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.AvgHR:
                if (AvgHR != a2.AvgHR)
                {
                    result = AvgHR.CompareTo(a2.AvgHR);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.MaxHR:
                if (MaxHR != a2.MaxHR)
                {
                    result = MaxHR.CompareTo(a2.MaxHR);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

            case RecordComparer.ComparisonType.StartDateTime:
            default:
                result = StartDateTime.CompareTo(a2.StartDateTime);
                break;
            }

            if (sortOrder == RecordComparer.Order.Descending)
            {
                return(result * -1);
            }
            else
            {
                return(result);
            }
        }
Ejemplo n.º 2
0
        // Default Sort(): Start date (newest first)
        public int CompareTo(object obj)
        {
            RecordWrapper a = (RecordWrapper)obj;

            return(DateTime.Compare(Convert.ToDateTime(a.StartDateTime, CultureInfo.InvariantCulture), Convert.ToDateTime(this.StartDateTime, CultureInfo.InvariantCulture)));
        }