private void OnAlphabeticalMenuDropDownOpening(object sender, EventArgs e) { if (!this.alphabeticalMenu.HasDropDownItems) { List <IFavorite> favorites = new SortableList <IFavorite>(PersistedFavorites) .SortByProperty("Name", SortOrder.Ascending); CreateAlphabeticalFavoriteMenuItems(favorites); var alphaMenuVisible = this.alphabeticalMenu.DropDownItems.Count > 0; this.alphabeticalMenu.Visible = alphaMenuVisible; } }
internal SortableList <FavoriteConfigurationElement> ToList() { var favorites = new SortableList <FavoriteConfigurationElement>(); foreach (FavoriteConfigurationElement favorite in this) { favorites.Add(favorite); } return(favorites); }
/// <summary> /// Replace the favorites in binding source doesnt affect performance /// </summary> private void UpdateFavoritesBindingSource(SortableList <IFavorite> newData) { var data = ConvertFavoritesToViewModel(newData); var lastSortedColumn = this.dataGridFavorites.FindLastSortedColumn(); if (lastSortedColumn != null) // keep last ordered column { var backupGliph = lastSortedColumn.HeaderCell.SortGlyphDirection; this.bsFavorites.DataSource = data.SortByProperty(lastSortedColumn.DataPropertyName, backupGliph); lastSortedColumn.HeaderCell.SortGlyphDirection = backupGliph; } else { this.bsFavorites.DataSource = data; } UpdateCountLabels(); }
private SortableList <FavoriteViewModel> ConvertFavoritesToViewModel(SortableList <IFavorite> source) { var sortedFavorites = source.Select(favorite => new FavoriteViewModel(favorite, this.persistence)); return(new SortableList <FavoriteViewModel>(sortedFavorites)); }
private void FavoritesSearchBox_Canceled(object sender, EventArgs e) { this.foundFavorites = new SortableList <IFavorite>(); this.UpdateFavoritesBindingSource(); }
private void FavoritesSearchBoxFound(object sender, FavoritesFoundEventArgs e) { this.foundFavorites = new SortableList <IFavorite>(e.Favorites); this.UpdateFavoritesBindingSource(); }