public void Sort(SortedBy by, bool sortAscending) { Comparison <CharacterGroup> how; int direction = sortAscending ? kAscending : kDescending; switch (by) { case SortedBy.Name: how = (a, b) => String.Compare(a.Name, b.Name, StringComparison.CurrentCulture) * direction; break; case SortedBy.Attributes: how = (a, b) => String.Compare(a.AttributesDisplay, b.AttributesDisplay, StringComparison.CurrentCulture) * direction; break; case SortedBy.Actor: how = (a, b) => { var actorA = m_project.VoiceActorList.GetVoiceActorById(a.VoiceActorId); var nameA = actorA == null ? String.Empty : actorA.Name; var actorB = m_project.VoiceActorList.GetVoiceActorById(b.VoiceActorId); var nameB = actorB == null ? String.Empty : actorB.Name; return(String.Compare(nameA, nameB, StringComparison.CurrentCulture) * direction); }; break; case SortedBy.EstimatedTime: how = (a, b) => a.EstimatedHours.CompareTo(b.EstimatedHours) * direction; break; default: throw new ArgumentException("Unexpected sorting method", "by"); } CharacterGroups.Sort(how); }
private void LabelRamUsage_Click(object sender, EventArgs e) { SortedBy temp = sortState; sortState = SortedBy.RAM; if (temp != sortState) { bgWorker1.ReportProgress(1); } }
////ncrunch: no coverage end protected bool Equals(OrderSpecification <TEntity> other) { ////ncrunch: no coverage start if (!this.IsReferenceEquals(other)) { return(false); } ////ncrunch: no coverage end var leftOrder = new AdHocOrderSpecification <TEntity>(); SortedBy()(leftOrder); var rightOrder = new AdHocOrderSpecification <TEntity>(); other.SortedBy()(rightOrder); return(leftOrder.Equals(rightOrder)); }
private void LabelProcessName_Click(object sender, EventArgs e) { SortedBy temp = sortState; sortState = SortedBy.NAME; if (temp != sortState) { bgWorker1.ReportProgress(1); } }
public List <int> Call <Name>(Named <Comparison <int>, Name> named) { List <int> l1 = new List <int> { 1, 5, 2 }; List <int> l2 = new List <int> { 9, 3, 7 }; SortedBy <int, Name> sorted1 = SortMerge.SortMerger.GdpSortBy <Name>(l1, named); SortedBy <int, Name> sorted2 = SortMerge.SortMerger.GdpSortBy <Name>(l2, named); return(SortMerge.SortMerger.GdpMergeBy(sorted1, sorted2, named)); }
/// <summary> /// Method for sorting notes by Subject /// </summary> private void Content_Button_sortSubject_Click(object sender, RoutedEventArgs e) { if (sorted == SortedBy.Subject) { SortNotes(SortedBy.SubjectReverse); sorted = SortedBy.SubjectReverse; } else { SortNotes(SortedBy.Subject); sorted = SortedBy.Subject; } }
private void SortByTime(object sender, RoutedEventArgs e) { if (sorted == SortedBy.Deadline) { SortNotes(SortedBy.DeadlineReverse); sorted = SortedBy.DeadlineReverse; } else { SortNotes(SortedBy.Deadline); sorted = SortedBy.Deadline; } }
/// <summary> /// Method for sorting notes by Deadline /// </summary> private void Content_Button_sortDeadline_Click(object sender, RoutedEventArgs e) { if (sorted == SortedBy.Deadline) { SortNotes(SortedBy.DeadlineReverse); sorted = SortedBy.DeadlineReverse; } else { SortNotes(SortedBy.Deadline); sorted = SortedBy.Deadline; } }
private void SortByTitle(object sender, RoutedEventArgs e) { if (sorted == SortedBy.Title) { SortNotes(SortedBy.TitleReverse); sorted = SortedBy.TitleReverse; } else { SortNotes(SortedBy.Title); sorted = SortedBy.Title; } }
/// <summary> /// Method for sorting notes by Creation date /// </summary> private void Content_Button_sortCreated_Click(object sender, RoutedEventArgs e) { if (sorted == SortedBy.Created) { SortNotes(SortedBy.CreatedReverse); sorted = SortedBy.CreatedReverse; } else { SortNotes(SortedBy.Created); sorted = SortedBy.Created; } }
public static IEnumerable <T> SortOrgGroupByHierarchy <T>(IEnumerable <T> orgGroupsEnumerable, SortedBy sortedBy) where T : OrgGroup { var orgGroups = orgGroupsEnumerable.ToArray(); OrgGroup Find(Guid?id) { if (id == null) { return(null); } return(orgGroups.FirstOrDefault(group => group.Id == id.Value)); } int NumberOfParents(OrgGroup group) { var parent = Find(group.ParentId); if (parent == null) { return(0); } int count = 0; while (parent != null && parent != group) { count++; parent = Find(parent.ParentId); } return(count); } var valueTuples = orgGroups.Select(group => (@group, parentCount: NumberOfParents(@group))); switch (sortedBy) { case SortedBy.Either: case SortedBy.ChildFirst: valueTuples = valueTuples.OrderByDescending(tuple => tuple.parentCount) .ThenBy(tuple => tuple.group.GroupName); break; case SortedBy.ParentFirst: valueTuples = valueTuples.OrderBy(tuple => tuple.parentCount) .ThenBy(tuple => tuple.group.GroupName); break; } return(valueTuples.Select(tuple => tuple.group)); }
public void OnSortFileSizeClick() { ResetSortButtonLabels(); if (sortedBy == SortedBy.Size && sortAscending) { sortSizeButton.GetComponentInChildren <Text>().text = "Size ↑"; sortAscending = false; } else { sortSizeButton.GetComponentInChildren <Text>().text = "Size ↓"; sortAscending = true; sortedBy = SortedBy.Size; } UpdateDir(); }
public static IEnumerable <BoringEvent> SortEvents <T>(this IEnumerable <BoringEvent> events, SortedBy sortByType, params Expression <Func <BoringEvent, T> >[] expressions) { IEnumerable <BoringEvent> retVal = null; switch (sortByType) { case SortedBy.Ascending: retVal = BoringEventExtensions.SortEventsAsc <T>(events, expressions); break; case SortedBy.Descending: retVal = BoringEventExtensions.SortEventsDesc <T>(events, expressions); break; default: throw new InvalidOperationException( string.Format("The SortedBy enumeration does not contain a case for the value of '{0}'.", Enum.GetName(typeof(SortedBy), sortByType))); } return(retVal); }
/// <summary> /// Sort by different parameters /// </summary> /// <param name="key">Key to sort by</param> public void sort(SortedBy key) { if (notes.Count > 1) { switch (key) { case SortedBy.Created: notes.Sort((x, y) => x.Created.CompareTo(y.Created)); break; case SortedBy.CreatedReverse: notes.Sort((x, y) => y.Created.CompareTo(x.Created)); break; case SortedBy.Deadline: notes.Sort((x, y) => x.Deadline.CompareTo(y.Deadline)); break; case SortedBy.DeadlineReverse: notes.Sort((x, y) => y.Deadline.CompareTo(x.Deadline)); break; case SortedBy.Subject: notes.Sort((x, y) => x.SubjectID.CompareTo(y.SubjectID)); break; case SortedBy.SubjectReverse: notes.Sort((x, y) => y.SubjectID.CompareTo(x.SubjectID)); break; case SortedBy.Title: notes.Sort((x, y) => x.Name.CompareTo(y.Name)); break; case SortedBy.TitleReverse: notes.Sort((x, y) => y.Name.CompareTo(x.Name)); break; } } }
public static bool IsOrgGroupSortedByHierarchy <T>(ICollection <T> orgGroups, SortedBy sortedBy = SortedBy.Either) where T : OrgGroup { if (orgGroups.Count <= 1) { return(true); } bool ParentInList(OrgGroup group) { return(orgGroups.Any(orgGroup => orgGroup.Id == @group.ParentId)); } var groupWithoutParent = orgGroups.FirstOrDefault(group => !ParentInList(@group)); var startsWithChild = orgGroups.First() != groupWithoutParent; switch (sortedBy) { case SortedBy.ChildFirst: if (!startsWithChild) { return(false); } break; case SortedBy.ParentFirst: if (startsWithChild) { return(false); } break; } OrgGroup previous = null; foreach (var current in startsWithChild ? orgGroups.Reverse() : orgGroups) { if (previous != null && current.ParentId != previous.Id) { return(false); } previous = current; } return(true); }
public void SortNotes(SortedBy by) { logic.sort(by); FillNotes(); }
public void SortAlphabetically() { if (Sorted == SortedBy.Alphabetically) return; Sorted = SortedBy.Alphabetically; LoadFilesInFolder (); AssureEnoughFilesAreCached (CurrentFileName, 2, 3); }
public void SortByDate() { if (Sorted == SortedBy.Date) return; Sorted = SortedBy.Date; LoadFilesInFolder (); AssureEnoughFilesAreCached (CurrentFileName, 2, 3); }
/// <summary> /// Initializes the object with the sorting set to Ascending by default. /// </summary> public SortedLinkedList() { _head = new Node <T>(default(T)); _sorting = SortedBy.Ascending; }
/// <summary> /// Initializes the object with the given sorting. /// /// Note: For now, a new object has to be created to change the sorting. /// </summary> /// <param name="sorting"></param> public SortedLinkedList(SortedBy sorting) { _head = new Node <T>(default(T)); _sorting = sorting; }