private void ReplaceSpritesFromSource()
{
List<Sprite> sprites = new List<Sprite>();
foreach (ListViewItem listItem in spriteList.SelectedItems) //Check sources still exist
{
Sprite spr = FindSpriteByNumber(Convert.ToInt32(listItem.Name.ToString()));
if (String.IsNullOrEmpty(spr.SourceFile))
{
Factory.GUIController.ShowMessage(String.Format("Sprite {0} does not have a source file. It may have been tile imported.", listItem.Name.ToString()), MessageBoxIcon.Error);
return;
}
else if (!File.Exists(spr.SourceFile))
{
Factory.GUIController.ShowMessage(String.Format("File {0} does not exist.", spr.SourceFile), MessageBoxIcon.Error);
return;
}
sprites.Add(spr);
}
foreach (Sprite spr in sprites)
{
try
{
Bitmap bmp = LoadSpriteFileFromDisk(spr.SourceFile);
bool alphaChannel = false;
if ((bmp.PixelFormat == PixelFormat.Format32bppArgb) && (Factory.AGSEditor.CurrentGame.Settings.ColorDepth == GameColorDepth.TrueColor))
{
alphaChannel = true;
}
NativeProxy.Instance.ReplaceSpriteWithBitmap(spr, bmp, (SpriteImportMethod)SpriteImportWindow.SpriteImportMethod, false, false, alphaChannel);
bmp.Dispose();
}
catch (Exception ex)
{
Factory.GUIController.ShowMessage(String.Format("There was an error importing the file, {0}. The error message was: '{1}' Please try again", spr.SourceFile, ex.Message), MessageBoxIcon.Warning);
RefreshSpriteDisplay();
return;
}
}
RefreshSpriteDisplay();
Factory.GUIController.ShowMessage("Import complete!", MessageBoxIcon.Information);
}