我有一个VSTO,用于更新powerpoint演示文稿中图形内的数据。但是当我从插件中截取屏幕截图时,它会在更新之前捕获图形,同时屏幕显示新数据。我假设它是因为当幻灯片显示时,powerpoint缓存图表并且它在屏幕上更新数据但不在实际演示文稿内部。有没有人知道如何让powerpoint在内部而不是仅在屏幕上重绘图形?或如何捕获包括更新图表的屏幕?这是我使用的代码:
PowerPoint.Slide activeSlide = Wnd.View.Slide;
PowerPoint.Shape pShp = activeSlide.Shapes[1];
Excel.Worksheet xlSH = pShp.Chart.ChartData.Workbook.WorkSheets[1];
Excel.Range tRange = xlSH.Cells.get_Range("A1", "B" + (data.options.Length + 1));
foreach (Option o in data.options)
{
row++;
xlSH.Cells.get_Range("A" + row, missing)).FormulaR1C1 = o.key;
xlSH.Cells.get_Range("B" + row, missing)).FormulaR1C1 = o.value;
}
pShp.Chart.Refresh();
Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bmpScreenCapture);
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
bmpScreenCapture.Size);
bmpScreenCapture.Save("C:\\file.jpg");
其中file不包含更新的图形,但包含原始图形。任何想法都非常感谢!