public void LoadData(
GraphicsDevice device,
SpriteBatch spriteBatch,
RenderTarget2D[] undoRedoRenderTargets,
Color backgroundColor)
{
var imageStateData = this.LoadImageStateData();
int end = imageStateData.FirstSavePoint == 0 ? imageStateData.LastSavePoint : imageStateData.MaxUndoRedoCount - 1;
// Don't read more than we need to - hence above we are calculating whether we have used all the renderTarets
for (int count = 0; count <= end; count++)
{
// Load the render target image
using (var imageTexture= Texture2D.FromFile(
device,
this.filenameResolver.ImageSavePointFilename(count)))
{
device.SetRenderTarget(undoRedoRenderTargets[count]);
spriteBatch.Begin();
device.Clear(backgroundColor);
spriteBatch.Draw(imageTexture, Vector2.Zero, backgroundColor);
spriteBatch.End();
}
// copy the master canvas recorder file into the working folder.
// We will then read/write to/from the working folder until the final save at the end,
// thus avoiding problem where render targets and playback files are out of sync if the
// app exists early
File.Copy(
this.filenameResolver.MasterCanvasRecorderFilename(count),
this.filenameResolver.WorkingCanvasRecorderFilename(count),
true);
}
}