IProgressEvents.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Windows.Forms;
  3. namespace PaintDotNet
  4. {
  5. public interface IProgressEvents<TItemInfo>
  6. {
  7. /// <summary>
  8. /// This method is called at the very beginning of the operation.
  9. /// </summary>
  10. /// <param name="owner">
  11. /// If the operation has a modal window open, this represents it. Otherwise, this is null and you should
  12. /// use your own current modal window.</param>
  13. /// <param name="callWhenUIShown">
  14. /// You must call this method after initializing any UI you want to display.
  15. /// If you will not be displaying UI, you must call this anyway.</param>
  16. /// <param name="cancelSink">
  17. /// An object that can be used to cancel the operation at any time after callWhenUIShown is invoked,
  18. /// and any time before EndOperation() is called.
  19. /// </param>
  20. /// <remarks>
  21. /// This method must not return until EndOperation() is called. Note that EndOperation() will
  22. /// be called from a separate thread.
  23. /// </remarks>
  24. void BeginOperation(IWin32Window owner, EventHandler callWhenUIShown, ICancelable cancelSink);
  25. /// <summary>
  26. /// Called to report the total number of work items that are part of the operation.
  27. /// </summary>
  28. /// <param name="itemCount">The total number of work items that are part of the operation.</param>
  29. void SetItemCount(int itemCount);
  30. /// <summary>
  31. /// Called to change which work item of the operation is in progress.
  32. /// </summary>
  33. /// <param name="itemOrdinal"></param>
  34. /// <remarks>
  35. /// This method is called after BeginOperation() but before BeginItem(),
  36. /// or after EndItem() but before BeginItem().
  37. /// </remarks>
  38. void SetItemOrdinal(int itemOrdinal);
  39. /// <summary>
  40. /// Called to report information about the current work item.
  41. /// </summary>
  42. /// <param name="itemInfo">Operation-dependent information about the current work item.</param>
  43. void SetItemInfo(TItemInfo itemInfo);
  44. /// <summary>
  45. /// Reports the total number of work units that are involved in completing the current work item.
  46. /// </summary>
  47. /// <param name="totalWork">The total number of work units that comprise the current work item.</param>
  48. void SetItemWorkTotal(long totalWork);
  49. /// <summary>
  50. /// Called when a work item is starting.
  51. /// </summary>
  52. /// <param name="itemName"></param>
  53. void BeginItem();
  54. /// <summary>
  55. /// Reports the total amount of progress for the current work item.
  56. /// </summary>
  57. /// <param name="totalProgress">The total number of work units that have completed for the current work item.</param>
  58. void SetItemWorkProgress(long totalProgress);
  59. /// <summary>
  60. /// Called when there is an error while completing the current work item.
  61. /// </summary>
  62. /// <param name="ex">The exception that was encountered while completing the current work item.</param>
  63. /// <returns>You must return a value from the ItemFailedUserChoice enumeration.</returns>
  64. WorkItemFailureAction ReportItemFailure(Exception ex);
  65. /// <summary>
  66. /// Called after a work item is finished.
  67. /// </summary>
  68. void EndItem(WorkItemResult result);
  69. /// <summary>
  70. /// Called after the operation is complete.
  71. /// </summary>
  72. /// <param name="result">Indicates whether the operation finished, or was cancelled.</param>
  73. /// <remarks>
  74. /// Even if the operation finished, individual work items may not have succeeded.
  75. /// You will need to track the data passed to to EndItem() ReportItemError() to be able to monitor this.
  76. /// You must close any UI shown during BeginOperation(), and then return from that method.
  77. /// </remarks>
  78. void EndOperation(OperationResult result);
  79. }
  80. }