IItemContainerGenerator.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using Perspex.Controls.Templates;
  7. namespace Perspex.Controls.Generators
  8. {
  9. /// <summary>
  10. /// Creates containers for items and maintains a list of created containers.
  11. /// </summary>
  12. public interface IItemContainerGenerator
  13. {
  14. /// <summary>
  15. /// Gets the currently realized containers.
  16. /// </summary>
  17. IEnumerable<IControl> Containers { get; }
  18. /// <summary>
  19. /// Signalled whenever new containers are initialized.
  20. /// </summary>
  21. IObservable<ItemContainers> ContainersInitialized { get; }
  22. /// <summary>
  23. /// Creates container controls for a collection of items.
  24. /// </summary>
  25. /// <param name="startingIndex">
  26. /// The index of the first item of the data in the containing collection.
  27. /// </param>
  28. /// <param name="items">The items.</param>
  29. /// <param name="selector">An optional member selector.</param>
  30. /// <returns>The created controls.</returns>
  31. IList<IControl> CreateContainers(
  32. int startingIndex,
  33. IEnumerable items,
  34. IMemberSelector selector);
  35. /// <summary>
  36. /// Removes a set of created containers from the index and returns the removed controls.
  37. /// </summary>
  38. /// <param name="startingIndex">
  39. /// The index of the first item of the data in the containing collection.
  40. /// </param>
  41. /// <param name="count">The the number of items to remove.</param>
  42. /// <returns>The removed containers.</returns>
  43. IList<IControl> RemoveContainers(int startingIndex, int count);
  44. /// <summary>
  45. /// Clears the created containers from the index and returns the removed controls.
  46. /// </summary>
  47. /// <returns>The removed controls.</returns>
  48. IList<IControl> ClearContainers();
  49. /// <summary>
  50. /// Gets the container control representing the item with the specified index.
  51. /// </summary>
  52. /// <param name="index">The index.</param>
  53. /// <returns>The container, or null if no container created.</returns>
  54. IControl ContainerFromIndex(int index);
  55. /// <summary>
  56. /// Gets the index of the specified container control.
  57. /// </summary>
  58. /// <param name="container">The container.</param>
  59. /// <returns>The index of the container, or -1 if not found.</returns>
  60. int IndexFromContainer(IControl container);
  61. }
  62. }