Exemple #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);
            }
        }
Exemple #2
0
        // Column specific sort
        public int CompareTo(Record a2, RecordComparer.ComparisonType comparisonMethod, RecordComparer.Order sortOrder)
        {
            int result = 0;

            switch (comparisonMethod)
            {
            // Define all different sort methods
            case RecordComparer.ComparisonType.AvgPower:
                if (AvgPower != a2.AvgPower)
                {
                    result = AvgPower.CompareTo(a2.AvgPower);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

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

                break;

            case RecordComparer.ComparisonType.Category:
                if (CategoryName != a2.CategoryName)
                {
                    result = CategoryName.CompareTo(a2.CategoryName);
                }
                else
                {
                    // TODO: WTF is this?
                    switch (Category.Type)
                    {
                    case RecordCategory.RecordType.DistancePace:
                        result = AvgPace.CompareTo(a2.AvgPace);
                        break;

                    case RecordCategory.RecordType.MaxTemperature:
                        result = Temp.CompareTo(a2.Temp);
                        break;
                    }
                }

                break;

            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.ActivityCategory:
                if (ActivityCategory != a2.ActivityCategory)
                {
                    result = ActivityCategory.CompareTo(a2.ActivityCategory);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

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

                break;

            case RecordComparer.ComparisonType.TotalTime:
                if (TotalTime != a2.TotalTime)
                {
                    result = TotalTime.CompareTo(a2.TotalTime);
                }
                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.Speed:
                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.TotalCalories:
                if (TotalCalories != a2.TotalCalories)
                {
                    result = TotalCalories.CompareTo(a2.TotalCalories);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

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

                break;

            case RecordComparer.ComparisonType.MaxSpeed:
                if (MaxSpeed != a2.MaxSpeed)
                {
                    result = MaxSpeed.CompareTo(a2.MaxSpeed);
                }
                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.MaxElevation:
                if (MaxElevation != a2.MaxElevation)
                {
                    result = MaxElevation.CompareTo(a2.MaxElevation);
                }
                else
                {
                    result = StartDateTime.CompareTo(a2.StartDateTime);
                }

                break;

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

                break;

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

                break;

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

                break;

            case RecordComparer.ComparisonType.MinGrade:
                if (MinGrade != a2.MinGrade)
                {
                    result = MinGrade.CompareTo(a2.MinGrade);
                }
                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);
            }
        }