Page.DropContainer drops container inside another container

Started by MrSir, August 29, 2014, 10:48:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MrSir

Hello

I have the following code, it Works fine, but if i drop 2 containers on the page, the second container gets placed inside the first container.


public int group(List<int> shapeIds, string heading) {

    Selection selection = visioPage.CreateSelection(VisSelectionTypes.visSelTypeEmpty, VisSelectMode.visSelModeOnlySuper, null);
    List<Shape> shapeList = new List<Shape>();

    if (shapeIds.Count > 0)
    {
        foreach (int id in shapeIds)
        {
            shapeList.Add(visioPage.Shapes.get_ItemFromID(id));
        }
     }
    else {
        return 0;
    }

    foreach (Shape shape in shapeList)
    {
        selection.Select(shape, (short)Microsoft.Office.Interop.Visio.VisSelectArgs.visSelect);
    }

    Document visioStencil = application.Documents.OpenEx(application.GetBuiltInStencilFile(Microsoft.Office.Interop.Visio.VisBuiltInStencilTypes.visBuiltInStencilContainers, Microsoft.Office.Interop.Visio.VisMeasurementSystem.visMSUS), (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visAddHidden);

    Shape containerShape = visioPage.DropContainer(visioStencil.Masters.get_ItemU("Plain"), selection);
    visioStencil.Close();
               
    return containerShape.ID;
}


I can't see any reason for this code to place the container inside another container, what gives?

Regards MrSir

Paul Herber

The last question you asked was about dropping one shape inside another.
By "drop 2 containers on the page" do you mean that you run this code twice?
If so, then yes, you will get two containers, one on top of the other, which as far as containers go (they invoke their own code within Visio) that'll put one inside the other.
Sorry, your code is weird, what the ^$@£% are you trying to do?
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

MrSir

Hello Paul

The code is more or less copy pasted from the Visio SDK Code samples (Container membership)
I use the group method to create groups/containers of shapes. Here is an example:


List<int> myShapes = new List<int>(); // List of shape ID's
myShapes.Add(1);
myShapes.Add(3);
myShapes.Add(10);

instance.group(myShapes, "This text is not used right now");

myShapes.Clear();

myShapes.Add(2);
myShapes.Add(5);
myShapes.Add(12);

instance.group(myShapes, "This text is not used right now");


The above creates 2 containers with shapes inside, but the containers are nested, but i think you answer my question "If so, then yes, you will get two containers, one on top of the other, which as far as containers go (they invoke their own code within Visio) that'll put one inside the other."

Regards MrSir