Discussion:
Converting a DSL diagram to PNG or any graphic format
(too old to reply)
Scott
2009-05-15 14:09:01 UTC
Permalink
In a standard VS2008 project you can create a Class Diagram. One of the
options on that class diagram is "Export Diagram as Image ..". This works
good for building documentation pages. It would be even better if I could get
the diagram to generate an image programmatically.

Is there a similar function that is available for generated dsl models? Not
on the designer side but on the client?

It appears that there is a separate app that generates the image for the
class diagrams. The title bar says "Export Diagram as Image", which means it
could be a specific app for the class diagram or potentially a more
generalized app that maybe could be used for the DSL model output?
--
Scott Norberg
Hongye Sun [MSFT]
2009-05-18 08:08:36 UTC
Permalink
Hi Scott,

If my understanding is correct, you want to add export to image function to
your DSL project clients. If so, it is possible to do that.

Product group has explained it at:
http://social.msdn.microsoft.com/Forums/cs-CZ/vsx/thread/28657edc-abb7-45cb-
9334-05c4acf30c2f

Class Designer is currectly using API:
Microsoft.VisualStudio.Modeling.Diagrams.Diagram.CreateBitmap().
In your own diagram, you can call this API by passing a collection of
shapes (or the collection Diagram.NestedChildShapes if you want to include
all shapes on the diagram). It will return a Bitmap object which you can
choose to save it as a file.

If you want something even closer to the Class Designer experience, there
is a class called
Microsoft.VisualStudio.EnterpriseTools.Shell.DiagramExporter, in the
assembly Microsoft.VisualStudio.Modeling.Sdk.Shell.dll (already referenced
from your Designer project if you created a solution via the DSL designer
wizard). You can construct an instance of this class given an object that
implements IServiceProvider, and then it is just a matter of calling
DiagramExporter.ExportDiagram (or ExportDiagrams to do multiple diagrams at
once). This takes a path (paths) to your diagram file(s), the directory on
disk you where you want the diagrams exported, the image format you want to
use, and a boolean value indicating whether existing diagrams should be
overwritten.

Please let me know if you encounter any problem when implementing it.

Thanks,
Hongye Sun (***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
***@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within?2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hongye Sun [MSFT]
2009-05-26 06:25:57 UTC
Permalink
Hi Scott,

Does this issue resolved? If there is any problem, please feel free to post
it here. Thanks.

Regards,
Hongye Sun (***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
***@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Loading...