IPlatformProvider.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. namespace Caliburn.Micro.Core {
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. /// <summary>
  6. /// Interface for platform specific operations that need enlightenment.
  7. /// </summary>
  8. public interface IPlatformProvider {
  9. #region Execute
  10. /// <summary>
  11. /// Indicates whether or not the framework is in design-time mode.
  12. /// </summary>
  13. bool InDesignMode { get; }
  14. /// <summary>
  15. /// Executes the action on the UI thread asynchronously.
  16. /// </summary>
  17. /// <param name="action">The action to execute.</param>
  18. void BeginOnUIThread(Action action);
  19. /// <summary>
  20. /// Executes the action on the UI thread asynchronously.
  21. /// </summary>
  22. /// <param name = "action">The action to execute.</param>
  23. Task OnUIThreadAsync(Action action);
  24. /// <summary>
  25. /// Executes the action on the UI thread.
  26. /// </summary>
  27. /// <param name = "action">The action to execute.</param>
  28. void OnUIThread(Action action);
  29. #endregion
  30. #region ViewAware
  31. /// <summary>
  32. /// Used to retrieve the root, non-framework-created view.
  33. /// </summary>
  34. /// <param name="view">The view to search.</param>
  35. /// <returns>The root element that was not created by the framework.</returns>
  36. /// <remarks>In certain instances the services create UI elements.
  37. /// For example, if you ask the window manager to show a UserControl as a dialog, it creates a window to host the UserControl in.
  38. /// The WindowManager marks that element as a framework-created element so that it can determine what it created vs. what was intended by the developer.
  39. /// Calling GetFirstNonGeneratedView allows the framework to discover what the original element was.
  40. /// </remarks>
  41. object GetFirstNonGeneratedView(object view);
  42. /// <summary>
  43. /// Executes the handler the fist time the view is loaded.
  44. /// </summary>
  45. /// <param name="view">The view.</param>
  46. /// <param name="handler">The handler.</param>
  47. void ExecuteOnFirstLoad(object view, Action<object> handler);
  48. /// <summary>
  49. /// Executes the handler the next time the view's LayoutUpdated event fires.
  50. /// </summary>
  51. /// <param name="view">The view.</param>
  52. /// <param name="handler">The handler.</param>
  53. void ExecuteOnLayoutUpdated(object view, Action<object> handler);
  54. /// <summary>
  55. /// Get the close action for the specified view model.
  56. /// </summary>
  57. /// <param name="viewModel">The view model to close.</param>
  58. /// <param name="views">The associated views.</param>
  59. /// <param name="dialogResult">The dialog result.</param>
  60. /// <returns>An <see cref="Action"/> to close the view model.</returns>
  61. Action GetViewCloseAction(object viewModel, ICollection<object> views, bool? dialogResult);
  62. #endregion
  63. }
  64. }