Finding this product very frustrating and lack of examples something that might drive us away from purchasing this product.
I’m trying to create a VSD file that includes a custom stencil. The only way I can get the stencil to be included in the diagram is to use the vst in the Diagram constructor or use an existing blank VSD that is using that template. I then have to run the AddMaster command for every one of my shapes (only showing a couple of the ones I need). This seems kind of inefficient since the original diagram I am opening should have those shapes available. In either case, it seems that if I am going to save it as a VDX file, it adds one shape on the page and the other shape is not even on the page (note that I am using the Layout options). The connection runs off the page. If I save it as png, it works fine, although I would prefer if it would use the background from the Sample.vsd that I am using as a base file. Let me know if additional code would be helpful here. Hard to paste code here so I won’t worry about formatting.
Note that the end solution will consist of a UI that allows the user to select different types of infrastructure where clicking next would generate an image file that can be displayed to the user on the web page. If they need to make further customizations to their architecture, they can download the vsd file, which would contain the custom stencil so what the user inputs can be understood by a process when they upload that same file after changes to read any changes they made manually to persist those changes to a database. So creating a vsd with the stencil is very important, but I also need for the vsd to build correctly. One other thing I noticed is that I always get a warning opening the file in Visio.
string visioStencil = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\MH Template.vst";
Diagram diagram = new Diagram(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Sample.VSD", LoadFileFormat.VSD);
diagram.AddMaster(visioStencil, “SharePoint”);
diagram.AddMaster(visioStencil, “SQL”);
diagram.AddMaster(visioStencil, “Dynamic connector”);
long rectangleId = diagram.AddShape(
pinX, pinY, width, height, “SharePoint”, pageNumber);
//Set the new shape’s properties
Aspose.Diagram.Shape shape = diagram.Pages[pageNumber].Shapes.GetShape(rectangleId);
shape.Name = “test1”;
shape.Line.LineColor.Value = “7”;
shape.Line.LineWeight.Value = 0.03;
shape.Fill.FillBkgnd.Value = “1”;
shape.Fill.FillForegnd.Value = “3”;
shape.Fill.FillPattern.Value = 31;
pinY = 6.5;
long starId = diagram.AddShape(
pinX, pinY, width, height, “SQL”, pageNumber);
//Set the star shape’s properties
shape = diagram.Pages[pageNumber].Shapes.GetShape(starId);
shape.Name = “test2”;
shape.Line.LineColor.Value = “#ff0000”;
shape.Line.LineWeight.Value = 0.03;
shape.Fill.FillBkgnd.Value = “#ff00ff”;
shape.Fill.FillForegnd.Value = “#0000ff”;
shape.Fill.FillPattern.Value = 31;
Aspose.Diagram.Shape connector1 = new Aspose.Diagram.Shape();
long connecter1Id = diagram.AddShape(connector1, “Dynamic connector”, 0);
diagram.Pages[0].ConnectShapesViaConnector(rectangleId, ConnectionPointPlace.Bottom,
starId, ConnectionPointPlace.Top, connecter1Id);
LayoutOptions flowChartOptions = new LayoutOptions();
flowChartOptions.Direction = LayoutDirection.TopToBottom;
flowChartOptions.SpaceShapes = 1;
diagram.Layout(flowChartOptions);
//Save the diagram
diagram.Save(“Diagram1.vdx”, SaveFileFormat.VDX);