private void AddPictures(string fileName)
{
try
{
Cursor = Cursors.WaitCursor;
if (_listFramesEdit.Any())
{
ResetUndoProp();
}
Size imageSize = _listFramesEdit.Count == 0 ? new Size(0, 0) : _listFramesEdit[0].From().Size;
// Insert the frame(s) and set the last delay used.
List<Bitmap> bitmapsList = ImageUtil.GetBitmapsFromFile(fileName, _listFramesEdit.Count, imageSize);
bitmapsList.Reverse();
int frame = 0;
foreach (Bitmap item in bitmapsList)
{
string endName = String.Format("{0}{1}I{2}.bmp", _pathTemp, frame, DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss"));
item.Save(endName, ImageFormat.Bmp);
_listFramesEdit.Insert(trackBar.Value, endName);
_listDelayEdit.Insert(trackBar.Value, _delay); //TODO: Get the delay.
frame++;
}
tvFrames.Add(bitmapsList.Count);
bitmapsList.Clear();
bitmapsList = null;
GC.Collect();
}
catch (Exception ex)
{
LogWriter.Log(ex, "Error importing image");
var errorViewer = new ExceptionViewer(ex);
errorViewer.ShowDialog();
}
finally
{
// Update the content for user
trackBar.Maximum = _listFramesEdit.Count - 1;
pictureBitmap.Image = _listFramesEdit[trackBar.Value].From();
this.Text = Resources.Title_EditorFrame + trackBar.Value + " - " + (_listFramesEdit.Count - 1);
this.Cursor = Cursors.Default;
DelayUpdate();
}
}