AGS.Editor.SpriteSelector.LaunchImageEditorForSprite C# (CSharp) Метод

LaunchImageEditorForSprite() приватный Метод

private LaunchImageEditorForSprite ( Sprite sprite ) : void
sprite Sprite
Результат void
        private void LaunchImageEditorForSprite(Sprite sprite)
        {
            ImageFormat fileFormat;
            string fileName = GetTempFileNameForSprite(sprite, out fileFormat);

            Bitmap bmp = Factory.NativeProxy.GetBitmapForSprite(sprite.Number);
            bmp.Save(fileName, fileFormat);

            DateTime fileLastModified = System.IO.File.GetLastWriteTimeUtc(fileName);

            try
            {
                BusyDialog.Show("Launching your image editor. Close it to return to AGS...", new BusyDialog.ProcessingHandler(LaunchImageEditorThread), fileName);
            }
            catch (Exception ex)
            {
                Factory.GUIController.ShowMessage("Unable to launch your image editor. Make sure you have an application installed to handle PNG and BMP files, and that it is not already running. If it is already running, close it and then try again.\n\nError: " + ex.Message, MessageBoxIcon.Warning);
            }

            DateTime fileNowModified = System.IO.File.GetLastWriteTimeUtc(fileName);
            if (fileNowModified.CompareTo(fileLastModified) != 0)
            {
                Bitmap newBmp = new Bitmap(fileName);
                if ((newBmp.PixelFormat == PixelFormat.Format8bppIndexed) !=
                    (bmp.PixelFormat == PixelFormat.Format8bppIndexed))
                {
                    Factory.GUIController.ShowMessage("The colour depth of the image has changed. You cannot change this with an in-place edit.", MessageBoxIcon.Warning);
                }
                else
                {
                    Factory.NativeProxy.ReplaceSpriteWithBitmap(sprite, newBmp,
                        SpriteImportMethod.LeaveAsIs, false, false, sprite.AlphaChannel);
                    RefreshSpriteDisplay();
                }
                newBmp.Dispose();
            }
            bmp.Dispose();
            try
            {
                File.Delete(fileName);
            }
            catch (IOException ex)
            {
                Factory.GUIController.ShowMessage("AGS was not able to delete the temporary sprite file. It could be that the image editor is still running and that AGS has not been able to properly detect when it shuts down. Please report this problem on the AGS Forums." + Environment.NewLine + Environment.NewLine + "Error: " + ex.Message, MessageBoxIcon.Warning);
            }
        }