public static Primitive Capture(Primitive fileName, Primitive border)
{
Type GraphicsWindowType = typeof(GraphicsWindow);
Type ShapesType = typeof(Shapes);
Type ImageListType = typeof(Microsoft.SmallBasic.Library.ImageList);
Dictionary<string, BitmapSource> _savedImages;
TextWindow.Show();
Utilities.bTextWindow = true;
Utilities.bBorder = border;
try
{
IntPtr _hWnd = User32.FindWindow(null, TextWindow.Title);
Image img = Utilities.captureWindow(_hWnd);
if (fileName == "")
{
InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
{
try
{
_savedImages = (Dictionary<string, BitmapSource>)ImageListType.GetField("_savedImages", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
string shapeName = ShapesType.GetMethod("GenerateNewName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).Invoke(null, new object[] { "ImageList" }).ToString();
_savedImages[shapeName] = FastPixel.GetBitmapImage((Bitmap)img);
return shapeName;
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return "";
});
return FastThread.InvokeWithReturn(ret).ToString();
}
else
{
Utilities.saveImage(img, fileName);
}
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return "";
}