A game about forced loneliness, made by TACStudios
1using System;
2
3using Codice.Client.BaseCommands;
4using Codice.Client.BaseCommands.CheckIn.Progress;
5using Codice.Client.Commands.CheckIn;
6using Codice.CM.Common;
7using PlasticGui;
8using PlasticGui.WorkspaceWindow;
9
10namespace Unity.PlasticSCM.Editor.Developer
11{
12 internal class CheckinProgress
13 {
14 internal bool CancelPressed;
15
16 internal CheckinProgress(WorkspaceInfo wkInfo, WorkspaceWindow workspaceWindow)
17 {
18 mWkInfo = wkInfo;
19 mWorkspaceWindow = workspaceWindow;
20
21 mWorkspaceWindow.Progress.CanCancelProgress = true;
22
23 mProgressRender = new CheckinUploadProgressRender(
24 PlasticLocalization.GetString(
25 PlasticLocalization.Name.CheckinProgressMultiThreadUploading),
26 PlasticLocalization.GetString(
27 PlasticLocalization.Name.CheckinProgressMultiThreadNumOfBlocks),
28 PlasticLocalization.GetString(PlasticLocalization.Name.CheckinProgressUploadingFiles),
29 PlasticLocalization.GetString(
30 PlasticLocalization.Name.CheckinProgressUploadingFileData),
31 PlasticLocalization.GetString(PlasticLocalization.Name.CheckinProgressOf),
32 PlasticLocalization.GetString(
33 PlasticLocalization.Name.RemainingProgressMessage));
34 }
35
36 internal void Refresh(
37 CheckinStatus checkinStatus,
38 BuildProgressSpeedAndRemainingTime.ProgressData progressData)
39 {
40 if (checkinStatus == null)
41 return;
42
43 var progress = mWorkspaceWindow.Progress;
44
45 progress.ProgressHeader = checkinStatus.StatusString;
46
47 if (checkinStatus.Status >= EnumCheckinStatus.eciConfirming)
48 progress.CanCancelProgress = false;
49
50 if (checkinStatus.Status == EnumCheckinStatus.eciCancelling)
51 return;
52
53 int nowTicks = Environment.TickCount;
54
55 progress.TotalProgressMessage = mProgressRender.GetUploadSize(
56 checkinStatus.TransferredSize, checkinStatus.TotalSize, progressData);
57
58 progress.TotalProgressPercent = GetProgressBarPercent.ForTransfer(
59 checkinStatus.TransferredSize, checkinStatus.TotalSize) / 100f;
60
61 progress.ShowCurrentBlock = mProgressRender.
62 NeedShowCurrentBlockForCheckinStatus(checkinStatus, nowTicks);
63
64 string currentFileInfo = mProgressRender.GetCurrentFileInfo(
65 checkinStatus.CurrentCheckinBlock, mWkInfo.ClientPath);
66
67 progress.ProgressHeader = currentFileInfo;
68
69 float fileProgressBarValue = GetProgressBarPercent.ForTransfer(
70 checkinStatus.CurrentCheckinBlock.UploadedSize,
71 checkinStatus.CurrentCheckinBlock.BlockSize) / 100f;
72
73 progress.CurrentBlockProgressPercent = fileProgressBarValue;
74
75 progress.CurrentBlockProgressMessage = mProgressRender.GetCurrentBlockUploadSize(
76 checkinStatus.CurrentCheckinBlock, nowTicks);
77 }
78
79 CheckinUploadProgressRender mProgressRender;
80 WorkspaceWindow mWorkspaceWindow;
81 WorkspaceInfo mWkInfo;
82 }
83}