暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ProgressOperationHandler.cs 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using Codice.Client.BaseCommands;
  2. using Codice.Client.Commands.CheckIn;
  3. using Codice.Client.Common;
  4. using Codice.CM.Common;
  5. using PlasticGui;
  6. using PlasticGui.WorkspaceWindow;
  7. namespace Unity.PlasticSCM.Editor.Developer
  8. {
  9. internal class ProgressOperationHandler
  10. {
  11. internal ProgressOperationHandler(WorkspaceInfo wkInfo, WorkspaceWindow workspaceWindow)
  12. {
  13. mWkInfo = wkInfo;
  14. mWorkspaceWindow = workspaceWindow;
  15. }
  16. internal void Update(double elapsedSeconds)
  17. {
  18. if (mUpdateProgress == null)
  19. return;
  20. mSecondsSinceLastProgressUpdate += elapsedSeconds;
  21. if (mSecondsSinceLastProgressUpdate > UPDATE_INTERVAL_SECONDS)
  22. {
  23. mUpdateProgress.OnUpdateProgress();
  24. mSecondsSinceLastProgressUpdate -= UPDATE_INTERVAL_SECONDS;
  25. }
  26. }
  27. internal bool CheckOperationInProgress()
  28. {
  29. if (IsOperationInProgress())
  30. {
  31. GuiMessage.ShowInformation(
  32. PlasticLocalization.GetString(PlasticLocalization.Name.OperationRunning),
  33. PlasticLocalization.GetString(PlasticLocalization.Name.OperationInProgress));
  34. return true;
  35. }
  36. return false;
  37. }
  38. internal bool IsOperationInProgress()
  39. {
  40. return mProgress != null
  41. || mUpdateProgress != null
  42. || mCheckinProgress != null;
  43. }
  44. internal void ShowProgress()
  45. {
  46. mProgress = new GenericProgress(mWorkspaceWindow);
  47. }
  48. internal void RefreshProgress(ProgressData progressData)
  49. {
  50. mProgress.RefreshProgress(progressData);
  51. }
  52. internal void EndProgress()
  53. {
  54. mProgress = null;
  55. mWorkspaceWindow.Progress.ResetProgress();
  56. mWorkspaceWindow.RequestRepaint();
  57. }
  58. internal void ShowUpdateProgress(string title, UpdateNotifier notifier)
  59. {
  60. mUpdateProgress = new UpdateProgress(
  61. notifier, mWkInfo.ClientPath, title, mWorkspaceWindow);
  62. mUpdateProgress.OnUpdateProgress();
  63. mSecondsSinceLastProgressUpdate = 0;
  64. }
  65. internal void ShowCheckinProgress()
  66. {
  67. mCheckinProgress = new CheckinProgress(mWkInfo, mWorkspaceWindow);
  68. }
  69. internal void RefreshCheckinProgress(
  70. CheckinStatus checkinStatus,
  71. BuildProgressSpeedAndRemainingTime.ProgressData progressData)
  72. {
  73. mCheckinProgress.Refresh(checkinStatus, progressData);
  74. }
  75. internal void CancelCheckinProgress()
  76. {
  77. mCheckinProgress.CancelPressed = true;
  78. }
  79. internal void EndUpdateProgress()
  80. {
  81. mUpdateProgress = null;
  82. mWorkspaceWindow.Progress.ResetProgress();
  83. mWorkspaceWindow.RequestRepaint();
  84. }
  85. internal void EndCheckinProgress()
  86. {
  87. mCheckinProgress = null;
  88. mWorkspaceWindow.Progress.ResetProgress();
  89. mWorkspaceWindow.RequestRepaint();
  90. }
  91. internal bool HasCheckinCancelled()
  92. {
  93. return mCheckinProgress.CancelPressed;
  94. }
  95. double mSecondsSinceLastProgressUpdate = 0;
  96. GenericProgress mProgress;
  97. UpdateProgress mUpdateProgress;
  98. CheckinProgress mCheckinProgress;
  99. WorkspaceInfo mWkInfo;
  100. WorkspaceWindow mWorkspaceWindow;
  101. const double UPDATE_INTERVAL_SECONDS = 0.5;
  102. }
  103. }