如何将图表图像从 Silverlight 应用程序复制到剪贴板?
我有一个 Silverlight 3.0 应用程序,带有一些自定义图形和一些图表。我需要找到将这些图形传输到 PowerPoint 演示文稿的最佳方法。
我读到 Silverlight 4.0 提供了剪贴板 API,但仅支持 Unicode 文本,而不支持图像。
有没有办法在不强迫用户手动 PrtSc 并粘贴到其他应用程序的情况下完成此任务?
I have a Silverlight 3.0 applications with some custom graphics and some charts. I need to find the best way to transfer these graphics to a PowerPoint presentation.
I've read that Silverlight 4.0 offers a Clipboard API, but there is only support for Unicode-text, not images.
Is there a way to achieve this task without forcing users to manually PrtSc and than paste to other applicatons?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 SL3 中没有简单的方法可以做到这一点。我的建议是使用 WriteableBitmap 并将其保存到isolatedStorage,然后使用文件保存对话框提示用户保存到他们的盒子中(然后他们必须将其放入 PowerPoint 中)。 SL3 中该对话框的唯一问题是它不允许您设置扩展名类型,因此他们需要输入 PNG 或 JPG 扩展名。此功能和 PrtSc、Ctrl+P 都需要多步用户操作,这始终是一个失败点。
在 SL4 中,有更多选择 - 您甚至不需要 SLOOB 中的剪贴板。您可以使用 AutomationFactory 来自动化 PowerPoint。
There's no simple way to do this in SL3. My recommendation would be to use a WriteableBitmap and save that to IsolatedStorage and then prompt the user with a FileSave Dialog to save to their box (and then they would have to put it in PowerPoint). The only problem with that Dialog in SL3 is that it doesn't allow you to set the extention type so they would need to type in the PNG or JPG extention. Both this and the PrtSc, Ctrl+P require multi-step user action and that is always a point of failure.
In SL4 there are more choices - you don't even need the Clipboard in an SLOOB. You can just use AutomationFactory to automate PowerPoint.
如果 True = HtmlPage.IsPopupWindowAllowed 那么
HtmlPage.PopupWindow(新 Uri("http://www.yourdomain. com/chartgenerator.ashx?param1=value1¶m2=value2"), "新", 选项)
如果
Chartgenerator.aspx 可以显示图像:
' 告诉浏览器显示内联
context.Response.AddHeader("Content-Disposition", "inline; filename=" & FilenameWithExt)
或显示打开、保存、取消对话框:
' 告诉浏览器保存而不是显示内联
context.Response.AddHeader("Content-Disposition", "attachment; filename=" & FilenameWithExt)
引用自 http://vbcity.com/blogs/mike-mcintyre/archive/ 2010/02/28/silverlight-3-pop-up-new-browser-window.aspx
If True = HtmlPage.IsPopupWindowAllowed Then
HtmlPage.PopupWindow(New Uri("http://www.yourdomain.com/chartgenerator.ashx?param1=value1¶m2=value2"), "new", options)
End If
chartgenerator.aspx can either display an image:
' tell the browser to display inline
context.Response.AddHeader("Content-Disposition", "inline; filename=" & FilenameWithExt)
or display an Open, Save, Cancel dialog:
' tell the browser to save rather than display inline
context.Response.AddHeader("Content-Disposition", "attachment; filename=" & FilenameWithExt)
quoted from http://vbcity.com/blogs/mike-mcintyre/archive/2010/02/28/silverlight-3-pop-up-new-browser-window.aspx