This project is read-only.

Remove Shape from Model

Sep 24, 2011 at 9:12 PM
Edited Sep 24, 2011 at 9:47 PM

I need to remove the shapes selected from model, but this code doesn't run.

Any Idea?

 

if (diagram1.Model.SelectedShapes().Values.Count > 0)

 

     foreach (Shape s in diagram1.Model.SelectedShapes().Values)

 

     {

          diagram1.Model.Shapes.Remove(s.Key);

     }

 

     diagram1.Refresh();

 

}

 

 

{ 

 

 

Dec 20, 2011 at 2:55 PM

Set the Element collection IsModifiable to true

diagram1.Controller.Model.Elements.SetModifiable(true);

if (diagram1.Model.SelectedShapes().Values.Count > 0)

 

     foreach (Shape s in diagram1.Model.SelectedShapes().Values)

 

     {

         diagram1.Controller.Model.Elements.Remove(s);

     }