Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Save Workflow to image (Read 10431 times)
Hillab
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jun 15th, 2009
Save Workflow to image
Jun 15th, 2009 at 7:11am
Print Post  
hello,

is there a way to save the all workflow into image?
or PDF or other format?

hilla
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save Workflow to image
Reply #1 - Jun 15th, 2009 at 7:39am
Print Post  
Hi,

It's not possible using the Silverlight 2 API. The Silverlight 3 version of the control will implement an image export function (using the WritableBitmap class available with Silverlight 3). At this time you can export an image on the server side using the mindfusion.diagramming.dll from our ASP.NET control:
https://www.mindfusion.eu/NetDiagramTrial.zip

We'll provide you with a free diagramming.dll copy if only for exporting images.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Hillab
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jun 15th, 2009
Re: Save Workflow to image
Reply #2 - Jun 16th, 2009 at 4:12pm
Print Post  
Thanx.

that mean i have to create the diagram at ASP?
or i can create the diagram in silverlight and past it to ASP only for export to image?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save Workflow to image
Reply #3 - Jun 17th, 2009 at 5:39am
Print Post  
Hi,

You can create the diagram in Silverlight, and pass the diagram XML to an .asmx service method that generates an image file and returns its URL. The service code could look like this

Code
Select All
Diagram diagram = new Diagram();
diagram.LoadFromString(xmlString);
System.Drawing.Image image = diagram.CreateImage();
image.Save(filePath);
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Save Workflow to image
Reply #4 - Jun 22nd, 2009 at 1:02pm
Print Post  
Hi Stoyan,

I am using the approach you gave, when loading in Netdiagram I get the following error:

Message"Exception has been thrown by the target of an invocation."

InnerException{"The value of argument 'value' (7) is invalid for Enum type 'GraphicsUnit'.\r\nParameter name: value"}System.Exception {System.ComponentModel.InvalidEnumArgumentException}

Can you please help me with this.

Amit
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save Workflow to image
Reply #5 - Jun 22nd, 2009 at 2:09pm
Print Post  
Hi Amit,

Set Diagram.MeasureUnit to Point or Pixel before calling SaveToXml, and restore it after that. NetDiagram does not yet support the default WpfPoint unit used in the Silverlight version.

Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Save Workflow to image
Reply #6 - Jun 23rd, 2009 at 10:56am
Print Post  
Hi Stoyan,

This works, thanks.

Now another problem. Shapenodes with Images are not getting correctly built.

I am using node.ImageWebLocation in the silverlight to set the location.

When the same XML is loaded in the netDiagramming object, the links and labels are properly created, but they don't have the images. What can be the reason.

Thanks,
Amit
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save Workflow to image
Reply #7 - Jun 23rd, 2009 at 11:22am
Print Post  
Hi Amit,

We've added these property a few of weeks ago and it is not supported yet by the mindfusion.diagramming.dll API. If you are using the Tag property, add a handler to the DeserializeTag event and examine the value of the ImageWebLocation sub-element of the tag's parent XML element to get the image name. Having the image name, you can load it on the server using System.Drawing.Image.FromFile(). If you don't use Tag, you could just assign to it the image name and it will be automatically loaded as DiagramItem.Tag value so you can avoid using the XML API.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Save Workflow to image
Reply #8 - Jun 24th, 2009 at 8:53am
Print Post  
Hi Stoyan,

On the diagramlite side I do not use Tag. So what exactly are you suggesting by saying the following, I am not very clear:

"If you don't use Tag, you could just assign to it the image name and it will be automatically loaded as DiagramItem.Tag value so you can avoid using the XML API. "

Please clarify.

Regards,
Amit
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save Workflow to image
Reply #9 - Jun 24th, 2009 at 11:33am
Print Post  
Hi,

You could set the tag of each node to the name of the image file displayed inside it.

On the client side:
node.Tag = "image1.png";

on the server side after loading th diagram:

foreach (ShapeNode node in d.Nodes)
     node.Image = Image.FromFile((string)node.Tag);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Save Workflow to image
Reply #10 - Jun 24th, 2009 at 12:01pm
Print Post  
Thanks Stoyan,

I was trying exactly that. I have one problem though, my images are in uri format. The  fromfile only takes full path. Is there any alternative to load from a uri:

Image.FromFile((string)node.Tag);

Best Regards,
Amit
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Save Workflow to image
Reply #11 - Jun 24th, 2009 at 1:30pm
Print Post  
HI Stoyan,

I figured out a way to load these. Thanks a lot for all the assistance.

Regards,
Amit
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Save Workflow to image
Reply #12 - Jun 24th, 2009 at 2:25pm
Print Post  
Hi Stoyan,

I am able to export the images, but my exported image has overlapped image and labels, which is not in the SL client side. Isent an email with the screen shots. How to fix it.

Thanks,
Amit
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save Workflow to image
Reply #13 - Jun 25th, 2009 at 6:17am
Print Post  
Hi Amit,

Have you defined the text and image positions through a custom Shape object? Only the shape ID is saved in the XML files, so you will need to define that shape on the server as well. E.g. before loading the diagram check if the shape is available, and define it if isn't.

Code
Select All
if (Shape.FromId("myshape") == null)
	Shape shape = new Shape(...); // copy the shape definition code
diagram.LoadFromXml(...);
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jaiswalamit
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 64
Joined: Feb 17th, 2009
Re: Save Workflow to image
Reply #14 - Jun 25th, 2009 at 12:27pm
Print Post  
Hi Stoyan,

Your recommendation solved my problem to some extent but there are 2 problems:
1. The overlap is still there inspite of having same custome shape
2. The node icons are very stretched out. I want them to be of same size as they appear in Silverlight Application.

Here is my code, please help urgently. I will also send the screen shots showing the issue in the email to you.:

Silverlight side code for node creation:
       private Shape GetRectTextShape()
       {
           var rrs = new MindFusion.Diagramming.Silverlight.Shape(
           new ElementTemplate[]
       {
               new RoundRectangleTemplate(0, 0, 140, 110, 0)
       },
           null,
           new Rect(0, 65, 200, 80),
           FillRule.Nonzero, "RectText");
           return rrs;
       }

      public static ShapeNode CreateNode(Diagram graph, NodeProps nodeProps)
       {
           BitmapImage nodeImage = null;
           string iconURL = string.Empty;

           ShapeNode child = new ShapeNode(graph);
           child.Shape = GetRectTextShape();   

           StringFormat sfmt = new StringFormat();
           sfmt.Alignment = StringAlignment.Near;
           sfmt.LineAlignment = StringAlignment.Near;
           child.TextFormat = sfmt;

           iconURL = "images/CI/" + nodeProps.Icon;
           child.Tag = nodeProps.Type.ToString();

           child.Text =  nodeProps.Label;
           child.ImageWebLocation =  iconURL;
           child.EnabledHandles = AdjustmentHandles.Move;
           child.ImageAlign = ImageAlign.TopCenter;
           child.FontSize = 9;
           child.FontFamily = new FontFamily("MS Sans Serif,Tahoma");
           child.Transparent = true;
           child.TabNavigation = KeyboardNavigationMode.Cycle;
           return child;
       }

SERVER SIDE CODE for loading and export:
    private Shape GetRectTextShape()
    {
       var rrs = new MindFusion.Diagramming.Shape(
       new ElementTemplate[]
       {
    
           new RoundRectangleTemplate(0, 0, 140, 110, 0)
       },
        
       null,
        new ElementTemplate[]
       {
               new RoundRectangleTemplate(0, 65, 200, 80, 0)
       },
       System.Drawing.Drawing2D.FillMode.Winding
       , "RectText");
       return rrs;
    }

CreateImagefromXMLUsingNetDiagram(...)
{
      Diagram diagram = new Diagram();
        diagram.LoadFromString(xmlString);

Shape custShape = GetRectTextShape();
Font font = new Font("MS Sans Serif,Tahoma", 7);

ShapeNode shapeNode = null;
string imageLocation;

IEnumerator iterator = diagram.Nodes.GetEnumerator();

while (iterator.MoveNext())
               {
                   shapeNode = iterator.Current as ShapeNode;
                   shapeNode.Shape = custShape;
                  
                   StringFormat sfmt = new StringFormat();
                   sfmt.Alignment = StringAlignment.Near;
                   sfmt.LineAlignment = StringAlignment.Near;
                   shapeNode.TextFormat = sfmt;
                   shapeNode.ImageAlign = ImageAlign.TopCenter;

                   imageLocation = "ClientBin/" + shapeNode.Tag as string;
                   imageLocation = Server.MapPath(imageLocation);
                   shapeNode.Image = System.Drawing.Image.FromFile(imageLocation);

                   shapeNode.Font = font;
                   shapeNode.Transparent = true;

                  
                }

diagram.ResizeToFitItems(0, true);
               System.Drawing.Image image = diagram.CreateImage();
               image.Save(@"D:\Temp\export.jpeg");

}
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint