We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Bugs when adding and manipulating trapezoid shape

Bug: Control handle formula is lost after adding trapezoid shapes. Consequently, when the added shape is selected, its yellow control handle is at wrong position (compared with direct dragging into the drawing place).


public static void Test6_Trapezoid_WrongControlHandlePosition()

{

string[] inputFileNames = new string[] {

"_Trapezoid_ReSavedFromVSDX.vsd"

};

foreach (string inputFileName in inputFileNames)

{

Diagram diagram = new Diagram(@"data\" + inputFileName);

long shapeId = diagram.AddShape(5.0, 8.0, 2, 2, @"Trapezoid", 0);

Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Text.Value.Add(new Txt(@"Trapezoid"));

// Save the new diagram

string outputDiagramPath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + inputFileName;

diagram.Save(outputDiagramPath + ".vsdx", SaveFileFormat.VSDX);

diagram.Save(outputDiagramPath + ".vdx", SaveFileFormat.VDX);

diagram.Save(outputDiagramPath + ".emf", SaveFileFormat.EMF);

}

}


Bug: Cannot assign fill color to the added trapezoid shape.


public static void Test7_Trapezoid_CannotAssignColor()

{

string[] inputFileNames = new string[] {

"_Trapezoid_ReSavedFromVSDX.vsd"

};

foreach (string inputFileName in inputFileNames)

{

Diagram diagram = new Diagram(@"data\" + inputFileName);

long shapeId = diagram.AddShape(5.0, 8.0, 2, 2, @"Trapezoid", 0);

Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Fill.FillBkgnd.Value = "#c8c8c8";

shape.Text.Value.Add(new Txt(@"Trapezoid"));

// Save the new diagram

string outputDiagramPath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + inputFileName;

diagram.Save(outputDiagramPath + ".vsdx", SaveFileFormat.VSDX);

diagram.Save(outputDiagramPath + ".vdx", SaveFileFormat.VDX);

diagram.Save(outputDiagramPath + ".emf", SaveFileFormat.EMF);

}

}


Bug: Nothing is shown after the coordinate collection of the added shape is replaced. More specifically, (1) checking the Geometry rows of the ShapeSheet shows that the MoveTo call turns out to be a LineTo row, (2) manually changing the row type fails complaining invalid row tag, (3) clicking individual coordinate row shows that the vertexes are at the desired position, however the text is at the initial position, which is very confusing...


public static void Test8_Trapezoid_CannotReplaceCoordinates()

{

string[] inputFileNames = new string[] {

"_Trapezoid_ReSavedFromVSDX.vsd"

};

foreach (string inputFileName in inputFileNames)

{

Diagram diagram = new Diagram(@"data\" + inputFileName);

long shapeId = diagram.AddShape(5.0, 8.0, 2, 2, @"Trapezoid", 0);

Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Text.Value.Add(new Txt(@"Trapezoid"));

Geom geom = shape.Geoms[0];

geom.CoordinateCol.Clear();

//Add MoveTo

MoveTo moveTo = new MoveTo();

moveTo.IX = geom.NextCoordinateIX;

moveTo.X.Value = 2.2;

moveTo.Y.Value = 2.2;

geom.CoordinateCol.Add(moveTo);

//Add LineTo

LineTo lineTo = new LineTo();

lineTo.IX = geom.NextCoordinateIX;

lineTo.X.Value = 3.2;

lineTo.Y.Value = 2.2;

geom.CoordinateCol.Add(lineTo);

//Add LineTo

lineTo = new LineTo();

lineTo.IX = geom.NextCoordinateIX;

lineTo.X.Value = 2.8;

lineTo.Y.Value = 3.2;

geom.CoordinateCol.Add(lineTo);

//Add LineTo

lineTo = new LineTo();

lineTo.IX = geom.NextCoordinateIX;

lineTo.X.Value = 2.3;

lineTo.Y.Value = 3.2;

geom.CoordinateCol.Add(lineTo);

//Add LineTo

lineTo = new LineTo();

lineTo.IX = geom.NextCoordinateIX;

lineTo.X.Value = 2.2; // back to the origin

lineTo.Y.Value = 2.2;

geom.CoordinateCol.Add(lineTo);

// Save the new diagram

string outputDiagramPath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + inputFileName;

diagram.Save(outputDiagramPath + ".vsdx", SaveFileFormat.VSDX);

diagram.Save(outputDiagramPath + ".vdx", SaveFileFormat.VDX);

diagram.Save(outputDiagramPath + ".emf", SaveFileFormat.EMF);

}

}



Can you help to check the issues above ? Many thanks for your efforts !


Hi Jiaguo,


Thank you for contacting support. We have investigated your sample Visio diagrams and code examples against the latest version 6.8.0 of Aspose.Diagram API. We managed to replicate the said problems as below:
comingnine:
Bug: Control handle formula is lost after adding trapezoid shapes. Consequently, when the added shape is selected, its yellow control handle is at wrong position (compared with direct dragging into the drawing place).
DIAGRAMNET-51085: The formulas are lost under the controls tab of Shapesheet on saving in VSDX
DIAGRAMNET-51086: The formulas are lost under the controls tab of Shapesheet on saving in VDX
DIAGRAMNET-51087: The layout of shape is changed on saving in EMF

Your post has also been linked to these tickets. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.
comingnine:
Bug: Cannot assign fill color to the added trapezoid shape.
Aspose.Diagram API properly sets the fill color value (RGB) in the Shapesheet. Please check in the attached screenshot: FillBkgndColor.png. Please also refer to this help topic: Setting the Fill Values of Shape
comingnine:
Bug: Nothing is shown after the coordinate collection of the added shape is replaced. More specifically, (1) checking the Geometry rows of the ShapeSheet shows that the MoveTo call turns out to be a LineTo row, (2) manually changing the row type fails complaining invalid row tag, (3) clicking individual coordinate row shows that the vertexes are at the desired position, however the text is at the initial position, which is very confusing.
The Clear method of the CoordinateCollection class does not delete MoveTo and LineTo entries. It clears data from these entries. You may edit them or first delete and then add new entries. It takes the coordinate values in inches, you may also convert inches to millimeters by dividing 25.4. Please use the following code example and let us know how that goes on your side:

[.NET, C#]
<span style=“color: rgb(0, 128, 0); background-color: rgb(255, 255, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>// load a Visio diagram
Diagram diagram = new Diagram(@“C:\AD\test801\data_Trapezoid_ReSavedFromVSDX.vsd”);
// add shape
long shapeId = diagram.AddShape(5.0, 8.0, 2, 2, @“Trapezoid”, 0);
Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@“Trapezoid”));
// delete geom entries
Geom geom = shape.Geoms[0];
geom.CoordinateCol.MoveToCol[0].Del = BOOL.True;
for (int i = 0; i < shape.Geoms[0].CoordinateCol.LineToCol.Count; i++ )
geom.CoordinateCol.LineToCol[i].Del = BOOL.True;

//Add MoveTo
MoveTo moveTo = new MoveTo();
moveTo.IX = geom.NextCoordinateIX;
moveTo.X.Value = 2.2 / 25.4;
moveTo.Y.Value = 2.2 / 25.4;
geom.CoordinateCol.Add(moveTo);

//Add LineTo
LineTo lineTo = new LineTo();
lineTo.IX = geom.NextCoordinateIX;
lineTo.X.Value = 3.2 / 25.4;
lineTo.Y.Value = 2.2 / 25.4;
geom.CoordinateCol.Add(lineTo);

//Add LineTo
lineTo = new LineTo();
lineTo.IX = geom.NextCoordinateIX;
lineTo.X.Value = 2.8 / 25.4;
lineTo.Y.Value = 3.2 / 25.4;
geom.CoordinateCol.Add(lineTo);

//Add LineTo
lineTo = new LineTo();
lineTo.IX = geom.NextCoordinateIX;
lineTo.X.Value = 2.3 / 25.4;
lineTo.Y.Value = 3.2 / 25.4;
geom.CoordinateCol.Add(lineTo);

//Add LineTo
lineTo = new LineTo();
lineTo.IX = geom.NextoordinateIX;
lineTo.X.Value = 2.2 / 25.4; // back to the origin
lineTo.Y.Value = 2.2 / 25.4;
geom.CoordinateCol.Add(lineTo);

// save the new diagram
diagram.Save(@“C:\AD\test801\TestCase03\Output.vsdx”, SaveFileFormat.VSDX);
diagram.Save(@“C:\AD\test801\TestCase03\Output.vdx”, SaveFileFormat.VDX);
diagram.Save(@“C:\AD\test801\TestCase03\Output.emf”, SaveFileFormat.EMF);

Your findings about the color and the coordinates are absolutely correct !
Thank you very much for your efforts to help !

Hi Jiaguo,


You are welcome. Please feel free to ask if you have any other question in reference of the Aspose.Diagram API, we will be happy to help you.

Hi Jiaguo,

Thank you for being patient. In reference to the ticket ID DIAGRAMNET-51086, please download and use the latest version 16.10.0 of Aspose.Diagram API.

imran.rafique:
Hi Jiaguo,

Thank you for being patient. In reference to the ticket ID DIAGRAMNET-51086, please download and use the latest version 16.10.0 of Aspose.Diagram API.


DIAGRAMNET-51086 is not solved as I tested.

Hi Jiague,


Thank you for the inquiry. We have evaluated your ticket ID DIAGRAMNET-51086 against the latest version 16.10.0. It preserves the control handle formula for adding a trapezoid shape and as a result, the yellow handle is in the right position. We have attached the output VDX and a screenshot for your kind reference. Please check and confirm us.

imran.rafique:
Hi Jiague,

Thank you for the inquiry. We have evaluated your ticket ID DIAGRAMNET-51086 against the latest version 16.10.0. It preserves the control handle formula for adding a trapezoid shape and as a result, the yellow handle is in the right position. We have attached the output VDX and a screenshot for your kind reference. Please check and confirm us.


It does not work as I tested. The code is below. The sample files are zipped and attached.

public static void Test6_Trapezoid_WrongControlHandlePosition()

{

string[] inputFileNames = new string[] { // When saved later, it seems that:

"_Trapezoid.vsdx",

"_Trapezoid_ReSavedFromVSDX.vsd" // Control formula is lost. --> When the shape is selected, the yellow handle is at wrong position.

};

foreach (string inputFileName in inputFileNames)

{

// Create a new diagram

Diagram diagram = new Diagram(@"data\" + inputFileName);

// Add a new circle shape with off-set radial gradient

long shapeId = diagram.AddShape(5.0, 8.0, 2, 2, @"Trapezoid", 0);

Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Text.Value.Add(new Txt(System.Diagnostics.FileVersionInfo.GetVersionInfo(@"Aspose.Diagram.dll").FileVersion));

// Save the new diagram

string outputDiagramPath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + inputFileName;

diagram.Save(outputDiagramPath + ".vsdx", SaveFileFormat.VSDX);

diagram.Save(outputDiagramPath + ".vdx", SaveFileFormat.VDX);

diagram.Save(outputDiagramPath + ".emf", SaveFileFormat.EMF);

}

}

Hi Jiague,


Thank you for the details. Please modify your sample code as below:

[.NET, C#]
// load an existing Visio diagram
Diagram diagram = new Diagram(@“C:\AD\test804_Trapezoid_ReSavedFromVSDX.vsd”);
// add a new circle shape with off-set radial gradient
long shapeId = diagram.AddShape(5.0, 8.0, 2, 2, @“Trapezoid”, 0);
Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(System.Diagnostics.FileVersionInfo.GetVersionInfo(@“Aspose.Diagram.dll”).FileVersion));

shape.Controls.GetControlFromName(“Row_1”).X.Ufe.F = “BOUND(Width0.25,0,FALSE,0,Width0.5)”;
shape.Controls.GetControlFromName(“Row_1”).Y.Ufe.F = “Height*1”;


// save the new diagram
diagram.Save(@“C:\AD\test804\Output03.vdx”, SaveFileFormat.VDX);

imran.rafique:
Hi Jiague,

Thank you for the details. Please modify your sample code as below:

[.NET, C#]
// load an existing Visio diagram Diagram diagram = new Diagram(@"C:\AD\test804\_Trapezoid_ReSavedFromVSDX.vsd"); // add a new circle shape with off-set radial gradient long shapeId = diagram.AddShape(5.0, 8.0, 2, 2, @"Trapezoid", 0); Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId); shape.Text.Value.Add(new Txt(System.Diagnostics.FileVersionInfo.GetVersionInfo(@"Aspose.Diagram.dll").FileVersion));
shape.Controls.GetControlFromName("Row_1").X.Ufe.F = "BOUND(Width*0.25,0,FALSE,0,Width*0.5)"; shape.Controls.GetControlFromName("Row_1").Y.Ufe.F = "Height*1";

// save the new diagram diagram.Save(@"C:\AD\test804\Output03.vdx", SaveFileFormat.VDX);


So the bug is not fixed at all.

In the way which you shew, you just modified the formula of the position of the control handle of the added shape. Please check:
(1) If you open the vsd using Visio, drag the master shape to the drawing space, and check the shape sheet of the added shape, the control handle fields are in black color, meaning they that bear default (correct) values.
(2) If you modify the formula of the position of the control handle of the added shape, save the drawing, open it in Visio, and check the shape sheet of the added shape, the control handle fields are in blue color, meaning that they bear customized data. This is both indication of bug, and waste of store space of the shape.

Please correct the root problem, i.e., preventing the erroneous modification of the control handle position when adding master shapes with Aspose.Diagram.

Hi Jiague,


Thank you for the inquiry. Please highlight the black and blue color of the control handle fields in the shapesheet. Please also let us know which Microsoft Visio version you are using. It’ll help us to be more specific.

imran.rafique:
Hi Jiague,

Thank you for the inquiry. Please highlight the black and blue color of the control handle fields in the shapesheet. Please also let us know which Microsoft Visio version you are using. It'll help us to be more specific.


Please check the pictures attached, with Visio 2016.

Hi Jiague,


Thank you for the details. You’re right. Microsoft Visio reveals it as the customized formulas in the blue (color) font under the control tab of Shapesheet. We’ve logged an enhancement in our issue tracking system as: DIAGRAMNET-51094. Your post has also been linked to this ticket. We’ll let you know once a significant progress has been made in this regard. We’re sorry for the inconvenience caused.

imran.rafique:
Hi Jiague,

Thank you for the details. You're right. Microsoft Visio reveals it as the customized formulas in the blue (color) font under the control tab of Shapesheet. We've logged an enhancement in our issue tracking system as: DIAGRAMNET-51094. Your post has also been linked to this ticket. We'll let you know once a significant progress has been made in this regard. We're sorry for the inconvenience caused.


Many thanks !

In fact, there are many other places that Aspose.Diagram should keep the original formula, if we compare the two pictures:

(1) locPinX and other fields in the Shape Transform section
(2) NoFill and NoLine fields in the Geometry section
(3) maybe some other places not shown

Can you help to correct the root problem ? I mean, if the field from the master shape contains formula, do not evaluate the value but instead copy the formula.

Many thanks !

Hi Jiague,


Thank you for the details. We have also addressed these points in the respective ticket ID DIAGRAMNET-51094. Our product team will surely consider these points as well. We’ll let you know once an update is available.

@comingnine,

The linked ticket ID DIAGRAMNET-51094 has been fixed. We will notify you once the next version 17.10 of Aspose.Diagram for .NET API is published.

@comingnine,

The linked ticket IDs DIAGRAMNET-51085 and DIAGRAMNET-51094 have been resolved. Please download and try the new version 17.10 of Aspose.Diagram for .NET API.