Diagram does not refresh when an element removed.

Editor
Oct 23, 2010 at 10:15 AM

hi

i'm facing a problem, when an element removed from diagram.

i have some Table object inside my diagram. when i removed one of them via this code :

private void btnDeleteNode_Click(object sender, EventArgs e)
{
            if (this._selectedElement != null)
            {
                this._model.Shapes.Remove(this._selectedElement.Key);
                this._diagram.Controller.Refresh();

                this._diagram.Controller.Invalidate();
                this._diagram.Controller.Refresh();
                this._diagram.Refresh();
            }
}

nothing happened and UI does not refreshed to delete selected shape from ui.

does something wrong ? i think it's a bug.

any help ?

Oct 25, 2010 at 1:07 PM
Edited Oct 25, 2010 at 1:39 PM

find in ...\Crainiate Open Diagram 5.0\Crainiate.Diagramming\Crainiate.Diagramming.Collections\Elements.cs

        public override bool Remove(string key)
        {
            return base.Remove(key);
        }

and replace on

        public override bool Remove(string key)
        {
            OnElementRemoved(base[key]);
            return base.Remove(key);
        }

find in ...\Crainiate Open Diagram 5.0\Crainiate.Diagramming\Model.cs

        //Occurs when an element is removed from the elements collection
        private void Element_Remove(object sender, ElementsEventArgs e)
        {
            if (e.Value is Shape) ResetLines((Shape)e.Value);

            //Remove from the renderlist
            Elements.Remove(e.Value);

            //Raise the ElementRemovedEvent
            OnElementRemoved(e.Value);
            OnModelInvalid();
        }

 

and replace on

        //Occurs when an element is removed from the elements collection
        private void Element_Remove(object sender, ElementsEventArgs e)
        {
            if (e.Value is Shape) ResetLines((Shape)e.Value);

            //Remove from the renderlist
            Elements.SetModifiable(true);
            Elements.Remove(e.Value);
            Elements.SetModifiable(false);

            //Raise the ElementRemovedEvent
            OnElementRemoved(e.Value);
            OnModelInvalid();
        }

 

Editor
Oct 28, 2010 at 9:06 PM

Thanks Dant11

It works good.

thanks for your help