public Main() { this.sortingMethod = new SortingMethod(); this.dataGenerator = new DataGenerator(); startTest(); }
private void SortCharacters(GUIListBox list, SortingMethod sortingMethod) { if (sortingMethod == SortingMethod.AlphabeticalAsc) { list.Content.RectTransform.SortChildren((x, y) => (x.GUIComponent.UserData as Tuple <CharacterInfo, float>).Item1.Name.CompareTo((y.GUIComponent.UserData as Tuple <CharacterInfo, float>).Item1.Name)); } else if (sortingMethod == SortingMethod.JobAsc) { SortCharacters(list, SortingMethod.AlphabeticalAsc); list.Content.RectTransform.SortChildren((x, y) => String.Compare((x.GUIComponent.UserData as Tuple <CharacterInfo, float>)?.Item1.Job.Name, (y.GUIComponent.UserData as Tuple <CharacterInfo, float>).Item1.Job.Name, StringComparison.Ordinal)); } else if (sortingMethod == SortingMethod.PriceAsc || sortingMethod == SortingMethod.PriceDesc) { SortCharacters(list, SortingMethod.AlphabeticalAsc); list.Content.RectTransform.SortChildren((x, y) => (x.GUIComponent.UserData as Tuple <CharacterInfo, float>).Item1.Salary.CompareTo((y.GUIComponent.UserData as Tuple <CharacterInfo, float>).Item1.Salary)); if (sortingMethod == SortingMethod.PriceDesc) { list.Content.RectTransform.ReverseChildren(); } } else if (sortingMethod == SortingMethod.SkillAsc || sortingMethod == SortingMethod.SkillDesc) { SortCharacters(list, SortingMethod.AlphabeticalAsc); list.Content.RectTransform.SortChildren((x, y) => (x.GUIComponent.UserData as Tuple <CharacterInfo, float>).Item2.CompareTo((y.GUIComponent.UserData as Tuple <CharacterInfo, float>).Item2)); if (sortingMethod == SortingMethod.SkillDesc) { list.Content.RectTransform.ReverseChildren(); } } }
static void Main(string[] args) { string[] data = new string[] { "will", "lukas", "dustin", "mike" }; data = SortingAlgorithms.ComputeArrayWithoutDelegate(data, SortingTypes.BubbleSort); foreach (var item in data) { Console.WriteLine(item.ToString()); } Console.WriteLine(""); // delegate method SortingMethod sortingMethod = new SortingMethod(SortingAlgorithms.QuickSort); data = SortingAlgorithms.ComputeArrayWithDelegates(data, sortingMethod); // is the same as // data = SortingAlgorithms.ComputeArrayWithDelegates( // data, // new SortingMethod(SortingAlgorithms.QuickSort) // ); foreach (var item in data) { Console.WriteLine(item.ToString()); } // Action is a delegate (pointer) to a method, that takes zero, one or more input parameters, // but does not return anything. Action <string> myAction = new Action <string>((userName) => { Console.WriteLine("Hello " + userName); }); myAction(Console.ReadLine()); }
public Report(DateTime from, DateTime to, bool includeReturnedOrders, bool includeUnshippedOrders, SortingMethod sortBy) { _fromDate = from; _toDate = to; _includeReturnedOrders = includeReturnedOrders; _includeUnshippedOrders = includeUnshippedOrders; _sortBy = sortBy; }
public async Task Start(SortingMethod method, SortTargetKind target) { var vm = (MainWindowViewModel)DataContext; vm.Method = method; vm.TargetKind = target; await vm.Sort(); }
public static string[] ComputeArrayWithDelegates(string[] data, SortingMethod sortingMethod) { // Do some stuff on the array // Order the array data = sortingMethod(data); // Do other stuff on the array return(data); }
private static void PrintAll(SortingMethod sortingMethod = SortingMethod.None) { var rows = _library.GetAll(sortingMethod); var table = new ConsoleTable("Title", "Description", "Rating"); foreach (var game in rows) { table.AddRow(PrettyFormat(game)); } table.Write(Format.Alternative); }
public String SorrtArray() { if (string.IsNullOrEmpty(StringValue)) { MessageBox.Show("Invalid string value, Please try again", "Error"); } if (SortingMethod.Equals(QuickSortMethod)) { return(GetQuickSort(StringValue)); } else { return(GetBubbleSort(StringValue)); } }
private string GetSortingName(SortingMethod sortingMethod) { switch (sortingMethod) { case SortingMethod.Insert: return("вставки"); case SortingMethod.Shella: return("Шелла"); case SortingMethod.Bubble: return("бульбашки"); } return(""); }
public void BrowseMangaTest(int year, MediaType type, SortingMethod sortingMethod, params string[] firstMangas) { var response = Browser.BrowseManga(year: year, type: type, sortingMethod: sortingMethod); Assert.AreEqual(HttpStatusCode.OK, response.RestResponse.StatusCode); Assert.NotNull(response.Mangas); var mangas = response.Mangas; Assert.NotNull(mangas); for (var i = 0; i < firstMangas.Length; i++) { Assert.AreEqual(firstMangas[i], mangas[i].TitleEnglish); } }
public void BrowseAnimeTest(int year, Season season, MediaType type, SortingMethod sortingMethod, params string[] firstAnimes) { var response = Browser.BrowseAnime(year: year, season: season, type: type, sortingMethod: sortingMethod); Assert.AreEqual(HttpStatusCode.OK, response.RestResponse.StatusCode); Assert.NotNull(response.Animes); var animes = response.Animes; Assert.NotNull(animes); for (var i = 0; i < firstAnimes.Length; i++) { Assert.AreEqual(firstAnimes[i], animes[i].TitleEnglish); } }
public static string createDiscoverURL(MediaType mediaType = MediaType.movie, SearchCategory category = SearchCategory.discover, int page = 1, string mediaID = "", //is a string as to be able to add to script without long effect SortingMethod sortMethod = SortingMethod.popularity, SortingOrder sortOrder = SortingOrder.desc, string query = "", bool includeAdult = false, Genre[] withGenres = null) { if (withGenres == null) { withGenres = new Genre[0]; } string genres = string.Join(",", withGenres); //returns the api url + category + mediatype return(startURL + "/" + Enum.GetName(typeof(SearchCategory), category) + "/" + Enum.GetName(typeof(MediaType), mediaType) + mediaID + "?api_key=" + apiKey + "&page=" + page + "&query=" + query + "&sort_by=" + Enum.GetName(typeof(SortingMethod), sortMethod) + "." + Enum.GetName(typeof(SortingOrder), sortOrder) + "&include_adult=" + includeAdult.ToString().ToLower() + "&with_genres=" + genres); }
public Game[] GetAll(SortingMethod sortingMethod = SortingMethod.None) { Game[] allGames = {}; switch (sortingMethod) { case SortingMethod.None: allGames = Games.ToArray(); break; case SortingMethod.Ascending: allGames = Games.OrderBy(g => g.Rating).ToArray(); break; case SortingMethod.Descending: allGames = Games.OrderByDescending(g => g.Rating).ToArray(); break; } return(allGames); }
public void CustomSort(T[] arr, SortingMethod <T> sortingMethod) { bool isSorted = false; T temp; while (!isSorted) { isSorted = true; for (int i = arr.GetLowerBound(0); i < arr.GetUpperBound(0); i++) { if (sortingMethod(arr[i], arr[i + 1])) { temp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = temp; isSorted = false; } } } }
public void CustomSort(T[] arr, SortingMethod <T> sortingMethod) { bool isSorted = false; T temp; while (!isSorted) { isSorted = true; for (int i = arr.GetLowerBound(0); i < arr.GetUpperBound(0); i++) { if (sortingMethod(arr[i], arr[i + 1])) { temp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = temp; isSorted = false; } } } SortingFinished?.Invoke(this, new SortingEventArgs <T>(arr)); }
public static void SortByNumberOfStrokes() { sortingMethod = SortingMethod.Strokes; currentWords.UpdateShownWords(); }
public static void SortByFrequency() { sortingMethod = SortingMethod.Frequency; currentWords.UpdateShownWords(); }
public void DoSortListViewBy(SortingMethod sortingMethod, bool sortDecending, List <ApartmentBlock> list) { //Debug.Log ("DO SORT LIST VIEW BY"); _CleanListView(); if (sortingMethod == SortingMethod.none) { InitiliseListInternal(list); } if (sortingMethod == SortingMethod.price) { //put al filterted apartment in a dictionary ready for sorting Dictionary <ApartmentBlock, string> apartmentToSort = new Dictionary <ApartmentBlock, string>(); foreach (ApartmentBlock apartments in list) { apartmentToSort.Add(apartments, apartments.unitInfo.unit_price.ToString().Replace(",", "")); } Debug.Log("Start"); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.floor) { //put al filterted apartment in a dictionary ready for sorting Dictionary <ApartmentBlock, string> apartmentToSort = new Dictionary <ApartmentBlock, string>(); foreach (ApartmentBlock apartments in list) { if (apartments.unitInfo.unitFloorName == "G") { apartments.unitInfo.unitFloorName = "00"; } Debug.Log(apartments.unitInfo.unitFloorName); apartmentToSort.Add(apartments, apartments.unitInfo.unitFloorName); } Debug.Log("Start"); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.area) { //put al filterted apartment in a dictionary ready for sorting Dictionary <ApartmentBlock, int> apartmentToSort = new Dictionary <ApartmentBlock, int>(); foreach (ApartmentBlock apartments in list) { if (String.IsNullOrEmpty(apartments.unitInfo.unit_sqft)) { apartments.unitInfo.unit_sqft = "0"; } apartmentToSort.Add(apartments, Convert.ToInt32(apartments.unitInfo.unit_sqft.Replace(",", ""))); } Debug.Log("Start"); SortActionInt(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.beds) { //put al filterted apartment in a dictionary ready for sorting Dictionary <ApartmentBlock, string> apartmentToSort = new Dictionary <ApartmentBlock, string>(); foreach (ApartmentBlock apartments in list) { apartmentToSort.Add(apartments, apartments.unitInfo.unitBedroomName); } Debug.Log("Start"); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.name) { //put al filterted apartment in a dictionary ready for sorting Dictionary <ApartmentBlock, string> apartmentToSort = new Dictionary <ApartmentBlock, string>(); foreach (ApartmentBlock apartments in list) { apartmentToSort.Add(apartments, apartments.unitInfo.unit_name); } Debug.Log("Start"); Debug.Log("Apartment to sort:" + apartmentToSort.Count); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.status) { //put al filterted apartment in a dictionary ready for sorting Dictionary <ApartmentBlock, int> apartmentToSort = new Dictionary <ApartmentBlock, int>(); foreach (ApartmentBlock apartments in list) { apartmentToSort.Add(apartments, apartments.unitInfo.unit_status); } Debug.Log("Start"); SortActionInt(sortDecending, apartmentToSort); } }
/// <summary> /// Gets the string corresponding to the given soring method. If the method is not recognized, /// adds an error the the log and returns the empty string. /// </summary> /// <param name="method">The method whose string to find.</param> /// <returns>The method's string.</returns> public static string GetStringFromSortingMethod(SortingMethod method) { if (sortingMethodToString.Keys.Contains(method)) { return sortingMethodToString[method]; } else { ErrorLogger.AddLog(string.Format("Did not recognized sorting method '{0}'.", method), ErrorSeverity.MODERATE); return ""; } }
public void RunSortInNewThread(T[] arr, SortingMethod <T> sortingMethod) { Thread th = new Thread(() => CustomSort(arr, sortingMethod)); th.Start(); }
public void DoSortListViewBy(SortingMethod sortingMethod, bool sortDecending, List<ApartmentBlock> list) { //Debug.Log ("DO SORT LIST VIEW BY"); _CleanListView(); if (sortingMethod == SortingMethod.none){ InitiliseListInternal(list); } if (sortingMethod == SortingMethod.price){ //put al filterted apartment in a dictionary ready for sorting Dictionary<ApartmentBlock,string> apartmentToSort= new Dictionary<ApartmentBlock,string>(); foreach (ApartmentBlock apartments in list){ apartmentToSort.Add(apartments, apartments.unitInfo.unit_price.ToString().Replace(",","")); } Debug.Log ("Start"); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.floor){ //put al filterted apartment in a dictionary ready for sorting Dictionary<ApartmentBlock,string> apartmentToSort= new Dictionary<ApartmentBlock,string>(); foreach (ApartmentBlock apartments in list){ if (apartments.unitInfo.unitFloorName == "G") apartments.unitInfo.unitFloorName = "00"; Debug.Log (apartments.unitInfo.unitFloorName); apartmentToSort.Add(apartments, apartments.unitInfo.unitFloorName ); } Debug.Log ("Start"); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.area){ //put al filterted apartment in a dictionary ready for sorting Dictionary<ApartmentBlock,int> apartmentToSort= new Dictionary<ApartmentBlock,int>(); foreach (ApartmentBlock apartments in list){ if (String.IsNullOrEmpty(apartments.unitInfo.unit_sqft)) apartments.unitInfo.unit_sqft = "0"; apartmentToSort.Add(apartments, Convert.ToInt32 (apartments.unitInfo.unit_sqft.Replace(",","")) ); } Debug.Log ("Start"); SortActionInt(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.beds){ //put al filterted apartment in a dictionary ready for sorting Dictionary<ApartmentBlock,string> apartmentToSort= new Dictionary<ApartmentBlock,string>(); foreach (ApartmentBlock apartments in list){ apartmentToSort.Add(apartments, apartments.unitInfo.unitBedroomName); } Debug.Log ("Start"); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.name){ //put al filterted apartment in a dictionary ready for sorting Dictionary<ApartmentBlock,string> apartmentToSort= new Dictionary<ApartmentBlock,string>(); foreach (ApartmentBlock apartments in list){ apartmentToSort.Add(apartments,apartments.unitInfo.unit_name); } Debug.Log ("Start"); Debug.Log ("Apartment to sort:" + apartmentToSort.Count); SortActionString(sortDecending, apartmentToSort); } //------------------- if (sortingMethod == SortingMethod.status){ //put al filterted apartment in a dictionary ready for sorting Dictionary<ApartmentBlock,int> apartmentToSort= new Dictionary<ApartmentBlock,int>(); foreach (ApartmentBlock apartments in list){ apartmentToSort.Add(apartments, apartments.unitInfo.unit_status); } Debug.Log ("Start"); SortActionInt(sortDecending, apartmentToSort); } }
private static Tuple <Solution, double> Optimize(PackingShape bin, IList <PackingItem> items, SortingMethod sorting, FittingMethod fitting, double delta, bool stackingConstraints, IEvaluator evaluator, CancellationToken token) { Permutation sorted = null; switch (sorting) { case SortingMethod.Given: sorted = new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray()); break; case SortingMethod.VolumeHeight: sorted = new Permutation(PermutationTypes.Absolute, items.Select((v, i) => new { Index = i, Item = v }) .OrderByDescending(x => x.Item.Depth * x.Item.Width * x.Item.Height) .ThenByDescending(x => x.Item.Height) .Select(x => x.Index).ToArray()); break; case SortingMethod.HeightVolume: sorted = new Permutation(PermutationTypes.Absolute, items.Select((v, i) => new { Index = i, Item = v }) .OrderByDescending(x => x.Item.Height) .ThenByDescending(x => x.Item.Depth * x.Item.Width * x.Item.Height) .Select(x => x.Index).ToArray()); break; case SortingMethod.AreaHeight: sorted = new Permutation(PermutationTypes.Absolute, items.Select((v, i) => new { Index = i, Item = v }) .OrderByDescending(x => x.Item.Depth * x.Item.Width) .ThenByDescending(x => x.Item.Height) .Select(x => x.Index).ToArray()); break; case SortingMethod.HeightArea: sorted = new Permutation(PermutationTypes.Absolute, items.Select((v, i) => new { Index = i, Item = v }) .OrderByDescending(x => x.Item.Height) .ThenByDescending(x => x.Item.Depth * x.Item.Width) .Select(x => x.Index).ToArray()); break; case SortingMethod.ClusteredAreaHeight: double clusterRange = bin.Width * bin.Depth * delta; sorted = new Permutation(PermutationTypes.Absolute, items.Select((v, i) => new { Index = i, Item = v, ClusterId = (int)(Math.Ceiling(v.Width * v.Depth / clusterRange)) }) .GroupBy(x => x.ClusterId) .Select(x => new { Cluster = x.Key, Items = x.OrderByDescending(y => y.Item.Height).ToList() }) .OrderByDescending(x => x.Cluster) .SelectMany(x => x.Items) .Select(x => x.Index).ToArray()); break; case SortingMethod.ClusteredHeightArea: double clusterRange2 = bin.Height * delta; sorted = new Permutation(PermutationTypes.Absolute, items.Select((v, i) => new { Index = i, Item = v, ClusterId = (int)(Math.Ceiling(v.Height / clusterRange2)) }) .GroupBy(x => x.ClusterId) .Select(x => new { Cluster = x.Key, Items = x.OrderByDescending(y => y.Item.Depth * y.Item.Width).ToList() }) .OrderByDescending(x => x.Cluster) .SelectMany(x => x.Items) .Select(x => x.Index).ToArray()); break; default: throw new ArgumentException("Unknown sorting method: " + sorting); } ExtremePointPermutationDecoderBase decoder = null; switch (fitting) { case FittingMethod.FirstFit: decoder = new ExtremePointPermutationDecoder(); break; case FittingMethod.FreeVolumeBestFit: decoder = new FreeVolumeBestFitExtremePointPermutationDecoder(); break; case FittingMethod.ResidualSpaceBestFit: decoder = new ResidualSpaceBestFitExtremePointPermutationDecoder(); break; default: throw new ArgumentException("Unknown fitting method: " + fitting); } var sol = decoder.Decode(sorted, bin, items, stackingConstraints); var fit = evaluator.Evaluate(sol); return(Tuple.Create(sol, fit)); }
public static void SortByPinyin() { sortingMethod = SortingMethod.Pinyin; currentWords.UpdateShownWords(); }
/// <summary> /// Sorts pages. /// </summary> /// <param name="pages">The pages list to sort.</param> /// <param name="sortBy">The sorting method.</param> /// <param name="reverse"><c>true</c> to sort in reverse order.</param> /// <returns>The sorted list, divided in relevant groups.</returns> public static SortedDictionary <SortingGroup, List <ExtendedPageInfo> > Sort(ExtendedPageInfo[] pages, SortingMethod sortBy, bool reverse) { switch (sortBy) { case SortingMethod.Title: return(SortByTitle(pages, reverse)); case SortingMethod.Creator: return(SortByCreator(pages, reverse)); case SortingMethod.User: return(SortByUser(pages, reverse)); case SortingMethod.DateTime: return(SortByDateTime(pages, reverse)); case SortingMethod.Creation: return(SortByCreation(pages, reverse)); default: throw new NotSupportedException("Invalid sorting method"); } }
public static void SortByExact() { sortingMethod = SortingMethod.Exact; currentWords.UpdateShownWords(); }
/// <summary> /// Prints the pages. /// </summary> public void PrintPages() { StringBuilder sb = new StringBuilder(65536); if (currentPages == null) { currentPages = GetAllPages(); } // Prepare ExtendedPageInfo array ExtendedPageInfo[] tempPageList = new ExtendedPageInfo[rangeEnd - rangeBegin + 1]; PageContent cnt; for (int i = 0; i < tempPageList.Length; i++) { cnt = Content.GetPageContent(currentPages[rangeBegin + i], true); tempPageList[i] = new ExtendedPageInfo(currentPages[rangeBegin + i], cnt.Title, cnt.LastModified, GetCreator(currentPages[rangeBegin + i]), cnt.User); } // Prepare for sorting bool reverse = false; SortingMethod sortBy = SortingMethod.Title; if (Request["SortBy"] != null) { try { sortBy = (SortingMethod)Enum.Parse(typeof(SortingMethod), Request["SortBy"], true); } catch { // Backwards compatibility if (Request["SortBy"].ToLowerInvariant() == "date") { sortBy = SortingMethod.DateTime; } } if (Request["Reverse"] != null) { reverse = true; } } SortedDictionary <SortingGroup, List <ExtendedPageInfo> > sortedPages = PageSortingTools.Sort(tempPageList, sortBy, reverse); sb.Append(@"<table id=""PageListTable"" class=""generic"" cellpadding=""0"" cellspacing=""0"">"); sb.Append("<thead>"); sb.Append(@"<tr class=""tableheader"">"); // Page title sb.Append(@"<th><a rel=""nofollow"" href="""); UrlTools.BuildUrl(sb, "AllPages.aspx?SortBy=Title", (!reverse && sortBy == SortingMethod.Title ? "&Reverse=1" : ""), (Request["Cat"] != null ? "&Cat=" + Tools.UrlEncode(Request["Cat"]) : ""), "&Page=", selectedPage.ToString()); sb.Append(@""" title="""); sb.Append(Properties.Messages.SortByTitle); sb.Append(@""">"); sb.Append(Properties.Messages.PageTitle); sb.Append((reverse && sortBy.Equals("title") ? " ↑" : "")); sb.Append((!reverse && sortBy.Equals("title") ? " ↓" : "")); sb.Append("</a></th>"); // Message count sb.Append(@"<th><img src=""Images/Comment.png"" alt=""Comments"" /></th>"); // Creation date/time sb.Append(@"<th><a rel=""nofollow"" href="""); UrlTools.BuildUrl(sb, "AllPages.aspx?SortBy=Creation", (!reverse && sortBy == SortingMethod.Creation ? "&Reverse=1" : ""), (Request["Cat"] != null ? "&Cat=" + Tools.UrlEncode(Request["Cat"]) : ""), "&Page=", selectedPage.ToString()); sb.Append(@""" title="""); sb.Append(Properties.Messages.SortByDate); sb.Append(@""">"); sb.Append(Properties.Messages.CreatedOn); sb.Append((reverse && sortBy.Equals("creation") ? " ↑" : "")); sb.Append((!reverse && sortBy.Equals("creation") ? " ↓" : "")); sb.Append("</a></th>"); // Mod. date/time sb.Append(@"<th><a rel=""nofollow"" href="""); UrlTools.BuildUrl(sb, "AllPages.aspx?SortBy=DateTime", (!reverse && sortBy == SortingMethod.DateTime ? "&Reverse=1" : ""), (Request["Cat"] != null ? "&Cat=" + Tools.UrlEncode(Request["Cat"]) : ""), "&Page=", selectedPage.ToString()); sb.Append(@""" title="""); sb.Append(Properties.Messages.SortByDate); sb.Append(@""">"); sb.Append(Properties.Messages.ModifiedOn); sb.Append((reverse && sortBy.Equals("date") ? " ↑" : "")); sb.Append((!reverse && sortBy.Equals("date") ? " ↓" : "")); sb.Append("</a></th>"); // Creator sb.Append(@"<th><a rel=""nofollow"" href="""); UrlTools.BuildUrl(sb, "AllPages.aspx?SortBy=Creator", (!reverse && sortBy == SortingMethod.Creator ? "&Reverse=1" : ""), (Request["Cat"] != null ? "&Cat=" + Tools.UrlEncode(Request["Cat"]) : ""), "&Page=", selectedPage.ToString()); sb.Append(@""" title="""); sb.Append(Properties.Messages.SortByUser); sb.Append(@""">"); sb.Append(Properties.Messages.CreatedBy); sb.Append((reverse && sortBy.Equals("creator") ? " ↑" : "")); sb.Append((!reverse && sortBy.Equals("creator") ? " ↓" : "")); sb.Append("</a></th>"); // Last author sb.Append(@"<th><a rel=""nofollow"" href="""); UrlTools.BuildUrl(sb, "AllPages.aspx?SortBy=User", (!reverse && sortBy == SortingMethod.User ? "&Reverse=1" : ""), (Request["Cat"] != null ? "&Cat=" + Tools.UrlEncode(Request["Cat"]) : ""), "&Page=", selectedPage.ToString()); sb.Append(@""" title="""); sb.Append(Properties.Messages.SortByUser); sb.Append(@""">"); sb.Append(Properties.Messages.ModifiedBy); sb.Append((reverse && sortBy.Equals("user") ? " ↑" : "")); sb.Append((!reverse && sortBy.Equals("user") ? " ↓" : "")); sb.Append("</a></th>"); // Categories sb.Append("<th>"); sb.Append(Properties.Messages.Categories); sb.Append("</th>"); sb.Append("</tr>"); sb.Append("</thead><tbody>"); foreach (SortingGroup key in sortedPages.Keys) { List <ExtendedPageInfo> pageList = sortedPages[key]; for (int i = 0; i < pageList.Count; i++) { if (i == 0) { // Add group header sb.Append(@"<tr class=""tablerow"">"); if (sortBy == SortingMethod.Title) { sb.AppendFormat("<td colspan=\"7\"><b>{0}</b></td>", key.Label); } else if (sortBy == SortingMethod.Creation) { sb.AppendFormat("<td colspan=\"2\"></td><td colspan=\"5\"><b>{0}</b></td>", key.Label); } else if (sortBy == SortingMethod.DateTime) { sb.AppendFormat("<td colspan=\"3\"></td><td colspan=\"4\"><b>{0}</b></td>", key.Label); } else if (sortBy == SortingMethod.Creator) { sb.AppendFormat("<td colspan=\"4\"></td><td colspan=\"3\"><b>{0}</b></td>", key.Label); } else if (sortBy == SortingMethod.User) { sb.AppendFormat("<td colspan=\"5\"></td><td colspan=\"2\"><b>{0}</b></td>", key.Label); } sb.Append("</tr>"); } sb.Append(@"<tr class=""tablerow"); if ((i + 1) % 2 == 0) { sb.Append("alternate"); } sb.Append(@""">"); // Page title sb.Append(@"<td>"); sb.Append(@"<a href="""); UrlTools.BuildUrl(sb, Tools.UrlEncode(pageList[i].PageInfo.FullName), Settings.PageExtension); sb.Append(@""">"); sb.Append(pageList[i].Title); sb.Append("</a>"); sb.Append("</td>"); // Message count sb.Append(@"<td>"); int msg = pageList[i].MessageCount; if (msg > 0) { sb.Append(@"<a href="""); UrlTools.BuildUrl(sb, Tools.UrlEncode(pageList[i].PageInfo.FullName), Settings.PageExtension, "?Discuss=1"); sb.Append(@""" title="""); sb.Append(Properties.Messages.Discuss); sb.Append(@""">"); sb.Append(msg.ToString()); sb.Append("</a>"); } else { sb.Append(" "); } sb.Append("</td>"); // Creation date/time sb.Append(@"<td>"); sb.Append(Preferences.AlignWithTimezone(pageList[i].CreationDateTime).ToString(Settings.DateTimeFormat) + " "); sb.Append("</td>"); // Mod. date/time sb.Append(@"<td>"); sb.Append(Preferences.AlignWithTimezone(pageList[i].ModificationDateTime).ToString(Settings.DateTimeFormat) + " "); sb.Append("</td>"); // Creator sb.Append(@"<td>"); sb.Append(Users.UserLink(pageList[i].Creator)); sb.Append("</td>"); // Last author sb.Append(@"<td>"); sb.Append(Users.UserLink(pageList[i].LastAuthor)); sb.Append("</td>"); // Categories CategoryInfo[] cats = Pages.GetCategoriesForPage(pageList[i].PageInfo); sb.Append(@"<td>"); if (cats.Length == 0) { sb.Append(@"<a href="""); UrlTools.BuildUrl(sb, "AllPages.aspx?Cat=-"); sb.Append(@""">"); sb.Append(Properties.Messages.NC); sb.Append("</a>"); } else { for (int k = 0; k < cats.Length; k++) { sb.Append(@"<a href="""); UrlTools.BuildUrl(sb, "AllPages.aspx?Cat=", Tools.UrlEncode(cats[k].FullName)); sb.Append(@""">"); sb.Append(NameTools.GetLocalName(cats[k].FullName)); sb.Append("</a>"); if (k != cats.Length - 1) { sb.Append(", "); } } } sb.Append("</td>"); sb.Append("</tr>"); } } sb.Append("</tbody>"); sb.Append("</table>"); Literal lbl = new Literal(); lbl.Text = sb.ToString(); pnlPageList.Controls.Clear(); pnlPageList.Controls.Add(lbl); }
private void SetUpScenary0() { this.SortingMethod = new SortingMethod(); this.DataGenerator = new DataGenerator(); }
/// <summary> /// Returns a new list containing all of the given elements sorted using the given method. /// Throws an ArgumentException if the sorting method is not valid. /// </summary> /// <param name="projects">The projects to sort.</param> /// <param name="method">The method to use to sort the projects.</param> /// <returns>The sorted list.</returns> public static List<Project> SortProjects(List<Project> projects, SortingMethod method) { List<Project> sortedProjects = new List<Project>(); // Sort based on the UserSettings switch (method) { case SortingMethod.OLD_FIRST: sortedProjects = projects.OrderBy(p => p.Id).ToList(); break; case SortingMethod.NEW_FIRST: sortedProjects = projects.OrderBy(p => p.Id).Reverse().ToList(); break; case SortingMethod.NAME_A_TO_Z: sortedProjects = projects.OrderBy(p => p.Name).ToList(); break; case SortingMethod.NAME_Z_TO_A: sortedProjects = projects.OrderBy(p => p.Name).Reverse().ToList(); break; default: ErrorLogger.AddLog(string.Format("Invalid sorting method {0} given. Cannot sort.", method), ErrorSeverity.MODERATE); sortedProjects = projects; break; } return sortedProjects; }