Hi,
I've been trying to produce a visio diagram showing a Server network.
I have created a blank 'Network' style visio diagram, and saved it as a template.
The following code compiles and runs, but the output file does not open directly, and when I download it and then try to open it, errors are displayed.
Any help in spottting the error would be much appreciated.
Thanks...
Private Sub btnGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGo.Click<SPAN style="COLOR: blue">Dim</SPAN> st <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">New</SPAN> <SPAN style="COLOR: #2b91af">FileStream</SPAN>(Server.MapPath(<SPAN style="COLOR: #a31515">"~\Drawing1.vdx"</SPAN>), <SPAN style="COLOR: #2b91af">FileMode</SPAN>.Open) vsdDiagram = <SPAN style="COLOR: blue">New</SPAN> <SPAN style="COLOR: #2b91af">Diagram</SPAN>(st) <SPAN style="COLOR: blue">Dim</SPAN> i1 <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Integer</SPAN> = AddItem(<SPAN style="COLOR: #a31515">"Fred"</SPAN>, 0, 6) <SPAN style="COLOR: blue">Dim</SPAN> i2 <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Integer</SPAN> = AddItem(<SPAN style="COLOR: #a31515">"Wilma"</SPAN>, 0, 4) <SPAN style="COLOR: blue">Dim</SPAN> i3 <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Integer</SPAN> = AddItem(<SPAN style="COLOR: #a31515">"Barney"</SPAN>, 0, 2) <SPAN style="COLOR: blue">Dim</SPAN> i4 <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Integer</SPAN> = AddItem(<SPAN style="COLOR: #a31515">"Betty"</SPAN>, 0, 0) ' note: i1, i2, i3 and i4 are all non-zero at this point</PRE><PRE style="FONT-FAMILY: Consolas; BACKGROUND: white; COLOR: black; FONT-SIZE: 13px"> <SPAN style="COLOR: green">' AddConnector(i1, i2)</SPAN> <SPAN style="COLOR: green">' AddConnector(i2, i3)</SPAN> <SPAN style="COLOR: green">' AddConnector(i3, i4)</SPAN> st.Close() <SPAN style="COLOR: blue">Me</SPAN>.Response.ContentType = <SPAN style="COLOR: #a31515">"application/vnd.ms-visio"</SPAN> <SPAN style="COLOR: blue">Me</SPAN>.Response.AppendHeader(<SPAN style="COLOR: #a31515">"Content-Disposition"</SPAN>, <SPAN style="COLOR: #a31515">"attachment; filename=Diagram.vdx"</SPAN>) <SPAN style="COLOR: blue">Me</SPAN>.Response.Flush() <SPAN style="COLOR: blue">Dim</SPAN> str <SPAN style="COLOR: blue">As</SPAN> System.IO.<SPAN style="COLOR: #2b91af">Stream</SPAN> = <SPAN style="COLOR: blue">Me</SPAN>.Response.OutputStream vsdDiagram.Save(str, Aspose.Diagram.<SPAN style="COLOR: #2b91af">SaveFileFormat</SPAN>.VDX) <SPAN style="COLOR: blue">Me</SPAN>.Response.End() <SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">Sub</SPAN></PRE><PRE style="FONT-FAMILY: Consolas; BACKGROUND: white; COLOR: black; FONT-SIZE: 13px"> <SPAN style="COLOR: blue">Private</SPAN> <SPAN style="COLOR: blue">Function</SPAN> AddItem(<SPAN style="COLOR: blue">ByVal</SPAN> sText <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">String</SPAN>, <SPAN style="COLOR: blue">ByVal</SPAN> lX <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Long</SPAN>, <SPAN style="COLOR: blue">ByVal</SPAN> lY <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Long</SPAN>) <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Integer</SPAN> <SPAN style="COLOR: green">'Get first page</SPAN> <SPAN style="COLOR: blue">If</SPAN> vsdDiagram.Pages.Count = 0 <SPAN style="COLOR: blue">Then</SPAN> <SPAN style="COLOR: blue">Return</SPAN> 0 <SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">If</SPAN> <SPAN style="COLOR: blue">Dim</SPAN> page0 <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: #2b91af">Page</SPAN> = vsdDiagram.Pages(0) <SPAN style="COLOR: green">'Get the rectangle master</SPAN> <SPAN style="COLOR: blue">Dim</SPAN> masterRectangle <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: #2b91af">Master</SPAN> = <SPAN style="COLOR: blue">Nothing</SPAN> <SPAN style="COLOR: blue">For</SPAN> <SPAN style="COLOR: blue">Each</SPAN> master <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: #2b91af">Master</SPAN> <SPAN style="COLOR: blue">In</SPAN> vsdDiagram.Masters <SPAN style="COLOR: blue">If</SPAN> master.Name = <SPAN style="COLOR: #a31515">"Server"</SPAN> <SPAN style="COLOR: blue">Then</SPAN> masterRectangle = master <SPAN style="COLOR: blue">Exit For</SPAN> <SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">If</SPAN> <SPAN style="COLOR: blue">Next</SPAN> master <SPAN style="COLOR: blue">If</SPAN> masterRectangle <SPAN style="COLOR: blue">Is</SPAN> <SPAN style="COLOR: blue">Nothing</SPAN> <SPAN style="COLOR: blue">Then</SPAN> <SPAN style="COLOR: blue">Return</SPAN> 0 <SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">If</SPAN> <SPAN style="COLOR: green">'Get next shape ID</SPAN> <SPAN style="COLOR: blue">Dim</SPAN> nextID <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Long</SPAN> = -1L <SPAN style="COLOR: blue">For</SPAN> <SPAN style="COLOR: blue">Each</SPAN> page <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: #2b91af">Page</SPAN> <SPAN style="COLOR: blue">In</SPAN> vsdDiagram.Pages <SPAN style="COLOR: blue">For</SPAN> <SPAN style="COLOR: blue">Each</SPAN> shape <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: #2b91af">Shape</SPAN> <SPAN style="COLOR: blue">In</SPAN> page.Shapes <SPAN style="COLOR: blue">Dim</SPAN> temp <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Long</SPAN> = GetMaxShapeID(shape) <SPAN style="COLOR: blue">If</SPAN> temp > nextID <SPAN style="COLOR: blue">Then</SPAN> nextID = temp <SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">If</SPAN> <SPAN style="COLOR: blue">Next</SPAN> shape <SPAN style="COLOR: blue">Next</SPAN> page nextID += 1 <SPAN style="COLOR: green">'Set shape properties and add it in the shapes' collection</SPAN> <SPAN style="COLOR: blue">Dim</SPAN> rectangle <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">New</SPAN> <SPAN style="COLOR: #2b91af">Shape</SPAN>() rectangle.Master = masterRectangle rectangle.MasterShape = masterRectangle.Shapes(0) rectangle.ID = nextID rectangle.XForm.PinX.Value = lX rectangle.XForm.PinY.Value = lY rectangle.Type = <SPAN style="COLOR: #2b91af">TypeValue</SPAN>.Shape rectangle.Text.Value.Add(<SPAN style="COLOR: blue">New</SPAN> <SPAN style="COLOR: #2b91af">Txt</SPAN>(sText)) rectangle.TextStyle = vsdDiagram.StyleSheets(3) <SPAN style="COLOR: green">'rectangle.Line.LineColor.Value = page0.Shapes(1).Fill.FillForegnd.Value</SPAN> <SPAN style="COLOR: green">'rectangle.Line.LineWeight.Value = 0.030416666666666672</SPAN> <SPAN style="COLOR: green">'rectangle.Line.Rounding.Value = 0.1</SPAN> <SPAN style="COLOR: green">'rectangle.Fill.FillBkgnd.Value = page0.Shapes(0).Fill.FillBkgnd.Value</SPAN> <SPAN style="COLOR: green">'rectangle.Fill.FillForegnd.Value = "#ebf8df"</SPAN> page0.Shapes.Add(rectangle) <SPAN style="COLOR: blue">Return</SPAN> nextID <SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">Function</SPAN></PRE>