public void SetProgress(string text)
{
// This has to happen on the UI thread
SendOrPostCallback method = o =>
{
int index = text.LastIndexOf('%');
int progressValue;
if (index > 4 && int.TryParse(text.Substring(index - 3, 3), out progressValue) && progressValue >= 0)
{
if (ProgressBar.Style != ProgressBarStyle.Blocks)
ProgressBar.Style = ProgressBarStyle.Blocks;
ProgressBar.Value = Math.Min(100, progressValue);
#if !__MonoCS__
if (GitCommands.Utils.EnvUtils.RunningOnWindows() && TaskbarManager.IsPlatformSupported)
{
try
{
TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal);
TaskbarManager.Instance.SetProgressValue(progressValue, 100);
}
catch (InvalidOperationException)
{
}
}
#endif
}
// Show last progress message in the title, unless it's showin in the control body already
if(!ConsoleOutput.IsDisplayingFullProcessOutput)
Text = text;
};
BeginInvoke(method, this);
}