PageRenderTime 60ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/toolkit/PhoneToolkitSample/Data/MoviesByCategory.cs

https://bitbucket.org/jeremejevs/word-steps
C# | 55 lines | 42 code | 9 blank | 4 comment | 3 complexity | 3e6c0aa08562daee9a6dc3c314bb3cc4 MD5 | raw file
  1. // (c) Copyright Microsoft Corporation.
  2. // This source is subject to the Microsoft Public License (Ms-PL).
  3. // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
  4. // All other rights reserved.
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Windows.Input;
  9. namespace PhoneToolkitSample.Data
  10. {
  11. public class MoviesByCategory : ObservableCollection<MoviesInCategory>
  12. {
  13. public MoviesByCategory()
  14. {
  15. List<string> sortedCategories = new List<string>(Movie.Categories);
  16. sortedCategories.Sort();
  17. foreach (string category in sortedCategories)
  18. {
  19. MoviesInCategory group = new MoviesInCategory(category);
  20. this.Add(group);
  21. for (int i = 0; i < 5; ++i)
  22. {
  23. group.Add(Movie.CreateRandom(category));
  24. }
  25. }
  26. }
  27. }
  28. public class MoreCommand : ICommand
  29. {
  30. #region ICommand Members
  31. public bool CanExecute(object parameter)
  32. {
  33. return true;
  34. }
  35. public event EventHandler CanExecuteChanged;
  36. public void Execute(object parameter)
  37. {
  38. MoviesInCategory group = parameter as MoviesInCategory;
  39. if (group != null)
  40. {
  41. group.Add(Movie.CreateRandom(group.Key));
  42. }
  43. }
  44. #endregion
  45. }
  46. }