DocumentProvider.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using PixiEditor.Models.Controllers;
  2. using PixiEditor.Models.DataHolders;
  3. using PixiEditor.Models.Layers;
  4. using System.Collections.Generic;
  5. namespace PixiEditor.Models.Services
  6. {
  7. /// <summary>
  8. /// Provides the active document and it's values like active layer and reference layer
  9. /// </summary>
  10. public class DocumentProvider
  11. {
  12. private readonly BitmapManager _bitmapManager;
  13. public DocumentProvider(BitmapManager bitmapManager)
  14. {
  15. _bitmapManager = bitmapManager;
  16. }
  17. /// <summary>
  18. /// Gets all opened documents
  19. /// </summary>
  20. public IEnumerable<Document> GetDocuments() => _bitmapManager.Documents;
  21. /// <summary>
  22. /// Gets the active document
  23. /// </summary>
  24. public Document GetDocument() => _bitmapManager.ActiveDocument;
  25. /// <summary>
  26. /// Get the layers of the opened document
  27. /// </summary>
  28. public IEnumerable<Layer> GetLayers() => _bitmapManager.ActiveDocument?.Layers;
  29. /// <summary>
  30. /// Gets the layer structure of the opened document
  31. /// </summary>
  32. public LayerStructure GetStructure() => _bitmapManager.ActiveDocument?.LayerStructure;
  33. /// <summary>
  34. /// Gets the active layer
  35. /// </summary>
  36. public Layer GetLayer() => _bitmapManager.ActiveLayer;
  37. /// <summary>
  38. /// Gets the surface of the active layer
  39. /// </summary>
  40. public Surface GetSurface() => _bitmapManager.ActiveLayer?.LayerBitmap;
  41. /// <summary>
  42. /// Gets the reference layer of the active document
  43. /// </summary>
  44. public Layer GetReferenceLayer() => _bitmapManager.ActiveDocument?.ReferenceLayer;
  45. /// <summary>
  46. /// Gets the reference layer surface of the active document
  47. /// </summary>
  48. public Surface GetReferenceSurface() => _bitmapManager.ActiveDocument?.ReferenceLayer?.LayerBitmap;
  49. /// <summary>
  50. /// Gets the renderer for the active document
  51. /// </summary>
  52. public LayerStackRenderer GetRenderer() => _bitmapManager.ActiveDocument?.Renderer;
  53. /// <summary>
  54. /// Gets the renderer for the reference layer of the active document
  55. /// </summary>
  56. public SingleLayerRenderer GetReferenceRenderer() => _bitmapManager.ActiveDocument?.ReferenceLayerRenderer;
  57. }
  58. }