Free Support Forum - aspose.com

Shape Text is not showing until movement

Hi, when adding new shapes to a diagram, the new shapes don’t show their text value until they are selected/moved with the mouse. I would like to know how to display the text automatically.

This is the code that is used to add the new shapes to the right of an existing diagram

Page targetPage = diagram.Pages.GetPage(pageIdInt);


double yDelta = targetPage.PageSheet.PageProps.PageHeight.Value - sourcePage.PageSheet.PageProps.PageHeight.Value;

double xDelta = pageStates[pageIdInt].RightMostShapeXPos + 2;

foreach (Shape newShape in sourcePage.Shapes)
            {
                long shapeId = targetPage.AddShape(newShape.XForm.PinX.Value + xDelta, newShape.XForm.PinY.Value + yDelta, newShape.XForm.Width.Value, newShape.XForm.Height.Value, newShape.Master.Name);

                Shape shape = targetPage.Shapes.GetShape(shapeId);

                foreach (Prop newShapeProp in newShape.Props)
                    shape.Props.Add(newShapeProp.Clone());

                // Add new shapes to the internal state dictionaries, such that they are linked to everything else during the relinking
                Prop IdProp = newShape.Props.GetProp("CDKId");

                if (IdProp != null)
                {
                    if (!IdProp.Value.Val.Contains("Container_"))
                    {
                        if (!currentPageState.DiagramShapesIdsPairs.ContainsKey(IdProp.Value.Val))
                            currentPageState.DiagramShapesIdsPairs.Add(IdProp.Value.Val, shape);
                    }

                    shape.Text = newShape.Text;

                    shape.TextXForm.TxtLocPinX.Value = 0;

                    shape.TextXForm.TxtHeight.Ufe.F = "=TEXTHEIGHT(TheText, 1)";
                    shape.TextXForm.TxtHeight.Ufe.Unit = MeasureConst.STR;


                    shape.RefreshData();
                }
            }

Again, the diagram ends up having the shapes, but the names are not shown under the shapes until they’re selected by an user. I would like them to be shown from the start.

Is there any way to make it show? Thank you

@umaknowregan

Could you please share your sample Diagram file with us along with the output generated at your end? We will test the scenario in our environment and address it accordingly. You can please add your files to .zip and attach to your post.