Esempio n. 1
0
        /// <summary>
        /// Sort the transfers from a model.
        /// </summary>
        /// <returns>List of sorted transfers</returns>
        /// <param name="m">Model from which to sort transfers</param>
        /// <param name="how">Sort method</param>
        /// <param name="descend">True for descending sort, false for ascending</param>
        public static List <TransferModel> SortTransfers(AstrogationModel m, SortEnum how, bool descend)
        {
            List <TransferModel> transfers = new List <TransferModel>(m.transfers);

            switch (how)
            {
            case SortEnum.Name:
                transfers.Sort((a, b) =>
                               a?.destination?.GetName().CompareTo(b?.destination?.GetName()) ?? 0);
                break;

            case SortEnum.Position:
                // Use the natural/default ordering in the model
                break;

            case SortEnum.Time:
                transfers.Sort((a, b) =>
                               a?.ejectionBurn?.atTime?.CompareTo(b?.ejectionBurn?.atTime ?? 0) ?? 0);
                break;

            case SortEnum.DeltaV:
                transfers.Sort((a, b) =>
                               a?.ejectionBurn?.totalDeltaV.CompareTo(b?.ejectionBurn?.totalDeltaV) ?? 0);
                break;

            default:
                DbgFmt("Bad sort argument: {0}", how.ToString());
                break;
            }
            if (descend)
            {
                transfers.Reverse();
            }
            return(transfers);
        }
Esempio n. 2
0
 public void AddOrderBy(string colName, SortEnum sort)
 {
     listOrderBy.Add(colName + " " + sort.ToString());
 }