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