Free Support Forum - aspose.com

Bizarre behaviour in Shape.Y get/set accessor

Hello,

I am using a purchased version of Aspose.Slides in a C# ASP.NET application and have stumbled upon a totally bizarre behaviour in the Shape.Y get/set property.

It seems that if the property get is NOT called before using set, the value is not changed in the set operation!

Here's some example code to demonstrate the behaviour:

Save the initial value of shape.Y so that we can use it later.
int initialShapeY = shape.Y;

Set the TextFrame to automatically resize.
shape.TextFrame.FitShapeToText = true;
shape.TextFrame.Width = 3000;

Some paragraphs/portions is added to the TextFrame of the shape.
//Code removed for brevity

After adding text, the shape resizes on the y-axis both upwards and downwards. I assume this behaviour is by design.

To correct the Y position after automatic resizing, I want to set the Y property to the old value: initialShapeY.

Example 1: shape.Y get accessor is NOT called before setting the property.
shape.Y = initialShapeY;
Debug.WriteLine("(adjusted) shape.Y = " + shape.Y);

Result: The Y value of the shape is NOT changed to the initialShapeY value.

Example 2: shape.Y set is called before calling get.
shape.Y = shape.Y;
shape.Y = initialShapeY;
Debug.WriteLine("(adjusted) shape.Y = " + shape.Y);

Result: The Y value of the shape is changed to the initialShapeY value.

It does not matter if shape.Y = shape.Y is used, or if the get accessor is just printed out (i.e. using Debug.WriteLine(shape.Y).

Thanks for reporting. We will investigate it and fix it as soon as possible.