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

Free Support Forum - aspose.com

Change shape color

Given the attached visio file, could you supply some code on how to change the flag colors?


My current code snippet is as follows:

foreach (Aspose.Diagram.Shape shape in vdxDiagram.Pages[0].Shapes)
{

foreach (Shape shapeFlag in shape.Shapes)
{
foreach (Shape shapeFlagPiece in shapeFlag.Shapes)
{
shapeFlag.Fill.FillBkgnd.Value = “C73838”;
shapeFlag.Fill.FillForegnd.Value = “C73838”;
shapeFlagPiece.Fill.FillBkgnd.Value = “C73838”;
shapeFlagPiece.Fill.FillForegnd.Value = “C73838”;

}
}
}

This should have changed the color of everything, but it doesn’t…

Hi Charles,


Thank you for contacting support. The group shape of each flag is protected. We can’t change flag colors manually. However, we’re further investing it and let you know our findings soon.

Hi Charles,


Thank you for being patient. In this regard, we have logged an investigation under ticket id DIAGRAMNET-50310 in our issue tracking system. Your post has also been linked to this issue. We’ll keep you informed regarding any available updates.

imran.rafique:
Hi Charles,

Thank you for being patient. In this regard, we have logged an investigation under ticket id DIAGRAMNET-50310 in our issue tracking system. Your post has also been linked to this issue. We'll keep you informed regarding any available updates.

I'm able to change the color of the flags if I save as PDF, but not if I save as any visio format.

I also attempted to just cover each flag with a new shape that I could edit, but I am unable to get the correct coordinates for each flag? Their are multiple Visios, each with flags in different positions, so we'd have to extract this data from the visio file somehow.

If you find that the flag is unable to be edited, could you supply code to find the coordinates of each flag so that I can drop a new shape on top of them?
Hi Charles,

Thank you for your inquiry. We're working over your query and will get back to you soon.

Hi Charles,

Thank you for being patient.
ctenc001:
I'm able to change the color of the flags if I save as PDF, but not if I save as any visio format.
We can change flag colors when saving to the PDF format. We have logged our comment against the ticket id DIAGRAMNET-50310.

In addition, when we exported Visio drawing to the PDF format without changing flag colors, then it some flag colors become blue instead of remaining red. We've logged this issue under ticket id DIAGRAMNET-50314 in our issue tacking system. Your post has also been linked to the issue for auto notification purpose.
ctenc001:
I also attempted to just cover each flag with a new shape that I could edit, but I am unable to get the correct coordinates for each flag? Their are multiple Visios, each with flags in different positions, so we'd have to extract this data from the visio file somehow.
Well, in this regard, Page.AddShape method allows you to pass pinX, pinY, width, height and master name parameters. You can get pinX, pinY, width and height from the shape class object as follows:

shape.XForm.PinX.Value
shape.XForm.PinY.Value
shape.XForm.Width.Value
shape.XForm.Height.Value

We hope, this helps. Please feel free to reply is in case of any confusion or questions.

[quote user=“imran.rafique”]


Well, in this regard, Page.AddShape method allows you to pass pinX, pinY, width, height and master name parameters. You can get pinX, pinY, width and height from the shape class object as follows:

shape.XForm.PinX.Value
shape.XForm.PinY.Value
shape.XForm.Width.Value
shape.XForm.Height.Value

We hope, this helps. Please feel free to reply is in case of any confusion or questions.

[/quote]

I am able to get the correct X-axis value, but the Y-axis value is wrong. Could you supply code to get the correct value of one of the flags?

Hi Charles,


Thank you for the inquiry. We managed to replicate the incorrect value of the y-coordinates. It is the case when a flag group shape is the sub-shape of another group shape. It returns correct coordinates of the shape which we can get from PageCollection class by id. As a workaround, you can ungroup these type of shapes manually. However, this issue has been logged under ticket id DIAGRAMNET-50315 in our issue tracking system. your request has also been linked to this issue. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

Hi Charles,


Thank you for being patient. From the specifics of ticket id DIAGRAMNET-50315, please use the sample code below:

[.NET, C#]
// load Visio diagram
Diagram diagram = new Diagram(“C:\temp\zcxer34v.vdx”);
// get group shape
Shape shape = diagram.Pages[0].Shapes.GetShape(138);
// get sub-shape of the group shape
Shape subShape = shape.Shapes.GetShape(140);

Matrix m = new Matrix();
// apply the translation vector
m.Translate(-(float)subShape.XForm.LocPinX.Value, -(float)subShape.XForm.LocPinY.Value);
// set the elements of that matrix to a rotation
m.Rotate((float)subShape.XForm.Angle.Value);
// apply the translation vector
m.Translate((float)subShape.XForm.PinX.Value, (float)subShape.XForm.PinY.Value);

// get pinx and piny
double pinx = m.OffsetX;
double piny = m.OffsetY;
// calculate the sub-shape pinx and piny
double resultx = shape.XForm.PinX.Value - shape.XForm.LocPinX.Value - pinx;
double resulty = shape.XForm.PinY.Value - shape.XForm.LocPinY.Value - piny;

We hope, this helps.