private void StopAsync()
{
#region Processing Page
this.Invoke((Action)delegate //Needed because it's a cross thread call.
{
#region Verifies the minimum size to display the Processing page
if (this.Size.Height < 220)
{
this.Size = new Size(this.Size.Width, 220);
}
if (this.Size.Width < 400)
{
this.Size = new Size(400, this.Size.Height);
}
#endregion
this.TransparencyKey = Color.Empty;
panelBottom.Visible = false;
//Using this makes all Processing calls to change threads.
panelTransparent.Controls.Add(Processing.Page = new Processing { Dock = DockStyle.Fill });
Processing.Undefined("Finishing record...");
Application.DoEvents();
});
#endregion
#region If show cursor is true, merge all bitmaps
//TODO: Make lighter
if (Settings.Default.showCursor)
{
this.Invoke((Action)(() => Processing.Undefined("Merging Cursors...")));
#region Merge Cursor and Bitmap
int numImage = 0;
foreach (var filename in _listFrames)
{
try
{
var imageTemp = filename.From();
using (var graph = Graphics.FromImage(imageTemp))
{
#region Mouse Clicks
if (_listCursor[numImage].Clicked && Settings.Default.showMouseClick)
{
//Draws the ellipse first, to get behind the cursor.
var rectEllipse = new Rectangle(
_listCursor[numImage].Position.X - (_listCursor[numImage].IconImage.Width / 2),
_listCursor[numImage].Position.Y - (_listCursor[numImage].IconImage.Height / 2),
_listCursor[numImage].IconImage.Width - 10,
_listCursor[numImage].IconImage.Height - 10);
graph.DrawEllipse(new Pen(new SolidBrush(Color.Yellow), 3), rectEllipse);
}
#endregion
var rect = new Rectangle(_listCursor[numImage].Position.X,
_listCursor[numImage].Position.Y, _listCursor[numImage].IconImage.Width,
_listCursor[numImage].IconImage.Height);
graph.DrawImage(_listCursor[numImage].IconImage, rect);
graph.Flush();
_listCursor[numImage].IconImage.Dispose();
}
imageTemp.Save(filename);
imageTemp.Dispose();
}
catch (Exception) { }
numImage++;
}
#endregion
}
#endregion
#region If fullscreen, resizes all the images, half of the size
if (Settings.Default.fullscreen)
{
this.Invoke((Action)ShowWindowAndHideTrayIcon);
this.Invoke((Action)(() => Processing.Undefined("Resizing Fullscreen Recording...")));
var bitmapAux = _listFrames[0].From();
ImageUtil.ResizeBitmap(_listFrames,
Convert.ToInt32(bitmapAux.Size.Width / 2),
Convert.ToInt32(bitmapAux.Size.Height / 2));
bitmapAux.Dispose();
GC.Collect();
}
#endregion
#region Creates the Delay
_listDelay = new List<int>();
int delayGlobal;
if (Settings.Default.snapshot)
{
delayGlobal = 600;
}
else
{
delayGlobal = 1000 / (int)numMaxFps.Value;
}
for (int i = 0; i < _listFrames.Count; i++)
{
_listDelay.Add(delayGlobal);
}
#endregion
}