Remove Shape from Model

Sep 24, 2011 at 8:12 PM
Edited Sep 24, 2011 at 8: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();

 

}

 

 

{ 

 

 

Developer
Dec 20, 2011 at 1: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);

     }