views:

354

answers:

2

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?

+3  A: 

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.

Otaku
I will read about AutomationFactory, I didn`t know about this. SL3 is not requirement, because I can upgrade to SL4 easily... But SLOOB is not an option!
zidane
@zidane: Yeah, do also a search for "ComAutomationFactory" - that is what it's name was when SL4 was in beta and there seems to be more AutomationFactory stuff written then. That said, it does require SLOOB because of the Elavated Privilages (and only works on Windows). It may be worth it to consider SLOOB though - prompt your users with teasers like "work even faster between between this app and PowerPoint. Install to your desktop for all the goodies!" :)
Otaku
+1  A: 

If True = HtmlPage.IsPopupWindowAllowed Then
HtmlPage.PopupWindow(New Uri("http://www.yourdomain.com/chartgenerator.ashx?param1=value1&param2=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

mangokun