public static void Sort <TSource, TKey>(this BindableCollection <TSource> source, Func <TSource, TKey> keySelector) { List <TSource> sorted = source.OrderBy(keySelector).ToList(); source.Clear(); foreach (var item in sorted) { source.Add(item); } }
public static void Sort <T>(this BindableCollection <T> collection, Func <T, object> order) { List <T> ordered = collection.OrderBy(order).ToList(); for (int index = 0; index < ordered.Count; index++) { T dataBindingConditionViewModel = ordered[index]; if (collection.IndexOf(dataBindingConditionViewModel) != index) { collection.Move(collection.IndexOf(dataBindingConditionViewModel), index); } } }
/// <inheritdoc /> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { BindableCollection <ColorGradientStop> colorGradients = (BindableCollection <ColorGradientStop>)value; GradientStopCollection collection = new GradientStopCollection(); if (colorGradients == null) { return(collection); } foreach (ColorGradientStop c in colorGradients.OrderBy(s => s.Position)) { collection.Add(new GradientStop(Color.FromArgb(c.Color.Alpha, c.Color.Red, c.Color.Green, c.Color.Blue), c.Position)); } return(collection); }
private void PopulateCombooxPLCConnections() { PLCConnectionsShortList = new BindableCollection <PLCconnectionComboBoxModel>(); foreach (var item in _originalListOfS7connections) { PLCConnectionsShortList.Add(new PLCconnectionComboBoxModel() { CPUmanufacturer = 1, Identity = item.Identity, PLCconnectionID = item.PLCconnectionID, ConnectionName = item.ConnectionName, }); PLCConnectionsShortList.OrderBy(x => x.PLCconnectionID); } }
private void ResultTable(BindableCollection<Listing> propertyList, Document doc) { iTextSharp.text.Font PropertyFont = new iTextSharp.text.Font(); iTextSharp.text.Font headerfont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 18f, iTextSharp.text.Font.BOLD); propertyList = (BindableCollection<Listing>)propertyList.OrderBy(x => x.Address).ToObservableCollection(); //Creating a table, and adding items dynamically PdfPTable resultTable = new PdfPTable(8); resultTable.TotalWidth = PageSize.A4.Width; resultTable.LockedWidth = true; PdfPCell header = new PdfPCell(new Phrase("Søgeresultatliste\n", headerfont)); header.Colspan = 8; header.PaddingBottom = 10f; resultTable.AddCell(header); resultTable.SetWidths(new float[] { 20f, 40f, 20f, 20f, 20f, 20f, 20f, 20f, }); resultTable.AddCell("Boligtype"); resultTable.AddCell("Adresse"); resultTable.AddCell("By/Postnr"); resultTable.AddCell("Pris"); resultTable.AddCell("Størrelse"); resultTable.AddCell("Liggetid"); resultTable.AddCell("Til salg/Solgt"); resultTable.AddCell("Byggeår"); for (int i = 0; i < NumberOfSearchResults; i++) { if (propertyList[1].IsSelected) { var item = propertyList[i]; resultTable.AddCell(item.PropertyType); PdfPCell adresscell = new PdfPCell(new Phrase(item.Address)); resultTable.AddCell(adresscell); resultTable.AddCell(item.Town + "(" + item.AreaCode + ")"); resultTable.AddCell(item.Price.ToString()); resultTable.AddCell(item.Size.ToString()); resultTable.AddCell(item.Demurrage.ToString()); resultTable.AddCell(item.ForSaleSold); resultTable.AddCell(item.YearBuilt.ToString()); } } if (resultTable != null) { doc.Add(resultTable); } }
public void PrepareSortFilterPopup(int id) { FilterViewModel filter = FiltersList.FirstOrDefault(f => f.columnId == id); if (filter == null) { List<string> breakdownData = GetBreakdownDataValues(id); BindableCollection<FilterCriteriaViewModel> filterCriteria = new BindableCollection<FilterCriteriaViewModel>(); foreach (string criteria in breakdownData) { filterCriteria.Add(new FilterCriteriaViewModel(id, criteria, this)); } try { filterCriteria = new BindableCollection<FilterCriteriaViewModel>(filterCriteria.OrderBy(x => Convert.ToInt32(x.Name))); } catch { filterCriteria = new BindableCollection<FilterCriteriaViewModel>(filterCriteria.OrderBy(x => x.Name)); } filter = new FilterViewModel(id, Parameter.playlist.displayColumns[id], SortType.None, filterCriteria, this); } else { filter.setSortType(filter.sortType); filter.RemoveButtonVisibility = "Visible"; filter.CloseButtonVisibility = "Collapsed"; } SelectedFilter = filter; }
public void PrepareSortFilterPopup(int id) { FilterViewModel filter = FiltersList.FirstOrDefault(f => f.columnId == id); if (filter == null) { List <string> breakdownData = GetBreakdownDataValues(id); BindableCollection <FilterCriteriaViewModel> filterCriteria = new BindableCollection <FilterCriteriaViewModel>(); foreach (string criteria in breakdownData) { filterCriteria.Add(new FilterCriteriaViewModel(id, criteria, this)); } try { filterCriteria = new BindableCollection <FilterCriteriaViewModel>(filterCriteria.OrderBy(x => Convert.ToInt32(x.Name))); } catch { filterCriteria = new BindableCollection <FilterCriteriaViewModel>(filterCriteria.OrderBy(x => x.Name)); } filter = new FilterViewModel(id, Parameter.playlist.displayColumns[id], SortType.None, filterCriteria, this); } else { filter.setSortType(filter.sortType); filter.RemoveButtonVisibility = "Visible"; filter.CloseButtonVisibility = "Collapsed"; } SelectedFilter = filter; }