protected virtual void OnSelectedSortOrderFunctionChanged(SortOrderFunction oldSelectedSortOrderFunction, SortOrderFunction newSelectedSortOrderFunction) { RaisePropertyChanged("SelectedSortOrderFunction", oldSelectedSortOrderFunction, newSelectedSortOrderFunction); //set preferred direction for specific order function //block search updates while setting direction blockUpdateSearchSorting = true; switch (newSelectedSortOrderFunction.EnumValue) { case SortOrder.relevance: case SortOrder.date: IsAscendingSelected = false; IsDescendingSelected = true; break; case SortOrder.title: case SortOrder.author: IsAscendingSelected = true; IsDescendingSelected = false; break; } blockUpdateSearchSorting = false; //update search UpdateSearchSorting(newSelectedSortOrderFunction.EnumValue, SelectedSortDirection); }
private void UpdateShelfContentInfo(Page page, SortOrderFunction order, SortDirection direction) { Info.Text = null; Info.From = null; Info.To = null; if (page.Hits.Count > 0) { if (order.EnumValue == SortOrder.relevance) { Info.Text = HBS.Search.SearchText; } else { //get first and last valid value var first = page.Hits.FirstOrDefault(hit => order.HasProperty(hit)); var last = page.Hits.LastOrDefault(hit => order.HasProperty(hit)); //get string representatives var firstString = ""; if (first != null) { firstString = order.GetRepresentative(first); } var lastString = ""; if (last != null) { lastString = order.GetRepresentative(last); } //set info properties Info.From = firstString; Info.To = lastString; } } IsInfoVisible = !string.IsNullOrEmpty(Info.From) || !string.IsNullOrEmpty(Info.To); }
public static SortOrderFunction GetSingleton(SortOrder order) { SortOrderFunction func = null; if (!SORT_ORDER_FUNCTION_SINGELTONS.TryGetValue(order, out func)) { func = new SortOrderFunction(order); SORT_ORDER_FUNCTION_SINGELTONS.Add(order, func); } return(func); }