Exemple #1
0
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public async Task LoadSeriesIndexDataAsync()
        {
            if (IsLoading || IsIndexDataLoaded)
            {
                return;
            }
            LoadingText = "Loading series index data...";
            IsLoading   = true;
            try
            {
                var serIndex = await CachedClient.GetSeriesIndexAsync();

                var serVmList = serIndex.Select(series => new SeriesPreviewModel {
                    ID = series.Id, Title = series.Title
                });
                SeriesIndex = AlphaKeyGroup <SeriesPreviewModel> .CreateGroups(
                    serVmList,
                    new System.Globalization.CultureInfo("zh-CN"),
                    svm => svm.Title, true);

                IsIndexDataLoaded = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Data error", MessageBoxButton.OK);
            }
            IsLoading = false;
        }
Exemple #2
0
        public CollectionViewModel(ICollectionService service, CollectionCommandHelper commands)
        {
            _service  = service;
            _commands = commands;

            SongClickCommand = new RelayCommand <ItemClickEventArgs>(SongClickExecute);

            if (IsInDesignModeStatic)
            {
                _service.LoadLibrary();
            }

            SortedSongs = AlphaKeyGroup <Song> .CreateGroups(Service.Songs.Where(p => !p.IsTemp).ToList(),
                                                             CultureInfo.CurrentCulture, item => item.Name, true);

            SortedArtists = AlphaKeyGroup <Artist> .CreateGroups(Service.Artists.Where(p => p.Songs.Count > 0).ToList(),
                                                                 CultureInfo.CurrentCulture, item => item.Name, true);

            SortedAlbums = AlphaKeyGroup <Album> .CreateGroups(Service.Albums.Where(p => p.Songs.Count > 0).ToList(),
                                                               CultureInfo.CurrentCulture, item => item.Name, true);

            Service.Songs.CollectionChanged   += OnCollectionChanged;
            Service.Albums.CollectionChanged  += OnCollectionChanged;
            Service.Artists.CollectionChanged += OnCollectionChanged;
        }
Exemple #3
0
        private async void LoadMovies()
        {
            TraktMovie[] myMovies = await controller.getUserMovies();

            ObservableCollection <ListItemViewModel> tempItems = new ObservableCollection <ListItemViewModel>();

            foreach (TraktMovie movie in myMovies)
            {
                tempItems.Add(new ListItemViewModel()
                {
                    Name = movie.Title, ImageSource = movie.Images.Poster, Imdb = movie.imdb_id, SubItemText = movie.year.ToString(), Genres = movie.Genres
                });
            }

            if (tempItems.Count == 0)
            {
                tempItems.Add(new ListItemViewModel()
                {
                    Name = "Nothing Found"
                });
            }

            this.LoadingMovies = false;

            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                this.Indicator.IsVisible = false;
                UpdateMyMovieView(AlphaKeyGroup <ListItemViewModel> .CreateGroups(tempItems, Thread.CurrentThread.CurrentUICulture, (ListItemViewModel s) => { return(s.Name); }, true));
            });
        }
        public async void LoadContactAsync()
        {
            #region 获取所有系统中的用户,注:理论上这里是获取该用户的好友列表,以下代码仅仅是为了演示聊天的基础功能,所以默认是获取所有用户的列表。
            AVQuery <AVUser> query = new AVQuery <AVUser>();
            var users = await query.FindAsync();

            if (users != null)
            {
                foreach (var u in users)
                {
                    if (u.ObjectId != AVUser.CurrentUser.ObjectId)//当前用户不显示在联系人列表里面。
                    {
                        AllContacts.Add(new DemoContact(u));
                    }
                }
                ContactsListVM = AlphaKeyGroup <DemoContact> .CreateGroups(AllContacts, Thread.CurrentThread.CurrentUICulture,
                                                                           (DemoContact s) =>
                {
                    return(s.Nickname);
                }, true);

                NotifyPropertyChanged("ContactsListVM");
            }
            #endregion
        }
Exemple #5
0
        private void LoadArtists()
        {
            ((CollectionViewSource)Resources["ListOfArtists"]).Source = null;
            List <Artist> listOfArtists = Ctr_Artist.Current.GetArtists();

            listOfArtists.OrderBy(s => s.Name);

            List <AlphaKeyGroup <Artist> > itemSource = AlphaKeyGroup <Artist> .CreateGroups(listOfArtists,
                                                                                             CultureInfo.CurrentUICulture,
                                                                                             a => a.Name, true);

            ((CollectionViewSource)Resources["ListOfArtists"]).Source = itemSource;


            //DownloadImages(listOfArtists);
            OpenPage(NavMode == NavigationMode.Back);

            if (listOfArtists.Count == 0)
            {
                PageHelper.MainPage?.ShowEmptyLibraryNotice();
            }
            else
            {
                PageHelper.MainPage?.HideEmptyLibraryNotice();
            }
        }
        private void Configure()
        {
            TracksByDateAdded = new OptimizedObservableCollection <Track>(
                _libraryService.Tracks.OrderByDescending(p => p.CreatedAt));
            TracksByTitle = AlphaKeyGroup.CreateGroups(_libraryService.Tracks, CultureInfo.CurrentCulture,
                                                       item => ((Track)item).Title);
            TracksByArtist = AlphaKeyGroup.CreateGroups(_libraryService.Tracks, CultureInfo.CurrentCulture,
                                                        item => ((Track)item).DisplayArtist);
            TracksByAlbum = AlphaKeyGroup.CreateGroups(_libraryService.Tracks, CultureInfo.CurrentCulture,
                                                       item => ((Track)item).AlbumTitle);

            ArtistsByName = AlphaKeyGroup.CreateGroups(
                _libraryService.Artists.Where(p => !p.IsSecondaryArtist), CultureInfo.CurrentCulture,
                item => ((Artist)item).Name);

            AlbumsByDateAdded = new OptimizedObservableCollection <Album>(
                _libraryService.Albums.OrderByDescending(p => p.Tracks.Min(track => track.CreatedAt)));
            AlbumsByTitle = AlphaKeyGroup.CreateGroups(_libraryService.Albums, CultureInfo.CurrentCulture,
                                                       item => ((Album)item).Title);
            AlbumsByArtist = AlphaKeyGroup.CreateGroups(_libraryService.Albums, CultureInfo.CurrentCulture,
                                                        item => ((Album)item).Artist.Name);

            _libraryService.Tracks.CollectionChanged  += OnCollectionChanged;
            _libraryService.Artists.CollectionChanged += OnCollectionChanged;
            _libraryService.Albums.CollectionChanged  += OnCollectionChanged;
        }
Exemple #7
0
        private void ContactsOnSearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            var items = e.Results;
//                from Contact con in e.Results
//                from ContactPhoneNumber phone in con.PhoneNumbers
//                where phone != null
//                select con;
            List <Contact> contactsWithPhones = new List <Contact>();

            foreach (var contact in items)
            {
                if (contact.PhoneNumbers.Count() != 0)
                {
                    contactsWithPhones.Add(contact);
                }
            }

            List <AlphaKeyGroup <Contact> > userDataSource = AlphaKeyGroup <Contact> .CreateGroups(contactsWithPhones,
                                                                                                   System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                                                   (Contact s) => s.DisplayName, true);

            var observableUsersSource = new ObservableCollection <AlphaKeyGroup <Contact> >(userDataSource);

            ContactsList.ItemsSource = observableUsersSource;
//            ContactsList.DataContext = items;
        }
Exemple #8
0
        public void updateFbFriendLongListSelector()
        {
            List <AlphaKeyGroup <FbFriend> > DataSource = AlphaKeyGroup <FbFriend> .CreateGroups(App.fbFriendsData.friends,
                                                                                                 System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                                                 (FbFriend s) => { return(s.name); }, true);

            FriendList.ItemsSource = DataSource;
        }
Exemple #9
0
        void populateStations()
        {
            List <AlphaKeyGroup <DetailedStationList> > DataSource = AlphaKeyGroup <DetailedStationList> .CreateGroups(detailedStationList,
                                                                                                                       System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                                                                       (DetailedStationList s) => { return(s.stationName); }, true);

            lsMainLines.ItemsSource = DataSource;
        }
        public PlaylistViewModel(string title)
        {
            _playlist = new Playlist(title);
            _playlist.InitializeAsync().GetAwaiter().GetResult();
            Songs = AlphaKeyGroup <Song> .CreateGroups(_playlist.Songs, s => s.Title);

            RemoveSongCommand         = new ActionCommand <Song>(ExecuteRemoveSong);
            OpenInFileExplorerCommand = new ActionCommand <Song>(ExecuteOpenInFileExplorer);
        }
        public RedLineSchedule()
        {
            InitializeComponent();
            Loaded += RedLineSchedule_Loaded;
            List <AlphaKeyGroup <TrainInfo> > DataSource = AlphaKeyGroup <TrainInfo> .CreateGroups(source,
                                                                                                   System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                                                   (TrainInfo s) => { return(s.TripName); }, true);

            //List<string>DataSource = new List<string>();
            List.ItemsSource = DataSource;
        }
Exemple #12
0
        private async void LoadWatchlist()
        {
            TraktShow[] myShows = await controller.getUserWatchlist();

            List <String> seenShows = new List <string>();
            Dictionary <String, TraktShowProgress> progressDictionary = new Dictionary <string, TraktShowProgress>();

            if (fullprogress != null)
            {
                foreach (TraktShowProgress progress in fullprogress)
                {
                    if (!progressDictionary.ContainsKey(progress.Show.tvdb_id))
                    {
                        progressDictionary.Add(progress.Show.tvdb_id, progress);
                    }

                    if (progress.Progress.Percentage == 100)
                    {
                        seenShows.Add(progress.Show.tvdb_id);
                    }
                }
            }

            ObservableCollection <ListItemViewModel> tempItems = new ObservableCollection <ListItemViewModel>();

            foreach (TraktShow show in myShows)
            {
                tempItems.Add(new ListItemViewModel()
                {
                    Name = show.Title, ImageSource = show.Images.Poster, Imdb = show.imdb_id, Tvdb = show.tvdb_id, SubItemText = show.year.ToString(), Genres = show.Genres, Progress = progressDictionary.ContainsKey(show.tvdb_id) ? progressDictionary[show.tvdb_id].Progress.Percentage : Int16.Parse("0"), ProgressText = progressDictionary.ContainsKey(show.tvdb_id) ? progressDictionary[show.tvdb_id].Progress.Left + " episodes left to see!" : "Can't fetch unseen episodes :-("
                });
            }

            if (tempItems.Count == 0)
            {
                tempItems.Add(new ListItemViewModel()
                {
                    Name = "Nothing Found"
                });
            }

            this.LoadingMyShows = false;

            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                this.ShowItems = AlphaKeyGroup <ListItemViewModel> .CreateGroups(tempItems, Thread.CurrentThread.CurrentUICulture, (ListItemViewModel s) => { return(s.Name); }, true);
                App.MyShowsViewModel.NotifyPropertyChanged("ShowItems");

                if (this.Indicator != null)
                {
                    this.Indicator.IsVisible = false;
                }
            });
        }
        public async void LoadSongs()
        {
            ((CollectionViewSource)Resources["ListOfSongs"]).Source = null;

            List <AlphaKeyGroup <Song> > itemSource;
            Song aux = null;

            listOfSongs = Ctr_Song.Current.GetSongs(false);

            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("SongsSortBy"))
            {
                if (ApplicationData.Current.LocalSettings.Values["SongsSortBy"].ToString() == Sorting.SortByTitle)
                {
                    listOfSongs.OrderBy(s => s.Title);
                    itemSource = AlphaKeyGroup <Song> .CreateGroups(listOfSongs,
                                                                    CultureInfo.InvariantCulture,
                                                                    a => a.Title, true);
                }
                else if (ApplicationData.Current.LocalSettings.Values["SongsSortBy"].ToString() == Sorting.SortByArtist)
                {
                    listOfSongs.OrderBy(s => s.Artist);
                    itemSource = AlphaKeyGroup <Song> .CreateGroups(listOfSongs,
                                                                    CultureInfo.InvariantCulture,
                                                                    a => a.Artist, true);
                }
                else if (ApplicationData.Current.LocalSettings.Values["SongsSortBy"].ToString() == Sorting.SortByAlbum)
                {
                    listOfSongs.OrderBy(s => s.Album);
                    itemSource = AlphaKeyGroup <Song> .CreateGroups(listOfSongs,
                                                                    CultureInfo.InvariantCulture,
                                                                    a => a.Album, true);
                }
                else
                {
                    listOfSongs.OrderBy(s => s.Title);
                    itemSource = AlphaKeyGroup <Song> .CreateGroups(listOfSongs,
                                                                    CultureInfo.InvariantCulture,
                                                                    a => a.Artist, true);
                }
            }
            else
            {
                ApplicationData.Current.LocalSettings.Values["SongsSortBy"] = Sorting.SortByArtist;

                listOfSongs.OrderBy(s => s.Artist);
                itemSource = AlphaKeyGroup <Song> .CreateGroups(listOfSongs,
                                                                CultureInfo.InvariantCulture,
                                                                a => a.Artist, true);
            }

            ((CollectionViewSource)Resources["ListOfSongs"]).Source = itemSource;

            OpenPage(NavMode == NavigationMode.Back);
        }
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;


            List <AlphaKeyGroup <GroceryItem> > DataSource = AlphaKeyGroup <GroceryItem> .CreateGroups(source,
                                                                                                       CultureInfo.CurrentUICulture,
                                                                                                       (GroceryItem gi) => { return(gi.ItemName); },
                                                                                                       true);
        }
        public async void LoadAlbums()
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
            {
                ((CollectionViewSource)Resources["ListOfAlbums"]).Source = null;
            });

            List <Album> listOfAlbums = Ctr_Album.Current.GetAlbums();
            List <AlphaKeyGroup <Album> > itemSource;

            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("AlbumsSortBy"))
            {
                if (ApplicationData.Current.LocalSettings.Values["AlbumsSortBy"].ToString() == Sorting.SortByTitle)
                {
                    //listOfAlbums.OrderBy(s => s.Name);
                    itemSource = AlphaKeyGroup <Album> .CreateGroups(listOfAlbums,
                                                                     CultureInfo.InvariantCulture,
                                                                     a => a.Name, true);
                }
                else if (ApplicationData.Current.LocalSettings.Values["AlbumsSortBy"].ToString() == Sorting.SortByArtist)
                {
                    //listOfAlbums.OrderBy(s => s.Artist);
                    itemSource = AlphaKeyGroup <Album> .CreateGroups(listOfAlbums,
                                                                     CultureInfo.InvariantCulture,
                                                                     a => a.Artist, true);
                }
                else if (ApplicationData.Current.LocalSettings.Values["AlbumsSortBy"].ToString() == Sorting.SortByYear)
                {
                    //listOfAlbums.OrderBy(s => s.Year);
                    itemSource = AlphaKeyGroup <Album> .CreateGroups(listOfAlbums,
                                                                     CultureInfo.InvariantCulture,
                                                                     a => Convert.ToString(a.Year), true);
                }
                else
                {
                    itemSource = AlphaKeyGroup <Album> .CreateGroups(listOfAlbums,
                                                                     CultureInfo.InvariantCulture,
                                                                     a => a.Name, true);
                }
            }
            else
            {
                ApplicationData.Current.LocalSettings.Values["AlbumsSortBy"] = Sorting.SortByTitle;
                itemSource = AlphaKeyGroup <Album> .CreateGroups(listOfAlbums,
                                                                 CultureInfo.InvariantCulture,
                                                                 a => a.Name, true);
            }

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
            {
                ((CollectionViewSource)Resources["ListOfAlbums"]).Source = itemSource;
            });
        }
 private void initGroupedItems()
 {
     if (ShouldGroup)
     {
         GroupedMusicItems = AlphaKeyGroup <MusicItem> .CreateGroups(
             MusicItems,
             GroupKeyOf);
     }
     else
     {
         GroupedMusicItems = new List <AlphaKeyGroup <MusicItem> >();
     }
 }
        private void Configure()
        {
            PeopleByName = new OptimizedObservableCollection <PersonViewModel>(_peopleService.People.OrderBy(p => p.Person.Name.Sort));

            PeopleByRank = new OptimizedObservableCollection <PersonViewModel>(_peopleService.People.OrderBy(p => p.Person.Stats.Rank));

            PeopleBySource = new OptimizedObservableCollection <AlphaKeyGroup>(AlphaKeyGroup.CreateGroups(_peopleService.People, CultureInfo.CurrentUICulture,
                                                                                                          x => ((PersonViewModel)x).Person.Name.Sort));

            PeopleByCountry = new OptimizedObservableCollection <AlphaKeyGroup>(AlphaKeyGroup.CreateGroups(_peopleService.People, CultureInfo.CurrentUICulture,
                                                                                                           x => ((PersonViewModel)x).Person.Place));

            Loaded?.Invoke(this, EventArgs.Empty);
        }
        public PivotPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            this.navigationHelper            = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;

            List <AlphaKeyGroup <GroceryItem> > DataSource = AlphaKeyGroup <GroceryItem> .CreateGroups(source,
                                                                                                       CultureInfo.CurrentUICulture,
                                                                                                       (GroceryItem gi) => { return(gi.ItemName); },
                                                                                                       true);
        }
Exemple #19
0
        public LongListSelectorSample()
        {
            InitializeComponent();
            DataContext = this;

            Buddies = AlphaKeyGroup <Person> .CreateGroups(AllPeople.Current, CultureInfo.CurrentUICulture, (p) => { return(p.FirstName); }, true);

            buddies.SelectionChanged += PersonSelectionChanged;

            LoadLinqMovies();

            MessageBox.Show(
                @"The LongListSelector is now built into Windows Phone 8, for better performance and new features including grid layout mode and ""sticky headers"".

This sample and the sample code demonstrates how to use the new, improved LongListSelector.");
        }
Exemple #20
0
        private void Callback(List <Model.Customer> listOfCustomer)
        {
            if (listOfCustomer != null)
            {
                foreach (var customer in listOfCustomer.OrderBy(x => x.FirstName).OrderBy(x => x.LastName))
                {
                    Customers.Add(new CustomerViewModel(customer));
                }

                var groups = AlphaKeyGroup <CustomerViewModel> .CreateGroups(Customers, System.Threading.Thread.CurrentThread.CurrentUICulture, s => { return(s.LastName); }, true);

                foreach (var group in groups)
                {
                    CustomersGroup.Add(group);
                }
            }
        }
        public async Task Sync()
        {
            if (!_playlist.HasSyncFolders)
            {
                Toast.ShowMessage(App.ResourceLoader.GetString("Message_NoFoldersToSync"));
                return;
            }

            var msgBox = new MessageBox
            {
                Title             = App.ResourceLoader.GetString("MessageBox_Title_SyncPlaylist"),
                Message           = App.ResourceLoader.GetString("MessageBox_Message_SyncPlaylist"),
                ButtonsVisibility = Visibility.Collapsed,
            };

            msgBox.Show();

            FlatSongs = null;
            var songsCount = _playlist.Songs.Count;
            await _playlist.Sync();

            var newGroups = AlphaKeyGroup <Song> .CreateGroups(_playlist.Songs, s => s.Title);

            foreach (var group in Songs)
            {
                group.Clear();
                var newGroup = newGroups.FirstOrDefault(g => g.Key == group.Key);
                if (newGroup == null || newGroup.Count == 0)
                {
                    continue;
                }

                foreach (var item in newGroup)
                {
                    group.Add(item);
                }
            }

            if (PlayerViewModel.PlaylistTitle == Title && songsCount != _playlist.Songs.Count)
            {
                ResetPlayerViewModel();
            }

            msgBox.Close();
        }
        private void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
        {
            try
            {
                //Bind the results to the user interface.
                //ContactResultsData.DataContext = e.Results;
                ContactResultsData.ItemsSource = AlphaKeyGroup <Contact> .CreateGroups(e.Results,
                                                                                       System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                                       (Contact s) => { return(s.DisplayName); }, true);
            }
            catch (System.Exception ex)
            {
                ContactResultsLabel.Text = "Unable to read contacts";
                ApplicationBar.IsVisible = true;
            }

            ContactResultsLabel.Text = e.Results.Any() ? "Select Members..." : "No contacts found.";
        }
        public DesignLibraryCollectionService(ILibraryService libraryService)
        {
            TracksByDateAdded = new OptimizedObservableCollection <Track>(
                libraryService.Tracks.OrderByDescending(p => p.CreatedAt));
            TracksByTitle = AlphaKeyGroup.CreateGroups(libraryService.Tracks, CultureInfo.CurrentCulture,
                                                       item => ((Track)item).Title);
            TracksByArtist = AlphaKeyGroup.CreateGroups(libraryService.Tracks, CultureInfo.CurrentCulture,
                                                        item => ((Track)item).DisplayArtist);
            TracksByAlbum = AlphaKeyGroup.CreateGroups(libraryService.Tracks, CultureInfo.CurrentCulture,
                                                       item => ((Track)item).AlbumTitle);

            ArtistsByName = AlphaKeyGroup.CreateGroups(
                libraryService.Artists.Where(p => !p.IsSecondaryArtist), CultureInfo.CurrentCulture,
                item => ((Artist)item).Name);

            AlbumsByTitle = AlphaKeyGroup.CreateGroups(libraryService.Albums, CultureInfo.CurrentCulture,
                                                       item => ((Album)item).Title);
        }
Exemple #24
0
        /// <summary>
        /// Load poems from db
        /// </summary>
        public void LoadData()
        {
            using (var context = DbContext.Create())
            {
                PoemDataSource = AlphaKeyGroup <IPoem> .CreateGroups(context.Poems,
                                                                     System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                     s => s.Title, true);

                var favPoems = context.Poems.Where(p => p.Bookmarked).ToList();
                FavoritePoemDataSource = AlphaKeyGroup <IPoem> .CreateGroups(favPoems,
                                                                             System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                             s => s.Title, true);

                var compleatedPoems = context.Poems.Where(p => p.Compleated).ToList();
                CompleatedPoemDataSource = AlphaKeyGroup <IPoem> .CreateGroups(compleatedPoems,
                                                                               System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                               s => s.Title, true);
            }
        }
        private void ResetSortedCollections()
        {
            var dateAdded = new OptimizedObservableCollection <Track>(
                _libraryService.Tracks.OrderByDescending(p => p.CreatedAt));

            TracksByDateAdded.SwitchTo(dateAdded);

            var tracksByTitle = AlphaKeyGroup.CreateGroups(_libraryService.Tracks, CultureInfo.CurrentCulture,
                                                           item => ((Track)item).Title);

            TracksByTitle.SwitchTo(tracksByTitle);

            var tracksByArtist = AlphaKeyGroup.CreateGroups(_libraryService.Tracks, CultureInfo.CurrentCulture,
                                                            item => ((Track)item).DisplayArtist);

            TracksByArtist.SwitchTo(tracksByArtist);

            var tracksByAlbum = AlphaKeyGroup.CreateGroups(_libraryService.Tracks, CultureInfo.CurrentCulture,
                                                           item => ((Track)item).AlbumTitle);

            TracksByAlbum.SwitchTo(tracksByAlbum);

            var artistsByName = AlphaKeyGroup.CreateGroups(
                _libraryService.Artists.Where(p => !p.IsSecondaryArtist), CultureInfo.CurrentCulture,
                item => ((Artist)item).Name);

            ArtistsByName = artistsByName;

            var albumsByDateAdded = new OptimizedObservableCollection <Album>(
                _libraryService.Albums.OrderByDescending(p => p.Tracks.Min(track => track.CreatedAt)));

            AlbumsByDateAdded = albumsByDateAdded;

            var albumsByTitle = AlphaKeyGroup.CreateGroups(_libraryService.Albums, CultureInfo.CurrentCulture,
                                                           item => ((Album)item).Title);

            AlbumsByTitle = albumsByTitle;

            var albumsByArtist = AlphaKeyGroup.CreateGroups(_libraryService.Albums, CultureInfo.CurrentCulture,
                                                            item => ((Album)item).Artist.Name);

            AlbumsByArtist = albumsByArtist;
        }
Exemple #26
0
        async void AddFriendView_Loaded(object sender, RoutedEventArgs e)
        {
            List <FacebookUser> data = await FacebookMethods.DownloadFriendsList();

            if (data != null)
            {
                List <AlphaKeyGroup <FacebookUser> > DataSource = new List <AlphaKeyGroup <FacebookUser> >();

                DataSource = AlphaKeyGroup <FacebookUser> .CreateGroups(data,
                                                                        System.Threading.Thread.CurrentThread.CurrentUICulture,
                                                                        (FacebookUser s) => { return(s.Name); }, true);

                lstFriends.ItemsSource = DataSource;
            }
            else
            {
                MessageBox.Show(AppResources.FriendAddView_Txt_FriendDownloadError, AppResources.ApplicationTitle, MessageBoxButton.OK);
            }
            pgrbDownloadedCompleted.Visibility = Visibility.Collapsed;
        }
        private void BindDataContext()
        {
            var birthdays = BirthdayUtility.GetBirthdays();

            LocalizeBirthdayText(birthdays);

            birthdays.AlphaGroupAllBirthdays = AlphaKeyGroup <FriendBirthday> .CreateGroups
                                               (
                birthdays.AllBirthdays,
                Thread.CurrentThread.CurrentUICulture,
                f => f.Name, true
                                               );

            BirthdayCardList.SelectedItems.Clear();
            birthdays.BirthdayCards = new ObservableCollection <CardEntity>();
            DataContext             = birthdays;

            foreach (var card in BirthdayUtility.GetBirthdayCards())
            {
                birthdays.BirthdayCards.Add(card);
            }
        }
Exemple #28
0
        /// <summary>
        /// Creating an aplabetical sorted group of the contacts in the store.
        /// </summary>
        /// <param name="items">Flat list of contacts</param>
        private List <AlphaKeyGroup <ContactItem> > alphaGroupSorting(IEnumerable <ContactItem> items)
        {
            ///////////////////////////////////////////////////
            //   To create the list grouped by letter, we add
            //   1) the list of items we're going to group
            //   2) how we are going to group them (in this case, by Title
            //   3) if we want to sort them (true)
            //
            //   This creates an alphabetized list of lists in which the items
            //   in each list all starts with the same letter. This type is
            //   recognized by our GridView and ListView controls and can
            //   be grouped appropriately as well as being responsive to a
            //   SemanticZoom control for the sake of a jumplist interaction
            ///////////////////////////////////////////////////

            var returnGroup = AlphaKeyGroup <ContactItem> .CreateGroups(
                items,                                         // ungrouped list of items
                (ContactItem s) => { return(s.ContactName); }, // the property to sort
                true);                                         // order the items alphabetically

            return(returnGroup);
        }
        public async Task InitializeData(bool withoutCache = false)
        {
            GroupedProjects = null;
            FlatProjects    = null;
            IsDataLoaded    = false;

            await jiraService.GetUserProfileAsync(App.UserName);

            DisplayPicture = jiraService.GetDisplayPicture(App.UserName).ToBitmapImage();

            var projects = await jiraService.GetProjects(App.ServerUrl, App.UserName, App.Password, withoutCache);

            GroupedProjects = AlphaKeyGroup <Project> .CreateGroups(projects, System.Threading.Thread.CurrentThread.CurrentUICulture, s => s.Name, true);

            FlatProjects = projects;
            Favourites   = await jiraService.GetFavourites();

            IsFavouriteExist = Favourites.Count > 0;

            IsGroupingEnabled = true;
            IsGroupingEnabled = new IsolatedStorageProperty <bool>(Settings.IsGroupingEnabled, true).Value;
            IsDataLoaded      = true;
        }
        public CollectionViewModel(ICollectionService service, IMiscellaneousService misc, CollectionCommandHelper commands)
        {
            _service  = service;
            _commands = commands;
            _misc     = misc;

            SongClickCommand  = new Command <ItemClickEventArgs>(SongClickExecute);
            VideoClickCommand = new Command <ItemClickEventArgs>(VideoClickExecute);

            SortedSongs = AlphaKeyGroup <Song> .CreateGroups(Service.Songs.Where(p => !p.IsTemp).ToList(),
                                                             CultureInfo.CurrentCulture, item => item.Name, true);

            SortedArtists = AlphaKeyGroup <Artist> .CreateGroups(Service.Artists.Where(p => p.Songs.Count > 0).ToList(),
                                                                 CultureInfo.CurrentCulture, item => item.Name, true);

            SortedAlbums = AlphaKeyGroup <Album> .CreateGroups(Service.Albums.Where(p => p.Songs.Count > 0).ToList(),
                                                               CultureInfo.CurrentCulture, item => item.Name, true);

            SortedVideos = AlphaKeyGroup <Video> .CreateGroups(Service.Videos, CultureInfo.CurrentCulture, item => item.Title, true);//Service.Videos;


            InitAsync();
        }