Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic how to keep the import fle's elements without changing when import into diagrm? (Read 2747 times)
heyx
Junior Member
**
Offline


I Love MindFusion!

Posts: 69
Joined: Oct 9th, 2014
how to keep the import fle's elements without changing when import into diagrm?
May 5th, 2015 at 9:35am
Print Post  
hi,
I use Visio2013Importer import a file in my Diagram, but it have much different after importing, could you please give me some help?
  and because of my visioFIle's size is more than 250K,could you please give me a email so that I can send it to you?
thanks
  

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: how to keep the import fle's elements without changing when import into diagrm?
Reply #1 - May 5th, 2015 at 11:07am
Print Post  
Hi,

You could send it to support@mindfusion.eu email address. At this time Visio2013Importer cannot handle arbitrary stencil shapes, but only maps basic flowchart shapes by name to their counterparts built into the diagram control. If you need to import from only a few stencils, you could handle the Visio2013Importer.ImportItem event to create corresponding DiagramNodes yourself.

We have recently implemented parser and renderer for Visio shapes which you can use through VisioNodes. They haven't been integrated into the importer yet, but you could handle ImportItem by creating a VisioNode for each imported item. However you should avoid importing shapes installed with Visio this way, as its standard stencil definitions are copyrighted by Microsoft. If you need to import standard shapes, better replace them with ShapeNodes showing corresponding geometry or bitmap image.

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


I Love MindFusion!

Posts: 69
Joined: Oct 9th, 2014
Re: how to keep the import fle's elements without changing when import into diagrm?
Reply #2 - May 7th, 2015 at 1:58am
Print Post  
hi Stoyan,
      
     I have send my project to this(support@mindfusion.eu) email,but there is no response. Do you receive my mail ?
thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: how to keep the import fle's elements without changing when import into diagrm?
Reply #3 - May 7th, 2015 at 12:34pm
Print Post  
Hi,

You could create bitmap images or custom shapes representing the Visio masters and assign them to imported nodes like this:

Code
Select All
private void button1_Click(object sender, EventArgs e)
{
	/*var contentMap = new Dictionary<string, VisioContent>();
	var stencil = VisioStencil.LoadFromXml("my_stencil.vsx");
	foreach (var master in stencil.Masters)
	{
		contentMap[master.UniversalName] = VisioContent.Create(stencil, master.Id);
	}*/

    var importer = new Visio2013Importer();
	importer.ImportItem += (s, args) =>
	{
		if (args.MasterName != "")
			Debug.WriteLine(args.MasterName);

		// show the silo-like shape
		if (args.MasterName == "主罐体")
		{
			var node = (ShapeNode)args.Item;
			node.Transparent = false;
			node.Shape = Shapes.Cylinder;
			// or node.Image = someBitmapImage;
		}

		// show the valve-like shape
		if (args.MasterName == "气动球阀")
		{
			var node = (ShapeNode)args.Item;
			node.Transparent = false;
			node.Shape = Shapes.Hourglass;
			// or node.Image = someBitmapImage;
		}
	};
	importer.Import("test.vsdx", diagram1);

	// remove child/helper nodes used to draw a larger group node in Visio
	var toDelete = new List<DiagramNode>();
	foreach (var node in diagram1.Nodes)
	{
		var master = TopmostMaster(node) as ShapeNode;
		if (master != null && master != node)
			toDelete.Add(node);
	}
	foreach (var node in toDelete)
		diagram1.Nodes.Remove(node);
}

DiagramNode TopmostMaster(DiagramNode node)
{
	if (node == null)
		return null;

	if (node.MasterGroup == null)
		return node;

	return TopmostMaster(node.MasterGroup.MainItem as DiagramNode);
} 



Unfortunately there's something in your stencil that our Vsx library cannot parse, throwing an exception, so you cannot use VisioNodes at this time; our developer will investigate. Otherwise you could also replace args.Item with a VisioNode whose Content is set to respective Vsx master.

I hope that helps,
Stoyan
« Last Edit: May 7th, 2015 at 4:45pm by Stoyo »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint